|  |  |  | 
|---|
|  |  |  | FunctionField, | 
|---|
|  |  |  | Pagination, | 
|---|
|  |  |  | useNotify, | 
|---|
|  |  |  | useRefresh, | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { Box, Chip, Card, Stack } from '@mui/material'; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | 
|---|
|  |  |  | <ReferenceInput source="taskType" label="table.field.task.taskType" reference="taskType"> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.task.taskType" optionText="name" filterToQuery={(val) => ({ name: val })} /> | 
|---|
|  |  |  | </ReferenceInput>, | 
|---|
|  |  |  | <ReferenceInput source="agvId" label="table.field.task.agvId" reference="agv"> | 
|---|
|  |  |  | <ReferenceInput source="agvId" label="table.field.task.agvId" reference="agv" alwaysOn> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.task.agvId" optionText="uuid" filterToQuery={(val) => ({ uuid: val })} /> | 
|---|
|  |  |  | </ReferenceInput>, | 
|---|
|  |  |  | // <DateInput source="ioTime" label="table.field.task.ioTime" />, | 
|---|
|  |  |  | // <DateInput source="startTime" label="table.field.task.startTime" />, | 
|---|
|  |  |  | // <DateInput source="endTime" label="table.field.task.endTime" />, | 
|---|
|  |  |  | // <DateInput source="errTime" label="table.field.task.errTime" />, | 
|---|
|  |  |  | <ReferenceInput source="oriSta" label="table.field.task.oriSta" reference="sta" alwaysOn> | 
|---|
|  |  |  | <ReferenceInput source="oriSta" label="table.field.task.oriSta" reference="sta"> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.task.oriSta" optionText="staNo" filterToQuery={(val) => ({ staNo: val })} /> | 
|---|
|  |  |  | </ReferenceInput>, | 
|---|
|  |  |  | <ReferenceInput source="oriLoc" label="table.field.task.oriLoc" reference="loc" alwaysOn> | 
|---|
|  |  |  | 
|---|
|  |  |  | <ReferenceInput source="oriCode" label="table.field.task.oriCode" reference="code"> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.task.oriCode" optionText="data" filterToQuery={(val) => ({ data: val })} /> | 
|---|
|  |  |  | </ReferenceInput>, | 
|---|
|  |  |  | <ReferenceInput source="destSta" label="table.field.task.destSta" reference="sta" alwaysOn> | 
|---|
|  |  |  | <ReferenceInput source="destSta" label="table.field.task.destSta" reference="sta"> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.task.destSta" optionText="staNo" filterToQuery={(val) => ({ staNo: val })} /> | 
|---|
|  |  |  | </ReferenceInput>, | 
|---|
|  |  |  | <ReferenceInput source="destLoc" label="table.field.task.destLoc" reference="loc" alwaysOn> | 
|---|
|  |  |  | 
|---|
|  |  |  | const TaskList = () => { | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const [createDialog, setCreateDialog] = useState(false); | 
|---|
|  |  |  | const [drawerVal, setDrawerVal] = useState(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [taskStsByComplete, setTaskStsByComplete] = useState(null); | 
|---|
|  |  |  | const [taskStsByCancel, setTaskStsByCancel] = useState(null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | request.post('/taskSts/list', { | 
|---|
|  |  |  | uuid: 'COMPLETE' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | headers: { | 
|---|
|  |  |  | 'Content-Type': 'application/x-www-form-urlencoded' | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).then(res => { | 
|---|
|  |  |  | setTaskStsByComplete(res.data.data[0]?.id); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | request.post('/taskSts/list', { | 
|---|
|  |  |  | uuid: 'CANCEL' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | headers: { | 
|---|
|  |  |  | 'Content-Type': 'application/x-www-form-urlencoded' | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).then(res => { | 
|---|
|  |  |  | setTaskStsByCancel(res.data.data[0]?.id); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, []); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const onComplete = (taskId) => { | 
|---|
|  |  |  | request.get("/task/complete/" + taskId).then(res => { | 
|---|
|  |  |  | const { code, msg, data } = res.data; | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | notify(msg || 'common.response.success', { type: 'success', messageArgs: { _: msg } }); | 
|---|
|  |  |  | refresh(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg || 'common.response.fail', { type: 'error', messageArgs: { _: msg } }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).catch(error => { | 
|---|
|  |  |  | notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | const { code, msg, data } = res.data; | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | notify(msg || 'common.response.success', { type: 'success', messageArgs: { _: msg } }); | 
|---|
|  |  |  | refresh(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg || 'common.response.fail', { type: 'error', messageArgs: { _: msg } }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).catch(error => { | 
|---|
|  |  |  | notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> | 
|---|
|  |  |  | <TextField source="memo" label="common.field.memo" sortable={false} /> | 
|---|
|  |  |  | <FunctionField label="common.field.opt" cellClassName="opt" render={record => ( | 
|---|
|  |  |  | (record.taskSts === 15 || true) && ( | 
|---|
|  |  |  | (record.taskSts !== taskStsByComplete && record.taskSts !== taskStsByCancel) && ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <ConfirmButton | 
|---|
|  |  |  | label="common.action.complete" | 
|---|