From 27f5533e3609ca5cc9e4d2894d2202410943f799 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期三, 26 十一月 2025 13:12:47 +0800
Subject: [PATCH] 添加手动下发任务功能

---
 rsf-admin/src/page/task/TaskList.jsx |   95 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 87 insertions(+), 8 deletions(-)

diff --git a/rsf-admin/src/page/task/TaskList.jsx b/rsf-admin/src/page/task/TaskList.jsx
index 4fa167a..4555b41 100644
--- a/rsf-admin/src/page/task/TaskList.jsx
+++ b/rsf-admin/src/page/task/TaskList.jsx
@@ -25,6 +25,8 @@
     SelectInput,
     NumberInput,
     Button,
+    useListContext,
+    useRedirect,
     EditButton,
 } from 'react-admin';
 import { Box, Typography, Card, Stack, Drawer } from '@mui/material';
@@ -35,10 +37,11 @@
 import CancelIcon from '@mui/icons-material/Cancel';
 import PageDrawer from "../components/PageDrawer";
 import TaskPanel from "./TaskPanel";
-import MyField from "../components/MyField";
+import PublicIcon from '@mui/icons-material/Public';
 import ConfirmButton from "../components/ConfirmButton";
-import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
-import * as Common from '@/utils/common';
+import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE, AUTO_RUN_CHECK_ORDERS } from '@/config/setting';
+import PlayArrowOutlinedIcon from '@mui/icons-material/PlayArrowOutlined';
+import PauseIcon from '@mui/icons-material/Pause';
 import ColorizeOutlinedIcon from '@mui/icons-material/ColorizeOutlined';
 import GradingOutlinedIcon from '@mui/icons-material/GradingOutlined';
 
@@ -55,9 +58,9 @@
         width: 248
     },
     '& .MuiTableCell-root': {
-    whiteSpace: 'nowrap',
-    overflow: 'visible',
-    textOverflow: 'unset'
+        whiteSpace: 'nowrap',
+        overflow: 'visible',
+        textOverflow: 'unset'
     }
 
 }));
@@ -67,7 +70,20 @@
     const translate = useTranslate();
     const refresh = useRefresh();
     const [drawerVal, setDrawerVal] = useState(false);
+    const [autoExce, setAutoExce] = useState(false);
+    const [menuPubExce, setMenuPubExce] = useState(false);
     const dict = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_warehouse_type')) || [];
+
+    useEffect(() => {
+        getConfig()
+    }, [])
+
+    const getConfig = async () => {
+        const { data: { code, data, msg } } = await request.get('/config/flag/' + AUTO_RUN_CHECK_ORDERS);
+        if (code === 200) {
+            setAutoExce(JSON.parse(data?.val))
+        }
+    }
 
     // useEffect(() => {
     //     const interval = setInterval(() => {
@@ -127,6 +143,8 @@
                 sort={{ field: "sort", order: "desc" }}
                 actions={(
                     <TopToolbar>
+                        <BulkAutoStartButton autoExce={autoExce} setAutoExce={setAutoExce} />
+                        <BulkAutoPauseButton autoExce={autoExce} setAutoExce={setAutoExce} />
                         <FilterButton />
                         <SelectColumnsButton preferenceKey='task' />
                     </TopToolbar>
@@ -135,11 +153,11 @@
             >
                 <StyledDatagrid
                     preferenceKey='task'
-                    bulkActionButtons={false}
+                    bulkActionButtons={<PublicTaskButton menuPubExce={menuPubExce} setMenuPubExce={setMenuPubExce}  />}
                     rowClick={false}
                     expand={<TaskPanel />}
                     expandSingle={true}
-                    omit={['id', 'createTime', 'createBy$', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status','warehType$']}
+                    omit={['id', 'createTime', 'createBy$', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status', 'warehType$']}
                 >
                     <NumberField source="id" />
                     <TextField source="taskCode" label="table.field.task.taskCode" />
@@ -183,6 +201,32 @@
 
 export default TaskList;
 
+
+const PublicTaskButton = ({ menuPubExce, setMenuPubExce }) => {
+    const record = useRecordContext();
+    const { selectedIds, onUnselectItems } = useListContext();
+    const notify = useNotify();
+    const redirect = useRedirect();
+    const pubClick = async () => {
+        onUnselectItems();
+        const { data: { code, data, msg } } = await request.post(`task/menual/exce/` + selectedIds);
+        if (code === 200) {
+            notify(msg);
+            refresh();
+        } else {
+            notify(msg);
+        }
+    }       
+
+    return (
+        <Button
+            onClick={pubClick}
+            label={"toolbar.publicWorking"}
+            startIcon={<PublicIcon />}
+        />
+    );
+}
+
 /**
  * 鐩樼偣
  * @returns te
@@ -205,6 +249,41 @@
     return (record?.taskStatus == 199 && record?.taskType == 107 ? <ConfirmButton label={"toolbar.check"} startIcon={<GradingOutlinedIcon />} onConfirm={checkClick} /> : <></>)
 }
 
+
+/**鑷姩涓嬪彂浠诲姟**/
+const BulkAutoStartButton = ({ autoExce, setAutoExce }) => {
+    const notify = useNotify();
+    const startClick = async () => {
+        setAutoExce(true)
+        const { data: { code, data, msg } } = await request.post('/config/byFlag', { val: true, flag: 'AUTO_RUN_CHECK_ORDERS' });
+        if (code === 200) {
+            notify(msg);
+        } else {
+            notify(msg);
+        }
+    }
+    return (
+        !autoExce ? <Button label="toolbar.autoStartLocs" onClick={startClick} startIcon={<PlayArrowOutlinedIcon />} /> : <></>
+    )
+}
+
+const BulkAutoPauseButton = ({ autoExce, setAutoExce }) => {
+    const notify = useNotify();
+    const pauseClick = async () => {
+        const { data: { code, data, msg } } = await request.post('/config/byFlag', { val: false, flag: 'AUTO_RUN_CHECK_ORDERS' });
+        if (code === 200) {
+            notify(msg);
+            setAutoExce(false)
+        } else {
+            notify(msg);
+        }
+    }
+    return (
+        autoExce ? <Button label="toolbar.pausePub" onClick={pauseClick} startIcon={<PauseIcon />} /> : <></>
+    )
+}
+
+
 /**
  * 鎷f枡鍑哄簱
  * @returns 

--
Gitblit v1.9.1