import EditIcon from '@mui/icons-material/Edit';
|
import { useState, useEffect } from 'react';
|
import {
|
Button, useListContext, SelectInput,
|
required, SelectArrayInput,
|
useTranslate, useNotify
|
} from 'react-admin';
|
import request from '@/utils/request';
|
|
const DictionarySelect = (props) => {
|
const { dictTypeCode, name, multiple = false, ...parmas } = 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 });
|
if (res?.data?.code === 200) {
|
|
setList(res.data.data.records.map((item) => {
|
return {
|
id: item.value,
|
name: item.label
|
}
|
}))
|
} else {
|
notify(res.data.msg);
|
}
|
}
|
const InputComponent = multiple ? SelectArrayInput : SelectInput;
|
|
return (
|
<InputComponent
|
source={name}
|
choices={list}
|
{...parmas}
|
/>
|
|
);
|
};
|
|
export default DictionarySelect;
|