import { useState, useEffect } from 'react';
|
import {
|
useTranslate, useNotify, required, AutocompleteInput
|
} from 'react-admin';
|
import request from '@/utils/request';
|
|
const BasStationSelect = (props) => {
|
const { dictTypeCode, label, name, validate, ...params } = props;
|
const translate = useTranslate();
|
const notify = useNotify();
|
const [list, setList] = useState([]);
|
|
useEffect(() => {
|
http();
|
}, [dictTypeCode]);
|
|
const http = async () => {
|
const res = await request.post('/basStation/page/v1', { current: 1, pageSize: 100 });
|
if (res?.data?.code === 200) {
|
setList(res.data.data.records.map((item) => {
|
return {
|
id: item.id.toString(),
|
name: item.stationName
|
};
|
}));
|
} else {
|
notify(res.data.msg);
|
}
|
};
|
|
return (
|
<AutocompleteInput
|
source={name}
|
label={label}
|
choices={list}
|
validate={validate}
|
options={{
|
ListboxProps: {
|
style: { maxHeight: '200px' }
|
},
|
...(params.options || {})
|
}}
|
fullWidth
|
{...params}
|
/>
|
);
|
};
|
|
export default BasStationSelect;
|