1
15 分钟以前 12d9f4e03c0331efc9a656356e78b9f314639707
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
46
47
48
49
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;