From 00ab993817c7cd9807052fdb643c03b4dc35b2a7 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期四, 13 十一月 2025 22:16:49 +0800
Subject: [PATCH] #新增 1. 拣货完成后,保存历史进出入库历史

---
 rsf-admin/src/page/orders/stock/OrderItemList.jsx |  124 ++++++++++++++++++++++++++++------------
 1 files changed, 86 insertions(+), 38 deletions(-)

diff --git a/rsf-admin/src/page/orders/stock/OrderItemList.jsx b/rsf-admin/src/page/orders/stock/OrderItemList.jsx
index 94e07d1..0affd7e 100644
--- a/rsf-admin/src/page/orders/stock/OrderItemList.jsx
+++ b/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";
@@ -43,6 +44,7 @@
 import MyField from "../../components/MyField";
 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': {
@@ -126,43 +128,7 @@
                 )}
                 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', 'orderId', 'sourceItemId', 'matnrId', 'purUnit','splrCode', 'purQty', 'createBy', 'packName', 'prodTime', 'splrName', 'splrCode', 'batch', 'packName', 'updateBy$', '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" />
-                    <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" />
-                    <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} />
-                </StyledDatagrid>
+                <DynamicFields />
             </List>
             <PageDrawer
                 title='stockItem Detail'
@@ -175,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>
+    )
+}

--
Gitblit v1.9.1