verou
2025-03-18 1ec363b2a7195cb47e35a7e119012e20366aa71a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import EditIcon from '@mui/icons-material/Edit';
import { useState, useEffect } from 'react';
import {
    Button, useListContext, SelectInput,
    required,
    useTranslate, useNotify
} from 'react-admin';
import request from '@/utils/request';
 
const DictionarySelect = (props) => {
    const { dictTypeCode, name, ...parmas } = props;
    const { selectedIds } = useListContext();
    const translate = useTranslate();
    const notify = useNotify();
    const [list, setList] = useState([])
 
    useEffect(() => {
        http()
    }, [dictTypeCode]);
 
    const http = async () => {
        const res = await request.post('/dictData/page', { dictTypeCode });
        if (res?.data?.code === 200) {
 
            setList(res.data.data.records.map((item) => {
                return {
                    id: item.value,
                    name: item.value
                }
            }))
        } else {
            notify(res.data.msg);
        }
    }
 
    return (
        <SelectInput
            source={name}
            choices={list}
            {...parmas}
        />
    );
};
 
export default DictionarySelect;