|  |  |  | 
|---|
|  |  |  | import { useState, useEffect } from 'react'; | 
|---|
|  |  |  | import { | 
|---|
|  |  |  | Button, useListContext, SelectInput, | 
|---|
|  |  |  | required, | 
|---|
|  |  |  | required, SelectArrayInput, | 
|---|
|  |  |  | useTranslate, useNotify | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import request from '@/utils/request'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const DictionarySelect = (props) => { | 
|---|
|  |  |  | const { dictTypeCode, name, ...parmas } = props; | 
|---|
|  |  |  | const { selectedIds } = useListContext(); | 
|---|
|  |  |  | const { dictTypeCode, name, multiple = false, ...parmas } = props; | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const [list, setList] = useState([]) | 
|---|
|  |  |  | 
|---|
|  |  |  | setList(res.data.data.records.map((item) => { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | id: item.value, | 
|---|
|  |  |  | name: item.value | 
|---|
|  |  |  | name: item.label | 
|---|
|  |  |  | } | 
|---|
|  |  |  | })) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(res.data.msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const InputComponent = multiple ? SelectArrayInput : SelectInput; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <SelectInput | 
|---|
|  |  |  | <InputComponent | 
|---|
|  |  |  | source={name} | 
|---|
|  |  |  | choices={list} | 
|---|
|  |  |  | {...parmas} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|