From 23dbf6d954141c2e6c589248a409f308dbc138f0 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 14 五月 2025 09:13:40 +0800
Subject: [PATCH] #Agv入库
---
rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx | 112 +++++++++++++++----------------------------------------
1 files changed, 31 insertions(+), 81 deletions(-)
diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx
index e20ce92..dd93b57 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx
@@ -4,12 +4,14 @@
SavedQueriesList,
FilterLiveSearch,
useNotify,
- useListContext
+ useListContext,
+ SearchInput
} from 'react-admin';
import BookmarkIcon from '@mui/icons-material/BookmarkBorder';
-import { Box, Typography, Card, CardContent, useTheme, TextField } from '@mui/material';
+import { Box, Typography, Card, CardContent, useTheme, Input } from '@mui/material';
import { RichTreeView } from "@mui/x-tree-view/RichTreeView";
import { TreeItem2 } from "@mui/x-tree-view/TreeItem2";
+
const MatListAside = () => {
const theme = useTheme();
@@ -17,35 +19,19 @@
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(['65']);
+ const [condition, setCondition] = useState('');
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 +39,19 @@
return item;
};
-
useEffect(() => {
- request.post('/matnrGroup/tree')
+ http()
+ }, [condition]);
+
+ const http = () => {
+ request.post('/matnrGroup/tree', { condition })
.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 +59,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 = (e) => {
+ setCondition(e.target.value)
};
- const handleSearch = () => {
- console.log('Search Input:', selectedOption);
- };
const CustomCheckbox = React.forwardRef(function CustomCheckbox(props, ref) {
return <input type="checkbox" ref={ref} {...props} />;
@@ -137,6 +85,7 @@
);
});
+
return (
<Card
sx={{
@@ -147,25 +96,26 @@
border: theme.palette.mode === 'light' && '1px solid #e0e0e3',
width: 250,
minWidth: 150,
- height: `calc(100% - 120px)`,
+ height: `100%`,
}}
>
<CardContent>
- <SavedQueriesList icon={<BookmarkIcon />} />
- <FilterLiveSearch source="condition" />
+ <Input
+ placeholder="鎼滅储鐗╂枡鍒嗙粍"
+ sx={{ '--Input-focused': 1, marginBottom: '10px' }}
+ onChange={handleSearch}
+ />
<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