From 46f737b0343c80a15ff68c7741ca76c8c56e488e Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期二, 24 三月 2026 18:49:56 +0800
Subject: [PATCH] #

---
 rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx |  220 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 118 insertions(+), 102 deletions(-)

diff --git a/rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx b/rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx
index 55761cc..a2f385e 100644
--- a/rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx
+++ b/rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx
@@ -21,38 +21,39 @@
 import WarehouseAreasItemCreate from "./WarehouseAreasItemCreate";
 import request from '@/utils/request';
 import MyExportButton from '../components/MyExportButton';
-import { DEFAULT_PAGE_SIZE } from '@/config/setting';
+import { DEFAULT_PAGE_SIZE, PAGE_DRAWER_WIDTH } from '@/config/setting';
 import StickyDataTable from "../components/StickyDataTable";
 import WarehouseIsptResult from "./WarehouseIsptResult";
 import useTableLayout from '@/utils/useTableLayout';
 
-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" />,
-    <TextInput source="matnrCode" label="table.field.warehouseAreasItem.matnrCode" />,
-    <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" />,
-    <ReferenceInput source="shipperId" label="table.field.warehouseAreasItem.shipperId" reference="companys">
+const baseFilters = [
+    <SearchInput key="condition" source="condition" alwaysOn />,
+    <NumberInput key="areaId" source="areaId" label="table.field.warehouseAreasItem.areaId" />,
+    <TextInput key="asnCode" source="asnCode" label="table.field.warehouseAreasItem.asnCode" />,
+    <TextInput key="areaName" source="areaName" label="table.field.warehouseAreasItem.areaName" />,
+    <NumberInput key="matnrId" source="matnrId" label="table.field.warehouseAreasItem.matnrId" />,
+    <TextInput key="matnrName" source="matnrName" label="table.field.warehouseAreasItem.matnrName" />,
+    <TextInput key="matnrCode" source="matnrCode" label="table.field.warehouseAreasItem.matnrCode" />,
+    <TextInput key="barcode" source="barcode" label="table.field.warehouseAreasItem.barcode" />,
+    <NumberInput key="anfme" source="anfme" label="table.field.warehouseAreasItem.anfme" />,
+    <TextInput key="batch" source="batch" label="table.field.warehouseAreasItem.batch" />,
+    <TextInput key="platOrderCode" source="platOrderCode" label="table.field.asnOrderItem.platOrderCode" />,
+    <TextInput key="platWorkCode" source="platWorkCode" label="table.field.asnOrderItem.platWorkCode" />,
+    <TextInput key="projectCode" source="projectCode" label="table.field.asnOrderItem.projectCode" />,
+    <TextInput key="unit" source="unit" label="table.field.warehouseAreasItem.unit" />,
+    <TextInput key="stockUnit" source="stockUnit" label="table.field.warehouseAreasItem.stockUnit" />,
+    <TextInput key="brand" source="brand" label="table.field.warehouseAreasItem.brand" />,
+    <ReferenceInput key="shipperId" source="shipperId" label="table.field.warehouseAreasItem.shipperId" reference="companys">
         <AutocompleteInput label="table.field.warehouseAreasItem.shipperId" optionText="name" filterToQuery={(val) => ({ name: val })} />
     </ReferenceInput>,
-    <TextInput source="splrId" label="table.field.warehouseAreasItem.splrId" />,
-    <NumberInput source="weight" label="table.field.warehouseAreasItem.weight" />,
-    <TextInput source="prodTime" label="table.field.warehouseAreasItem.prodTime" />,
-    <TextInput source="splrBtch" label="table.field.warehouseAreasItem.splrBtch" />,
+    <TextInput key="splrId" source="splrId" label="table.field.warehouseAreasItem.splrId" />,
+    <NumberInput key="weight" source="weight" label="table.field.warehouseAreasItem.weight" />,
+    <TextInput key="prodTime" source="prodTime" label="table.field.warehouseAreasItem.prodTime" />,
+    <TextInput key="splrBtch" source="splrBtch" label="table.field.warehouseAreasItem.splrBtch" />,
 
-    <TextInput label="common.field.memo" source="memo" />,
+    <TextInput key="memo" label="common.field.memo" source="memo" />,
     <SelectInput
+        key="status"
         label="common.field.status"
         source="status"
         choices={[
@@ -61,19 +62,71 @@
         ]}
         resettable
     />,
-]
+];
+
+const baseFilterSources = new Set(baseFilters.map((item) => item.props.source).filter(Boolean));
+
+const hiddenColumns = [
+    'prodTime', 'platOrderCode', 'id', 'createTime', 'memo', 'areaId', 'brand',
+    'weight', 'splrId', 'projectCode', 'statusBool', 'extendFields.[priceUnitId]', 'isptResult$',
+    'extendFields.[inStockType]', 'matnrId', 'trackCode', 'workQty', 'batch', 'shipperId',
+    'isptResult', 'createBy$', 'extendFields.[baseUnitId]'
+];
+
+const baseColumns = [
+    <NumberField key="id" source="id" />,
+    <TextField key="areaName" source="areaName" label="鏀惰揣鍖哄悕绉�" />,
+    <TextField key="asnCode" source="asnCode" label="table.field.warehouseAreasItem.asnCode" />,
+    <TextField key="platWorkCode" source="platWorkCode" label="table.field.asnOrderItem.platWorkCode" />,
+    <TextField key="platItemId" source="platItemId" label="table.field.deliveryItem.platItemId" />,
+    <NumberField key="matnrId" source="matnrId" label="table.field.warehouseAreasItem.matnrId" />,
+    <TextField key="matnrCode" source="matnrCode" label="table.field.warehouseAreasItem.matnrCode" />,
+    <TextField key="maktx" source="maktx" label="table.field.warehouseAreasItem.matnrName" />,
+    <TextField key="splrBatch" source="splrBatch" label="table.field.warehouseAreasItem.splrBtch" />,
+    <TextField key="batch" source="batch" label="table.field.warehouseAreasItem.batch" />,
+    <TextField key="trackCode" source="trackCode" label="table.field.warehouseAreasItem.barcode" />,
+    <TextField key="unit" source="unit" label="table.field.warehouseAreasItem.unit" />,
+    <NumberField key="anfme" source="anfme" label="table.field.warehouseAreasItem.anfme" />,
+    <NumberField key="workQty" source="workQty" label="table.field.warehouseAreasItem.workQty" />,
+    <NumberField key="ableQty" source="ableQty" label="table.field.warehouseAreasItem.qty" />,
+    <TextField key="platOrderCode" source="platOrderCode" label="table.field.asnOrderItem.platOrderCode" />,
+    <TextField key="projectCode" source="projectCode" label="table.field.asnOrderItem.projectCode" />,
+    <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 trailingColumns = [
+    <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} />,
+];
+
+const buildDynamicFilter = (field) => (
+    <TextInput key={field.fields} source={field.fields} label={field.fieldsAlise} />
+);
+
+const buildDynamicColumn = (field) => (
+    <TextField key={field.fields} source={`extendFields.[${field.fields}]`} label={field.fieldsAlise} />
+);
 
 const WarehouseAreasItemList = () => {
     const [itemInfo, setItemInfo] = useState({})
     const [createDialog, setCreateDialog] = useState(false);
     const [drawerVal, setDrawerVal] = useState(false);
+    const [dynamicFilters, setDynamicFilters] = useState([]);
 
     return (
         <Box display="flex">
             <List
                 title={"menu.warehouseAreasItem"}
                 empty={false}
-                filters={filters}
                 sort={{ field: "create_time", order: "desc" }}
                 sx={{
                     flexGrow: 1,
@@ -81,6 +134,7 @@
                         theme.transitions.create(['all'], {
                             duration: theme.transitions.duration.enteringScreen,
                         }),
+                    marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                 }}
                 actions={(
                     <TopToolbar>
@@ -89,9 +143,13 @@
                         <MyExportButton />
                     </TopToolbar>
                 )}
+                filters={[...baseFilters, ...dynamicFilters]}
                 perPage={DEFAULT_PAGE_SIZE}
             >
-                <DynamicFields />
+                <DynamicFields
+                    drawerOpen={!!drawerVal}
+                    onDynamicFiltersChange={setDynamicFilters}
+                />
             </List>
             <WarehouseAreasItemCreate
                 open={createDialog}
@@ -117,88 +175,46 @@
 export default WarehouseAreasItemList;
 
 
-const DynamicFields = () => {
+const DynamicFields = ({ drawerOpen, onDynamicFiltersChange }) => {
     const notify = useNotify();
     const [columns, setColumns] = useState([]);
     const { isLoading } = useListContext();
-    const { boxMaxWidth, boxMaxHeight } = useTableLayout();
-
-    const hiddenColumns = [
-        'prodTime', 'platOrderCode', 'id', 'createTime', 'memo', 'areaId', 'brand',
-        'weight', 'splrId', 'projectCode', 'statusBool', 'extendFields.[priceUnitId]', 'isptResult$',
-        'extendFields.[inStockType]', 'matnrId', 'trackCode', 'workQty', 'batch', 'shipperId',
-        'isptResult', 'createBy$', 'extendFields.[baseUnitId]'
-    ];
+    const { boxMaxWidth, boxMaxHeight } = useTableLayout(drawerOpen);
 
     useEffect(() => {
-        getDynamicFields();
-    }, []);
+        let active = true;
 
-    const getDynamicFields = async () => {
-        const { data: { code, data, msg }, } = await request.get("/fields/enable/list");
-        if (code === 200) {
-            const arr = [
-                <NumberField key="id" source="id" />,
-                // <NumberField key="areaId" source="areaId" label="table.field.warehouseAreasItem.areaId" />,
-                <TextField key="areaName" source="areaName" label="鏀惰揣鍖哄悕绉�" />,    //table.field.warehouseAreasItem.areaName
-                <TextField key="asnCode" source="asnCode" label="table.field.warehouseAreasItem.asnCode" />,
-                <TextField source="platWorkCode" label="table.field.asnOrderItem.platWorkCode" />, 
-                <TextField source="platItemId" label="table.field.deliveryItem.platItemId" />, 
-                <NumberField key="matnrId" source="matnrId" label="table.field.warehouseAreasItem.matnrId" />,
-                <TextField key="matnrCode" source="matnrCode" label="table.field.warehouseAreasItem.matnrCode" />,
-                <TextField key="maktx" source="maktx" label="table.field.warehouseAreasItem.matnrName" />,
-                <TextField key="splrBatch" source="splrBatch" label="table.field.warehouseAreasItem.splrBtch" />,
-                <TextField key="batch" source="batch" label="table.field.warehouseAreasItem.batch" />,
-                <TextField key="trackCode" source="trackCode" label="table.field.warehouseAreasItem.barcode" />,
-                <TextField key="unit" source="unit" label="table.field.warehouseAreasItem.unit" />,
-                <NumberField key="anfme" source="anfme" label="table.field.warehouseAreasItem.anfme" />,
-                <NumberField key="workQty" source="workQty" label="table.field.warehouseAreasItem.workQty" />,
-                <NumberField key="ableQty" source="ableQty" label="table.field.warehouseAreasItem.qty" />,
-                <TextField source="platOrderCode" label="table.field.asnOrderItem.platOrderCode" />,                
-                <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="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.forEach(el => {
-                var i = 0;
-                filters.forEach((item) => {
-                    if (item.key === el.fields) {
-                        i = 1;
-                    }
-                });
-                if (i === 0) {
-                    filters.push(<TextInput key={el.fields} source={el.fields} label={el.fieldsAlise} />);
+        const getDynamicFields = async () => {
+            try {
+                const { data: { code, data, msg }, } = await request.get("/fields/enable/list");
+                if (!active) {
+                    return;
                 }
-            });
-        } else {
-            notify(msg);
-        }
-    }
+                if (code === 200) {
+                    const dynamicColumns = data.map(buildDynamicColumn);
+                    const nextDynamicFilters = data
+                        .filter((field) => !baseFilterSources.has(field.fields))
+                        .map(buildDynamicFilter);
+
+                    setColumns([...baseColumns, ...dynamicColumns, ...trailingColumns]);
+                    onDynamicFiltersChange(nextDynamicFilters);
+                } else {
+                    notify(msg);
+                }
+            } catch (error) {
+                if (active) {
+                    notify('璇锋眰鍑洪敊');
+                }
+            }
+        };
+
+        getDynamicFields();
+
+        return () => {
+            active = false;
+            onDynamicFiltersChange([]);
+        };
+    }, [notify, onDynamicFiltersChange]);
 
     return (
         <Box sx={{

--
Gitblit v1.9.1