From d6b25d39193f9ad8d3e5cebf5f6b77f1813bd971 Mon Sep 17 00:00:00 2001
From: verou <857149855@qq.com>
Date: 星期三, 26 三月 2025 09:50:16 +0800
Subject: [PATCH] 11
---
rsf-admin/src/page/basicInfo/loc/LocListAside.jsx | 125 +++++++++++++++++++++++++++++++++++++++++
rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx | 2
rsf-admin/src/page/basicInfo/loc/LocList.jsx | 39 ++++++++++++
3 files changed, 163 insertions(+), 3 deletions(-)
diff --git a/rsf-admin/src/page/basicInfo/loc/LocList.jsx b/rsf-admin/src/page/basicInfo/loc/LocList.jsx
index 0d2f8e5..af7f744 100644
--- a/rsf-admin/src/page/basicInfo/loc/LocList.jsx
+++ b/rsf-admin/src/page/basicInfo/loc/LocList.jsx
@@ -55,6 +55,8 @@
import request from '@/utils/request';
import DiscountIcon from '@mui/icons-material/Discount';
import LinkIcon from '@mui/icons-material/Link';
+import InitModal from "./InitModal";
+import LocListAside from "./LocListAside";
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
'& .css-1vooibu-MuiSvgIcon-root': {
@@ -139,7 +141,7 @@
const [createDialog, setCreateDialog] = useState(false);
const [drawerVal, setDrawerVal] = useState(false);
-
+ const [initDialog, setInitDialog] = useState(false);
return (
<Box display="flex">
@@ -153,7 +155,33 @@
marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
}}
title={"menu.loc"}
- empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
+ empty={<EmptyData
+ children={
+ <Box sx={{ gap: 2, display: 'flex' }}>
+ <Button
+ variant="contained"
+ color="primary"
+ sx={{
+ fontSize: '1em',
+ mt: 2
+ }}
+ onClick={() => { setCreateDialog(true) }}>
+ {translate('create.empty.button')}
+ </Button>
+
+ <Button
+ variant="contained"
+ color="primary"
+ sx={{
+ fontSize: '1em',
+ mt: 2
+ }}
+ onClick={() => { setInitDialog(true) }}>
+ {translate('toolbar.locInit')}
+ </Button>
+ </Box>
+ }
+ onClick={() => { }} />}
filters={filters}
sort={{ field: "create_time", order: "desc" }}
actions={(
@@ -166,6 +194,7 @@
</TopToolbar>
)}
perPage={DEFAULT_PAGE_SIZE}
+ aside={<LocListAside />}
>
<StyledDatagrid
preferenceKey='loc'
@@ -232,6 +261,11 @@
setDrawerVal={setDrawerVal}
>
</PageDrawer>
+
+ <InitModal
+ open={initDialog}
+ setOpen={setInitDialog}
+ />
</Box>
)
}
@@ -272,6 +306,7 @@
const [createDialog, setCreateDialog] = useState(false);
+
return (
<>
<Button onClick={() => setCreateDialog(true)} label={"toolbar.batch"}>
diff --git a/rsf-admin/src/page/basicInfo/loc/LocListAside.jsx b/rsf-admin/src/page/basicInfo/loc/LocListAside.jsx
new file mode 100644
index 0000000..72a68da
--- /dev/null
+++ b/rsf-admin/src/page/basicInfo/loc/LocListAside.jsx
@@ -0,0 +1,125 @@
+import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
+import request from '@/utils/request';
+import {
+ SavedQueriesList,
+ FilterLiveSearch,
+ useNotify,
+ useListContext,
+ SearchInput
+} from 'react-admin';
+import BookmarkIcon from '@mui/icons-material/BookmarkBorder';
+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";
+import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';
+
+const LocListAside = () => {
+ const theme = useTheme();
+ const notify = useNotify();
+ const { setFilters } = useListContext(); // 鑾峰彇鍒楄〃涓婁笅鏂�
+ const [selectedOption, setSelectedOption] = useState(null);
+ const [treeData, setTreeData] = useState([]);
+ const [defaultIds, setDefaultIds] = useState(['65']);
+ const [condition, setCondition] = useState('');
+
+ const haveChildren = (item) => {
+ if (Array.isArray(item)) {
+ return item.map((k) => haveChildren(k));
+ }
+
+ if (item && typeof item === 'object') {
+ if (item.id !== undefined) {
+ item.id = item.id.toString();
+ }
+
+ if (item.children && Array.isArray(item.children)) {
+ item.children = haveChildren(item.children);
+ }
+ }
+
+ return item;
+ };
+ useEffect(() => {
+ 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)
+ setDefaultIds([items.at(0).id])
+
+ } else {
+ notify(res.data.msg);
+ }
+ })
+ .catch(error => {
+ notify('Error fetching tree data');
+ });
+
+ }
+ const handleNodeSelect = (event, nodeId) => {
+ console.log(nodeId);
+ // setFilters({ groupId: nodeId });
+ };
+ const handleSearch = (e) => {
+ setCondition(e.target.value)
+ };
+
+ const apiRef = useTreeViewApiRef();
+
+
+ const CustomCheckbox = React.forwardRef(function CustomCheckbox(props, ref) {
+ return <input type="checkbox" ref={ref} {...props} />;
+ });
+
+ const CustomTreeItem = React.forwardRef(function CustomTreeItem(props, ref) {
+ return (
+ <TreeItem2
+ {...props}
+ ref={ref}
+ slots={{
+ checkbox: CustomCheckbox,
+ }}
+ />
+ );
+ });
+
+
+ return (
+ <Card
+ sx={{
+ order: -1,
+ mr: 2,
+ mt: 8,
+ alignSelf: 'flex-start',
+ border: theme.palette.mode === 'light' && '1px solid #e0e0e3',
+ width: 250,
+ minWidth: 150,
+ height: `100%`,
+ }}
+ >
+ <CardContent>
+ {/* <Input
+ placeholder="鎼滅储搴撲綅"
+ sx={{ '--Input-focused': 1, marginBottom: '10px' }}
+ onChange={handleSearch}
+ /> */}
+ <RichTreeView
+ defaultExpandedItems={defaultIds}
+ expansionTrigger="iconContainer"
+ items={treeData}
+ slots={CustomTreeItem}
+ apiRef={apiRef}
+ onItemClick={handleNodeSelect} // 鐩戝惉鑺傜偣鐐瑰嚮浜嬩欢
+ />
+
+ </CardContent>
+ </Card>
+ )
+}
+
+export default LocListAside;
diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
index 6bfc5ee..2a7d658 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
@@ -196,7 +196,7 @@
<NumberField key="stagn" source="stagn" label="table.field.matnr.stagn" />,
<NumberField key="valid" source="valid" label="table.field.matnr.valid" />,
<NumberField key="validWarn" source="validWarn" label="table.field.matnr.validWarn" />,
- <NumberField key="flagCheck" source="flagCheck" label="table.field.matnr.flagCheck" />,
+ <BooleanField key="flagCheck" source="flagCheck" label="table.field.matnr.flagCheck" sortable={false} />,
<ReferenceField key="updateBy" source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
<TextField source="nickname" />
</ReferenceField>,
--
Gitblit v1.9.1