zhang
17 小时以前 af5081bc0d0668d526a204076557a171097ddb8d
zy-acs-flow/src/page/task/TaskList.jsx
@@ -35,7 +35,7 @@
    useNotify,
    useRefresh,
} from 'react-admin';
import { Box, Chip, Card, Stack } from '@mui/material';
import { Box, Chip, Card, Stack, LinearProgress } from '@mui/material';
import { styled } from '@mui/material/styles';
import TaskCreate from "./TaskCreate";
import TaskPanel from "./TaskPanel";
@@ -70,6 +70,20 @@
        width: 200
    },
}));
const UPLINK_STATUS_CHOICES = [
    { id: 'NONE', name: 'page.task.enums.uplinkSts.NONE', color: 'default' },
    { id: 'PENDING', name: 'page.task.enums.uplinkSts.PENDING', color: 'warning' },
    { id: 'SENDING', name: 'page.task.enums.uplinkSts.SENDING', color: 'info' },
    { id: 'SUCCESS', name: 'page.task.enums.uplinkSts.SUCCESS', color: 'success' },
    { id: 'FAILED', name: 'page.task.enums.uplinkSts.FAILED', color: 'error' },
    { id: 'SKIPPED', name: 'page.task.enums.uplinkSts.SKIPPED', color: 'secondary' },
];
const UPLINK_STATUS_MAP = UPLINK_STATUS_CHOICES.reduce((acc, item) => {
    acc[item.id] = item;
    return acc;
}, {});
const filters = [
    // <SearchInput source="condition" alwaysOn />,
@@ -115,6 +129,7 @@
        <AutocompleteInput label="table.field.task.destCode" optionText="data" filterToQuery={(val) => ({ data: val })} />
    </ReferenceInput>,
    <TextInput source="emptyMk" label="table.field.task.emptyMk" />,
    <SelectInput source="uplinkSts" label="table.field.task.uplinkSts" choices={UPLINK_STATUS_CHOICES} />,
    <TextInput source="zpallet" label="table.field.task.zpallet" />,
    // <TextInput source="phase" label="table.field.task.phase" />,
    <TextInput source="errDesc" label="table.field.task.errDesc" />,
@@ -130,12 +145,12 @@
    />,
]
const TaskList = () => {
const TaskListContent = () => {
    const translate = useTranslate();
    const notify = useNotify();
    const refresh = useRefresh();
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
    const { isLoading } = useListContext();
    const [taskStsByComplete, setTaskStsByComplete] = useState(null);
    const [taskStsByCancel, setTaskStsByCancel] = useState(null);
@@ -160,6 +175,7 @@
            setTaskStsByCancel(res.data.data[0]?.id);
        })
    }, []);
    const onComplete = (taskId) => {
        request.get("/task/complete/" + taskId).then(res => {
@@ -190,6 +206,163 @@
    }
    return (
        <Box sx={{ position: 'relative' }}>
            {isLoading && (
                <LinearProgress
                    sx={{
                        height: "2px",
                        position: 'absolute',
                        top: 0,
                        left: 0,
                        right: 0,
                    }}
                />
            )}
            <StyledDatagrid
                preferenceKey='task'
                bulkActionButtons={false}
                rowClick={(id, resource, record) => false}
                expand={() => <TaskPanel />}
                expandSingle={true}
                omit={['id', 'uuid', 'startTime', 'endTime', 'errTime', 'emptyMk', 'zpallet',
                    'oriSta', 'oriLoc', 'oriCode', 'destSta', 'destLoc', 'destCode', 'errDesc',
                    'updateTime', 'updateBy', 'ioTime', 'createBy', 'statusBool', 'memo']}
            >
                <NumberField source="id" />
                <TextField source="uuid" label="table.field.task.uuid" sortable={false} />
                <TextField source="seqNum" label="table.field.task.seqNum" sortable={false} />
                <ReferenceField source="busId" label="table.field.task.busId" reference="bus" link={false} sortable={false}>
                    <TextField source="busNo" />
                </ReferenceField>
                <ReferenceField source="agvId" label="table.field.task.agvId" reference="agv" link={false} sortable={false}>
                    <TextField source="uuid" />
                </ReferenceField>
                {/* <TextField source="name" label="table.field.task.name" /> */}
                <ReferenceField source="taskType" label="table.field.task.taskType" reference="taskType" link={false} sortable={false}>
                    <TextField source="name" />
                </ReferenceField>
                {/* <ReferenceField source="taskSts" label="table.field.task.taskSts" reference="taskSts" link={false} sortable={false}>
                        <TextField source="name" />
                    </ReferenceField> */}
                <ReferenceField source="taskSts" label="table.field.task.taskSts" reference="taskSts" link={false} sortable={true}>
                    <FunctionField render={record => (
                        <Chip
                            label={record.name}
                            variant="outlined"
                            size="small"
                            color={getTaskStsChipColor(record.name)}
                            sx={{ fontSize: '0.75rem' }}
                        />
                    )} />
                    {/* <TextField source="name" /> */}
                </ReferenceField>
                <DateField source="ioTime" label="table.field.task.ioTime" showTime sortable={false} />
                <DateField source="startTime" label="table.field.task.startTime" showTime sortable={false} />
                <DateField source="endTime" label="table.field.task.endTime" showTime sortable={false} />
                <DateField source="errTime" label="table.field.task.errTime" showTime sortable={false} />
                <ReferenceField source="oriSta" label="table.field.task.oriSta" reference="sta" link={false} sortable={false}>
                    <TextField source="staNo" />
                </ReferenceField>
                <ReferenceField source="oriLoc" label="table.field.task.oriLoc" reference="loc" link={false} sortable={false}>
                    <TextField source="locNo" />
                </ReferenceField>
                <ReferenceField source="oriCode" label="table.field.task.oriCode" reference="code" link={false} sortable={false}>
                    <TextField source="data" />
                </ReferenceField>
                <ReferenceField source="destSta" label="table.field.task.destSta" reference="sta" link={false} sortable={false}>
                    <TextField source="staNo" />
                </ReferenceField>
                <ReferenceField source="destLoc" label="table.field.task.destLoc" reference="loc" link={false} sortable={false}>
                    <TextField source="locNo" />
                </ReferenceField>
                <ReferenceField source="destCode" label="table.field.task.destCode" reference="code" link={false} sortable={false}>
                    <TextField source="data" />
                </ReferenceField>
                <TextField source="oriDesc" label="table.field.task.oriDesc" sortable={false} />
                <TextField source="destDesc" label="table.field.task.destDesc" sortable={false} />
                <NumberField source="priority" label="table.field.task.priority" sortable={false} />
                <FunctionField
                    label="table.field.task.uplinkSts"
                    sortable={false}
                    render={record => {
                        const meta = UPLINK_STATUS_MAP[record?.uplinkSts];
                        return (
                            <Chip
                                label={meta?.name ? translate(meta.name) : translate('common.enums.na')}
                                variant="outlined"
                                size="small"
                                color={meta?.color ?? 'default'}
                                sx={{ fontSize: '0.75rem' }}
                            />
                        );
                    }}
                />
                <TextField source="emptyMk" label="table.field.task.emptyMk" sortable={false} />
                <TextField source="zpallet" label="table.field.task.zpallet" sortable={false} />
                <TextField source="errDesc" label="table.field.task.errDesc" sortable={false} />
                <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
                    <TextField source="nickname" />
                </ReferenceField>
                <DateField source="updateTime" label="common.field.updateTime" showTime />
                <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}>
                    <TextField source="nickname" />
                </ReferenceField>
                <DateField source="createTime" label="common.field.createTime" showTime sortable={false} />
                <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 !== taskStsByComplete && record.taskSts !== taskStsByCancel) && (
                        <>
                            <ConfirmButton
                                label="common.action.complete"
                                size="small"
                                color="primary"
                                startIcon={<CheckIcon />}
                                sx={{
                                    padding: '1px',
                                    fontSize: '.75rem',
                                    '& .MuiButton-startIcon': {
                                        marginRight: '2px'
                                    },
                                    mr: 1
                                }}
                                data={record.seqNum}
                                onConfirm={() => {
                                    onComplete(record.id);
                                }}
                            />
                            <ConfirmButton
                                label="ra.action.cancel"
                                size="small"
                                color="error"
                                startIcon={<ClearIcon />}
                                sx={{
                                    padding: '1px',
                                    fontSize: '.75rem',
                                    '& .MuiButton-startIcon': {
                                        marginRight: '1.5px'
                                    },
                                }}
                                data={record.seqNum}
                                onConfirm={() => {
                                    onCancel(record.id);
                                }}
                            />
                        </>
                    )
                )} />
            </StyledDatagrid>
        </Box>
    )
}
const TaskList = () => {
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
    return (
        <Box display="flex">
            <List
                sx={{
@@ -216,125 +389,7 @@
                perPage={25}
                aside={<TaskListAside />}
            >
                <StyledDatagrid
                    preferenceKey='task'
                    bulkActionButtons={false}
                    rowClick={(id, resource, record) => false}
                    expand={() => <TaskPanel />}
                    expandSingle={true}
                    omit={['id', 'uuid', 'startTime', 'endTime', 'errTime', 'emptyMk', 'zpallet',
                        'oriSta', 'oriLoc', 'oriCode', 'destSta', 'destLoc', 'destCode', 'errDesc',
                        'updateTime', 'updateBy', 'ioTime', 'createBy', 'statusBool', 'memo']}
                >
                    <NumberField source="id" />
                    <TextField source="uuid" label="table.field.task.uuid" sortable={false} />
                    <TextField source="seqNum" label="table.field.task.seqNum" sortable={false} />
                    <ReferenceField source="busId" label="table.field.task.busId" reference="bus" link={false} sortable={false}>
                        <TextField source="busNo" />
                    </ReferenceField>
                    <ReferenceField source="agvId" label="table.field.task.agvId" reference="agv" link={false} sortable={false}>
                        <TextField source="uuid" />
                    </ReferenceField>
                    {/* <TextField source="name" label="table.field.task.name" /> */}
                    <ReferenceField source="taskType" label="table.field.task.taskType" reference="taskType" link={false} sortable={false}>
                        <TextField source="name" />
                    </ReferenceField>
                    {/* <ReferenceField source="taskSts" label="table.field.task.taskSts" reference="taskSts" link={false} sortable={false}>
                        <TextField source="name" />
                    </ReferenceField> */}
                    <ReferenceField source="taskSts" label="table.field.task.taskSts" reference="taskSts" link={false} sortable={true}>
                        <FunctionField render={record => (
                            <Chip
                                label={record.name}
                                variant="outlined"
                                size="small"
                                color={getTaskStsChipColor(record.name)}
                                sx={{ fontSize: '0.75rem' }}
                            />
                        )} />
                        {/* <TextField source="name" /> */}
                    </ReferenceField>
                    <DateField source="ioTime" label="table.field.task.ioTime" showTime sortable={false} />
                    <DateField source="startTime" label="table.field.task.startTime" showTime sortable={false} />
                    <DateField source="endTime" label="table.field.task.endTime" showTime sortable={false} />
                    <DateField source="errTime" label="table.field.task.errTime" showTime sortable={false} />
                    <ReferenceField source="oriSta" label="table.field.task.oriSta" reference="sta" link={false} sortable={false}>
                        <TextField source="staNo" />
                    </ReferenceField>
                    <ReferenceField source="oriLoc" label="table.field.task.oriLoc" reference="loc" link={false} sortable={false}>
                        <TextField source="locNo" />
                    </ReferenceField>
                    <ReferenceField source="oriCode" label="table.field.task.oriCode" reference="code" link={false} sortable={false}>
                        <TextField source="data" />
                    </ReferenceField>
                    <ReferenceField source="destSta" label="table.field.task.destSta" reference="sta" link={false} sortable={false}>
                        <TextField source="staNo" />
                    </ReferenceField>
                    <ReferenceField source="destLoc" label="table.field.task.destLoc" reference="loc" link={false} sortable={false}>
                        <TextField source="locNo" />
                    </ReferenceField>
                    <ReferenceField source="destCode" label="table.field.task.destCode" reference="code" link={false} sortable={false}>
                        <TextField source="data" />
                    </ReferenceField>
                    <TextField source="oriDesc" label="table.field.task.oriDesc" sortable={false} />
                    <TextField source="destDesc" label="table.field.task.destDesc" sortable={false} />
                    <NumberField source="priority" label="table.field.task.priority" sortable={false} />
                    <TextField source="emptyMk" label="table.field.task.emptyMk" sortable={false} />
                    <TextField source="zpallet" label="table.field.task.zpallet" sortable={false} />
                    <TextField source="errDesc" label="table.field.task.errDesc" sortable={false} />
                    <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
                        <TextField source="nickname" />
                    </ReferenceField>
                    <DateField source="updateTime" label="common.field.updateTime" showTime />
                    <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}>
                        <TextField source="nickname" />
                    </ReferenceField>
                    <DateField source="createTime" label="common.field.createTime" showTime sortable={false} />
                    <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 !== taskStsByComplete && record.taskSts !== taskStsByCancel) && (
                            <>
                                <ConfirmButton
                                    label="common.action.complete"
                                    size="small"
                                    color="primary"
                                    startIcon={<CheckIcon />}
                                    sx={{
                                        padding: '1px',
                                        fontSize: '.75rem',
                                        '& .MuiButton-startIcon': {
                                            marginRight: '2px'
                                        },
                                        mr: 1
                                    }}
                                    data={record.seqNum}
                                    onConfirm={() => {
                                        onComplete(record.id);
                                    }}
                                />
                                <ConfirmButton
                                    label="ra.action.cancel"
                                    size="small"
                                    color="error"
                                    startIcon={<ClearIcon />}
                                    sx={{
                                        padding: '1px',
                                        fontSize: '.75rem',
                                        '& .MuiButton-startIcon': {
                                            marginRight: '1.5px'
                                        },
                                    }}
                                    data={record.seqNum}
                                    onConfirm={() => {
                                        onCancel(record.id);
                                    }}
                                />
                            </>
                        )
                    )} />
                </StyledDatagrid>
                <TaskListContent drawerVal={drawerVal} />
            </List>
            <TaskCreate
                open={createDialog}