cl
2026-04-21 c55a86895cabc3e91c2e7aa4eab099a7287e0ae6
rsf-admin/src/page/locItem/LocItemList.jsx
@@ -27,22 +27,20 @@
    DateInput,
    SelectInput,
    NumberInput,
    useRefresh,
    ReferenceInput,
    ReferenceArrayInput,
    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 LocItemCreate from "./LocItemCreate";
import LocItemPanel from "./LocItemPanel";
import EmptyData from "../components/EmptyData";
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 request from '@/utils/request';
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
@@ -54,30 +52,34 @@
    '& .column-name': {
    },
    '& .opt': {
        width: 100
        width: 200
    },
}));
const locUseStatusChoices = typeof localStorage !== 'undefined'
    ? (JSON.parse(localStorage.getItem('sys_dicts') || '[]')).filter((d) => d.dictTypeCode === 'sys_loc_use_stas')
    : [];
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <DateInput label='common.time.after' source="timeStart" />,
    <DateInput label='common.time.before' source="timeEnd" />,
    <AutocompleteInput
        source="useStatus"
        label="table.field.loc.useStatus"
        choices={locUseStatusChoices}
        optionText="label"
        optionValue="value"
        resettable
    />,
    <NumberInput source="locId" label="table.field.locItem.locId" />,
    <TextInput source="locCode" label="table.field.locItem.locCode" />,
    <NumberInput source="orderId" label="table.field.locItem.orderId" />,
    <TextInput source="type" label="table.field.locItem.type" />,
    <NumberInput source="orderItemId" label="table.field.locItem.orderItemId" />,
    <NumberInput source="wkType" label="table.field.locItem.wkType" />,
    <TextInput source="barcode" label="table.field.locItem.barcode" />,
    <NumberInput source="matnrId" label="table.field.locItem.matnrId" />,
    <TextInput source="maktx" label="table.field.locItem.maktx" />,
    <TextInput source="matnrCode" label="table.field.locItem.matnrCode" />,
    <TextInput source="trackCode" label="table.field.locItem.trackCode" />,
    <TextInput source="unit" label="table.field.locItem.unit" />,
    <NumberInput source="anfme" label="table.field.locItem.anfme" />,
    <NumberInput source="qty" label="table.field.locItem.qty" />,
    <NumberInput source="workQty" label="table.field.locItem.workQty" />,
    <TextInput source="batch" label="table.field.locItem.batch" />,
    <TextInput source="splrBatch" label="table.field.locItem.splrBatch" />,
    <TextInput source="spec" label="table.field.locItem.spec" />,
    <TextInput source="model" label="table.field.locItem.model" />,
    <TextInput source="fieldsIndex" label="table.field.locItem.fieldsIndex" />,
@@ -95,7 +97,6 @@
const LocItemList = () => {
    const translate = useTranslate();
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
@@ -111,57 +112,18 @@
                    marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                }}
                title={"menu.locItem"}
                empty={false}
                empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
                filters={filters}
                sort={{ field: "create_time", order: "desc" }}
                actions={(
                    <TopToolbar>
                        <FilterButton />
                        {/* <MyCreateButton onClick={() => { setCreateDialog(true) }} /> */}
                        <SelectColumnsButton preferenceKey='locItem' />
                        {/* <MyExportButton /> */}
                    </TopToolbar>
                )}
                perPage={DEFAULT_PAGE_SIZE}
            >
                <StyledDatagrid
                    preferenceKey='locItem'
                    bulkActionButtons={false}
                    rowClick={false}
                    expand={() => <LocItemPanel />}
                    expandSingle={true}
                    omit={['id', 'createTime','locId','orderId', 'orderItemId', 'matnrId', 'splrBatch','workQty','qty', 'createBy', 'memo','fieldsIndex']}
                >
                    <NumberField source="id" />
                    <NumberField source="locId" label="table.field.locItem.locId" />
                    <TextField source="locCode" label="table.field.locItem.locCode" />
                    <NumberField source="orderId" label="table.field.locItem.orderId" />
                    <TextField source="type$" label="table.field.locItem.type" />
                    <NumberField source="orderItemId" label="table.field.locItem.orderItemId" />
                    <NumberField source="wkType$" label="table.field.locItem.wkType" />
                    <NumberField source="matnrId" label="table.field.locItem.matnrId" />
                    <TextField source="matnrCode" label="table.field.locItem.matnrCode" />
                    <TextField source="maktx" label="table.field.locItem.maktx" />
                    <TextField source="spec" label="table.field.locItem.spec" />
                    <TextField source="model" label="table.field.locItem.model" />
                    <TextField source="batch" label="table.field.locItem.batch" />
                    <TextField source="trackCode" label="table.field.locItem.trackCode" />
                    <TextField source="unit" label="table.field.locItem.unit" />
                    <NumberField source="anfme" label="table.field.locItem.anfme" />
                    <TextField source="splrBatch" label="table.field.locItem.splrBatch" />
                    <TextField source="fieldsIndex" label="table.field.locItem.fieldsIndex" />
                    <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>
            <LocItemCreate
                open={createDialog}
@@ -178,3 +140,95 @@
}
export default LocItemList;
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="locId" label="table.field.locItem.locId" />,
                <TextField source="locCode" label="table.field.locItem.locCode" />,
                <TextField source="barcode" label="table.field.locItem.barcode" />,
                <TextField source="locUseStatus$" label="table.field.loc.useStatus" />,
                <NumberField source="matnrId" label="table.field.locItem.matnrId" />,
                <TextField source="maktx" label="table.field.locItem.maktx" />,
                <TextField source="matnrCode" label="table.field.locItem.matnrCode" />,
                <TextField source="unit" label="table.field.locItem.unit" />,
                <NumberField source="anfme" label="table.field.locItem.anfme" options={{ minimumFractionDigits: 2, maximumFractionDigits: 2 }} />,
                <TextField source="batch" label="table.field.locItem.batch" />,
                <NumberField source="splrId" label="table.field.locItem.splrId" />,
                <TextField source="spec" label="table.field.locItem.spec" />,
                <TextField source="model" label="table.field.locItem.model" />
            ]
            // 现品票号已隐藏:过滤扩展字段中的现品票号
            // const fields = data.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />)
            const filteredFields = (data || []).filter(el => el.fields !== 'crushNo' && el.fieldsAlise !== '现品票号');
            const fields = filteredFields.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />)
            const lastArr = [
                <DateField source="updateTime" label="common.field.updateTime" showTime />,
                <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
                    <TextField source="nickname" />
                </ReferenceField>,
                <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 />,
                <TextField source="memo" label="common.field.memo" sortable={false} />,
            ]
            setColumns([...arr, ...fields, ...lastArr]);
            // 现品票号已隐藏:过滤筛选项中的现品票号
            // data.map(el => {
            filteredFields.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}  alwaysOn/>)
            })
        } 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='locItem'
                    bulkActionButtons={false}
                    rowClick={(id, resource, record) => false}
                    expand={false}
                    expandSingle={true}
                    omit={['id', 'createTime', 'createBy', 'memo', 'splrId', 'locId', 'matnrId']}
                >
                    {columns.map((column) => column)}
                </StyledDatagrid>}
        </Box>
    )
}