From 0fa81f359baef1b5e6075fcbb81cc76802133377 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期五, 30 五月 2025 13:33:30 +0800
Subject: [PATCH] #移库找库位优化

---
 rsf-admin/src/page/task/TaskList.jsx |   85 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 74 insertions(+), 11 deletions(-)

diff --git a/rsf-admin/src/page/task/TaskList.jsx b/rsf-admin/src/page/task/TaskList.jsx
index 068a809..e630c39 100644
--- a/rsf-admin/src/page/task/TaskList.jsx
+++ b/rsf-admin/src/page/task/TaskList.jsx
@@ -43,6 +43,8 @@
 import ConfirmButton from "../components/ConfirmButton";
 import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
 import * as Common from '@/utils/common';
+import ColorizeOutlinedIcon from '@mui/icons-material/ColorizeOutlined';
+import GradingOutlinedIcon from '@mui/icons-material/GradingOutlined';
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -61,8 +63,17 @@
 
 const TaskList = (props) => {
     const translate = useTranslate();
+    const refresh = useRefresh();
     const [drawerVal, setDrawerVal] = useState(false);
     const dict = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_warehouse_type')) || [];
+
+    // useEffect(() => {
+    //     const interval = setInterval(() => {
+    //         refresh();
+    //     }, 5000); // 姣�5绉掑埛鏂颁竴娆�
+
+    //     return () => clearInterval(interval); // 娓呴櫎瀹氭椂鍣�
+    // }, [refresh])
 
     const filters = [
         <SearchInput source="condition" alwaysOn />,
@@ -101,6 +112,7 @@
     return (
         <Box display="flex">
             <List
+                queryOptions={{ refetchInterval: 5000 }}
                 sx={{
                     flexGrow: 1,
                     transition: (theme) =>
@@ -112,7 +124,7 @@
                 title={"menu.task"}
                 empty={false}
                 filters={filters}
-                sort={{ field: "create_time", order: "desc" }}
+                sort={{ field: "sort", order: "desc" }}
                 actions={(
                     <TopToolbar>
                         <FilterButton />
@@ -133,7 +145,7 @@
                     rowClick={false}
                     expand={false}
                     expandSingle={true}
-                    omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status', 'sort']}
+                    omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status']}
                 >
                     <NumberField source="id" />
                     <TextField source="taskCode" label="table.field.task.taskCode" />
@@ -157,10 +169,12 @@
                     {/* <BooleanField source="statusBool" label="common.field.status" sortable={false} /> */}
                     <TextField source="memo" label="common.field.memo" sortable={false} />
                     <WrapperField cellClassName="opt" label="common.field.opt" onClick={(e) => e.stopPropagation()} >
-                        <EditButton  label="toolbar.detail"/>
+                        <EditButton label="toolbar.detail" />
                         <DoneButton sx={{ padding: '1px', fontSize: '.75rem' }} ></DoneButton>
                         <CancelButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
-                        <SetTopButton sx={{ padding: '1px', fontSize: '.75rem' }} ></SetTopButton>
+                        <CheckButton />
+                        <PickButton />
+                        <SetTopButton />
                     </WrapperField>
                 </StyledDatagrid>
             </List>
@@ -175,6 +189,52 @@
 }
 
 export default TaskList;
+
+/**
+ * 鐩樼偣
+ * @returns te
+ */
+const CheckButton = () => {
+    const record = useRecordContext();
+    const notify = useNotify();
+    const refresh = useRefresh();
+
+    const checkClick = async () => {
+        const { data: { code, data, msg } } = await request.post(`/task/check/` + record.id);
+        if (code === 200) {
+            notify(msg);
+            refresh();
+        } else {
+            notify(msg);
+        }
+    }
+
+    return (record?.taskStatus == 199 && record?.taskType == 107 ? <ConfirmButton label={"toolbar.check"} startIcon={<GradingOutlinedIcon />} onConfirm={checkClick} /> : <></>)
+}
+
+/**
+ * 鎷f枡鍑哄簱
+ * @returns 
+ */
+const PickButton = () => {
+    const record = useRecordContext();
+    const notify = useNotify();
+    const refresh = useRefresh();
+
+    const pickClick = async () => {
+        const { data: { code, data, msg } } = await request.post(`/task/pick/` + record.id);
+        if (code === 200) {
+            notify(msg);
+            refresh();
+        } else {
+            notify(msg);
+        }
+    }
+
+    return (
+        record?.taskStatus == 199 && record?.taskType == 103 ? <ConfirmButton label={"toolbar.pick"} startIcon={<ColorizeOutlinedIcon />} onConfirm={pickClick} /> : <></>
+    )
+}
 
 
 /**
@@ -199,7 +259,7 @@
         }
     }
     return (
-        record?.taskStatus < 98 ? (<ConfirmButton label={"toolbar.complete"} color="secondary" startIcon={<TaskAltIcon />} onConfirm={clickComplete} />) : (<></>)
+        ((record?.taskStatus < 98) || (record?.taskType >= 101 && record?.taskStatus < 198)) ? (<ConfirmButton label={"toolbar.complete"} color="secondary" startIcon={<TaskAltIcon />} onConfirm={clickComplete} />) : (<></>)
     )
 }
 
@@ -227,7 +287,7 @@
         }
     }
     return (
-        record.taskStatus === 1 ?
+        (record.taskStatus == 1 || record.taskStatus == 101) && (record.taskType == 1 || record.taskType == 101 || record.taskType == 10 || record.taskType == 103 || record.taskType == 11) ?
             <Button
                 onClick={clickCancel}
                 label="toolbar.cancel">
@@ -260,11 +320,14 @@
         }
     }
     return (
-        <Button
-            onClick={clickTop}
-            label="toolbar.top">
-            <AlignVerticalTopIcon />
-        </Button>
+        (record.taskStatus == 1 || record.taskStatus == 101) && (record.taskType == 1 || record.taskType == 101 || record.taskType == 10 || record.taskType == 103 || record.taskType == 11) ?
+            <Button
+                onClick={clickTop}
+                label="toolbar.top">
+                <AlignVerticalTopIcon />
+            </Button>
+        :
+        <></>
     )
 }
 

--
Gitblit v1.9.1