verou
2025-03-21 242bcd15240d652874a9b19823d2ef3ed1f90347
rsf-admin/src/page/basicInfo/matnr/MatnrListAside.jsx
@@ -4,10 +4,11 @@
    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";
@@ -18,7 +19,8 @@
    const { setFilters } = useListContext(); // 获取列表上下文
    const [selectedOption, setSelectedOption] = useState(null);
    const [treeData, setTreeData] = useState([]);
    const [defaultIds, setDefaultIds] = useState(['29']);
    const [defaultIds, setDefaultIds] = useState(['65']);
    const [condition, setCondition] = useState('');
    const haveChildren = (item) => {
        if (Array.isArray(item)) {
@@ -38,15 +40,17 @@
        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)
                    setDefaultIds([items.at(0).id])
                } else {
                    notify(res.data.msg);
@@ -56,12 +60,12 @@
                notify('Error fetching tree data');
            });
    }, []);
    }
    const handleNodeSelect = (event, nodeId) => {
        setFilters({ groupId: nodeId });
    };
    const handleSearch = () => {
        console.log('Search Input:', selectedOption);
    const handleSearch = (e) => {
        setCondition(e.target.value)
    };
@@ -92,12 +96,15 @@
                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
                    defaultExpandedItems={defaultIds}
                    expansionTrigger="iconContainer"