skyouc
22 小时以前 00ab993817c7cd9807052fdb643c03b4dc35b2a7
rsf-admin/src/page/orders/stock/OrderItemList.jsx
@@ -28,12 +28,13 @@
    SelectInput,
    NumberInput,
    ReferenceInput,
    useRefresh,
    ReferenceArrayInput,
    AutocompleteInput,
    DeleteButton,
    useGetRecordId,
} from 'react-admin';
import { Box, Typography, Card, Stack } from '@mui/material';
import { Box, Typography, Card, Stack, LinearProgress  } from '@mui/material';
import { styled } from '@mui/material/styles';
import OrderItemCreate from "./OrderItemCreate";
import EmptyData from "../../components/EmptyData";
@@ -41,8 +42,9 @@
import MyExportButton from '../../components/MyExportButton';
import PageDrawer from "../../components/PageDrawer";
import MyField from "../../components/MyField";
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_ITEM_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
import request from '@/utils/request';
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
@@ -60,8 +62,8 @@
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <DateInput label='common.time.after' source="timeStart"  />,
    <DateInput label='common.time.before' source="timeEnd"  />,
    <DateInput label='common.time.after' source="timeStart" />,
    <DateInput label='common.time.before' source="timeEnd" />,
    <NumberInput source="orderId" label="table.field.stockItem.orderId" />,
    <TextInput source="orderCode" label="table.field.stockItem.orderCode" />,
    <TextInput source="sourceItemId" label="table.field.stockItem.sourceItemId" />,
@@ -124,48 +126,9 @@
                        <MyExportButton />
                    </TopToolbar>
                )}
                perPage={DEFAULT_PAGE_SIZE}
                perPage={DEFAULT_ITEM_PAGE_SIZE}
            >
                <StyledDatagrid
                    preferenceKey='stockItem'
                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
                    rowClick={(id, resource, record) => false}
                    expand={false}
                    expandSingle={true}
                    omit={['id', 'createTime', 'createBy', 'memo']}
                >
                    <NumberField source="id" />
                    <NumberField source="orderId" label="table.field.stockItem.orderId" />
                    <TextField source="orderCode" label="table.field.stockItem.orderCode" />
                    <TextField source="sourceItemId" label="table.field.stockItem.sourceItemId" />
                    <TextField source="matnrId" label="table.field.stockItem.matnrId" />
                    <TextField source="matnrCode" label="table.field.stockItem.matnrCode" />
                    <TextField source="maktx" label="table.field.stockItem.maktx" />
                    <NumberField source="anfme" label="table.field.stockItem.anfme" />
                    <TextField source="stockUnit" label="table.field.stockItem.stockUnit" />
                    <NumberField source="workQty" label="table.field.stockItem.workQty" />
                    <NumberField source="purQty" label="table.field.stockItem.purQty" />
                    <TextField source="purUnit" label="table.field.stockItem.purUnit" />
                    <NumberField source="qty" label="table.field.stockItem.qty" />
                    <TextField source="splrCode" label="table.field.stockItem.splrCode" />
                    <TextField source="batch" label="table.field.stockItem.batch" />
                    <TextField source="splrBatch" label="table.field.stockItem.splrBatch" />
                    <TextField source="splrName" label="table.field.stockItem.splrName" />
                    <TextField source="trackCode" label="table.field.stockItem.trackCode" />
                    <TextField source="barcode" label="table.field.stockItem.barcode" />
                    <TextField source="prodTime" label="table.field.stockItem.prodTime" />
                    <TextField source="packName" label="table.field.stockItem.packName" />
                    <TextField source="updateBy$" label="common.field.updateBy" />
                    <DateField source="updateTime" label="common.field.updateTime" showTime />
                    <TextField source="createBy$" label="common.field.createBy" />
                    <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">
                        <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} />
                        <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
                    </WrapperField>
                </StyledDatagrid>
                <DynamicFields />
            </List>
            <PageDrawer
                title='stockItem Detail'
@@ -178,3 +141,85 @@
}
export default OrderItemList;
const DynamicFields = (props) => {
    const translate = useTranslate();
    const notify = useNotify();
    const [columns, setColumns] = useState([]);
    const { isLoading } = useListContext();
    const refresh = useRefresh();
    useEffect(() => {
        getDynamicFields();
    }, []);
    const getDynamicFields = async () => {
        const { data: { code, data, msg } } = await request.get("/fields/enable/list");
        if (code == 200) {
            const arr = [
                <NumberField source="id" />,
                <NumberField source="orderId" label="table.field.stockItem.orderId" />,
                <TextField source="orderCode" label="table.field.stockItem.orderCode" />,
                <TextField source="sourceItemId" label="table.field.stockItem.sourceItemId" />,
                <TextField source="matnrId" label="table.field.stockItem.matnrId" />,
                <TextField source="matnrCode" label="table.field.stockItem.matnrCode" />,
                <TextField source="maktx" label="table.field.stockItem.maktx" />,
                <NumberField source="anfme" label="table.field.stockItem.anfme" />,
                <TextField source="stockUnit" label="table.field.stockItem.stockUnit" />,
                <NumberField source="workQty" label="table.field.stockItem.workQty" />,
                <TextField source="locCode" label="table.field.loc.code" />,
                <TextField source="barcode" label="table.field.task.barcode" />,
                <NumberField source="purQty" label="table.field.stockItem.purQty" />,
                <TextField source="purUnit" label="table.field.stockItem.purUnit" />,
                <NumberField source="qty" label="table.field.stockItem.qty" />,
                <TextField source="splrCode" label="table.field.stockItem.splrCode" />,
                <TextField source="batch" label="table.field.stockItem.batch" />,
                <TextField source="splrBatch" label="table.field.stockItem.splrBatch" />,
                <TextField source="splrName" label="table.field.stockItem.splrName" />,
                <TextField source="trackCode" label="table.field.stockItem.trackCode" />,
                <TextField source="prodTime" label="table.field.stockItem.prodTime" />,
                <TextField source="packName" label="table.field.stockItem.packName" />
            ]
            const fields = data.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />)
            const lastArr = [
                <TextField source="updateBy$" label="common.field.updateBy" />,
                <DateField source="updateTime" label="common.field.updateTime" showTime />,
                <TextField source="createBy$" label="common.field.createBy" />,
                <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} />
            ]
            setColumns([...arr, ...fields, ...lastArr]);
        } else {
            notify(msg);
        }
    }
    return (
        <Box sx={{ position: 'relative', minHeight: "60vh", }}>
            {isLoading && (
                <LinearProgress
                    sx={{
                        height: "2px",
                        position: 'absolute',
                        top: 0,
                        left: 0,
                        right: 0,
                    }}
                />
            )}
            {columns.length > 0 &&
                <StyledDatagrid
                    preferenceKey='stockItem'
                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
                    rowClick={(id, resource, record) => false}
                    expand={false}
                    expandSingle={true}
                    omit={['id', 'createTime', 'orderId', 'sourceItemId', 'matnrId', 'purUnit', 'splrCode', 'purQty', 'createBy', 'packName', 'prodTime', 'splrName', 'splrCode', 'batch', 'trackCode',  'updateBy$', 'createBy$', 'memo']}
                >
                    {columns.map((column) => column)}
                </StyledDatagrid>}
        </Box>
    )
}