/*
 * Creator:     ML
 * CreatDate:   2020-06-15
 * descripts：  贫困户配置 编辑 新增
 * */
import React from 'react';
import { Select, Input, Row, Col, Button, Spin, Divider, Popconfirm, message, Icon, Form, Modal, Card, Switch, DatePicker, Popover, List, InputNumber, Menu } from 'antd';
import { $http } from 'containers/config/https';
import 'assets/css/system.css';
import { Util } from 'tools/index';
// import PubilcTablePagination from '../common/PubilcTablePagination.jsx';
import store from 'store/index';
import moment from 'moment';

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

const formItemLayout = {
    labelCol: { span: 10 },
    wrapperCol: { span: 14 },
}
const paddRightCol = {
    paddingRight: "0px",
    paddingLeft: "10px"
}
const formItemLayoutList = {
    labelCol: { span: 5 },
    wrapperCol: { span: 19 }
}
const formItemLayou113 = {
    labelCol: { span: 11 },
    wrapperCol: { span: 13 },
}
const formItemLayoutTop = {
    labelCol: { span: 9 },
    wrapperCol: { span: 15 },
}
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: [],
                isopenOne: false,
                isopenTwo: false,
                isopenThree: false,
                formatType: true
            }
        }
        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.getSelectData();
            this.getHealth();
            let data = {}
            data = {
                params: [{
                    provinceFlag: localStorage.getItem('province') != null ? '' : 1,	//省
                    cityFlag: localStorage.getItem('city') != null ? '' : 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
                            })
                        }
                    } else {

                    }
                }
            })
        }
        showModal = (record, num) => {
            this.setState({
                modalVisible: true,
                params: record,
                birthDoor: true,//卡信息地址
                birthCity: [],
                birthAreas: [],
                birthVillages: [],
                birthHamlets: [],
                num,
            })
        }
        closeModal = () => {
            this.props.form.resetFields()
            this.setState({
                modalVisible: false,
                params: {}
            })
        }
        getSelectData = () => {
            let data = {
                params: [{
                    // provinceFlag: localStorage.getItem('province') != null ? '' : 1,	//省
                    // cityFlag: localStorage.getItem('city') != null ? '' : 1,  //市
                    patTypeFlag: 1,//病人类型
                    eduFlag: 1,
                    relationFlag: 1
                }],
            }
            $http.post("urlS", this, {
                code: "03030005",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        console.log("resres", res)
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ patType: res.patType }, ...{ education: res.education }, ...{ relation: res.relation } }
                        })

                    } else {

                    }
                },
                error: function (error) {

                }
            });
        }
        getHealth = () => {
            let data = {
                params: [{
                }],
            }
            $http.post("urlS", this, {
                code: "03030096",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ health: res.result }, }
                        })

                    } else {

                    }
                },
                error: function (error) {
                }
            })
            let dataTwo = {
                params: [{
                }],
            }
            $http.post("urlS", this, {
                code: "03030097",
                data: dataTwo,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ labor: res.result }, }
                        })

                    } else {

                    }
                },
                error: function (error) {

                }
            });
            let dataT = {
                params: [{
                }],
            }
            $http.post("urlS", this, {
                code: "03030098",
                data: dataT,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            baseParms: { ...this.state.baseParms, ...{ shake: res.result }, }
                        })

                    } 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 } }
                        })
                    } 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 } }
                        })
                    } 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 = () => {
            const { propMethod: { findData } } = this.props;
            findData();
            this.closeModal();
        }
        save = () => {
            this.props.form.validateFields((err, values) => {
                // const { params } = this.state;
                if (err) return;
                const session = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : '';
                const hospID = session.hospID ? session.hospID : "";
                let par = {
                    params: [{
                        patName: values.patName || "",
                        patIDCardNo: values.patIDCardNo || "",
                        patMobile: values.patMobile || "",
                        poorNum: values.poorNum || "",
                        relationshipID: values.relationshipID || "",
                        patEduID: values.patEduID || "",
                        patNationID: values.patNationID || "",
                        nationId: values.patNationID || "",
                        countryId: values.countryId || "",
                        patProvinceID: values.birthProvinceID || "",
                        patCityID: values.birthCityID || "",
                        patAreaID: values.birthAreaID || "",
                        patVillageID: values.birthVillageID || "",
                        patHamletID: values.birthHamletID || "",
                        labourSkillID: values.labourSkillID || "",
                        reducePovertyID: values.reducePovertyID || "",
                        healthStatus: values.healthStatus||[],
                        updateUserID: session.userID ? session.userID : "",
                        distinguishTime:values.firstDate ? moment(values.firstDate).format('YYYY') : undefined,//首次识别
                        poorDistinguishTime:values.poorFirstDate ? moment(values.poorFirstDate).format('YYYY-MM') : undefined,//贫困首次识别
                        reducePovertyYear:values.poorDate ? moment(values.poorDate).format('YYYY') : undefined,//脱贫年度
                      }]
                  
                };
                    $http.post("urlS", this, {
                        code: "03030095",
                        data:par,
                        success: function (res) {
                            if (+res.errorCode === 0 && +res.result.successNum!=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)
        }
        handlePanelChange = (v, number, name) => {
            this.setState({
                ["isopen" + number]: false
            })
            if (number == "Three") {
                let a = moment(v).format("YYYY-MM")
                this.props.form.setFieldsValue({
                    [name]: moment(a, "YYYY-MM")
                })
                this.setState({
                    formatType: true
                })
            } else {
                let a = moment(v).format("YYYY")
                this.props.form.setFieldsValue({
                    [name]: moment(a, "YYYY")
                })
            }
        }

        handleOpenChange = (status, number) => {
            // console.log(status) 
            if (number == "Three") {
                this.setState({
                    formatType: !status
                })
            }
            if (status) {
                this.setState({ ["isopen" + number]: true })
            } else {
                this.setState({ ["isopen" + number]: false })

            }
        }

        clearValue = (number, name) => {
            this.props.form.setFieldsValue({
                [name]: undefined
            })
            if (number == "Three") {
                this.setState({
                    formatType: true
                })
            }
            this.setState({
                ["isopen" + number]: false
            })

        }
        render() {
            const { propMethod } = this.props;
            const { getFieldDecorator } = this.props.form;
            const { baseParms, localProvince, num, localCity, birthCity, birthAreas, birthVillages, birthHamlets, provinceArr, cityArr, areasArr, VillagesArr, hamletsArr, modalVisible, params } = this.state;
            let firstCityItem = [] //省,市Option
            let birthCityItem = []
            let birthAreasItem = []//县Option
            let birthVillagesItem = []//乡
            let birthHamletsItem = []//村
            //角色
            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 educationOp = []
            baseParms.education && baseParms.education.map(item => {
                educationOp.push(<Option key={item.id} role={item.descripts + "^" + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //与户主关系
            let relationOp = []
            baseParms.relation && baseParms.relation.map(item => {
                relationOp.push(<Option key={item.id} role={item.descripts + "^" + item.descriptsSPCode} 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 healthOp = []
            baseParms.health && baseParms.health.map(item => {
                healthOp.push(<Option key={item.descripts} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={item.descripts}>{item.descripts}</Option>)
            })
            //劳动属性
            let laborOp = []
            baseParms.labor && baseParms.labor.map(item => {
                laborOp.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //是否脱贫
            let shakeOp = []
            baseParms.shake && baseParms.shake.map(item => {
                shakeOp.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} className="patNameDom">
                                <FormItem {...formItemLayout} label='姓名'>
                                    {getFieldDecorator('patName', {
                                        initialValue: params && params.patName  ? params && params.patName  : undefined,
                                        rules: [{ required: true, message: '请输入姓名', },
                                        ],
                                    })(
                                        <Input />
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} >
                                <FormItem  {...formItemLayout} label='证件号码'>
                                    {getFieldDecorator('patIDCardNo', {
                                        validateTrigger: ["onPressEnter", "onBlur"],
                                        initialValue: params && params.patIDCardNo ?params.patIDCardNo : undefined,
                                        rules: [{ required: true, message: '请输入证件号码' },
                                        { validator: Util.vailIdCard },],
                                        getValueFromEvent: (event) => {
                                            return event.target.value.replace(/[^\d|Xx]/g, '')
                                        },
                                    })(
                                        <Input
                                            style={{ padding: "0 2px", }}
                                            maxLength={18}
                                        />
                                    )}
                                </FormItem>
                            </Col> <Col span={6} >
                                <FormItem  {...formItemLayout} label='手机号码'>
                                    {getFieldDecorator('patMobile', {
                                        initialValue: params && params.patMobile ? params.patMobile : undefined,
                                        rules: [{ required: true, message: '请输入手机号码' }],
                                    })(
                                        <Input
                                            style={{ padding: "0 2px", }}
                                            maxLength={11}
                                            type="number"
                                        />
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label='人数'>
                                    {getFieldDecorator('poorNum', {
                                        initialValue: params && params.poorNum ?  params.poorNum : undefined,
                                        rules: [{ required: true, message: '请输入人数' },
                                        ],
                                    })(
                                        <InputNumber style={{ width: "100%" }} min={1} />
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6}>
                                <FormItem {...formItemLayou113} label='与户主关系'>
                                    {getFieldDecorator('relationshipID', {
                                        initialValue: params && params.relationshipID ? params.relationshipID : undefined,
                                        rules: [{ required: false, message: '请选择与户主关系' }],
                                    })(
                                        <Select showSearch optionFilterProp="role" >
                                            {relationOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6}>
                                <FormItem {...formItemLayout} label='文化程度'>
                                    {getFieldDecorator('patEduID', {
                                        initialValue: params && params.educationID ? params && params.educationID : undefined,
                                        rules: [{ required: false, message: '请选择文化程度' }],
                                    })(
                                        <Select showSearch optionFilterProp="role" >
                                            {educationOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label='劳动技能'>
                                    {getFieldDecorator('labourSkillID', {
                                        initialValue: params && params.labourSkillID ? String(params.labourSkillID) : undefined,
                                        rules: [{ required: true, message: '请选择劳动技能' },
                                        ],
                                    })(
                                        <Select showSearch optionFilterProp="role" >
                                            {laborOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            {/* <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('patNationID', {
                                        initialValue: params && params.patNationID ? String(params.patNationID) : undefined,
                                        rules: [{ required: false, message: '请选择民族' }],
                                    })(
                                        <Select showSearch allowClear optionFilterProp="role" >
                                            {nationOp}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6}>
                                <FormItem  {...formItemLayou113} label='省'>
                                    {getFieldDecorator('birthProvinceID',
                                        {
                                            initialValue: params && params.provinceID ? params.provinceID : undefined,
                                            rules: [{ required: false, 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: false, 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: false, 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: false, 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  {...formItemLayou113} 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('reducePovertyID', {
                                        initialValue: params && params.reducePovertyID ? params.reducePovertyID : undefined,
                                        rules: [{ required: true, message: '请选择脱贫属性', },
                                        ],
                                    })(
                                        <Select showSearch allowClear optionFilterProp="role" >
                                        {shakeOp}
                                    </Select> )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label='脱贫年度'>
                                    {getFieldDecorator('poorDate', {
                                        initialValue: params && params.reducePovertyYear ? moment(params.reducePovertyYear, "YYYY") : undefined,
                                        rules: [{ required: true, message: '请输入脱贫年度', },
                                        ],
                                    })(
                                        <DatePicker
                                            open={this.state.isopenOne}
                                            mode="year"
                                            placeholder='请选择年份'
                                            format="YYYY"
                                            onOpenChange={(e) => this.handleOpenChange(e, "One",)}
                                            onPanelChange={(v) => this.handlePanelChange(v, "One", "poorDate")}
                                            onChange={() => this.clearValue("One", "poorDate")}
                                        />
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayout} label='首次识别时间'>
                                    {getFieldDecorator('firstDate', {
                                        initialValue: params && params.distinguishTime ? moment(params.distinguishTime, "YYYY") : undefined,
                                        rules: [{ required: true, message: '请选择首次识别时间', },
                                        ],
                                    })(
                                        <DatePicker
                                            open={this.state.isopenTwo}
                                            mode="year"
                                            placeholder='请选择年份'
                                            format="YYYY"
                                            onOpenChange={(e) => this.handleOpenChange(e, "Two",)}
                                            onPanelChange={(v) => this.handlePanelChange(v, "Two", "firstDate")}
                                            onChange={() => this.clearValue("Two", "firstDate")}
                                        />
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={6} className="patNameDom">
                                <FormItem {...formItemLayou113} label='贫困人员识别时间'>
                                    {getFieldDecorator('poorFirstDate', {
                                        initialValue: params && params.poorDistinguishTime ? moment(params.poorDistinguishTime, "YYYY-MM") : undefined,
                                        rules: [{ required: true, message: '请选择贫困人员识别时间', },
                                        ],
                                    })(
                                        <DatePicker
                                            open={this.state.isopenThree}
                                            mode="month"
                                            placeholder='请选择年份'
                                            format={this.state.formatType ? 'YYYY-MM' : 'YYYYMM'}
                                            onOpenChange={(e) => this.handleOpenChange(e, "Three",)}
                                            onPanelChange={(v) => this.handlePanelChange(v, "Three", "poorFirstDate")}
                                            onChange={() => this.clearValue("Three", "poorFirstDate")}
                                        />
                                    )}
                                </FormItem>
                            </Col>
                            <Col span={18} className="patNameDom">
                                <FormItem {...formItemLayoutList} label='健康状况'>
                                    {getFieldDecorator('healthStatus', {
                                        initialValue: params && params.healthStatus && params.healthStatus.length > 0 ? params.healthStatus : undefined,
                                        rules: [{ required: true, message: '请选择健康状况', },
                                        ],
                                    })(
                                        <Select
                                            mode="multiple"
                                            style={{ width: '100%' }}
                                            placeholder="请选择健康状况"
                                            onChange={this.handleChangeCardType}
                                        >
                                            {healthOp}
                                        </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);