From 173fa3fa574eca7ccfae0dff28cb077cc4a5f391 Mon Sep 17 00:00:00 2001
From: verou <857149855@qq.com>
Date: 星期三, 19 三月 2025 08:05:11 +0800
Subject: [PATCH] fix:树状修改

---
 rsf-admin/src/page/basicInfo/loc/InitModal.jsx        |    1 
 rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx |   89 ++++++++------------------------------------
 rsf-admin/src/page/basicInfo/loc/LocEdit.jsx          |    2 
 rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx      |    4 +-
 rsf-admin/src/page/basicInfo/loc/LocList.jsx          |   11 +++--
 rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx      |    2 
 6 files changed, 26 insertions(+), 83 deletions(-)

diff --git a/rsf-admin/src/page/basicInfo/loc/InitModal.jsx b/rsf-admin/src/page/basicInfo/loc/InitModal.jsx
index 15156ca..80c6a2b 100644
--- a/rsf-admin/src/page/basicInfo/loc/InitModal.jsx
+++ b/rsf-admin/src/page/basicInfo/loc/InitModal.jsx
@@ -133,7 +133,6 @@
                                     value={formData.locType}
                                     onChange={(e) => handleChange(e.target.value, 'locType')}
                                     size="small"
-                                    validate={[required()]}
                                     dictTypeCode="sys_width_type"
                                 />
                             </Grid>
diff --git a/rsf-admin/src/page/basicInfo/loc/LocEdit.jsx b/rsf-admin/src/page/basicInfo/loc/LocEdit.jsx
index 3ea6793..a7fa2b8 100644
--- a/rsf-admin/src/page/basicInfo/loc/LocEdit.jsx
+++ b/rsf-admin/src/page/basicInfo/loc/LocEdit.jsx
@@ -171,7 +171,7 @@
                             <Grid item xs={6} display="flex" gap={1}>
                                 <NumberInput
                                     label="table.field.loc.row"
-                                    source="lrow"
+                                    source="row"
                                     validate={required()}
                                 />
                             </Grid>
diff --git a/rsf-admin/src/page/basicInfo/loc/LocList.jsx b/rsf-admin/src/page/basicInfo/loc/LocList.jsx
index c64bbb7..720770f 100644
--- a/rsf-admin/src/page/basicInfo/loc/LocList.jsx
+++ b/rsf-admin/src/page/basicInfo/loc/LocList.jsx
@@ -148,16 +148,16 @@
                     <NumberField source="warehouseId$" label="table.field.loc.warehouseId" />
                     <NumberField source="areaId$" label="table.field.loc.areaId" />
                     <TextField source="code" label="table.field.loc.code" />
-                    <TextField source="type" label="table.field.loc.type" />
+                    <TextField source="type$" label="table.field.loc.type" />
                     <TextField source="name" label="table.field.loc.name" />
                     <NumberField source="flagLogic" label="table.field.loc.flagLogic" />
                     <TextField source="fucAtrrs" label="table.field.loc.fucAtrrs" />
                     <TextField source="barcode" label="table.field.loc.barcode" />
                     <TextField source="unit" label="table.field.loc.unit" />
-                    <TextField source="size" label="table.field.loc.length" />
-                    <TextField source="size" label="table.field.loc.width" />
-                    <TextField source="size" label="table.field.loc.height" />
-                    <NumberField source="lrow" label="table.field.loc.row" />
+                    <TextField source="length" label="table.field.loc.length" />
+                    <TextField source="width" label="table.field.loc.width" />
+                    <TextField source="height" label="table.field.loc.height" />
+                    <NumberField source="row" label="table.field.loc.row" />
                     <NumberField source="col" label="table.field.loc.col" />
                     <NumberField source="lev" label="table.field.loc.lev" />
                     <NumberField source="channel" label="table.field.loc.channel" />
@@ -165,6 +165,7 @@
                     <NumberField source="maxPack" label="table.field.loc.maxPack" />
                     <NumberField source="flagLabelMange" label="table.field.loc.flagLabelMange" />
                     <TextField source="locAttrs" label="table.field.loc.locAttrs" />
+                    <TextField source="useStatus$" label="table.field.loc.useStatus" />
                     <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
                         <TextField source="nickname" />
                     </ReferenceField>
diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx
index cb35859..bffec91 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx
@@ -90,7 +90,7 @@
                 defaultValues={{}}
             // validate={(values) => { }}
             >
-                <Grid container width={{ xs: '20%', xl: '80%' }} rowSpacing={3} columnSpacing={3}>
+                <Grid container rowSpacing={3} columnSpacing={3}>
 
                     <Grid item xs={12} md={10}>
                         <Typography variant="h6" gutterBottom>
diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
index 90889d9..af3b2c8 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
@@ -66,7 +66,7 @@
         width: '200px'
     },
     '& .RaList-main': {
-        minHeight: '80vh'
+        minHeight: '90vh'
     },
     '& .column-name': {
     },
@@ -149,7 +149,7 @@
     const { isLoading } = useListContext();
 
     return (
-        <Box sx={{ position: 'relative', minHeight: "40vh", }}>
+        <Box sx={{ position: 'relative', minHeight: "60vh", }}>
             {isLoading && (
                 <LinearProgress
                     sx={{
diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx
index e20ce92..3a836ee 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx
@@ -11,41 +11,25 @@
 import { RichTreeView } from "@mui/x-tree-view/RichTreeView";
 import { TreeItem2 } from "@mui/x-tree-view/TreeItem2";
 
+
 const MatListAside = () => {
     const theme = useTheme();
     const notify = useNotify();
     const { setFilters } = useListContext(); // 鑾峰彇鍒楄〃涓婁笅鏂�
     const [selectedOption, setSelectedOption] = useState(null);
     const [treeData, setTreeData] = useState([]);
-    // 鐢ㄤ簬绠$悊灞曞紑椤圭殑鐘舵��
-    const [expandedItems, setExpandedItems] = useState([]);
-
-    // 閫掑綊鏀堕泦鎵�鏈夎妭鐐圭殑 id
-    const collectAllNodeIds = (nodes) => {
-        let allIds = [];
-        nodes.forEach((node) => {
-            allIds.push(node.id.toString());
-            if (node.children && Array.isArray(node.children)) {
-                allIds = allIds.concat(collectAllNodeIds(node.children));
-            }
-        });
-        return allIds;
-    };
+    const [defaultIds, setDefaultIds] = useState(['29']);
 
     const haveChildren = (item) => {
-        // 濡傛灉 item 鏄竴涓暟缁勶紝閬嶅巻鏁扮粍涓殑姣忎釜鍏冪礌
         if (Array.isArray(item)) {
             return item.map((k) => haveChildren(k));
         }
 
-        // 濡傛灉 item 鏄竴涓璞�
         if (item && typeof item === 'object') {
-            // 灏� id 杞崲涓哄瓧绗︿覆
             if (item.id !== undefined) {
                 item.id = item.id.toString();
             }
 
-            // 濡傛灉瀛樺湪 children锛岄�掑綊澶勭悊 children
             if (item.children && Array.isArray(item.children)) {
                 item.children = haveChildren(item.children);
             }
@@ -53,16 +37,17 @@
 
         return item;
     };
-
     useEffect(() => {
         request.post('/matnrGroup/tree')
             .then(res => {
                 if (res?.data?.code === 200) {
                     let data = res.data.data;
-                    let items = haveChildren(data);
-                    setTreeData(items);
-                    // 褰撴爲鏁版嵁鏇存柊鏃讹紝鏇存柊灞曞紑椤圭姸鎬�
-                    setExpandedItems(collectAllNodeIds(items));
+                    let items = haveChildren(data)
+
+                    setTreeData(items)
+                    setDefaultIds([items.at(0).id])
+
+
                 } else {
                     notify(res.data.msg);
                 }
@@ -70,56 +55,15 @@
             .catch(error => {
                 notify('Error fetching tree data');
             });
+
     }, []);
-
-    const treeData1 = [
-        {
-            id: '19',
-            label: '鍗婃垚鍝� ',
-            editable: true,
-            children: [
-                {
-                    id: 'grid-community',
-                    label: '@mui/x-data-grid',
-                    editable: true,
-                    children: [
-                        { id: 'grid-community22', label: '@mui/x-data-grid', editable: true },
-                    ],
-                },
-                { id: 'grid-pro', label: '@mui/x-data-grid-pro', editable: true },
-                { id: 'grid-premium', label: '@mui/x-data-grid-premium', editable: true },
-            ],
-        },
-        {
-            id: '18',
-            label: '鍘熸潗鏂�',
-        },
-        {
-            id: 'charts',
-            label: 'Charts',
-            children: [{ id: 'charts-community', label: '@mui/x-charts' }],
-        },
-        {
-            id: 'tree-view',
-            label: 'Tree View',
-            children: [{ id: 'tree-view-community', label: '@mui/x-tree-view' }],
-        },
-        {
-            id: 'tree-view2',
-            label: 'Tree View3',
-            children: [{ id: 'tree-view-community1', label: '@mui/x-tree-view' }],
-        },
-    ];
-
     const handleNodeSelect = (event, nodeId) => {
-        console.log('Selected Node ID:', nodeId);
         setFilters({ groupId: nodeId });
-        // 鍦ㄨ繖閲屽彲浠ユ牴鎹� nodeId 鏇存柊涓诲唴瀹瑰尯鍩�
     };
-
     const handleSearch = () => {
         console.log('Search Input:', selectedOption);
     };
+
 
     const CustomCheckbox = React.forwardRef(function CustomCheckbox(props, ref) {
         return <input type="checkbox" ref={ref} {...props} />;
@@ -136,6 +80,7 @@
             />
         );
     });
+
 
     return (
         <Card
@@ -154,18 +99,16 @@
                 <SavedQueriesList icon={<BookmarkIcon />} />
                 <FilterLiveSearch source="condition" />
                 <RichTreeView
-                    // 浣跨敤 expandedItems 鎺у埗灞曞紑鐘舵��
-                    expandedItems={expandedItems}
-                    // 澶勭悊灞曞紑椤圭姸鎬佺殑鍙樺寲
-                    onExpandedItemsChange={(newExpandedItems) => setExpandedItems(newExpandedItems)}
+                    defaultExpandedItems={defaultIds}
                     expansionTrigger="iconContainer"
                     items={treeData}
                     slots={CustomTreeItem}
                     onItemClick={handleNodeSelect} // 鐩戝惉鑺傜偣鐐瑰嚮浜嬩欢
                 />
+
             </CardContent>
         </Card>
-    );
-};
+    )
+}
 
-export default MatListAside;
\ No newline at end of file
+export default MatListAside;

--
Gitblit v1.9.1