// 入院通知登记
import React from 'react';
import { Card, Row, Col, Form, Icon, Table, Button, DatePicker, Select, Input, Tooltip, message, Popconfirm } from 'antd';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import ReadCard from '../../../components/readcard/ReadCard';
import { $http } from 'containers/config/https';
import store from 'store';
import style from './style/style.less'
import Moment from 'moment';

const { Option } = Select;
const FormItem = Form.Item;
const { TextArea } = Input;
let user;
const formItemLayout = {    // label 和input宽度
    labelCol: { span: 9 },
    wrapperCol: { span: 15 },
};
const formItemLayoutAdd = {    // label 和input宽度
    labelCol: { span: 5 },
    wrapperCol: { span: 19 },
};
const formItemLayoutAddress = {    // label 和input宽度
    labelCol: { span: 2 },
    wrapperCol: { span: 22 },
};
const formItemLayoutSex = {    // label 和input宽度
    labelCol: { span: 4 },
    wrapperCol: { span: 20 },
};
const now = new Date(); //当前日期
const AdmissionRegistration = Form.create()(
    class extends React.Component {
        constructor() {
            super();
            this.state = {
                locList: [],         //科室
                wardList: [],        //病区
                docList: [],         //医生
                locInfo: [], // 科室名称下拉框
                wardInfo: [],//病区
                wardBedAry: [],//床号
                userInfo: [],//医生
                admReason: [],//费别
                readInfoLoading: false,//无卡时loading信息
                data: [],
                initCardDr: "",  //卡类型ID 
                baseParms: {},
                patInfo: {},
                page: 1,
                pageSize: 10,
                record: {},
                columns: [],
                tipsCardNo: "",//建卡卡号错误提示 - 文字信息
                nowRead: 'n',//卡类型设置是否可操作
                cardLength: "",//卡长度
                nowCost: 0,//当前卡费
                nowInv: '',//是否显示发票
                replenishZero: "",//是否补0
                repariFeeFlag: "N",//费用置为0或空
                cardNoVisible: false,//建卡卡号错误提示 - title框显示
                idCardCodePop: '',
                visible: false,
                presentCity: [],//籍贯市区信息
                presentAreas: [],//籍贯县信息
                presentVillages: [],//籍贯乡信息
                presentHamlets: [],//籍贯村落信息
                patCredTypeID: "",       //患者证件类型
                contactCredTypeID: "",   //紧急联系人证件类型
                patCredNo: "",
                needDay: "",
                appointDate: "",
                patNumber: "",           //患者证件号
                contactCredNo: "",       //联系人证件号
                tipsCardNo: "",//建卡卡号错误提示 - 文字信息
                locID: '',
                remainBed: 0, //剩余床位数
                //E 空数据校验, M 手机号校验,N 数值类型元素校验
                tipsItem: [
                    {
                        code: "patName",
                        flag: "E",
                        msg: "请填写患者姓名"
                    }, {
                        code: "patSexID",
                        flag: "E",
                        msg: "请选择性别"
                    }, {
                        code: "patCredTypeID",
                        flag: "E",
                        msg: "请选择证件类型"
                    }, {
                        code: "patTypeID",
                        flag: "E",
                        msg: "请选择病人类型"
                    }, {
                        code: "patMobile",
                        flag: "M",
                        msg: "请输入正确的手机号"
                    }, {
                        code: "presentAddressDesc",
                        flag: "E",
                        msg: "请填写现住址详细地址"
                    }, {
                        code: "inHospNum",
                        flag: "N",
                        msg: "非正整数"
                    }, {
                        code: "admReasonID",
                        flag: "E",
                        msg: "请选择结算类型"
                    }, {
                        code: "inWardID",
                        flag: "E",
                        msg: "请选择就诊病区"
                    }, {
                        code: "inLocID",
                        flag: "E",
                        msg: "请选择就诊科室"
                    }, {
                        code: "patEContactMobile",
                        flag: "M",
                        msg: "手机号不正确"
                    }, {
                        code: "patCompanyTel",
                        flag: "M",
                        msg: "手机号不正确"
                    }],
                cacheCityIdData: [], //存储
                cacheAreaIdData: [],
                ENObj: {},
                CNObj: {},



            };
            user = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
            this.cardNo = React.createRef();
            this.patName = React.createRef();
            this.patCredNo = React.createRef();
            this.ward = React.createRef();

        }

        componentDidMount() {
            this.loadColumn();
            this.getLocList("locList", "");
            this.loadBaseParms();
            this.getDepartmentInformation();
            let listData = document.querySelectorAll('.ReginHeight  .ant-table-body');
            if (listData.length > 0) {
                listData[0].style.height = store.getState().tableHeight.y - 55 + 'px';
            }
        }

        componentWillReceiveProps(props) {

        }
        // 3.13.23.获取科室信息
        getDepartmentInformation() {
            let data = {
                params: [{

                }]
            }
            $http.post('urlS', this, {
                code: "04090022",
                data: data,
                success: function (res) {
                    if (res.errorCode == '0') {
                        this.setState({
                            locInfo: res.result.locInfo,  //科室                      
                            userInfo: res.result.userInfo,//医生
                            wardInfo: res.result.wardInfo,//病区
                            admReason: res.result.admReason,//费别
                            wardBedAry: res.result.wardBedAry,//床号
                        })
                    } else {
                        this.setState({ DepartmentInformation: [] })
                    }
                }
            })
        }
        handleReset = () => {
            this.props.form.resetFields();
            this.setState({
                record: {},
                dataSource: [],
                patInfo: {},
                admInfo: {},
                selectData: [],
                docList: [],    //医生 
                readInfoLoading: false,
                inHospDisabled: false,
                presentCity: [],//籍贯市区信息
                presentAreas: [],//籍贯县信息
                presentVillages: [],//籍贯乡信息
                presentHamlets: [],//籍贯村落信
                patCredTypeID: "",       //患者证件类型
                contactCredTypeID: "",   //紧急联系人证件类型
                //提示信息
                tipsPatName: "",
                tipsPatSexID: "",
                tipsPatCredTypeID: "",
                tipsPatCredNo: "",
                tipsPatTypeID: "",
                tipsPatMobile: "",
                tipsPresentAddressDesc: "",
                tipsInHospNum: "",
                tipsAdmReasonID: "",
                tipsInLocID: "",
                tipsInWardID: "",
                tipsPatEContactCredTypeIDNo: "",
                tipsPatEContactMobile: "",
                tipsPatCompanyTel: "",
            })
        }

        //加载下拉框信息
        loadBaseParms = () => {
            let data = {}
            data = {
                params: [{
                    cardTypeFlag: 1,//卡类型
                    credTypeFlag: 1,//证件类型
                    patTypeFlag: 1,//病人类型
                    sexFlag: 1,	//性别
                    countryFlag: 1,	//国家
                    nationFlag: 1,//民族
                    occupationFlag: 1,//职业
                    maritalFlag: 1,	//婚姻
                    socialStatusFlag: 1,//身份标签
                    ageUnitFlag: '',
                    payMethodFlag: '',
                    provinceFlag: 1,	//省
                    cityFlag: 1,  //市 
                    relationFlag: 1,
                    admReasonFlag: "1",
                    wardListFlag: 1,
                    wardColumnFlag: 1,
                }]
            }
            $http.post('urlS', this, {
                code: '03030005',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        let defCardType = {};
                        res.cardType.map((item, i) => {
                            if (item.defaultFlag === "Y") {
                                defCardType = res.cardType[i];
                            }
                        })
                        if ((!defCardType.id) && (res.cardType.length > 0)) {
                            defCardType = res.cardType[0];
                        }
                        this.setState({
                            initCardDr: defCardType.id,
                            nowRead: defCardType.readMode,
                            cardLength: defCardType.cardLength && defCardType.cardLength != "" ? defCardType.cardLength + "位," : "",
                            nowCost: defCardType.cardCost,
                            idCardCodePop: defCardType.code,
                            nowInv: defCardType.invFlag,
                            replenishZero: defCardType.replenishZero,
                            repariFeeFlag: defCardType.repariFeeFlag,
                            cardNoVisible: false,
                            baseParms: res,
                            province: res.province,
                            firstCity: res.city,
                            admReasonList: res.admReason,
                            wardList: res.wardList,
                            wardListColumns: res.wardColumn,
                            wardColumnsWidth: res.wardTotalWidth,
                        })
                    }
                }
            })
        }
        handlesubmit = (flag) => {
            let that = this;
            this.checkAllTips();
            let data = {};
            this.props.form.validateFields((err, values) => {
                if (!err) {
                    let data = {}
                    data = {
                        params: [{
                            ID: this.state.record ? this.state.record.id : '',
                            patID: this.state.patInfo.patID ? this.state.patInfo.patID : (this.state.record ? this.state.record.patID : ''),
                            patName: values.patName ? values.patName : '',
                            mobile: values.patMobile ? values.patMobile : '',
                            appointDate: values.EndData ? values.EndData : '',
                            days: values.approve ? values.approve : '',
                            sex: values.patSexID ? values.patSexID : '',
                            locID: values.locID ? values.locID : '',
                            wardID: values.wardID ? values.wardID : '',
                            provinceID: values.presentProvinceID ? values.presentProvinceID : '',
                            cityID: values.presentCityID ? values.presentCityID : '',
                            areaID: values.presentAreaID ? values.presentAreaID : '',
                            villageID: values.presentVillageID ? values.presentVillageID : '',
                            hamletID: values.presentHamletID ? values.presentHamletID : '',
                            address: values.presentAddressDesc ? values.presentAddressDesc : '',
                            reason: values.Reason ? values.Reason : '',
                            contactUser: values.patEContact ? values.patEContact : '',
                            contactMobile: values.patEContactMobile ? values.patEContactMobile : '',
                            notes: values.notes ? values.notes : '',
                            notify: flag == "send" ? "Y" : "N"
                            //mobile\appointDate\days: values.status ? values.status : '',
                        }],
                    };
                    $http.post('urlS', this, {
                        code: "04200001",
                        data: data,
                        success: function (res) {
                            if (+res.errorCode === 0 && res.result) {
                                message.success('保存成功');
                                this.selectInfoByCondition();
                                this.handleReset();//重置表单
                                this.setState({
                                    record: {},
                                    patInfo: {},
                                })
                            } else {
                                message.error('失败：' + res.errorMessage);
                            }
                        },
                    });
                }
            })

        }
        onColumnRef = (ref) => {
            this.columnRef = ref;
        }
        //查询列头数据
        loadColumn = () => {
            let data = {
                params: [{
                    compontName: 'AppointInHospital',
                    type: "C",
                    reactCode: ['AppointInHospital'],
                }]
            }
            $http.post('urlDeault', this, {
                code: "01040073",
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        let column = res.result.C;
                        if (user.language == 'EN') {
                            for (let i = 0; i < column.length; i++) {
                                column[i].title = column[i].enDescripts
                            }
                        }
                        for (let i = 0; i < column.length; i++) {
                            var diagColumns = [];
                                diagColumns.push({
                                    title: user.language != 'EN' ? user.language != 'EN' ? column[i].title : column[i].enDescripts : column[i].enDescripts,
                                    dataIndex: column[i].dataIndex,
                                    width: column[i].width,
                                    align: 'center',
                                    render: (text, data, index) => {
                                        return (
                                            <span><font style={{color:data.notifyCode}}>{text}</font></span>
                                        )
                                    }
                                })
                                column[i] = diagColumns[0]
                        }
                        this.setState({
                            columns: column,
                            tableWidth: res.totalWidth,
                            ENObj: res.result.language.EN,
                            CNObj: res.result.language.CN,

                        }, () => {
                            this.getAppointInHospital();
                        })
                    }
                }
            })
        }

        /**  
         *  获取查询预约住院Table表数据
        */
        getAppointInHospital() {
            let data = {
                params: [{
                    needDay: this.state.needDay,
                    appointDate: this.state.appointDate,
                    patNumber: this.state.patNumber,
                }]
            }
            $http.post('urlDeault', this, {
                code: "04200002",
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        this.setState({
                            data: res.result.appointInHospitalArr
                        });
                    } else {
                        message.error('获取基本信息失败!:' + res.errorMessage);
                    }
                }
            })
        }

        selectInfoByCondition = () => {
            this.setState({
                page: 1
            }, () => {
                this.getAppointInHospital()
            })
        }

        changePersonMark = (e) => {
            this.setState({
                patNumber: e.target.value
            })
        }

        selectDispatchInfo = (flag, e, timeString) => {
            this.setState({
                [flag]: timeString
            }, () => {
                this.selectInfoByCondition()
            })
        }

        onRow = (record) => {
            var that = this
            return {
                onClick: () => {
                    if (that.state.record.id != undefined && that.state.record.id == record.id) {
                        that.setState({
                            record: {},
                        })
                    } else {
                        this.getAreas(record.cityID, 'present', "0");
                        this.getVillages(record.areaID, 'present', "0");
                        setTimeout(() => {
                            that.setState({
                                record: record,
                                patInfo: record,
                                patInfo: {},
                            })
                        }, 100)
                    }
                }
            };
           
        }
         // 表格行的类名
         setRowClassName = (record) => {
            return record.id === this.state.record.id ? 'clickRowStyle' : '';
        }
      
        //清空表单
        resetFields = () => {
            this.props.form.resetFields(); //清空所有
        }
        //校验所有需要校验的数据
        checkAllTips = () => {
            //E 空数据校验, M 手机号校验,N 数值类型元素校验
            this.state.tipsItem.map((item) => {
                switch (item.flag) {
                    case "M":
                        this.onTipsItemTel(item.code, item.msg);
                        break;
                    case "N":
                        this.onTipsItemInHosNum(item.code, item.msg);
                        break;
                    case "E":
                        this.onTipsItemBlur(item.code, item.msg)
                        break;
                }
            })
        }
        ///需要提醒的住院次数校验
        onTipsItemInHosNum(flag, title) {
            let tipsFlag = "tips" + this.firstToUp(flag);
            let regex = new RegExp(/^[1-9]\d*$/);
            let value = this.props.form.getFieldValue(flag);
            if (!regex.test(value)) {
                this.setState({
                    [tipsFlag]: title,
                })
            } else {
                this.setState({
                    [tipsFlag]: "",
                })
            }
        }
        //病区获取焦点
        onWardFocus = (flag, e) => {
            const locID = this.props.form.getFieldValue('inLocID');
            if ((this.state.wardList.length === 0) && (locID) && (locID !== "")) {
                this.getLocList("wardList", locID);
            }
            let tips = "tips" + this.firstToUp(flag);
            this.setState({
                [tips]: "",
            })
        }
        //科室获取焦点
        onLocFocus = () => {
            if (this.state.locList.length === 0) {
                this.getLocList("locList", "");
            }
            let tipsFlag = "tips" + this.firstToUp("inLocID");
            this.setState({
                [tipsFlag]: "",
            })
        }
        //科室改变
        onInLocChange = (value, option) => {
            this.props.form.setFieldsValue({
                inWardID: undefined,
            });
            if (value) {
                this.getLocList("wardList", value);
            } else {
                this.getDepartmentInformation();
                this.props.form.setFieldsValue({
                    admDocID: '',
                    wardID: '',
                    admLocBedID: ''

                })
            }
        }
        getLocList = (flag, locID) => {
            let linkFlag = "", docFlag = "";
            if (flag === "locList") {
                linkFlag = "";
            } else {
                linkFlag = "1";
                docFlag = "1";
            }
            let data = {
                params: [{
                    type: "I^OI",
                    hospID: user.hospID,
                    locID: locID,
                    detailFlag: "",
                    linkFlag: linkFlag,
                    docFlag: docFlag,
                    linkType: "W",
                }]
            }
            $http.post('urlDeault', this, {
                code: "04020008", data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        if (flag === "locList") {
                            this.setState({
                                locInfo: res.result.Data,
                                //locInfo:res.result.Data.locInfo,
                            })
                        } else {
                            if (res.result.Data.length > 0) {
                                this.setState({
                                    // userInfo: res.result.Data[0].locDoctor,
                                    // wardInfo: res.result.Data[0].linkLoc,
                                    // [flag]: res.result.Data[0].linkLoc
                                }, () => {
                                    //清空form表单的值
                                    this.props.form.setFieldsValue({
                                        admDocID: '',
                                        wardID: '',
                                        admLocBedID: ''

                                    })
                                })
                            }
                        }
                    }
                }
            })
        }
        //病区
        loadBedList = (wardID) => {
            let data = {
                params: [{
                    wardID: wardID,
                }]
            }
            $http.post('urlDeault', this, {
                code: "04090022",
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        this.setState({
                            wardBedAry: res.result.wardBedAry,//床号
                        }, () => {
                            //清空form表单的值
                            this.props.form.setFieldsValue({
                                admLocBedID: ''
                            })
                        })
                    }
                }
            })
        }
        //病区改变
        onInWardChange = (value, option) => {
            if (value) {
                this.loadBedList(value);
                // this.onInLocChange(value);
            } else {
                this.props.form.setFieldsValue({
                    admLocBedID: ''
                })
            }
        }
        ///需要提醒的手机号校验
        onTipsItemTel(flag, title) {
            let tipsFlag = "tips" + this.firstToUp(flag);
            this.props.form.validateFields([flag,], (errors, values) => {
                if (!errors) {
                    let regex = new RegExp(/^1\d{10}$/);
                    if (values[flag] && (values[flag] !== "")) {
                        if (!regex.test(values[flag])) {
                            this.setState({
                                [tipsFlag]: title,
                            })
                        } else {
                            this.setState({
                                [tipsFlag]: "",
                            })
                        }
                    }

                } else {
                    this.setState({
                        [tipsFlag]: errors[flag].errors[0].message,
                    })
                }
            });
        }
        ///需要提醒的Input元素失去焦点
        onTipsItemBlur(flag, title, e) {
            const value = this.props.form.getFieldValue(flag);
            let tipsFlag = "tips" + this.firstToUp(flag);
            let msg = "";
            if (!value || (value === "")) {
                msg = title;
            }
            this.setState({
                [tipsFlag]: msg,
            })
        }
        //元素获取焦点时触发
        onFocus = (flag, e) => {
            let tipsFlag = "tips" + this.firstToUp(flag);
            this.setState({
                [tipsFlag]: "",
            })
        }
        //首字母大写
        firstToUp = (str) => {
            return str.substring(0, 1).toUpperCase() + str.substring(1);

        }
        //进行卡号检测补0操作
        handleZero = () => {
            if (this.props.form.getFieldValue('cardNo') && this.props.form.getFieldValue('cardNo').length == 0) {
                this.setState({
                    cardNoVisible: false
                })
                return
            } else {
                this.handleLength()
            }
        }
        //不足12字补0
        handleLength = () => {
            if (this.state.replenishZero == "Y" && parseInt(this.state.cardLength) && parseInt(this.state.cardLength) > 0 && this.props.form.getFieldValue('cardNo') && this.props.form.getFieldValue('cardNo').length > 0) {
                let No = this.props.form.getFieldValue('cardNo') ? this.props.form.getFieldValue('cardNo') : ''
                let length = parseInt(this.state.cardLength)
                let num = (Array(length).join(0) + No).slice(-length)
                this.props.form.setFieldsValue({ cardNo: num });
                this.setState({
                    cardNoVisible: false,
                });
                return
            }
        }
        //卡号失去焦点 onCardBlur
        onCardBlur = (e) => {
            if (e) {
                this.handleZero();
                this.cardTip(1);
            }

        }

        //卡号改变时触发
        onCardNoChange = (e) => {
            e.stopPropagation();
            if (e.target.value === "") {
                this.setState({
                    cardNoVisible: false,
                    tipsCardNo: "",
                })
            }
        }
        //建卡卡号
        cardTip = (num) => {
            this.props.form.validateFields(['cardNo',], (errors, values) => {
                if (errors == null && num != 1) {
                    setTimeout(() => {
                        this.patName.current.focus();
                    }, 300)
                    return
                }
                if (!errors) {
                    this.setState({
                        cardNoVisible: false
                    })
                    if (num != 1) {
                        if (this.props.form.getFieldValue('cardNo')) {
                            setTimeout(() => {
                                this.patName.current.focus();
                            }, 300)

                        }
                    }
                } else {
                    this.setState({
                        cardNoVisible: true,
                        tipsCardNo: errors.cardNo.errors[0].message,
                    })
                }
            });
        }
        //卡号回车
        onCardPressEnter = () => {

            if (this.state.replenishZero == "Y" && parseInt(this.state.cardLength) && parseInt(this.state.cardLength) > 0 && this.props.form.getFieldValue('cardNo') && this.props.form.getFieldValue('cardNo').length > 0) {
                let No = this.props.form.getFieldValue('cardNo') ? this.props.form.getFieldValue('cardNo') : ''
                let length = parseInt(this.state.cardLength)
                let num = (Array(length).join(0) + No).slice(-length)
                this.props.form.setFieldsValue({ cardNo: num });
                this.setState({
                    cardNoVisible: false,
                });

            }
            let errorMsg = "";
            let cardNo = this.props.form.getFieldValue('cardNo');
            this.validFunction("", cardNo, (error) => {
                errorMsg = error;
            });
            if (errorMsg && (errorMsg !== "")) {
                message.warn(errorMsg);
                return;
            }
            if (cardNo && cardNo.length > 0) {
                this.getPatInfo("", "");
            } else {
                message.warn("请输入卡号!");
                return;
            }

        }

        //查询床位数
        loadBedList = (wardID) => {
            let data = {
                params: [{
                    wardID: wardID,
                }]
            }
            $http.post('urlDeault', this, {
                code: "04020018",
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        if (res.result.length == 0) {
                            message.warn("该病区剩余空床数为0！")
                        }
                        this.setState({
                            remainBed: res.result.length,
                        })
                    }
                }
            })
        }

        //获取患者信息
        getPatInfo = (credTypeID, credNo) => {
            let cardNo = this.props.form.getFieldValue('cardNo');
            let cardTypeID = this.props.form.getFieldValue('cardTypeID');
            let number = this.props.form.getFieldValue('number');
            if (credTypeID !== "") {
                cardNo = "";
                cardTypeID = "";
                number = "";
            }
            let data = {}
            data = {
                params: [{
                    cardTypeID: cardTypeID ? cardTypeID : '',
                    cardNo: cardNo ? cardNo : '',
                    credTypeID: credTypeID,
                    credNo: credNo,
                    number: number,
                }],
            }
            $http.post('urlS', this, {
                code: '03060001',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        //判断接口请求成功数据是否返回成功
                        let patInfo = res.result.patInfo;
                        this.setState({
                            patInfo: patInfo,
                            record: {},
                        })
                    }
                }
            })

        }
        initPatInfo = () => {
            this.setState({
                patInfo: {},
                admInfo: {},
                patAdminInfo: {},
                readInfoLoading: false,
                adminListVisible: false,
            })
        }
        //选择建卡类型 格式验证
        validFunction = (rule, value, callback) => {
            //控制选择建卡和卡操作选择绑卡id 正确提示 及 校验
            if ((value === "") || (!value)) {
                callback();
                return;
            }
            let diffLength = this.state.cardLengthCard;
            let replenishZero = this.state.replenishZero;
            let idCardCodePop = this.state.replenishZero;
            if (idCardCodePop == '02') {
                var city = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江 ", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北 ", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏 ", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外 " };
                var tip = "";
                var pass = true;
                if (!value || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(value)) {
                    callback('身份证号格式错误'); // 校验未通过
                    return;
                }

                else if (!city[value.substr(0, 2)]) {
                    callback('身份证号格式错误'); // 校验未通过
                    return;
                }
                else {
                    //18位身份证需要验证最后一位校验位
                    if (value.length == 18) {
                        value = value.split('');
                        //∑(ai×Wi)(mod 11)
                        //加权因子
                        var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
                        //校验位
                        var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
                        var sum = 0;
                        var ai = 0;
                        var wi = 0;
                        for (var i = 0; i < 17; i++) {
                            ai = value[i];
                            wi = factor[i];
                            sum += ai * wi;
                        }
                        var last = parity[sum % 11];
                        //最后一位不区分大小写
                        if (value[17] == 'x') value[17] = value[17].toUpperCase();
                        if (parity[sum % 11] != value[17]) {
                            callback('最后一位校验位错误'); // 校验未通过
                            return;
                        }
                    }
                }
                callback();
            }
            if (replenishZero == "N" && parseInt(diffLength) > 0 && idCardCodePop != '12') {
                let length = parseInt(diffLength)
                var reg = new RegExp('^\\d{' + length + '}$')
                if (!reg.test(value)) {
                    callback('该卡号长度不正确，请输入有效卡号'); // 校验未通过
                    return;
                } else {
                }
            }
            if (replenishZero == "Y" && parseInt(diffLength) > 0) {
                let length = parseInt(diffLength)
                var reg = new RegExp("^\\d{" + length + "}$");
                if (!reg.test(value)) {
                    callback('该卡号无效，请输入有效卡号,数字可自动补0'); // 校验未通过
                    return;
                } else {
                }
            }
            if (replenishZero == "N" && !parseInt(diffLength) > 0) {
                if (!/^[0-9]*$/.test(value)) {
                    callback('请输入任意数字'); // 校验未通过
                    return;
                } else {
                }
            }
            callback();
        }
        //卡类型改变触发
        onCardTypeChange = (value, Option) => {

            setTimeout(() => {
                this.cardNo.current.focus();
            }, 300)
            if (value) {
                this.setState({
                    initCardDr: Option.props.data.id,
                    nowRead: Option.props.data.readMode,
                    cardLength: Option.props.data.cardLength && Option.props.data.cardLength != "" ? Option.props.data.cardLength + "位," : "",
                    nowCost: Option.props.data.cardCost,
                    nowInv: Option.props.data.invFlag,
                    replenishZero: Option.props.data.replenishZero,
                    repariFeeFlag: Option.props.data.repariFeeFlag,
                    cardNoVisible: false,
                    idCardCodePop: Option.props.data.code,
                })
            }
        }
        onNumberPressEnter = () => {
            if (this.props.form.getFieldValue('number') && this.props.form.getFieldValue('number').length > 0) {
                this.getPatInfo("", "");
            } else {
                message.warn("请输入病人ID/身份证号!");
                return;
            }


        }
        //读卡时调用
        handleReadCard = (e) => {
            // message.warn("暂不能读卡");
            const cardTypeID = this.state.initCardDr;
            this.readCard.ReadCard(cardTypeID, "R", (json) => {
                if (!Util.isEmpty(json)) {
                    this.props.form.setFieldsValue({ cardNo: json.cardNo, number: !Util.isEmpty(json.patInfo.patNo) ? json.patInfo.patNo : '' });
                    this.setState({
                        cardNoVisible: false,
                    }, () => {
                        this.onNumberPressEnter();
                    });
                }
            })
        }

        //选择或清除省
        onProvinceChange(flag, value, option) {
            if (value) {
                let city = []
                city = this.state.firstCity.filter((item) => item.province == value);
                let patInfo = this.state.patInfo;
                let patFlag = this.firstToUp(flag);
                if (patInfo["pat" + patFlag + "ProvinceID"]) {
                    patInfo["pat" + patFlag + "ProvinceID"] = undefined;
                    patInfo["pat" + patFlag + "CityID"] = undefined;
                    patInfo["pat" + patFlag + "AreaID"] = undefined;
                    patInfo["pat" + patFlag + "VillageID"] = undefined;
                    patInfo["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "City"]: city,
                    [flag + "Areas"]: [],
                    [flag + "Villages"]: [],
                    [flag + "Hamlets"]: [],
                    patInfo: patInfo,
                })
            } else {
                //清除省
                this.props.form.setFieldsValue({
                    [flag + "CityID"]: undefined,
                    [flag + "AreaID"]: undefined,
                    [flag + "VillageID"]: undefined,
                    [flag + "HamletID"]: undefined
                });
                let patInfo = this.state.patInfo;
                let patFlag = this.firstToUp(flag);
                if (patInfo["pat" + patFlag + "ProvinceID"]) {
                    patInfo["pat" + patFlag + "ProvinceID"] = undefined;
                    patInfo["pat" + patFlag + "CityID"] = undefined;
                    patInfo["pat" + patFlag + "AreaID"] = undefined;
                    patInfo["pat" + patFlag + "VillageID"] = undefined;
                    patInfo["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "City"]: [],
                    [flag + "Areas"]: [],
                    [flag + "Villages"]: [],
                    [flag + "Hamlets"]: [],
                    patInfo: patInfo,
                })
            }
        }
        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.firstCity.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"]: option.props.zip,
                });

                let patInfo = this.state.patInfo;
                let patFlag = this.firstToUp(flag);
                if (patInfo["pat" + patFlag + "CityID"]) {
                    patInfo["pat" + patFlag + "CityID"] = undefined;
                    patInfo["pat" + patFlag + "AreaID"] = undefined;
                    patInfo["pat" + patFlag + "VillageID"] = undefined;
                    patInfo["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    patInfo: patInfo,
                })
                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 patInfo = this.state.patInfo;
                let patFlag = this.firstToUp(flag);
                if (patInfo["pat" + patFlag + "CityID"]) {
                    patInfo["pat" + patFlag + "CityID"] = undefined;
                    patInfo["pat" + patFlag + "AreaID"] = undefined;
                    patInfo["pat" + patFlag + "VillageID"] = undefined;
                    patInfo["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "Areas"]: [],
                    [flag + "Villages"]: [],
                    [flag + "Hamlets"]: [],
                    patInfo: patInfo,
                })
            }
        }
        //选择市时加载县数据
        getAreas = (cityID, flag, cleanFlag) => {
            let data = {
                params: [{
                    cityId: cityID
                }],
            }
            if (this.state.cacheCityIdData[cityID]) {
                if (cleanFlag === "1") {
                    this.setState({
                        [flag + "Areas"]: this.state.cacheCityIdData[cityID],
                        [flag + "Villages"]: [],
                        [flag + "Hamlets"]: [],
                    })
                } else {
                    this.setState({
                        [flag + "Areas"]: this.state.cacheCityIdData[cityID],
                    })
                }
                return;
            }
            let cacheCityIdData = []
            $http.post('urlS', this, {
                code: '03030006',
                data: data,
                success: function (res) {
                    cacheCityIdData[cityID] = res.result
                    this.setState({
                        cacheCityIdData: { ...this.state.cacheCityIdData, ...cacheCityIdData }
                    })

                    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"]: option.props.zip,
                });
                this.getVillages(value, flag, "1");
            } else {
                //清除市
                this.props.form.setFieldsValue({
                    [flag + "VillageID"]: undefined,
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined,
                });
                let patInfo = this.state.patInfo;
                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 (patInfo["pat" + patFlag + "AreaID"]) {
                    patInfo["pat" + patFlag + "AreaID"] = undefined;
                    patInfo["pat" + patFlag + "VillageID"] = undefined;
                    patInfo["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "Villages"]: [],
                    [flag + "Hamlets"]: [],
                    patInfo: patInfo,
                })
            }
        }
        //县获取焦点
        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");
            }
        }

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

                    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"]: [],
                        })
                    }
                }
            })

        }
        //选择县或清除乡
        onVillageChange(flag, value, option) {
            if (value) {
                this.props.form.setFieldsValue({
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: option.props.zip,
                });
                this.getHamlets(value, flag);
            } else {
                //清除市
                this.props.form.setFieldsValue({
                    [flag + "HamletID"]: undefined,
                    [flag + "ZIP"]: undefined
                });
                let patInfo = this.state.patInfo;
                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 (patInfo["pat" + patFlag + "VillageID"]) {
                    patInfo["pat" + patFlag + "VillageID"] = undefined;
                    patInfo["pat" + patFlag + "HamletID"] = undefined;
                }
                this.setState({
                    [flag + "Hamlets"]: [],
                    patInfo: patInfo,
                })
            }
        }
        //乡获取焦点时调用
        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");
            }
        }
        //选择乡时加载村数据
        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"]: [],
                        })
                    }
                }
            })

        }
        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);
            }
        }
        render() {
            var language = user.language
            var languageObj = {}
            if (language == "EN") {
                languageObj = this.state.ENObj
            } else {
                languageObj = this.state.CNObj
            }
            const { getFieldDecorator } = this.props.form;
            const mesIcon = <Icon type="exclamation-circle" />
            let { baseParms, nowRead, initCardDr, cardLength, tipsCardNo, patInfo, record } = this.state; //卡信息
            let { province, firstCity, presentCity, presentAreas, presentVillages, presentHamlets } = this.state; //省,市
            let firstCityItem = [], presentCityItem = [], presentAreasItem = [], presentVillagesItem = [], presentHamletsItem = []; //省,市Option
            let credTypeItem = [], sexItem = [];
            let card = []
            baseParms.cardType && baseParms.cardType.map(item => {
                card.push(<Option key={item.id} disabled={item.disabled ? true : false} data={item} value={String(item.id)}>{item.descripts}</Option>)
            })
            let provinceItem = [];
            province && province.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>)
            });
            //第一次加载的城市;
            firstCity && firstCity.map(item => {
                firstCityItem.push(<Option provinceid={item.province} zip={item.zipCode} key={item.id} role={item.descripts + '^' + item.descriptsSPCode} value={String(item.id)} className={'2' + item.province} title={item.descripts}>{item.descripts}</Option>)
            });
            //现住址
            if ((!presentCity) || (presentCity.length === 0)) {
                //籍贯城市下拉数据为空时加载所有城市
                presentCityItem = firstCityItem;
            } else {
                presentCity && presentCity.map(item => {
                    presentCityItem.push(<Option provinceid={item.province} key={item.id} zip={item.zipCode} role={item.descripts + '^' + item.descriptsSPCode} value={String(item.id)} className={'2' + item.province} title={item.descripts}>{item.descripts}</Option>)
                });
            }
            presentAreas && presentAreas.map(item => {
                presentAreasItem.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} zip={item.zipCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            });
            if ((presentAreas) && (presentAreas.length === 0) && (patInfo.patPresentAreaID)) {
                presentAreasItem.push(<Option key={patInfo.patPresentAreaID} role={patInfo.patPresentAreaDesc} title={patInfo.patPresentAreaDesc} value={String(patInfo.patPresentAreaID)}>{patInfo.patPresentAreaDesc}</Option>)
            }
            presentVillages && presentVillages.map(item => {
                presentVillagesItem.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} zip={item.zipCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            });
            if ((presentVillages) && (presentVillages.length === 0) && (patInfo.patPresentVillageID)) {
                presentVillagesItem.push(<Option key={patInfo.patPresentVillageID} role={patInfo.patPresentVillageDesc} title={patInfo.patPresentVillageDesc} value={String(patInfo.patPresentVillageID)}>{patInfo.patPresentVillageDesc}</Option>)
            }
            presentHamlets && presentHamlets.map(item => {
                presentHamletsItem.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} zip={item.zipCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            });
            if ((presentHamlets) && (presentHamlets.length === 0) && (patInfo.patPresentHamletID)) {
                presentHamletsItem.push(<Option key={patInfo.patPresentHamletID} role={patInfo.patPresentHamletDesc} title={patInfo.patPresentHamletDesc} value={String(patInfo.patPresentHamletID)}>{patInfo.patPresentHamletDesc}</Option>)
            }
            //性别
            baseParms.sex && baseParms.sex.map(item => {
                sexItem.push(<Option key={item.id} value={String(item.id)}>{item.descripts}</Option>)
            });

            return (
                <div className="Reginstration">
                    <ColumnAuthoritysModel
                        clientWidth='800px'
                        compontName="AppointInHospital"
                        configType="C"
                        onRef={this.onColumnRef}
                        reloadData={this.loadColumn}
                    />
                    <Row>
                        <Col span={10}>
                            <Card
                                size="small"
                                title={<div>{languageObj.AppointInHospitalAdmissionnoticelist!= null ? languageObj.AppointInHospitalAdmissionnoticelist.descripts : ""}</div>}
                            >
                                <div style={{ height: store.getState().tableHeight.y + 170 + 'px' }}>
                                    <div style={{ marginRight: '19%', textAlign: 'right' }}>
                                    {languageObj.AppointInHospitalcharacterist!= null ? languageObj.AppointInHospitalcharacterist.descripts : ""}<Input placeholder={languageObj.AppointInHospitalpatIDpatNmecardphone!= null ? languageObj.AppointInHospitalpatIDpatNmecardphone.descripts : ""} onChange={this.changePersonMark} onPressEnter={this.selectInfoByCondition} style={{ width: '60%' }}
                                        /><br />
                                  {languageObj.AppointInHospitalappointDate!= null ? languageObj.AppointInHospitalappointDate.descripts : ""}<DatePicker format="YYYY-MM-DD" style={{ width: '60%', marginTop: '5px' }}
                                            onChange={this.selectDispatchInfo.bind(this, "appointDate")}
                                        /><br />
                                 {languageObj.AppointInHospitalnotifiedDate!= null ? languageObj.AppointInHospitalnotifiedDate.descripts : ""}<DatePicker format="YYYY-MM-DD" style={{ width: '60%', marginTop: '5px' }}
                                            onChange={this.selectDispatchInfo.bind(this, "needDay")}
                                        />
                                        <Button style={{ marginTop: '5px', marginLeft: '35%' }}>{languageObj.AppointInHospitalSearch!= null ? languageObj.AppointInHospitalSearch.descripts : ""}</Button>
                                    </div>
                                    <Table
                                        onHeaderRow={column => {
                                            return {
                                                onDoubleClick: () => {
                                                    this.columnRef.onOpenModel();
                                                },
                                            };
                                        }}
                                        style={{ marginTop: '5px' }}
                                        columns={this.state.columns}
                                        dataSource={this.state.data}
                                        pagination={false}
                                        onRow={this.onRow}
                                        bordered
                                        rowClassName={this.setRowClassName}
                                        rowKey={row => row.id}
                                        scroll={{ x: 620, y: store.getState().tableHeight.y - 50 }}
                                        className="ReginHeight"
                                    />
                                </div>

                            </Card>
                        </Col>
                        <Col span={14}>
                            <Card
                                size="small"
                                title={<span>{languageObj.AppointInHospitalAdmissionnoticelist!= null ? languageObj.AppointInHospitalAdmissionnoticelist.descripts : ""} </span>}
                            >
                                <div style={{ height: store.getState().tableHeight.y + 170 + 'px', overflow: 'auto' }}>
                                    <ReadCard ref={r => this.readCard = r} />
                                    <Col span={24}>
                                        <Form>
                                            <Row style={{ padding: ' 0 6px' }}>
                                                <Col span={10} style={{ paddingRight: '15px' }}>
                                                    <FormItem {...formItemLayoutAdd} label={languageObj.AppointInHospitalcharacterist!= null ? languageObj.AppointInHospitalcharacterist.descripts : ""}>
                                                        {getFieldDecorator('number', {
                                                        })(
                                                            <Input allowClear={true} onPressEnter={this.onNumberPressEnter} placeholder={languageObj.AppointInHospitalpatIDpatNmecardphone!= null ? languageObj.AppointInHospitalpatIDpatNmecardphone.descripts : ""}/>
                                                        )}
                                                    </FormItem>

                                                </Col>
                                                <Col span={5} style={{ paddingRight: '15px' }}>
                                                    <FormItem label="">
                                                        {getFieldDecorator('cardTypeID', {
                                                            initialValue: initCardDr,
                                                            rules: [{ required: true}],
                                                        })(
                                                            <Select 
                                                                placeholder={languageObj.AppointInHospitalcardTypeID!= null ? languageObj.AppointInHospitalcardTypeID.descripts : ""}
                                                                onChange={this.onCardTypeChange}
                                                            >
                                                                {card}
                                                            </Select>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={7} className="cardNoDom">
                                                    <Tooltip getPopupContainer={() => document.querySelector('.cardNoDom')} overlayStyle={{ zIndex: 999, }} overlayClassName="toolTipDom topTips" title={<div className="titleIcon">{mesIcon}<span >{tipsCardNo}</span></div>} visible={this.state.tipsCardNo !== ""}>
                                                        <FormItem label="">
                                                            {getFieldDecorator('cardNo', {
                                                                validateTrigger: [""],
                                                                rules: [
                                                                    { validator: this.validFunction },
                                                                ],
                                                                getValueFromEvent: (event) => {
                                                                    return initCardDr == '3' ? event.target.value.replace(/[^\d|Xx]/g, '') : event.target.value.replace(/\D/g, '')
                                                                },
                                                            })(
                                                                <Input
                                                                    ref={this.cardNo}
                                                                    maxLength={initCardDr == '3' ? 18 : (initCardDr == '1' ? 12 : 99)}
                                                                    allowClear={true}
                                                                    onBlur={this.onCardBlur}
                                                                    autoFocus={true}
                                                                    placeholder={nowRead == 'R' ? '请点击读卡按钮查找病人' : (nowRead == "" && initCardDr == '1' ? cardLength + '刷卡/输入或点击读卡（卡号可自动补零）' : (nowRead == "" && initCardDr != '1' ? cardLength + '刷卡/输入或点击读卡' : (nowRead == 'I' && initCardDr == "1" ? cardLength + '刷卡/输入卡号（卡号可自动补零）' : (nowRead == 'I' && initCardDr != "1" ? cardLength + '刷卡/输入卡号' : ""))))}
                                                                    onPressEnter={this.onCardPressEnter}
                                                                    onChange={this.onCardNoChange}
                                                                    onFocus={this.onFocus.bind(this, "cardNo")}
                                                                />
                                                            )}
                                                        </FormItem>
                                                    </Tooltip>
                                                </Col>
                                                <Col span={2} style={{ textAlign: 'right', marginLeft: '-32px' }}>
                                                    <FormItem {...formItemLayout}>
                                                        <Button onClick={this.handleReadCard} style={{ backgroundColor: '#1890ff', color: '#FFF' }}>读卡</Button>
                                                    </FormItem>

                                                </Col>
                                            </Row>
                                            <Row>
                                                <Col span={6} style={{ paddingRight: '15px' }}>
                                                    <FormItem {...formItemLayout} label={languageObj.AppointInHospitalpatName!= null ? languageObj.AppointInHospitalpatName.descripts : ""}>
                                                        {getFieldDecorator('patName', {
                                                            initialValue: patInfo.patName ? patInfo.patName : (record ? record.patName : ""),
                                                            rules: [{ required: true}],
                                                        })(
                                                            <Input
                                                                onBlur={this.onTipsItemBlur.bind(this, "patName", "请填写患者姓名")}
                                                                onPressEnter={this.onTipsItemBlur.bind(this, "patName", "请填写患者姓名")}
                                                                ref={this.patName}
                                                                onFocus={this.onFocus.bind(this, "patName")}
                                                            />
                                                        )}
                                                    </FormItem>

                                                </Col>
                                                <Col span={6} style={{ paddingRight: '15px' }} >
                                                    <FormItem {...formItemLayout} label={languageObj.AppointInHospitalsex!= null ? languageObj.AppointInHospitalsex.descripts : ""}>
                                                        {getFieldDecorator('patSexID', {
                                                            rules: [{ required: true}],
                                                            initialValue: patInfo.patSexID ? patInfo.patSexID : (record ? record.sexID : ""),
                                                        })(
                                                            <Select
                                                                onFocus={this.onFocus.bind(this, "patSexID")}
                                                            >
                                                                {sexItem}
                                                            </Select>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={6} style={{ paddingRight: '15px' }}>
                                                    <FormItem {...formItemLayout} label={languageObj.AppointInHospitalphone!= null ? languageObj.AppointInHospitalphone.descripts : ""}>
                                                        {getFieldDecorator('patMobile', {
                                                            initialValue: patInfo.patMobile ? patInfo.patMobile : (record ? record.mobile : ""),
                                                            rules: [{ required: true, message: '请填写', },
                                                            { pattern: new RegExp(/^1\d{10}$/), message: '请输入手机号' }
                                                            ],
                                                            getValueFromEvent: (event) => {
                                                                return event.target.value.replace(/\D/g, '')
                                                            },
                                                        })(
                                                            <Input
                                                                maxLength={11}
                                                                onFocus={this.onFocus.bind(this, "patMobile")}
                                                            />
                                                        )}
                                                    </FormItem>
                                                </Col>
                                            </Row>
                                            <Row>
                                                <Col span={6}>
                                                    <FormItem {...formItemLayout} label={languageObj.AppointInHospitalappointDate!= null ? languageObj.AppointInHospitalappointDate.descripts : ""}>
                                                        {getFieldDecorator('EndData', {
                                                            initialValue: record.appointDate ? Moment(record.appointDate, 'HH:mm') : null,
                                                            rules: [{ required: true }]
                                                        })(
                                                            <DatePicker style={{ width: '100%' }} disabledDate={(curDate) => {
                                                                return curDate && curDate <= Moment().endOf('day');
                                                            }} />
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={6}>
                                                    <FormItem {...formItemLayout} label={languageObj.AppointInHospitalapprove!= null ? languageObj.AppointInHospitalapprove.descripts : ""}>
                                                        {getFieldDecorator('approve', {
                                                            initialValue: record ? record.days : "",
                                                            rules: [{ required: false }]
                                                        })(
                                                            <Input />
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={1} style={{ textAlign: 'right', marginLeft: '-46px', marginTop: '4px' }}>
                                                    <Button style={{ backgroundColor: '#ccc' }}>天</Button>
                                                </Col>
                                                {this.state.record.notify=="N" && this.state.record.appointDate<this.state.now ?(<div>
                                                    <Col span={2} style={{ marginTop: '6px', marginLeft: '5px' }}>
                                                        <span style={{ color: 'orange' }}>已超时！</span>
                                                    </Col>
                                                </div>) : ""}
                                            </Row>
                                            <Row >
                                                <Col span={6}>
                                                    <FormItem {...formItemLayout} label={languageObj.AppointInHospitallocID!= null ? languageObj.AppointInHospitallocID.descripts : ""}>
                                                        {getFieldDecorator('locID', {
                                                            initialValue: patInfo.locID ? patInfo.locID : (record ? record.locID : ""),
                                                            rules: [{ required: true }]
                                                        })(
                                                            <Select
                                                                allowClear
                                                                showSearch
                                                                optionFilterProp='role'
                                                                onFocus={this.onLocFocus}
                                                                onChange={this.onInLocChange}
                                                            >
                                                                {this.state.locInfo.map(data => (
                                                                    <Select.Option role={data.descripts + '^' + data.descriptsSPCode} key={data.id}>{data.descripts}</Select.Option>
                                                                ))}
                                                            </Select>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={6}>
                                                    <FormItem {...formItemLayout} label={languageObj.AppointInHospitalInWard!= null ? languageObj.AppointInHospitalInWard.descripts : ""}>
                                                        {getFieldDecorator('wardID', {
                                                            initialValue: patInfo.wardID ? patInfo.wardID : (record ? record.wardID : ""),
                                                            rules: [{ required: true }]
                                                        })(
                                                            <Select
                                                                allowClear
                                                                showSearch
                                                                optionFilterProp='role'
                                                                onFocus={this.onWardFocus.bind(this, "inWardID")}
                                                                onChange={this.onInWardChange}
                                                            >
                                                                {this.state.wardInfo.map(data => (
                                                                    <Select.Option role={data.descripts + '^' + data.descriptsSPCode} key={data.id}>{data.descripts}</Select.Option>
                                                                ))}
                                                            </Select>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                          
                                                <Col span={4} style={{ marginTop: '6px', marginLeft: '5px' }}>
                                                <span style={{ color: 'orange' }}>  {languageObj.AppointInHospitalTherearecurrently3bedsward != null ? languageObj.AppointInHospitalTherearecurrently3bedsward.descripts : ""}</span>
                                                </Col>
                                            </Row>
                                            <Row>
                                                <Col span={5} style={{ paddingRight: '15px' }}>
                                                    <FormItem {...formItemLayout} label={languageObj.AppointInHospitaladdress!= null ? languageObj.AppointInHospitaladdress.descripts : ""}>
                                                        {getFieldDecorator('presentProvinceID', {
                                                            initialValue: patInfo.patPresentProvinceID ? patInfo.patPresentProvinceID : (record ? record.provinceID : ""),
                                                        })(
                                                            <Select
                                                                allowClear={true}
                                                                showSearch={true}
                                                                placeholder={languageObj.AppointInHospitalpresentProvince!= null ? languageObj.AppointInHospitalpresentProvince.descripts : ""}
                                                                optionFilterProp="role"
                                                                onChange={this.onProvinceChange.bind(this, "present")}
                                                            >
                                                                {provinceItem}
                                                            </Select>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={4} style={{ paddingRight: '15px' }}>
                                                    <FormItem label=''>
                                                        {getFieldDecorator('presentCityID',
                                                            {
                                                                initialValue: patInfo.patPresentCityID ? patInfo.patPresentCityID : (record ? record.cityID : ""),
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch={true}
                                                                    placeholder={languageObj.AppointInHospitalpresentCity!= null ? languageObj.AppointInHospitalpresentCity.descripts : ""}
                                                                    optionFilterProp="role"
                                                                    onChange={this.onCityChange.bind(this, "present")}
                                                                    onFocus={this.onCityFocus.bind(this, "presentProvinceID", "presentCity")}
                                                                >
                                                                    {
                                                                        presentCityItem
                                                                    }
                                                                </Select>


                                                            )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={4} style={{ paddingRight: '15px' }}>
                                                    <FormItem label=''>
                                                        {getFieldDecorator('presentAreaID', {
                                                            initialValue: patInfo.patPresentAreaID ? patInfo.patPresentAreaID : (record ? record.areaID : ""),
                                                        })(
                                                            <Select
                                                                allowClear={true}
                                                                showSearch={true}
                                                                placeholder={languageObj.AppointInHospitalpresentArea!= null ? languageObj.AppointInHospitalpresentArea.descripts : ""}
                                                                optionFilterProp="role"
                                                                onChange={this.onAreaChange.bind(this, "present")}
                                                                onFocus={this.onAreaFocus.bind(this, "presentCityID", "present")}
                                                            >
                                                                {presentAreasItem}
                                                            </Select>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={4} style={{ paddingRight: '15px' }}>
                                                    <FormItem label=''>
                                                        {getFieldDecorator('presentVillageID', {
                                                            initialValue: patInfo.patPresentVillageID ? patInfo.patPresentVillageID : (record ? record.villageID : ""),
                                                        })(
                                                            <Select
                                                                allowClear={true}
                                                                showSearch={true}
                                                                placeholder={languageObj.AppointInHospitalpresentVillage!= null ? languageObj.AppointInHospitalpresentVillage.descripts : ""}
                                                                optionFilterProp="role"
                                                                onChange={this.onVillageChange.bind(this, "present")}
                                                                onFocus={this.onVillageFocus.bind(this, "presentAreaID", "present")}
                                                            >
                                                                {presentVillagesItem}
                                                            </Select>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={4} style={{ paddingRight: '15px' }}>
                                                    <FormItem label=''>
                                                        {getFieldDecorator('presentHamletID', {
                                                            initialValue: patInfo.patPresentHamletID ? patInfo.patPresentHamletID : (record ? record.hamletID : ""),
                                                        })(
                                                            <Select
                                                                allowClear={true}
                                                                showSearch={true}
                                                                placeholder={languageObj.AppointInHospitalpresentHamlet!= null ? languageObj.AppointInHospitalpresentHamlet.descripts : ""}
                                                                optionFilterProp="role"
                                                                onFocus={this.onHamletFocus.bind(this, "presentVillageID", "present")}
                                                            >
                                                                {presentHamletsItem}
                                                            </Select>
                                                        )}
                                                    </FormItem>
                                                </Col>

                                            </Row>
                                            <Row>
                                                <Col span={24} className="presentAddress">
                                                    <FormItem {...formItemLayoutAddress} label={languageObj.AppointInHospitalpresentAddress	!= null ? languageObj.AppointInHospitalpresentAddress.descripts : ""}>
                                                        {getFieldDecorator('presentAddressDesc', {
                                                            rules: [{ required: true, message: '请填写详细地址' }],
                                                            initialValue: patInfo.patPresentAddressDesc ? patInfo.patPresentAddressDesc : (record ? record.address : ""),
                                                        })(
                                                            <Input
                                                                onBlur={this.onTipsItemBlur.bind(this, "presentAddressDesc", "请填写现住址详细地址")}
                                                                onPressEnter={this.onTipsItemBlur.bind(this, "presentAddressDesc", "请填写现住址详细地址")}
                                                                placeholder={languageObj.AppointInHospitaldetailedAddress != null ? languageObj.AppointInHospitaldetailedAddress.descripts : ""}
                                                                onFocus={this.onFocus.bind(this, "presentAddressDesc")}
                                                            />
                                                        )}
                                                    </FormItem>
                                                </Col>
                                            </Row>
                                            <Row>
                                                <Col span={24} className="presentAddress">
                                                    <FormItem  {...formItemLayoutAddress} label={languageObj.AppointInHospitalReason != null ? languageObj.AppointInHospitalReason.descripts : ""}>
                                                        {getFieldDecorator('Reason', {
                                                            initialValue: record ? record.reason : "",
                                                            rules: [{ required: true }]
                                                        })(
                                                            <Input placeholder={languageObj.AppointInHospitalPleasereason != null ? languageObj.AppointInHospitalPleasereason.descripts : ""}/>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                            </Row>
                                            <Row>
                                                <Col span={12}  style={{ paddingRight: '15px' }}  className="formItemLayoutSex">
                                                    <FormItem {...formItemLayoutSex} label={languageObj.AppointInHospitalpatEContact != null ? languageObj.AppointInHospitalpatEContact.descripts : ""}>
                                                        {getFieldDecorator('patEContact', {
                                                            initialValue: patInfo.patEContact ? patInfo.patEContact : (record ? record.contactUser : ""),

                                                        })(
                                                            <Input />
                                                        )}
                                                    </FormItem>
                                                </Col>
                                                <Col span={12}className="formItemLayoutSex">
                                                    <FormItem {...formItemLayoutSex} label={languageObj.AppointInHospitalpatMobile != null ? languageObj.AppointInHospitalpatMobile.descripts : ""}>
                                                        {getFieldDecorator('patEContactMobile', {
                                                            initialValue: patInfo.patEContactMobile ? patInfo.patEContactMobile : (record ? record.contactMobile : ""),
                                                            rules: [{ required: false, message: '请填写', },
                                                            { pattern: new RegExp(/^1\d{10}$/), message: '请输入正确的联系电话' }
                                                            ],
                                                            getValueFromEvent: (event) => {
                                                                return event.target.value.replace(/\D/g, '')
                                                            },
                                                        })(
                                                            <Input
                                                                maxLength={11}
                                                                onBlur={this.onTipsItemTel.bind(this, "patEContactMobile", "手机号不正确")}
                                                                onFocus={this.onFocus.bind(this, "patEContactMobile")}
                                                            />
                                                        )}
                                                    </FormItem>
                                                </Col>
                                            </Row>
                                            <Row>
                                                <Col span={24} className="presentAddress">
                                                    <FormItem  {...formItemLayoutAddress} label={languageObj.AppointInHospitalnotes != null ? languageObj.AppointInHospitalnotes.descripts : ""}>
                                                        {getFieldDecorator('notes', {
                                                            initialValue: record ? record.notes : "",

                                                        })(
                                                            <Input placeholder={languageObj.AppointInHospitalPleaseentercomments != null ? languageObj.AppointInHospitalPleaseentercomments.descripts : ""}/>
                                                        )}
                                                    </FormItem>
                                                </Col>
                                            </Row>
                                        </Form>
                                        <Row type="flex" justify="center">
                                            <Col span={2}>
                                                {(this.state.record.notify == "N" ? (
                                                    <Button
                                                        type='primary'
                                                        htmlType="submit"
                                                        onClick={this.handlesubmit.bind(this, "send")}
                                                    >
                                                       {languageObj.AppointInHospitalnotice != null ? languageObj.AppointInHospitalnotice.descripts : ""}
                                            </Button>
                                                ) : "")}
                                            </Col>
                                            <Col span={2}>

                                                <Button
                                                    type='primary'
                                                    htmlType="submit"
                                                    onClick={this.handlesubmit.bind(this, "add")}
                                                >
                                                  {languageObj.AppointInHospitalsave != null ? languageObj.AppointInHospitalsave.descripts : ""}
                                                    </Button>

                                            </Col>
                                            <Col span={2} style={{ margin: '0 8px 0 0' }}>

                                                <Button
                                                    type='primary'
                                                    htmlType="submit"
                                                    onClick={this.handleReset}
                                                >
                                                   {languageObj.AppointInHospitalclear != null ? languageObj.AppointInHospitalclear.descripts : ""}
                                                    </Button>
                                                   
                                            </Col>
                                        </Row>
                                    </Col>
                                </div>
                            </Card>
                        </Col>
                    </Row>
                </div>
            )
        }
    }
);

export default AdmissionRegistration;