| import { useState, useEffect } from 'react'; | 
| import { | 
|     useTranslate, useNotify, required | 
| } from 'react-admin'; | 
| import request from '@/utils/request'; | 
| import { Select, MenuItem, FormControl, InputLabel } from '@mui/material'; | 
|   | 
| const DictSelect = (props) => { | 
|     const { dictTypeCode, label, group, value, onChange, ...params } = props; | 
|     const translate = useTranslate(); | 
|     const notify = useNotify(); | 
|     const [list, setList] = useState([]); | 
|   | 
|     useEffect(() => { | 
|         http(); | 
|     }, [dictTypeCode]); | 
|   | 
|     const http = async () => { | 
|         const res = await request.post('/dictData/page', { dictTypeCode, group }); | 
|         if (res?.data?.code === 200) { | 
|             setList(res.data.data.records.map((item) => { | 
|                 return { | 
|                     value: item.value, | 
|                     label: item.label | 
|                 }; | 
|             })); | 
|         } else { | 
|             notify(res.data.msg); | 
|         } | 
|     }; | 
|   | 
|     const handleChange = (event) => { | 
|         const selectedValue = event.target.value; | 
|         if (onChange) { | 
|             onChange(event); | 
|         } | 
|     }; | 
|   | 
|     const validValue = list.some(item => item.value === value) ? value : ''; | 
|   | 
|     return ( | 
|         <FormControl fullWidth> | 
|             <InputLabel id="demo-select-small-label">{label}</InputLabel> | 
|             <Select | 
|                 labelId="demo-select-small-label" | 
|                 value={validValue} | 
|                 variant="filled" | 
|                 onChange={handleChange} | 
|                 size='small' | 
|             > | 
|                 {list.map((item) => ( | 
|                     <MenuItem key={item.value} value={item.value}> | 
|                         {item.label} | 
|                     </MenuItem> | 
|                 ))} | 
|             </Select> | 
|         </FormControl> | 
|     ); | 
| }; | 
|   | 
| export default DictSelect;     |