skyouc
2025-05-23 d1027f95a39e9cdebec119ce42c678a8ad00a9df
rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx
@@ -29,20 +29,24 @@
    NumberInput,
    ReferenceInput,
    ReferenceArrayInput,
    useRefresh,
    AutocompleteInput,
    DeleteButton,
} 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 WarehouseAreasItemCreate from "./WarehouseAreasItemCreate";
import WarehouseAreasItemPanel from "./WarehouseAreasItemPanel";
import EmptyData from "../components/EmptyData";
import request from '@/utils/request';
import MyCreateButton from "../components/MyCreateButton";
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 * as Common from '@/utils/common';
import WarehouseIsptResult from "./WarehouseIsptResult"
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
@@ -60,8 +64,8 @@
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <NumberInput source="areaId" label="table.field.warehouseAreasItem.areaId" />,
    <TextInput source="asnCode" label="table.field.warehouseAreasItem.asnCode" />,
    <TextInput source="areaName" label="table.field.warehouseAreasItem.areaName" />,
    <NumberInput source="matnrId" label="table.field.warehouseAreasItem.matnrId" />,
    <TextInput source="matnrName" label="table.field.warehouseAreasItem.matnrName" />,
@@ -69,6 +73,9 @@
    <TextInput source="barcode" label="table.field.warehouseAreasItem.barcode" />,
    <NumberInput source="anfme" label="table.field.warehouseAreasItem.anfme" />,
    <TextInput source="batch" label="table.field.warehouseAreasItem.batch" />,
    <TextInput source="platOrderCode" label="table.field.asnOrderItem.platOrderCode" />,
    <TextInput source="platWorkCode" label="table.field.asnOrderItem.platWorkCode" />,
    <TextInput source="projectCode" label="table.field.asnOrderItem.projectCode" />,
    <TextInput source="unit" label="table.field.warehouseAreasItem.unit" />,
    <TextInput source="stockUnit" label="table.field.warehouseAreasItem.stockUnit" />,
    <TextInput source="brand" label="table.field.warehouseAreasItem.brand" />,
@@ -94,89 +101,157 @@
const WarehouseAreasItemList = () => {
    const translate = useTranslate();
    const [itemInfo, setItemInfo] = useState({})
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
    return (
        <Box display="flex">
            <List
                title={"menu.warehouseAreasItem"}
                empty={false}
                filters={filters}
                sort={{ field: "create_time", order: "desc" }}
                sx={{
                    flexGrow: 1,
                    transition: (theme) =>
                        theme.transitions.create(['all'], {
                            duration: theme.transitions.duration.enteringScreen,
                        }),
                    marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                }}
                title={"menu.warehouseAreasItem"}
                empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
                filters={filters}
                sort={{ field: "create_time", order: "desc" }}
                actions={(
                    <TopToolbar>
                        <FilterButton />
                        <MyCreateButton onClick={() => { setCreateDialog(true) }} />
                        <SelectColumnsButton preferenceKey='warehouseAreasItem' />
                        <MyExportButton />
                    </TopToolbar>
                )}
                perPage={DEFAULT_PAGE_SIZE}
            >
                <StyledDatagrid
                    preferenceKey='warehouseAreasItem'
                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
                    rowClick={(id, resource, record) => false}
                    omit={['id', 'createTime', 'createBy', 'memo', 'areaId', 'matnrId']}
                >
                    <NumberField source="id" />
                    <NumberField source="areaId" label="table.field.warehouseAreasItem.areaId" />
                    <TextField source="areaName" label="table.field.warehouseAreasItem.areaName" />
                    <NumberField source="matnrId" label="table.field.warehouseAreasItem.matnrId" />
                    <TextField source="matnrName" label="table.field.warehouseAreasItem.matnrName" />
                    <TextField source="matnrCode" label="table.field.warehouseAreasItem.matnrCode" />
                    <TextField source="trackCode" label="table.field.warehouseAreasItem.barcode" />
                    <NumberField source="anfme" label="table.field.warehouseAreasItem.anfme" />
                    <TextField source="batch" label="table.field.warehouseAreasItem.batch" />
                    <TextField source="unit" label="table.field.warehouseAreasItem.unit" />
                    <TextField source="stockUnit" label="table.field.warehouseAreasItem.stockUnit" />
                    <TextField source="brand" label="table.field.warehouseAreasItem.brand" />
                    <ReferenceField source="shipperId" label="table.field.warehouseAreasItem.shipperId" reference="companys" link={false} sortable={false}>
                        <TextField source="name" />
                    </ReferenceField>
                    <TextField source="splrId" label="table.field.warehouseAreasItem.splrId" />
                    <NumberField source="weight" label="table.field.warehouseAreasItem.weight" />
                    <TextField source="prodTime" label="table.field.warehouseAreasItem.prodTime" />
                    <TextField source="splrBtch" label="table.field.warehouseAreasItem.splrBtch" />
                    <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} />
                    <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
                    drawerVal={drawerVal}
                    setDrawerVal={setDrawerVal}
                    itemInfo={itemInfo}
                    setItemInfo={setItemInfo} />
            </List>
            <WarehouseAreasItemCreate
                open={createDialog}
                setOpen={setCreateDialog}
            />
            <PageDrawer
            <WarehouseIsptResult
                record={itemInfo}
                drawerVal={drawerVal}
                from="warehosueItem"
                setDrawerVal={setDrawerVal}
            >
            </WarehouseIsptResult>
            {/* <PageDrawer
                title='WarehouseAreasItem Detail'
                drawerVal={drawerVal}
                setDrawerVal={setDrawerVal}
            >
            </PageDrawer>
            </PageDrawer> */}
        </Box>
    )
}
export default WarehouseAreasItemList;
const DynamicFields = (props) => {
    const { drawerVal, setDrawerVal, itemInfo, setItemInfo } = 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 key="id" source="id" />,
                <TextField key="asnCode" source="asnCode" label="table.field.warehouseAreasItem.asnCode" />,
                <NumberField key="areaId" source="areaId" label="table.field.warehouseAreasItem.areaId" />,
                <TextField key="areaName" source="areaName" label="table.field.warehouseAreasItem.areaName" />,
                <NumberField key="matnrId" source="matnrId" label="table.field.warehouseAreasItem.matnrId" />,
                <TextField key="maktx" source="maktx" label="table.field.warehouseAreasItem.matnrName" />,
                <TextField key="matnrCode" source="matnrCode" label="table.field.warehouseAreasItem.matnrCode" />,
                <TextField key="trackCode" source="trackCode" label="table.field.warehouseAreasItem.barcode" />,
                <NumberField key="anfme" source="anfme" label="table.field.warehouseAreasItem.anfme" />,
                <NumberField key="workQty" source="workQty" label="table.field.warehouseAreasItem.workQty" />,
                <NumberField key="qty" source="qty" label="table.field.warehouseAreasItem.qty" />,
                <TextField source="platOrderCode" label="table.field.asnOrderItem.platOrderCode" />,
                <TextField source="platWorkCode" label="table.field.asnOrderItem.platWorkCode" />,
                <TextField source="projectCode" label="table.field.asnOrderItem.projectCode" />,
                // <MyField source="isptQty" label="table.field.qlyIsptItem.anfme"
                //     onClick={(event, record, val) => {
                //         event.stopPropagation();
                //         setItemInfo(record)
                //         setDrawerVal(!!drawerVal && drawerVal === val ? null : val);
                //     }}
                // />,
                <TextField key="splrBatch" source="splrBatch" label="table.field.warehouseAreasItem.splrBtch" />,
                <TextField key="batch" source="batch" label="table.field.warehouseAreasItem.batch" />,
                <TextField key="unit" source="unit" label="table.field.warehouseAreasItem.unit" />,
                <TextField key="stockUnit" source="stockUnit" label="table.field.warehouseAreasItem.stockUnit" />,
                <TextField key="brand" source="brand" label="table.field.warehouseAreasItem.brand" />,
                <TextField key="shipperId" source="shipperId" label="table.field.warehouseAreasItem.shipperId" />,
                <TextField key="splrId" source="splrId" label="table.field.warehouseAreasItem.splrId" />,
                <TextField key="isptResult" source="isptResult$" label="table.field.warehouseAreasItem.isptResult" sortable={false} />,
                <NumberField key="weight" source="weight" label="table.field.warehouseAreasItem.weight" />,
                <TextField key="prodTime" source="prodTime" label="table.field.warehouseAreasItem.prodTime" />,
            ]
            const fields = data.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />)
            const lastArr = [
                <TextField key="updateBy" source="updateBy$" label="common.field.updateBy" />,
                <DateField key="updateTime" source="updateTime" label="common.field.updateTime" showTime />,
                <TextField key="createBy" source="createBy$" label="common.field.createBy" />,
                <DateField key="createTime" source="createTime" label="common.field.createTime" showTime />,
                <BooleanField key="statusBool" source="statusBool" label="common.field.status" sortable={false} />,
                <TextField key="memo" source="memo" label="common.field.memo" sortable={false} />,
            ]
            setColumns([...arr, ...fields, ...lastArr]);
            //filters添加过滤字段
            data.map(el => {
                var i = 0;
                filters.map((item) => {
                    if (item.key === el.fields) {
                        i = 1;
                    }
                })
                i === 0 && filters.push(<TextInput key={el.fields} source={el.fields} label={el.fieldsAlise} />)
            })
        } 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='warehouseAreasItem'
                    bulkActionButtons={false}
                    rowClick={(id, resource, record) => false}
                    omit={['id', 'createTime', 'memo', 'areaId', 'brand', 'createBy$', 'weight', 'matnrId', 'batch', 'shipperId', 'splrId', 'platWorkCode', 'projectCode']}
                >
                    {columns.map((column) => column)}
                </StyledDatagrid>}
        </Box>
    )
}