import cityList from '@/utils/city'
import { Cascader } from 'antd'
import React from 'react'
type Props = {
    change: (v: any) => void,//回调
    fieldNames?: { label: string, value: string, childern: string },//自定义字段名称如需地域编号vlaue改id
    disabled?: boolean
}
/**
 * 地域联调 
 * @param fieldNames?:{ label: 'label', value: 'value', children: 'children' }自定义字段名称如需地域编号vlaue改id
 * @param change: (v: any[]) => void 回调函数选中后返回一个数组
 */
const CityCascader = React.memo((props: Props) => {
    const { change, fieldNames, disabled = false } = props
    return <Cascader
        options={cityList()}
        fieldNames={fieldNames || { label: 'label', value: 'value', children: 'children' }}
        onChange={change}
        placeholder="选择地域"
        style={{ minWidth: 220 }}
        disabled={disabled}
    />
})

export default CityCascader