|  |  |  | 
|---|
|  |  |  | useNotify, | 
|---|
|  |  |  | TextInput | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { Box, Button, Card, Stack, CardContent, Skeleton } from '@mui/material'; | 
|---|
|  |  |  | import { Box, Button, Card, Stack, CardContent, Skeleton, TextField } from '@mui/material'; | 
|---|
|  |  |  | import { SimpleTreeView, TreeItem, RichTreeView, useTreeViewApiRef } from '@mui/x-tree-view'; | 
|---|
|  |  |  | import SaveIcon from '@mui/icons-material/Save'; | 
|---|
|  |  |  | import request from '@/utils/request' | 
|---|
|  |  |  | 
|---|
|  |  |  | const [treeData, setTreeData] = useState([]); | 
|---|
|  |  |  | const [selectedItems, setSelectedItems] = useState([]); | 
|---|
|  |  |  | const [expandedItems, setExpandedItems] = useState([]); | 
|---|
|  |  |  | const [parmas, setParmas] = useState({ condition: '' }); | 
|---|
|  |  |  | const toggledItemRef = useRef({}); | 
|---|
|  |  |  | const apiRef = useTreeViewApiRef(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | reload() | 
|---|
|  |  |  | }, [role, originMenuIds]) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const reload = () => { | 
|---|
|  |  |  | setSelectedItems(originMenuIds.map(item => item + "")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const transformTree = (treeData) => { | 
|---|
|  |  |  | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const http = async () => { | 
|---|
|  |  |  | const res = await request.post('/menu' + '/tree', { condition: '' }); | 
|---|
|  |  |  | const res = await request.post('/menu/tree', parmas); | 
|---|
|  |  |  | if (res?.data?.code === 200) { | 
|---|
|  |  |  | const transformData = transformTree(res.data.data); | 
|---|
|  |  |  | setTreeData(transformData); | 
|---|
|  |  |  | 
|---|
|  |  |  | setTimeout(() => { | 
|---|
|  |  |  | http(); | 
|---|
|  |  |  | }, 200); | 
|---|
|  |  |  | }, [role, originMenuIds]) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const getAllItemItemIds = () => { | 
|---|
|  |  |  | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const search = (e) => { | 
|---|
|  |  |  | const value = e.target.value; | 
|---|
|  |  |  | setParmas({ | 
|---|
|  |  |  | ...parmas, | 
|---|
|  |  |  | condition: value | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | reload() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <Card sx={{ | 
|---|
|  |  |  | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | <Box sx={{ | 
|---|
|  |  |  | display: 'flex', | 
|---|
|  |  |  | justifyContent: 'flex-start' | 
|---|
|  |  |  | justifyContent: 'space-between', | 
|---|
|  |  |  | alignItems: 'center' | 
|---|
|  |  |  | }}> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <Button startIcon={<SaveIcon />} variant="contained" onClick={handleSave}> | 
|---|
|  |  |  | <TextField sx={{ width: '200px' }} label="搜索菜单" variant="outlined" value={parmas.condition} onChange={(e) => search(e)} /> | 
|---|
|  |  |  | <Button startIcon={<SaveIcon />} size="small" variant="contained" onClick={handleSave} sx={{ height: '40px' }}> | 
|---|
|  |  |  | {translate('ra.action.save')} | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | </Box> | 
|---|