|  |  |  | 
|---|
|  |  |  | SelectInput, | 
|---|
|  |  |  | NumberInput, | 
|---|
|  |  |  | Button, | 
|---|
|  |  |  | EditButton, | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { Box, Typography, Card, Stack, Drawer } from '@mui/material'; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | import TaskCreate from "./TaskCreate"; | 
|---|
|  |  |  | import TaskPanel from "./TaskPanel"; | 
|---|
|  |  |  | import EmptyData from "../components/EmptyData"; | 
|---|
|  |  |  | import MyCreateButton from "../components/MyCreateButton"; | 
|---|
|  |  |  | import MyExportButton from '../components/MyExportButton'; | 
|---|
|  |  |  | import SwapVertIcon from '@mui/icons-material/SwapVert'; | 
|---|
|  |  |  | import AlignVerticalTopIcon from '@mui/icons-material/AlignVerticalTop'; | 
|---|
|  |  |  | import TaskAltIcon from '@mui/icons-material/TaskAlt'; | 
|---|
|  |  |  | import CancelIcon from '@mui/icons-material/Cancel'; | 
|---|
|  |  |  | import PageDrawer from "../components/PageDrawer"; | 
|---|
|  |  |  | import TaskPanel from "./TaskPanel"; | 
|---|
|  |  |  | import MyField from "../components/MyField"; | 
|---|
|  |  |  | 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': { | 
|---|
|  |  |  | 
|---|
|  |  |  | '& .opt': { | 
|---|
|  |  |  | width: 248 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | '& .MuiTableCell-root': { | 
|---|
|  |  |  | whiteSpace: 'nowrap', | 
|---|
|  |  |  | overflow: 'visible', | 
|---|
|  |  |  | textOverflow: 'unset' | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | })); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 />, | 
|---|
|  |  |  | 
|---|
|  |  |  | />, | 
|---|
|  |  |  | ] | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Box display="flex"> | 
|---|
|  |  |  | <List | 
|---|
|  |  |  | queryOptions={{ refetchInterval: 5000 }} | 
|---|
|  |  |  | sx={{ | 
|---|
|  |  |  | flexGrow: 1, | 
|---|
|  |  |  | transition: (theme) => | 
|---|
|  |  |  | 
|---|
|  |  |  | title={"menu.task"} | 
|---|
|  |  |  | empty={false} | 
|---|
|  |  |  | filters={filters} | 
|---|
|  |  |  | sort={{ field: "create_time", order: "desc" }} | 
|---|
|  |  |  | sort={{ field: "sort", order: "desc" }} | 
|---|
|  |  |  | actions={( | 
|---|
|  |  |  | <TopToolbar> | 
|---|
|  |  |  | <FilterButton /> | 
|---|
|  |  |  | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <StyledDatagrid | 
|---|
|  |  |  | preferenceKey='task' | 
|---|
|  |  |  | bulkActionButtons={ | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <BulkResortButton /> | 
|---|
|  |  |  | <BulkCancelButton /> | 
|---|
|  |  |  | <BulkDeleteButton mutationMode={OPERATE_MODE} /> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | } | 
|---|
|  |  |  | rowClick={'edit'} | 
|---|
|  |  |  | expand={false} | 
|---|
|  |  |  | bulkActionButtons={false} | 
|---|
|  |  |  | rowClick={false} | 
|---|
|  |  |  | expand={<TaskPanel />} | 
|---|
|  |  |  | expandSingle={true} | 
|---|
|  |  |  | omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status', 'sort']} | 
|---|
|  |  |  | omit={['id', 'createTime', 'createBy$', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status','warehType$']} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <NumberField source="id" /> | 
|---|
|  |  |  | <TextField source="taskCode" label="table.field.task.taskCode" /> | 
|---|
|  |  |  | <NumberField source="taskStatus$" label="table.field.task.taskStatus" /> | 
|---|
|  |  |  | <NumberField source="taskType$" label="table.field.task.taskType" /> | 
|---|
|  |  |  | <NumberField source="warehType$" label="table.field.task.taskType" /> | 
|---|
|  |  |  | <NumberField source="warehType$" label="table.field.task.warehType" /> | 
|---|
|  |  |  | <TextField source="orgLoc" label="table.field.task.orgLoc" /> | 
|---|
|  |  |  | <TextField source="orgSite" label="table.field.task.orgSite" /> | 
|---|
|  |  |  | <TextField source="targLoc" label="table.field.task.targLoc" /> | 
|---|
|  |  |  | 
|---|
|  |  |  | <TextField source="createBy$" label="common.field.createBy" /> | 
|---|
|  |  |  | <DateField source="updateTime" label="common.field.updateTime" showTime /> | 
|---|
|  |  |  | <DateField source="createTime" label="common.field.createTime" showTime /> | 
|---|
|  |  |  | {/* <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" /> | 
|---|
|  |  |  | <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> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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} /> : <></>) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 拣料出库 | 
|---|
|  |  |  | * @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} /> : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 完成操作 | 
|---|
|  |  |  | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const clickComplete = (event) => { | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | const clickComplete = () => { | 
|---|
|  |  |  | completeTask(record) | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | //完成任务 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <ConfirmButton label={"toolbar.complete"} color="secondary" startIcon={<TaskAltIcon />} onConfirm={clickComplete} /> | 
|---|
|  |  |  | ((record?.taskStatus < 98) || (record?.taskType >= 101 && record?.taskStatus < 198)) || (record?.taskType == 11 && record?.taskStatus == 101) ? (<ConfirmButton label={"toolbar.complete"} color="secondary" startIcon={<TaskAltIcon />} onConfirm={clickComplete} />) : (<></>) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const clickCancel = (event) => { | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | const clickCancel = () => { | 
|---|
|  |  |  | cancleTask(record) | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | //取消任务 | 
|---|
|  |  |  | const cancleTask = async (row) => { | 
|---|
|  |  |  | console.log(row); | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post(`/task/remove/` + row.id); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | record.taskStatus === 1 ? | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | onClick={clickCancel} | 
|---|
|  |  |  | label="toolbar.cancel"> | 
|---|
|  |  |  | <CancelIcon /> | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | (record.taskStatus == 1 || record.taskStatus == 101) && (record.taskType == 1 || record.taskType == 101 || record.taskType == 10 || record.taskType == 107 || record.taskType == 103 || record.taskType == 11) ? | 
|---|
|  |  |  | <ConfirmButton | 
|---|
|  |  |  | onConfirm={clickCancel} | 
|---|
|  |  |  | startIcon={<CancelIcon />} | 
|---|
|  |  |  | label={"toolbar.cancel"}> | 
|---|
|  |  |  | </ConfirmButton> | 
|---|
|  |  |  | : | 
|---|
|  |  |  | <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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> | 
|---|
|  |  |  | : | 
|---|
|  |  |  | <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|