/*
 * @Note:
 * @Author: 2058827620@qq.com
 * @Date: 2022-04-03 10:53:25
 */
import React, { useState, useRef, useEffect } from 'react';
import { Cascader } from 'antd';

import services from '@/services/admin';

const { addr3Tree } = services.ComController;


export const Addr3 = ({ defaultValue, ...restProps }) => {
    const [addr, setAddr] = useState([]);
    const { onChange } = restProps;


    useEffect(() => {
        addr3Tree().then(({ data }) => {
            setAddr(data);
        }).catch();
    }, []);
    const onCheckChange = (value, option) => {
        onChange(option);
    }

    return (
        <>
            <Cascader
                allowClear
                defaultValue={defaultValue}
                changeOnSelect
                options={addr}
                onChange={onCheckChange}
                placeholder="选择省市区"
                fieldNames={{ label: 'name', value: 'name', children: 'children' }}
            />
        </>
    );
};

export default Addr3;
