skyouc
3 天以前 92a30abbdc9f65cb1a45a65e39cbfd3f6b52461e
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
import * as React from 'react';
import { SelectArrayInput, useRecordContext } from 'react-admin';
import request from '@/utils/request'
 
const WarehouseAreaSelect = (props) => {
    const [arr, setArr] = React.useState([]);
    const [loading, setLoading] = React.useState(true);    
 
    React.useEffect(() => {
        setLoading(true);
        request.post('/warehouseAreas/list', {}).then(res => {
            if (res?.data?.code === 200) {
                setArr(res.data.data.map(item => {
                    return {
                        id: item.id,
                        name: item.name
                    }
                }));
            }
            setLoading(false);
        }).catch(() => {
            setLoading(false);
        });
    }, []);
 
    return (
        <SelectArrayInput
            {...props}
            choices={arr}
            disabled={loading}
        />
    );
};
 
export default WarehouseAreaSelect;