1
2 天以前 08a7fef6fbfc0a959ffa7e928bdae819079db2de
rsf-admin/src/page/task/TaskPanel.jsx
@@ -1,135 +1,97 @@
import React, { useState, useRef, useEffect, useMemo } from "react";
import { Box, Card, CardContent, Grid, Typography, Tooltip, Pagination } from '@mui/material';
import { Box } from '@mui/material';
import {
    List,
    DatagridConfigurable,
    SearchInput,
    TopToolbar,
    SelectColumnsButton,
    EditButton,
    FilterButton,
    CreateButton,
    ExportButton,
    BulkDeleteButton,
    useDataProvider,
    WrapperField,
    useGetList,
    DataTable,
    useRecordContext,
    useTranslate,
    useNotify,
    useListContext,
    FunctionField,
    TextField,
    NumberField,
    DateField,
    BooleanField,
    ReferenceField,
    TextInput,
    DateTimeInput,
    DateInput,
    SelectInput,
    NumberInput,
    ReferenceInput,
    ReferenceArrayInput,
    AutocompleteInput,
    DeleteButton,
    useList,
    ReferenceManyField,
} from 'react-admin';
import { styled } from '@mui/material/styles';
import PageDrawer from "../components/PageDrawer";
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
        height: '.9em'
    },
    '& .RaDatagrid-row': {
        cursor: 'auto'
    },
    '& .column-name': {
    },
    '& .opt': {
        width: 200
    },
}));
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <DateInput label='common.time.after' source="timeStart"  />,
    <DateInput label='common.time.before' source="timeEnd" />,
    <NumberInput source="taskId" label="table.field.taskItem.taskId" />,
    <NumberInput source="orderId" label="table.field.taskItem.orderId" />,
    <NumberInput source="orderType" label="table.field.taskItem.orderType" />,
    <NumberInput source="orderItemId" label="table.field.taskItem.orderItemId" />,
    <NumberInput source="matnrId" label="table.field.taskItem.matnrId" />,
    <TextInput source="maktx" label="table.field.taskItem.maktx" />,
    <TextInput source="matnrCode" label="table.field.taskItem.matnrCode" />,
    <TextInput source="unit" label="table.field.taskItem.unit" />,
    <NumberInput source="anfme" label="table.field.taskItem.anfme" />,
    <TextInput source="batch" label="table.field.taskItem.batch" />,
    <TextInput source="spec" label="table.field.taskItem.spec" />,
    <TextInput source="model" label="table.field.taskItem.model" />,
    <TextInput label="common.field.memo" source="memo" />,
    <SelectInput
        label="common.field.status"
        source="status"
        choices={[
            { id: '1', name: 'common.enums.statusTrue' },
            { id: '0', name: 'common.enums.statusFalse' },
        ]}
        resettable
    />,
]
const TaskPanel = () => {
    const record = useRecordContext();
    const translate = useTranslate();
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
    // const { data, isPending, error } = useGetList('taskItem', { pagination: { page: 1, perPage: 10 } });
    // const listContext = useList({
    //     data,
    //     isPending,
    //     perPage: 10,
    //     sort: {field: 'create_time', order: 'DESC'}
    // })
    return (
        <>
            <Box display="flex">
                <ReferenceManyField pagination={<Pagination />} reference="taskItem" target="task_id">
                    <StyledDatagrid
                        preferenceKey='taskItem'
                <List resource="taskItem"
                    sx={{
                        flexGrow: 1,
                        transition: (theme) =>
                            theme.transitions.create(['all'], {
                                duration: theme.transitions.duration.enteringScreen,
                            }),
                        marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                    }}
                    filter={{ taskId: record.id }}
                    // title={"menu.taskItem"}
                    pagination={false}
                    empty={false}
                    actions={false}
                >
                    <DataTable
                        bulkActionButtons={false}
                        rowClick={(id, resource, record) => false}
                        expandSingle={true}
                        omit={['id', 'createTime', 'createBy', 'memo', 'taskId', 'orderId', 'orderItemId', 'matnrId']}
                        rowClick={false}
                        expandSingle
                    >
                        <NumberField source="id" />
                        <NumberField source="taskId" label="table.field.taskItem.taskId" />
                        <NumberField source="orderId" label="table.field.taskItem.orderId" />
                        <NumberField source="orderType$" label="table.field.taskItem.orderType" />
                        <NumberField source="orderItemId" label="table.field.taskItem.orderItemId" />
                        <NumberField source="matnrId" label="table.field.taskItem.matnrId" />
                        <TextField source="maktx" label="table.field.taskItem.maktx" />
                        <TextField source="matnrCode" label="table.field.taskItem.matnrCode" />
                        <TextField source="unit" label="table.field.taskItem.unit" />
                        <NumberField source="anfme" label="table.field.taskItem.anfme" />
                        <TextField source="batch" label="table.field.taskItem.batch" />
                        <TextField source="spec" label="table.field.taskItem.spec" />
                        <TextField source="model" label="table.field.taskItem.model" />
                        <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 />
                        <BooleanField source="statusBool" label="common.field.status" sortable={false} />
                        <TextField source="memo" label="common.field.memo" sortable={false} />
                    </StyledDatagrid>
                </ReferenceManyField>
                        {/* <NumberField source="id" /> */}
                        {/* <NumberField source="taskId" label="table.field.taskItem.taskId" /> */}
                        {/* <NumberField source="orderId" label="table.field.taskItem.orderId" /> */}
                        <DataTable.Col source="orderType$" label="table.field.taskItem.orderType">
                            <NumberField source="orderType$" label="table.field.taskItem.orderType" />
                        </DataTable.Col>
                        {/* <TextField source="sourceCode" label="table.field.taskItem.sourceCode" /> */}
                        {/* <NumberField source="orderItemId" label="table.field.taskItem.orderItemId" /> */}
                        <DataTable.Col source="wkType$" label="table.field.taskItem.wkType">
                            <NumberField source="wkType$" label="table.field.taskItem.wkType" />
                        </DataTable.Col>
                        <DataTable.Col source="platWorkCode" label="table.field.asnOrderItem.platWorkCode">
                            <TextField source="platWorkCode" label="table.field.asnOrderItem.platWorkCode" />
                        </DataTable.Col>
                        <DataTable.Col source="platItemId" label="table.field.asnOrderItemLog.platItemId">
                            <TextField source="platItemId" label="table.field.asnOrderItemLog.platItemId" />
                        </DataTable.Col>
                        {/* <NumberField source="matnrId" label="table.field.taskItem.matnrId" /> */}
                        <DataTable.Col source="matnrCode" label="table.field.taskItem.matnrCode">
                            <TextField source="matnrCode" label="table.field.taskItem.matnrCode" />
                        </DataTable.Col>
                        <DataTable.Col source="maktx" label="table.field.taskItem.maktx">
                            <TextField source="maktx" label="table.field.taskItem.maktx" />
                        </DataTable.Col>
                        <DataTable.Col source="batch" label="table.field.taskItem.batch">
                            <TextField source="batch" label="table.field.taskItem.batch" />
                        </DataTable.Col>
                        <DataTable.Col source="unit" label="table.field.taskItem.unit">
                            <TextField source="unit" label="table.field.taskItem.unit" />
                        </DataTable.Col>
                        <DataTable.Col source="anfme" label="table.field.taskItem.anfme">
                            <NumberField source="anfme" label="table.field.taskItem.anfme" />
                        </DataTable.Col>
                        {/* <TextField source="spec" label="table.field.taskItem.spec" />
                        <TextField source="model" label="table.field.taskItem.model" /> */}
                        <DataTable.Col source="updateBy$" label="common.field.updateBy">
                            <TextField source="updateBy$" label="common.field.updateBy" />
                        </DataTable.Col>
                        {/* <TextField source="createBy$" label="common.field.createBy"/> */}
                        <DataTable.Col source="updateTime" label="common.field.updateTime">
                            <DateField source="updateTime" label="common.field.updateTime" showTime />
                        </DataTable.Col>
                        {/* <DateField source="createTime" label="common.field.createTime" showTime /> */}
                        {/* <TextField source="memo" label="common.field.memo" sortable={false} /> */}
                    </DataTable>
                </List>
            </Box>
        </>
    );