//卡信息配置
import React from 'react';
import { Select, Row, Col, Button, message, Form, Modal, Switch } from 'antd';
import { $http } from 'containers/config/https';
import { Util } from 'tools';
import 'assets/css/system.css';
import store from 'store/index';

const { Option } = Select;
const FormItem = Form.Item;

const formItemLayout = {
    labelCol: { span: 10 },
    wrapperCol: { span: 14 },
}

const formItemLayoutList = {
    labelCol: { span: 5 },
    wrapperCol: { span: 19 }
}

const HBCardConfigModal = Form.create()(
    class HBCardConfigModal extends React.Component {
        constructor(props) {
            super(props);
            this.state = {
                data: [],
                columns: [],
                total: 0,
                page: 1,
                pageSize: 10,
                baseParms: {},
                values: {},
                id: "",
                provinceArr: [],
                cityArr: [],
                areasArr: [],
                VillagesArr: [],
                hamletsArr: [],
                heightTable: "",
                modalVisible: false,
                birthDoor: true,//卡信息地址
                birthCity: [],//卡信息地市区信息
                birthAreas: [],//卡信息地县信息
                birthVillages: [],//卡信息地乡信息
                birthHamlets: [],//卡信息地村落信息
                patTypeStrData: [],
                cardTypeStrData: [],
                occupationOptionData: [], // 职业
            }
        }

        componentDidMount() {
            this.props.modalRef(this)
            // 初始化设置table的高度以及表体的高度 内容高度 height 
            if (document.querySelector('.ant-table-body')) {
                document.querySelector('.ant-table-body').style.height = store.getState().tableHeight.y - 40 + 'px'
            }
            this.getBaseParams();
            this.getPatType();
            let data = {}
            data = {
                params: [{
                    provinceFlag: localStorage.getItem('province') != null ? '' : 1, // 省
                    cityFlag: localStorage.getItem('city') != null ? '' : 1, // 市
                    occupationFlag: 1, // 职业
                }]
            }
            $http.post('urlS', this, {
                code: '03030005',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        if (JSON.parse(localStorage.getItem('province')) && JSON.parse(localStorage.getItem('province')).length > 0) {
                            this.setState({
                                localProvince: JSON.parse(localStorage.getItem('province'))
                            })
                        } else {
                            localStorage.setItem('province', JSON.stringify(res.province))
                            this.setState({
                                localProvince: res.province
                            })
                        } if (JSON.parse(localStorage.getItem('city')) && JSON.parse(localStorage.getItem('city')).length > 0) {
                            this.setState({
                                localCity: JSON.parse(localStorage.getItem('city'))
                            })
                        } else {
                            localStorage.setItem('city', JSON.stringify(res.city))
                            this.setState({
                                localCity: res.city
                            })
                        }
                        this.setState({ occupationOptionData: res?.occupation || [] });
                    }
                }
            })
            this.credTypeList()
        }

        // 证件类型加载
        credTypeList() {
            let data = {
                "params": [{
                    code: '',
                }]
            };

            $http.post('urlS', this, {
                code: "01040036",
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    if (errorCode === '0') {
                        this.setState({
                            credTypeData: res.result
                        })
                    }
                }
            });
        }

        showModal = (record, num) => {
            const requireFlagVal = record?.requireFlagArr || [];
            if (requireFlagVal && requireFlagVal.length > 0) {
                let requireFlagArr = [];
                for (let i = 0; i < requireFlagVal.length; i++) {
                    let requireFlagObj = requireFlagVal[i];
                    if (requireFlagObj && Object.prototype.toString.call(requireFlagObj) === '[object Object]') {
                        for (let keys in requireFlagObj) {
                            requireFlagArr.push(keys);
                        }
                    }
                }
                record.requireFlagArr = requireFlagArr;
            }
            this.setState({
                modalVisible: true,
                params: record,
                birthDoor: true,//卡信息地址
                birthCity: [],
                birthAreas: [],
                birthVillages: [],
                birthHamlets: [],
                num,
            })
        }

        closeModal = () => {
            this.props.form.resetFields()
            this.setState({
                modalVisible: false,
                params: {}
            })
        }

        getPatType = () => {
            let data = {
                params: [{
                    patTypeFlag: 1,//病人类型
                }],
            }
            $http.post("urlS", this, {
                code: "03030005",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ patType: res.patType, requireFlag: res?.requireFlag || [] } }
                        })
                    } else {

                    }
                },
                error: function (error) {

                }
            });
        }

        //获取对应的医院基础信息数据
        getBaseParams = () => {
            let data = {
                params: [{
                    hospID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : ''
                }],
            }
            $http.post("urlS", this, {
                code: "01040059",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ cardType: res.cardType } }
                        })
                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            });
            $http.post("urlS", this, {
                code: "06010032",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ sex: res.result.data } }
                        })
                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            });
            $http.post("urlS", this, {
                code: "06010034",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ nation: res.result.data } }
                        })
                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            });
            $http.post("urlS", this, {
                code: "03030023",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ country: res.result } }
                        })
                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            });
            $http.post("urlS", this, {
                code: "03030027",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ group: res.result.Data } }
                        })
                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            });
        }

        FindData = () => {
            this.props.propMethod && this.props.propMethod?.findData();
            this.closeModal();
        }

        save = () => {
            this.props.form.validateFields((err, values) => {
                const { params, baseParms } = this.state;
                if (err) return;
                const session = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : '';
                const hospID = session.hospID ? session.hospID : '';
                let requireFlagVal = values?.requireFlagArr || [];
                let requireFlagArr = [];
                if (requireFlagVal && requireFlagVal.length > 0) {
                    for (let i = 0; i < requireFlagVal.length; i++) {
                        let requireFlagID = requireFlagVal[i];
                        requireFlagArr.push({
                            [requireFlagID]: Util.returnDataCccordingToAttributes(baseParms?.requireFlag || [], requireFlagID, 'id')?.descripts || ''
                        })
                    }
                }
                let par = {
                    hospID: values.hospID || '',
                    credTypeID: values.credTypeID || '',
                    groupId: values.groupId || '',
                    cardTypeId: values.cardTypeId || '',
                    sexId: values.sexId || '',
                    nationId: values.nationId || '',
                    patTypeId: values.patTypeId || '',
                    countryId: values.countryId || '',
                    provinceId: values.birthProvinceID || '',
                    cityId: values.birthCityID || '',
                    areaId: values.birthAreaID || '',
                    villageId: values.birthVillageID || '',
                    hamletId: values.birthHamletID || '',
                    cardTypeStr: values.cardTypeStr || '',
                    patTypeStr: values.patTypeStr || '',
                    structAddress: this.state.defaultFlag == true ? "Y" : "N",
                    updateUserID: session.userID ? session.userID : '',
                    occupationRequireFlag: values?.occupationRequireFlag ? 'Y' : 'N', // 职业必填标志
                    occupationID: values?.occupationID || '', // 默认职业
                    requireFlagArr, // 必填项
                };
                if (params && params.id) {
                    par = { ...par, ...{ id: params.id } };
                    $http.post("urlS", this, {
                        code: "03030021",
                        data: {
                            params: [par]
                        },
                        success: function (res) {
                            if (+res.errorCode === 0) {
                                message.success("修改成功")
                                this.FindData();
                            } else {
                                message.error('失败：' + res.errorMessage);
                            }
                        },
                        error: function (error) {
                            message.error('失败：' + error);
                        }
                    });
                } else {
                    par = { ...par, ...{ hospId: hospID } };
                    $http.post("urlS", this, {
                        code: "03030020",
                        data: {
                            params: [par]
                        },
                        success: function (res) {
                            if (+res.errorCode === 0) {
                                message.success("新增成功")
                                this.FindData();
                            } else {
                                message.error('失败：' + res.errorMessage);
                            }
                        },
                        error: function (error) {
                            message.error('失败：' + error);
                        }
                    });
                }
            })
        }

        // delete = () => {
        //     let data = {
        //         params: [{
        //             hospID: this.state.hospID,
        //             updateUserID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
        //         }],
        //     }
        //     $http.post("urlS", this, {
        //         code: "05100210",
        //         data: data,
        //         success: function (res) {
        //             if (+res.errorCode === 0) {
        //                 message.success("删除成功")
        //                 this.reset()
        //                 this.FindData()
        //             } else {
        //                 message.error('失败：' + res.errorMessage);
        //             }
        //         },
        //         error: function (error) {
        //             message.error('失败：' + error);
        //         }
        //     })
        // }

        reset = () => {
            this.props.form.resetFields();
            this.setState({
                params: {},
                defaultFlag: false,
            })
        }

        //选择或清除省
        onProvinceChange(flag, value, option) {
            if (value) {
                let city = []
                city = this.state.localCity.filter((item) => item.province == value);
                let params = this.state.params;
                let patFlag = this.firstToUp(flag);
                if (params["pat" + patFlag + "ProvinceID"]) {
                    params["pat" + patFlag + "ProvinceID"] = undefined;
                    params["pat" + patFlag + "CityID"] = undefined;
                    params["pat" + patFlag + "AreaID"] = undefined;
                    params["pat" + patFlag + "VillageID"] = undefined;
                    params["pat" + patFlag + "HamletID"] = undefined;
                }
                if (city && city.length == 0) {
                    this.setState({
                        [flag + "Door"]: false
                    })
                } else {
                    this.setState({
                        [flag + "Door"]: true
                    })
                }
                this.setState({
                    [flag + "City"]: city,
                    [flag + "Areas"]: [],
                    [flag + "Villages"]: [],
                    [flag + "Hamlets"]: [],
                    params: params,
                })
                this.props.form.setFieldsValue({
                    [flag + "CityID"]: undefined,
                    [flag + "AreaID"]: undefined,
                    [flag + "VillageID"]: undefined,
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined
                });
            } else {
                //清除省
                this.props.form.setFieldsValue({
                    [flag + "CityID"]: undefined,
                    [flag + "AreaID"]: undefined,
                    [flag + "VillageID"]: undefined,
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined
                });
                let params = this.state.params;
                let patFlag = this.firstToUp(flag);
                if (params["pat" + patFlag + "ProvinceID"]) {
                    params["pat" + patFlag + "ProvinceID"] = undefined;
                    params["pat" + patFlag + "CityID"] = undefined;
                    params["pat" + patFlag + "AreaID"] = undefined;
                    params["pat" + patFlag + "VillageID"] = undefined;
                    params["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "City"]: [],
                    [flag + "Areas"]: [],
                    [flag + "Villages"]: [],
                    [flag + "Hamlets"]: [],
                    params: params,
                })
            }
        }

        //首字母大写
        firstToUp = (str) => {
            return str.substring(0, 1).toUpperCase() + str.substring(1);
            // 正则法
            // str = str.toLowerCase();
            // var reg = /\b(\w)|\s(\w)/g; //  \b判断边界\s判断空格
            // return str.replace(reg, function (m) {
            //     return m.toUpperCase()
            // });
        }

        onCityFocus = (provinceFlag, cityFlag) => {
            let city = this.state[cityFlag];
            let provinceID = this.props.form.getFieldValue(provinceFlag);
            if ((city.length === 0) && (provinceID)) {
                let newCity = []
                newCity = this.state.localCity.filter((item) => item.province == provinceID);
                this.setState({
                    [cityFlag]: newCity,
                })
            }
        }

        //选择或清除市
        onCityChange(flag, value, option) {
            if (value) {
                this.props.form.setFieldsValue({
                    [flag + "ProvinceID"]: option.props.provinceid,
                    [flag + "AreaID"]: undefined,
                    [flag + "VillageID"]: undefined,
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined
                });
                let params = this.state.params;
                let patFlag = this.firstToUp(flag);
                if (params["pat" + patFlag + "CityID"]) {
                    params["pat" + patFlag + "CityID"] = undefined;
                    params["pat" + patFlag + "AreaID"] = undefined;
                    params["pat" + patFlag + "VillageID"] = undefined;
                    params["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    params: params,
                })
                this.getAreas(value, flag, "1");
            } else {
                //清除市
                this.props.form.setFieldsValue({
                    [flag + "CityID"]: undefined,
                    [flag + "AreaID"]: undefined,
                    [flag + "VillageID"]: undefined,
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined
                });
                let params = this.state.params;
                let patFlag = this.firstToUp(flag);
                if (params["pat" + patFlag + "CityID"]) {
                    params["pat" + patFlag + "CityID"] = undefined;
                    params["pat" + patFlag + "AreaID"] = undefined;
                    params["pat" + patFlag + "VillageID"] = undefined;
                    params["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "Areas"]: [],
                    [flag + "Villages"]: [],
                    [flag + "Hamlets"]: [],
                    params: params,
                })
            }
        }

        //选择市时加载县数据
        getAreas = (cityID, flag, cleanFlag) => {
            let data = {
                params: [{
                    cityId: cityID
                }],
            }
            $http.post('urlS', this, {
                code: '03030006',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        if (cleanFlag === "1") {
                            this.setState({
                                [flag + "Areas"]: res.result,
                                [flag + "Villages"]: [],
                                [flag + "Hamlets"]: [],
                            })
                        } else {
                            this.setState({
                                [flag + "Areas"]: res.result,
                            })
                        }
                    } else {
                        this.setState({
                            [flag + "Areas"]: [],
                            [flag + "Villages"]: [],
                            [flag + "Hamlets"]: [],
                        })
                    }
                }
            })
        }

        //选择或清除县
        onAreaChange(flag, value, option) {
            if (value) {
                this.props.form.setFieldsValue({
                    [flag + "VillageID"]: undefined,
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined
                });
                this.getVillages(value, flag, "1");
            } else {
                //清除市
                this.props.form.setFieldsValue({
                    [flag + "VillageID"]: undefined,
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined
                });
                let params = this.state.params;
                let patFlag = "";
                switch (flag) {
                    case "birth":
                        patFlag = "Birth";
                        break;
                    case "native":
                        patFlag = "Native";
                        break;
                    case "present":
                        patFlag = "Present";
                        break;
                    case "register":
                        patFlag = "Register";
                        break;
                    case "company":
                        patFlag = "Company";
                        break;
                    case "contact":
                        patFlag = "Contact";
                        break;
                }
                if (params["pat" + patFlag + "AreaID"]) {
                    params["pat" + patFlag + "AreaID"] = undefined;
                    params["pat" + patFlag + "VillageID"] = undefined;
                    params["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "Villages"]: [],
                    [flag + "Hamlets"]: [],
                    params: params,
                })
            }
        }

        //县获取焦点
        onAreaFocus(cityFlag, areaFlag) {
            let area = this.state[areaFlag + "Areas"];
            let cityID = this.props.form.getFieldValue(cityFlag);
            if ((area.length === 0) && (cityID)) {
                this.getAreas(cityID, areaFlag, "0");
            }
        }

        //选择乡时加载村数据
        getHamlets = (villageID, flag) => {
            let data = {
                params: [{
                    villageId: villageID
                }],
            }
            $http.post('urlS', this, {
                code: '03030008',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            [flag + "hamlets"]: res.result,
                        })
                    } else {
                        this.setState({
                            [flag + "hamlets"]: [],
                        })
                    }
                }
            })
        }

        //选择或清除乡
        onVillageChange(flag, value, option) {
            // console.log("flag",flag,"value",value,"option",option)
            // presentZIP
            if (value) {
                this.props.form.setFieldsValue({
                    [flag + "HamletID"]: undefined
                });
                this.getHamlets(value, flag);
            } else {
                //清除市
                this.props.form.setFieldsValue({
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined
                });
                let params = this.state.params;
                let patFlag = "";
                switch (flag) {
                    case "birth":
                        patFlag = "Birth";
                        break;
                    case "native":
                        patFlag = "Native";
                        break;
                    case "present":
                        patFlag = "Present";
                        break;
                    case "register":
                        patFlag = "Register";
                        break;
                    case "company":
                        patFlag = "Company";
                        break;
                    case "contact":
                        patFlag = "Contact";
                        break;
                }
                if (params["pat" + patFlag + "VillageID"]) {
                    params["pat" + patFlag + "VillageID"] = undefined;
                    params["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "Hamlets"]: [],
                    params: params,
                })
            }
        }

        //乡获取焦点时调用
        onVillageFocus(areaFlag, villageFlag) {
            let village = this.state[villageFlag + "Villages"];
            let areaID = this.props.form.getFieldValue(areaFlag);
            if ((village.length === 0) && (areaID)) {
                this.getVillages(areaID, villageFlag, "0");
            }
        }

        //选择县时加载乡数据
        getVillages = (countyID, flag, cleanFlag) => {
            let data = {
                params: [{
                    areaId: countyID,
                }],
            }
            $http.post('urlS', this, {
                code: '03030007',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        if (cleanFlag === "1") {
                            this.setState({
                                [flag + "Villages"]: res.result,
                                [flag + "Hamlets"]: [],
                            })
                        } else {
                            this.setState({
                                [flag + "Villages"]: res.result,
                            })
                        }
                    } else {
                        this.setState({
                            [flag + "Villages"]: [],
                            [flag + "Hamlets"]: [],
                        })
                    }
                }
            })
        }

        onHamletFocus(villageFlag, hamletsFlag) {
            let hamlets = this.state[hamletsFlag + "Hamlets"];
            let villageID = this.props.form.getFieldValue(villageFlag);
            if ((hamlets.length === 0) && (villageID)) {
                this.getHamlets(villageID, hamletsFlag);
            }
        }

        // 显示分页总条数
        showTotal(total) {
            return `共 ${total} 条`;
        }

        getSelectData = (data) => {
            if (data) {
                if (data.countryId) {
                    this.getProvince(data.countryId);
                }
                if (data.provinceId) {
                    this.getCity(data.provinceId);
                }
                if (data.cityId) {
                    this.getAreas(data.cityId);
                }
                if (data.areaId) {
                    this.getVillages(data.areaId);
                }
                if (data.villageId) {
                    this.getHamlet(data.villageId);
                }
            }
        }

        setSelectData = (data) => {
            this.setState({ defaultFlag: data })
        }

        //swith开关状态处理
        onChangeSwith = (v) => {
            //   const {defaultFlag}=this.props
            //   console.log("this.props.default",this.props.defaultFlag)
            //  this.props.setDefaultFlag(v);
            // this.state.defaultFlag
            this.setState({ defaultFlag: v })
        }

        handleChangeCardType = (value) => {
            // console.log("value",value)
        }

        handleChangePatType = (value) => {
            // console.log("value",value)
        }

        render() {
            const { supHealthBur } = this.props;
            const { getFieldDecorator } = this.props.form;
            const { baseParms, localProvince, num, localCity, birthCity, birthAreas, birthVillages, birthHamlets, occupationOptionData, modalVisible, params } = this.state;
            let firstCityItem = [] //省,市Option
            let birthCityItem = []
            let birthAreasItem = []//县Option
            let birthVillagesItem = []//乡
            let birthHamletsItem = []//村
            let credTypeDataOption = []
            //证件类型
            this.state.credTypeData && this.state.credTypeData.map((item, index) => {
                credTypeDataOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
            })
            // 医院
            let supHealthBurOps = []
            supHealthBur && supHealthBur.map(item => {
                supHealthBurOps.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //角色
            let groupOp = []
            baseParms.group && baseParms.group.map(item => {
                groupOp.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //卡类型
            let cardTypeOp = []
            let cardTypeStrOpt = []
            baseParms.cardType && baseParms.cardType.map(item => {
                cardTypeOp.push(<Option key={item.id} role={item.descripts} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
                cardTypeStrOpt.push(<Option key={item.id} role={item.descripts} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //性别
            let sexOp = []
            baseParms.sex && baseParms.sex.map(item => {
                sexOp.push(<Option key={item.id} role={item.descripts} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //民族
            let nationOp = []
            baseParms.nation && baseParms.nation.map(item => {
                nationOp.push(<Option key={item.id} role={item.descripts} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //患者类别
            let patTypeOp = []
            let patTypeStrOpt = []
            baseParms.patType && baseParms.patType.map(item => {
                patTypeOp.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
                patTypeStrOpt.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //国家
            let countryOp = []
            baseParms.country && baseParms.country.map(item => {
                countryOp.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })

            let provinceItem = [];
            localProvince && localProvince.map(item => {
                provinceItem.push(<Option key={item.id} className={'1' + item.province} role={item.descripts + '^' + item.descriptsSPCode} value={String(item.id)} title={item.descripts}>{item.descripts}</Option>)
            });

            // let firstCityItem = []
            //第一次加载的城市;
            localCity && localCity.map(item => {
                firstCityItem.push(<Option provinceid={item.province} key={item.id} role={item.descripts + '^' + item.descriptsSPCode} value={String(item.id)} className={'2' + item.province} title={item.descripts}>{item.descripts}</Option>)
            });
            //卡信息城市
            if ((!birthCity && this.state.birthDoor) || (birthCity && birthCity.length === 0 && this.state.birthDoor)) {
                //卡信息城市下拉数据为空时加载所有城市
                birthCityItem = firstCityItem;
            } else {
                birthCity && birthCity.map(item => {
                    birthCityItem.push(<Option provinceid={item.province} key={item.id} role={item.descripts + '^' + item.descriptsSPCode} value={String(item.id)} className={'2' + item.province} title={item.descripts}>{item.descripts}</Option>)
                });
            }
            birthAreas && birthAreas.map(item => {
                birthAreasItem.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            });
            if ((birthAreas) && (birthAreas.length === 0) && (params && params.areaId)) {
                birthAreasItem.push(<Option key={params.areaId} role={params.areaDesc} title={params.areaDesc} value={String(params.areaId)}>{params.areaDesc}</Option>)
            }
            birthVillages && birthVillages.map(item => {
                birthVillagesItem.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            });
            if ((birthVillages) && (birthVillages.length === 0) && (params && params.villageId)) {
                birthVillagesItem.push(<Option key={params.villageId} role={params.villageDesc} title={params.villageDesc} value={String(params.villageId)}>{params.villageDesc}</Option>)
            }
            birthHamlets && birthHamlets.map(item => {
                birthHamletsItem.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            });
            if ((birthHamlets) && (birthHamlets.length === 0) && (params && params.hamletId)) {
                birthHamletsItem.push(<Option key={params.hamletId} role={params.hamletDesc} title={params.hamletDesc} value={String(params.hamletId)}>{params.hamletDesc}</Option>)
            }
            return (
                <Modal
                    onCancel={() => this.closeModal()}
                    title={<span>{num && num == "1" ? '编辑卡信息' : '添加卡信息'}</span>}
                    visible={modalVisible}
                    width={1200}
                    footer={null}
                >
                    <Form style={{ height: "100%", overflow: "hidden auto" }}>
                        <Row>
                            <Col span={6} >
                                <FormItem {...formItemLayout} label='医院'>
                                    {getFieldDecorator('hospID', {
                                        initialValue: params && params.hospId ? params && params.hospId : undefined,
                                        rules: [{ required: false, message: '' }],
                                    })(
                                        <Select showSearch allowClear optionFilterProp="role" >
                                            {supHealthBurOps}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label='角色'>
                                    {getFieldDecorator('groupId', {
                                        initialValue: params && params.groupId ? params && params.groupId : undefined,
                                        rules: [{ required: false, message: '请输入', },
                                        ],
                                    })(
                                        <Select showSearch allowClear optionFilterProp="role" >
                                            {groupOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6}>
                                <FormItem {...formItemLayout} label='卡类型'>
                                    {getFieldDecorator('cardTypeId', {
                                        initialValue: params && params.cardTypeId ? params.cardTypeId : undefined,
                                        rules: [{ required: true, message: '请选择卡类型' }],
                                    })(
                                        <Select showSearch optionFilterProp="role" >
                                            {cardTypeOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6}>
                                <FormItem {...formItemLayout} label='证件类型'>
                                    {getFieldDecorator('credTypeID', {
                                        initialValue: params && params.credTypeID ? params.credTypeID : undefined,
                                        rules: [{ required: true, message: '请选择证件类型' }],
                                    })(
                                        <Select showSearch optionFilterProp="role" >
                                            {credTypeDataOption}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6}>
                                <FormItem {...formItemLayout} label='性别'>
                                    {getFieldDecorator('sexId', {
                                        initialValue: params && params.sexId ? params && params.sexId : undefined,
                                        rules: [{ required: true, message: '请选择性别' }],
                                    })(
                                        <Select showSearch optionFilterProp="role" >
                                            {sexOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label='患者类别'>
                                    {getFieldDecorator('patTypeId', {
                                        initialValue: params && params.patTypeId ? String(params.patTypeId) : undefined,
                                        rules: [{ required: true, message: '请选择患者类别' },
                                        ],
                                    })(
                                        <Select showSearch optionFilterProp="role" >
                                            {patTypeOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label="默认职业">
                                    {getFieldDecorator('occupationID', {
                                        initialValue: params && params.occupationID ? String(params.occupationID) : undefined,
                                    })(
                                        <Select allowClear showSearch optionFilterProp="search">
                                            {React.$SelectOptions(occupationOptionData, 'value')}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label="职业是否必填">
                                    {getFieldDecorator('occupationRequireFlag', {
                                        valuePropName: 'checked',
                                        initialValue: params && params?.occupationRequireFlag === 'Y' ? true : false,
                                    })(
                                        <Switch checkedChildren="是" unCheckedChildren="否" />
                                    )}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row>
                            <Col span={6} >
                                <FormItem {...formItemLayout} label='国家'>
                                    {getFieldDecorator('countryId', {
                                        initialValue: params && params.countryId ? String(params.countryId) : undefined,
                                        rules: [{ required: true, message: '请选择国家' }],
                                    })(
                                        <Select showSearch optionFilterProp="role" >
                                            {countryOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} >
                                <FormItem {...formItemLayout} label='民族'>
                                    {getFieldDecorator('nationId', {
                                        initialValue: params && params.nationId ? String(params.nationId) : undefined,
                                        rules: [{ required: false, message: '请选择民族' }],
                                    })(
                                        <Select showSearch allowClear optionFilterProp="role" >
                                            {nationOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6}>
                                <FormItem  {...formItemLayout} label='省'>
                                    {getFieldDecorator('birthProvinceID',
                                        {
                                            initialValue: params && params.provinceId ? params.provinceId : undefined,
                                            rules: [{ required: true, message: '请选择省' }],
                                        })(
                                            <Select
                                                ref={this.bornProvince}
                                                allowClear={true}
                                                showSearch={true}
                                                placeholder='省'
                                                optionFilterProp="role"
                                                onChange={this.onProvinceChange.bind(this, "birth")}
                                            >
                                                {
                                                    localProvince && localProvince.map(item => {
                                                        return (<Option key={item.id + "birth"} className={'1' + item.province} role={item.descripts + '^' + item.descriptsSPCode} value={String(item.id)} title={item.descripts}>{item.descripts}</Option>)
                                                    })
                                                }
                                            </Select>
                                        )}
                                </FormItem>
                            </Col>
                            <Col span={6}  >
                                <FormItem  {...formItemLayout} label='市'>
                                    {getFieldDecorator('birthCityID',
                                        {
                                            initialValue: params && params.cityId ? params.cityId : undefined,
                                            rules: [{ required: true, message: '请选择市' }],
                                        })(
                                            <Select
                                                ref={this.birthCity}
                                                allowClear={true}
                                                showSearch={true}
                                                placeholder='市'
                                                optionFilterProp="role"
                                                onFocus={this.onCityFocus.bind(this, "birthProvinceID", "birthCity")}
                                                onChange={this.onCityChange.bind(this, "birth")}
                                            >
                                                {birthCityItem}
                                            </Select>
                                        )}
                                </FormItem>
                            </Col>
                            <Col span={6} >
                                <FormItem  {...formItemLayout} label='县'>
                                    {getFieldDecorator('birthAreaID',
                                        {
                                            initialValue: params && params.areaId ? params.areaId : undefined,
                                            rules: [{ required: true, message: '请选择县' }],
                                        })(
                                            <Select
                                                ref={this.bornCountry}
                                                allowClear={true}
                                                showSearch={true}
                                                placeholder='县'
                                                optionFilterProp="role"
                                                onChange={this.onAreaChange.bind(this, "birth")}
                                                onFocus={this.onAreaFocus.bind(this, "birthCityID", "birth")}
                                            >
                                                {birthAreasItem}
                                            </Select>
                                        )}
                                </FormItem>
                            </Col>
                            <Col span={6} >
                                <FormItem {...formItemLayout} label='乡'>
                                    {getFieldDecorator('birthVillageID',
                                        {
                                            initialValue: params && params.villageId ? params.villageId : undefined,
                                            // rules: [{ required: true, message: '请选择乡' }],
                                        })(
                                            <Select
                                                ref={this.bornVillage}
                                                allowClear={true}
                                                showSearch={true}
                                                placeholder='乡'
                                                optionFilterProp="role"
                                                onChange={this.onVillageChange.bind(this, "birth")}
                                                onFocus={this.onVillageFocus.bind(this, "birthAreaID", "birth")}
                                            >
                                                {birthVillagesItem}
                                            </Select>
                                        )}
                                </FormItem>
                            </Col>
                            <Col span={6} >
                                <FormItem  {...formItemLayout} label='村'>
                                    {getFieldDecorator('birthHamletID',
                                        {
                                            initialValue: params && params.hamletId ? params.hamletId : undefined,
                                            rules: [{ required: false, message: '请选择村' }],
                                        })(
                                            <Select
                                                ref={this.bornHamlet}
                                                allowClear={true}
                                                showSearch={true}
                                                placeholder='村'
                                                optionFilterProp="role"
                                                onFocus={this.onHamletFocus.bind(this, "birthVillageID", "birth")}
                                            >
                                            </Select>
                                        )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label='结构化地址'>
                                    {getFieldDecorator('structAddress', {
                                        initialValue: undefined,
                                        valuePropName: 'checked',
                                        rules: [{ required: false, message: '请输入网站', },
                                        ],
                                    })(
                                        <Switch checkedChildren="是" unCheckedChildren="否" onChange={(v) => { this.onChangeSwith(v) }} />
                                    )}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row>
                            <Col span={12} className="patNameDom">
                                <FormItem {...formItemLayoutList} label='卡类型列表'>
                                    {getFieldDecorator('cardTypeStr', {
                                        initialValue: params && params.cardTypeList && params.cardTypeList.length > 0 ? params.cardTypeList : undefined,
                                        rules: [{ required: true, message: '请选择卡类型', },
                                        ],
                                    })(
                                        <Select
                                            mode="multiple"
                                            style={{ width: '100%' }}
                                            placeholder="请选择卡类型"
                                            onChange={this.handleChangeCardType}
                                        >
                                            {cardTypeStrOpt}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={12} className="patNameDom">
                                <FormItem {...formItemLayoutList} label='患者类型列表'>
                                    {getFieldDecorator('patTypeStr', {
                                        initialValue: params && params.patTypeList && params.patTypeList.length > 0 ? params.patTypeList : undefined,
                                        rules: [{ required: true, message: '请选择患者类别', },
                                        ],
                                    })(
                                        <Select
                                            mode="multiple"
                                            style={{ width: '100%' }}
                                            placeholder="请选择患者类别"
                                            onChange={this.handleChangePatType}
                                        >
                                            {patTypeStrOpt}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row>
                            <Col span={12} className="patNameDom">
                                <FormItem {...formItemLayoutList} label="必填项">
                                    {getFieldDecorator('requireFlagArr', {
                                        initialValue: params && params.requireFlagArr && params.requireFlagArr.length > 0 ? params.requireFlagArr : undefined,
                                        rules: [{ required: false, message: '请选择必填项', },
                                        ],
                                    })(
                                        <Select
                                            mode="multiple"
                                            style={{ width: '100%' }}
                                            placeholder="请选择必填项"
                                        >
                                            {React.$SelectOptions(baseParms?.requireFlag || [])}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row style={{ display: "flex", justifyContent: "center" }}>
                            <Col span={2} >
                                <FormItem {...formItemLayout}>
                                    {getFieldDecorator('cBtn', {
                                        initialValue: undefined,
                                    })(
                                        <Button onClick={this.closeModal}>取消</Button>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={2} >
                                <FormItem {...formItemLayout}>
                                    {getFieldDecorator('uBtn', {
                                        initialValue: undefined,
                                    })(
                                        <Button type="primary" onClick={this.save}>{num && num == "1" ? '更新' : '新增'}</Button>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={2} >
                                <FormItem {...formItemLayout}>
                                    {getFieldDecorator('rBtn', {
                                        initialValue: undefined,
                                    })(
                                        <Button type="primary" onClick={this.reset}>重置</Button>
                                    )}
                                </FormItem>
                            </Col>
                        </Row>
                    </Form>
                </Modal>
            );
        }
    });
export default Form.create()(HBCardConfigModal);