// 急诊预检分级主界面
import React from 'react';
import { Form, Row, Col, Tabs, Checkbox, Radio, Icon, Table, Switch, Select, Input, Button, message, Divider, Popconfirm } from 'antd';
import { $http } from 'containers/config/https';
import { Util } from 'tools/index';
import store from 'store';
import moment from 'moment';

import ESIRateModel from './ESIRateModel.jsx'
import TraumaRateModel from './TraumaRateModel.jsx'
import PainScoreModel from './PainScoreModel.jsx'
import REMSRatingModal from './REMSRatingModal.jsx'
import MEWSRatingModal from './MEWSRatingModal.jsx'
import PainRatingModal from './PainRatingModal.jsx'

const formItemLayout = {    // label 和input宽度
    labelCol: { span: 7 },
    wrapperCol: { span: 17 },
};
const formItemAddLayout = {    // label 和input宽度
    labelCol: { span: 7 },
    wrapperCol: { span: 20 },
};
const formItemSw = {    // label 和input宽度
    lg: { span: 6 },
};
const formItemAdd = {    // label 和input宽度
    labelCol: { span: 14 },
    wrapperCol: { span: 8, offset: 2 },
};
const radioLayout = {    // label 和input宽度
    labelCol: { span: 2 },
    wrapperCol: { span: 22 },
};
const { TextArea } = Input;
const { TabPane } = Tabs;
const FormItem = Form.Item;
var arr = [];
var Obj = {};

let userData;
const PreliminaryCenter = Form.create()(
    class extends React.Component {
        constructor(props) {
            super(props);
            this.state = {
                vitalSigns: [],//存储 生命特征
                patInfo: {},
                baseParms: {},
                TableData: [],//表格数据
                pastHistory: [],//既往史
                patSource: [],//患者来源
                specialPopulation: [],//特殊人群
                wayOfVisiting: [],//来诊方式
                sixMajorDiseases: [],//六大病种
                ideology: [],//意识形态按钮
                patientScore: [],//患者评分
                tableData: [],
                cardType: '',
                patID: '',              //患者ID
                eSIRate: false,          //ESI评分
                painScore: false,        //疼痛评分
                traumaRate: false,       //创伤评级
                patTraumaGradeID: '',    //创伤评级记录ID
                patPainScoreID: '',      //疼痛评级记录ID
                patESIGradeID: '',       //ESI评分记录ID
                rEMSRate: false,         //REMS评级
                mEWSRate: false,         //MEWS评级
                painRate: false,         //疼痛评级
                patREMSRateID: '',       //REMS评级记录ID
                patMEWSRateID: '',       //MEWS评级记录ID
                patPainRateID: '',      //疼痛评级记录ID

                TraumaRateInfo: {},    //创伤评级数据对象
                painRateInfo: {},      //疼痛评级数据对象
                ESIRateInfo: {},       //ESI评分数据对象
                REMSGradeInfo: {},       //REMS评级数据对象
                MEWSGradeInfo: {},       //MEWS评级数据对象
                painScoreInfo: {},      //疼痛评级数据对象

                TraumaRateScore: {},    //创伤评级评分对象
                painRateScore: {},      //疼痛评级评分对象
                ESIRateScore: {},       //ESI评分对象
                REMSGradeScore: {},       //REMS评级评分对象
                MEWSGradeScore: {},       //MEWS评级评分对象
                painScoreObj: {},            //疼痛评级评分对象 

                ideo: {},
                isHover: '', // 按鈕hover状态
                btnStatus: [],
                level: '',
                score: '',
                childCode: '',
                childDescripts: '',
                childNumber: '',
                pastHistoryPar: [],
                vitalSignsPar: {},
                consciousPar: '',
                patGradePar: [],
                symptomPar: []
            };
            userData = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
            this.myRef1 = React.createRef();
            this.myRef2 = React.createRef();
            this.myRef3 = React.createRef();
            this.myRef4 = React.createRef();
            this.myRef5 = React.createRef();
            this.myRef6 = React.createRef();
            this.myRef7 = React.createRef();
            this.columns = [
                {
                    title: '分级',
                    dataIndex: 'level',
                    width: '15%',
                    align: "center"
                },
                {
                    title: '得分',
                    dataIndex: 'score',
                    width: '15%',
                    align: "center"
                },
                {
                    title: '评分项',
                    dataIndex: 'scoreItem',
                    align: "center",
                    width: '40%'
                },
                {
                    title: '操作',
                    dataIndex: 'operation',
                    align: "center",
                    width: 100,
                    render: (text, record) => (
                        <span>
                            {/* <Icon type="delete" style={{ color: 'rgba(240,65,52,1)' }}></Icon> */}
                            {/* <Popconfirm title="删除不可恢复，你确定要删除吗?" onConfirm={() => this.handleDelete(text, record)}> */}
                            <Button type='primary' onClick={() => this.handleDelete(text, record)} size='small' disabled={!record.symptomID}>删除</Button>
                            {/* </Popconfirm> */}
                        </span>
                    )
                },
            ];

        }
        componentDidMount() {
            this.loadBaseParms();
            this.loadButton();
            // this.ScoreInfo();
            this.props.onRef(this)


        }
        componentWillUnmount() {
            this.setState = (state, callback) => {
                return
            }
        }
        callback(key) {
            console.log(key);
        }
        // 下拉框选中事件
        handleOnSelect = (num) => {
            switch (num) {
                case 1:
                    setTimeout(() => {
                        this.myRef2.current.focus();
                    }, 300)
                    break;
                case 2:
                    setTimeout(() => {
                        this.myRef3.current.focus();
                    }, 300)
                    break;
                case 3:
                    setTimeout(() => {
                        this.myRef4.current.focus();
                    }, 300)
                    break;
                case 4:
                    setTimeout(() => {
                        this.myRef5.current.focus();
                    }, 300)
                    break;
                case 5:
                    setTimeout(() => {
                        this.myRef6.current.focus();
                    }, 300)
                    break;
                case 6:
                    setTimeout(() => {
                        this.myRef7.current.focus();
                    }, 300)
                    break;
                default:
                    setTimeout(() => {
                        this.myRef1.current.focus();
                    }, 300)
                    break;
            }
        }
        // 删除算分数据
        handleDelete = (text, value) => {
            var id = value.symptomID;
            //console.log(text, value)
            var { symptomPar } = this.state;
            if (!Util.isEmpty(id)) {
                for (var i = 0; i < symptomPar.length; i++) {
                    if (id == symptomPar[i]) {
                        symptomPar[i] = undefined
                    }

                }
            }
            this.setState({ symptomPar }, () => {
                this.scoreInfo();
            })
        };
        //输入病人卡信息进行读卡操作
        handleInmations = (credN) => {

            let data = {}
            const { cardType } = this.state
            data = {
                params: [{
                    cardTypeID: cardType,
                    cardNo: credN.target.value,
                    credTypeID: "",
                    credNo: ''
                }],
            }
            $http.post('urlS', this, {
                code: '03030009',
                data: data,
                success: function (res) {
                    const basicData = res.result.patInfo
                    this.props.form.setFieldsValue({
                        patName: basicData.patName,
                        patAge: basicData.patAge,
                        patIDCardNo: basicData.patIDCardNo,
                        patSexID: basicData.patSexID,
                        patBirthDate: basicData.patBirthDate,
                        patNationID: basicData.patNationID,
                        patMobile: basicData.patMobile,
                        patCountryID: basicData.patCountryID,
                        patAddress: basicData.patAddress,
                        patNo: basicData.patNo,
                    }, () => this.setState({ patID: basicData.patID }))
                    // this.setState({ patID: basicData.patID })
                    var { loadPatID } = this.props;
                    loadPatID && loadPatID(basicData.patID);
                    this.props.setRightCom(preGradeInfo);
                }
            })
        }
        //获取登记信息数据
        getPreGradeData = (datas) => {
            // console.log("被调用了",datas)
            let data = {}
            data = {
                params: [{
                    patNo: datas.patNo
                }]
            }
            $http.post('urlS', this, {
                code: '04140009',
                data: data,
                success: function (res) {
                    let basicData = res.result.basicInfo;
                    let preGradeInfo = res.result.preGradeInfo;
                    let preGradeScoreInfo = res.result.preGradeScoreInfo;
                    let patScore = res.result.patScore;
                    //debugger;                    
                    let btnStatus = [];
                    if (preGradeInfo.patMEWSRateID != '') {
                        btnStatus.push('mEWSRate')
                    }
                    if (preGradeInfo.patPainRateID != '') {
                        btnStatus.push('painRate')
                    }
                    if (preGradeInfo.patPainScoreID != '') {
                        btnStatus.push('painScore')
                    }
                    if (preGradeInfo.patREMSRateID != '') {
                        btnStatus.push('rEMSRate')
                    }
                    if (preGradeInfo.patTraumaGradeID != '') {
                        btnStatus.push('traumaRate')
                    }
                    if (preGradeInfo.patESIGradeID != '') {
                        btnStatus.push('eSIRate')
                    }
                    this.props.form.setFieldsValue({
                        patName: basicData.patName,
                        patAge: basicData.patAge,
                        registerDateTime: preGradeInfo.registerDateTime,//来诊时间
                        patIDCardNo: basicData.patIDCardNo,
                        patSexID: basicData.patSexID,
                        patBirthDate: basicData.patBirthDate,
                        patNationID: basicData.patNationID,
                        patMobile: basicData.patMobile,
                        patCountryID: basicData.patCountryID,
                        patAddress: basicData.patPresentAddressDesc,
                        patNo: basicData.patNo,
                        patAddress: basicData.patAddress,
                        nurseReason: preGradeInfo.nurseReason,
                        inBatchesFlag: preGradeInfo.inBatchesFlag,
                        inBatchesNumber: preGradeInfo.inBatchesNumber,
                        pastHistory: preGradeInfo.pastHistory,
                        patSource: preGradeInfo.patSource,
                        sixDiseaseSpecies: preGradeInfo.sixDiseaseSpecies,
                        specialPopulation: preGradeInfo.specialPopulation,
                        conditionArea: preGradeInfo.conditionArea,
                        condition: preGradeInfo.condition,
                        admMode: preGradeInfo.admMode,
                        notes: preGradeInfo.notes,
                        Ideology: preGradeInfo.Ideology,
                        greenChannel: preGradeInfo.greenChannel,
                        SPO2: preGradeInfo.temperatureDetail.SPO2,
                        breath: preGradeInfo.temperatureDetail.breath,
                        diastolicPressure: preGradeInfo.temperatureDetail.diastolicPressure,
                        heartRate: preGradeInfo.temperatureDetail.heartRate,
                        systolicPressure: preGradeInfo.temperatureDetail.systolicPressure,
                        temperature: preGradeInfo.temperatureDetail.temperature,
                        patTraumaGradeID: preGradeInfo.patTraumaGradeID,    //创伤评级记录ID
                        patPainScoreID: preGradeInfo.patPainScoreID,     //疼痛评级记录ID
                        patESIGradeID: preGradeInfo.patESIGradeID,      //ESI评分记录ID
                        patREMSRateID: preGradeInfo.patREMSRateID,       //REMS评级记录ID
                        patMEWSRateID: preGradeInfo.patMEWSRateID,       //MEWS评级记录ID
                        patPainRateID: preGradeInfo.patPainRateID      //疼痛评级记录ID

                    })
                    this.setState({
                        patID: basicData.patID,
                        patTraumaGradeID: preGradeInfo.patTraumaGradeID,    //创伤评级数据对象 
                        patPainRateID: preGradeInfo.patPainRateID,      //疼痛评级数据对象
                        patESIGradeID: preGradeInfo.patESIGradeID,       //ESI评分数据对象
                        patREMSRateID: preGradeInfo.patREMSRateID,      //REMS评级数据对象
                        patMEWSRateID: preGradeInfo.patMEWSRateID,       //MEWS评级数据对象
                        patPainScoreID: preGradeInfo.patPainScoreID,     //疼痛评级数据对象
                        btnStatus,
                        isHover: preGradeInfo.ideology,
                        TableData: preGradeScoreInfo,
                        pastHistoryPar: preGradeInfo.pastHistory ? preGradeInfo.pastHistory : [],
                        vitalSignsPar: preGradeInfo.temperatureDetail ? preGradeInfo.temperatureDetail : {},
                        consciousPar: preGradeInfo.consciousPar ? preGradeInfo.consciousPar : '',
                        patGradePar: patScore ? patScore : [],
                        // symptomPar:this.state.symptomPar ? this.state.symptomPar : []
                    })
                    var { loadPatID } = this.props;
                    loadPatID && loadPatID(basicData.patID);
                    this.props.setRightCom(preGradeInfo);
                    this.props.getTableData(preGradeScoreInfo)
                    // this.props.setRightScore(preGradeScoreInfo[0]);
                }
            })
        }
        // 请求登记号回车事件
        getPatBasicDataEnter = (e) => {
            //console.log("被调用",e)
            let data = {}
            data = {
                params: [{
                    number: e.target.value
                }]
            }
            $http.post('urlS', this, {
                code: '03030004',
                data: data,
                success: function (res) {
                    const basicData = res.result.Data[0]
                    //console.log(res)
                    this.props.form.setFieldsValue({
                        patName: basicData.patName,
                        patAge: basicData.patAge,
                        patIDCardNo: basicData.patIDCardNo,
                        patSexID: basicData.patSexID,
                        patBirthDate: basicData.patBirthDate,
                        patNationID: basicData.patNationID,
                        patMobile: basicData.patMobile,
                        patCountryID: basicData.patCountryID,
                        patAddress: basicData.patPresentAddressDesc,
                        patNo: basicData.patNo
                    }, () => this.setState({ patID: basicData.patID }))
                    // this.setState({ patID: basicData.patID });
                    var { loadPatID } = this.props;
                    loadPatID && loadPatID(basicData.patID)
                }
            })
        }
        //按钮显示数据
        loadButton = () => {
            let data = {
                params: [{

                }]
            }
            $http.post('urlS', this, {
                code: "04140001",
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        this.setState({
                            pastHistory: res.pastHistory,
                            patSource: res.patSource,
                            specialPopulation: res.specialPopulation,
                            wayOfVisiting: res.wayOfVisiting,
                            sixMajorDiseases: res.sixMajorDiseases,
                            ideology: res.ideology,
                            patientScore: res.patientScore
                        })
                    }
                }
            })
        }
        //加载下拉框信息
        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: 1,
                    provinceFlag: 1,    //省
                    cityFlag: 1,  //市 
                    relationFlag: 1,
                    admReasonFlag: "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,
                            nowInv: defCardType.invFlag,
                            replenishZero: defCardType.replenishZero,
                            repariFeeFlag: defCardType.repariFeeFlag,
                            cardNoVisible: false,
                            baseParms: res,
                            province: res.province,
                            firstCity: res.city,
                            admReasonList: res.admReason,
                        })
                    }
                }
            })
        }
        //重置
        handleReset = () => {
            this.props.form.resetFields();
            this.setState({
                patInfo: {},
                btnStatus: [],
                isHover: '',
            })
        }
        //卡类型改变触发
        onCardTypeChange = (value, Option) => {
            this.setState({ cardType: value })
            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
                })
            }


        }

        getFormValues = (callback) => {
            this.props.form.validateFields((err, values) => {
                let obj = values;
                obj.TraumaRateInfo = this.state.TraumaRateInfo    //创伤评级数据对象 
                obj.painRateInfo = this.state.painRateInfo      //疼痛评级数据对象
                obj.ESIRateInfo = this.state.ESIRateInfo       //ESI评分数据对象
                obj.REMSGradeInfo = this.state.REMSGradeInfo      //REMS评级数据对象
                obj.MEWSGradeInfo = this.state.MEWSGradeInfo       //MEWS评级数据对象
                obj.painScoreInfo = this.state.painScoreInfo     //疼痛评级数据对象
                obj.ideo = this.state.ideo
                if (!err) {
                    callback(obj)
                }
            })
        }
        getForm = (callback) => {

        }
        //元素获取焦点时触发
        onFocus = (flag, e) => {
            let tipsFlag = "tips" + this.firstToUp(flag);
            this.setState({
                [tipsFlag]: "",
            })
        }
        ///需要提醒的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,
            })
        }
        //首字母大写
        firstToUp = (str) => {
            return str.substring(0, 1).toUpperCase() + str.substring(1);
        }

        handleTest = (type, desc) => {
            // console.log('type111',type)
            let { btnStatus } = this.state;
            btnStatus.push(type);
            btnStatus = [...btnStatus]
            const childRef = type + "Child"
            this[childRef].loadFormData();
            this.setState({
                [type]: true,
                btnStatus,
                childCode: type,
                childDescripts: desc
            })
        }
        //意识形态的点击事件
        setUpGrading(val) {
            // console.log('qqqqq',val)
            this.setState({
                ideo: val.id,
                isHover: val.id,
                consciousPar: val.code
            }, () => this.scoreInfo())
        }

        /** 去重*/
        unique5(arr) {
            var x = new Set(arr);
            return [...x];
        }

        handleOk = (e, args, childNumber) => {
            const { painScoreInfo } = args || {}
            // console.log('', e, painScoreInfo, childNumber)
            let { patGradePar } = this.state;
            let obj = {
                code: this.state.childCode ? this.state.childCode : undefined,
                descripts: this.state.childDescripts ? this.state.childDescripts : undefined,
                value: this.state.childCode !== 'eSIRate' ? childNumber : "",
                level: this.state.childCode === 'eSIRate' ? childNumber : ""
            };
            patGradePar.push(obj);
            // console.log(patGradePar)
            patGradePar = this.unique5(patGradePar);
            // console.log(patGradePar);
            this.setState(args);
            this.setState({ childNumber, patGradePar }, () => { this.scoreInfo() });


        }
        handleSymptom = (id) => {
            // debugger
            let { symptomPar } = this.state;
            if (id !== '') {
                symptomPar.push(id);
                symptomPar = this.unique5(symptomPar);
                this.setState({ symptomPar }, () => {
                    this.scoreInfo()
                })
            }
        }
        handlePastHistoryInfo = (e) => {
            this.setState({
                pastHistoryPar: e
            }, () => this.scoreInfo())
            // if (e !== '') {
            //     this.scoreInfo('pastHistory', e)
            // }
        }
        handleVitalSignInfo = (code, val) => {
            // console.log(code, val)
            let { vitalSignsPar } = this.state;
            vitalSignsPar[code] = val;
            this.setState({
                vitalSignsPar
            }, () => this.scoreInfo())
        }

        //设置生命体征数据
        getVitalSigns = (code, value) => {
            if (code == 'systolicPressure' || code == 'diastolicPressure' || code == 'SPO2' || code == 'breath' || code == 'temperature' || code == 'heartRate' || code == 'pulse') {
                return [...this.state.vitalSigns, { code: code, value: value }]
            }
            return [];
        }
        //3.24.1.7.根据得分计算等级
        scoreInfo = () => {
            // let pastHistory=[]
            // if(val instanceof Array){
            //     pastHistory = val
            // }
            //获取生命体征数据
            // let vitalSigns = this.getVitalSigns(code, val);
            let data = {
                params: [{
                    vitalSigns: [{
                        pastHistory: this.state.pastHistoryPar ? this.state.pastHistoryPar : [],//既往史
                        vitalSign: this.state.vitalSignsPar ? this.state.vitalSignsPar : {},
                        conscious: {    //意识形态
                            code: this.state.consciousPar ? this.state.consciousPar : '',
                        }
                    }],
                    patScore: this.state.patGradePar ? this.state.patGradePar : [],
                    symptom: this.state.symptomPar ? this.state.symptomPar : []
                }]
            }
            $http.post('urlS', this, {
                code: "04140014",
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        this.setState({
                            TableData: res.result,
                        })
                        this.props.getTableData(res.result)
                    }
                }
            })
        }

        render() {
            const { getFieldDecorator } = this.props.form;
            let { patInfo } = this.state; //患者信息
            let { baseParms, initCardDr } = this.state; //卡信息
            let nationItem = [], sexItem = [], countryItem = [];
            let { ideology, patientScore } = this.state;//按钮的信息
            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>)
            })
            //性别
            baseParms.sex && baseParms.sex.map(item => {
                sexItem.push(<Option key={item.id} value={String(item.id)}>{item.descripts}</Option>)
            });
            //国籍
            baseParms.country && baseParms.country.map(item => {
                countryItem.push(<Option key={item.id} title={item.descripts} role={item.descripts + '^' + item.descriptsSPCode} value={String(item.id)}>{item.descripts}</Option>)
            });
            //民族
            baseParms.nation && baseParms.nation.map(item => {
                nationItem.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            });

            return (
                <div className="WarehouseEntryCheck1">
                    <div>
                        <Row>
                            <Col>
                                <Tabs onChange={this.callback} type="card">
                                    <TabPane tab="基本信息" key="1">
                                    </TabPane>
                                    <TabPane tab="其他信息" key="2">
                                    </TabPane>
                                </Tabs>
                            </Col>

                        </Row>
                        <Row>
                            <Form>
                                <Row>
                                    <Row>
                                        <Col span={4} style={{ textAlign: 'right' }}>
                                            <FormItem {...formItemLayout} label="卡号">
                                                {getFieldDecorator('cardNo', {
                                                    initialValue: "",
                                                    rules: [{ required: false, message: '请输入卡号' }]
                                                })(
                                                    <Input
                                                        onPressEnter={this.handleInmations}
                                                    />
                                                )}
                                            </FormItem>

                                        </Col>
                                        <Col span={2} style={{ textAlign: 'right' }}>
                                            <FormItem {...formItemLayout}>
                                                <Button onClick={this.handleReadCard} style={{ marginLeft: '14px', backgroundColor: '#1890ff', color: '#FFF' }}>读卡</Button>
                                            </FormItem>

                                        </Col>

                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="卡类型">
                                                {getFieldDecorator('cardTypeID', {
                                                    initialValue: initCardDr,
                                                    rules: [{ required: false, message: '请选择卡类型' }],
                                                })(
                                                    <Select placeholder='请选择卡类型'
                                                        placeholder='请选择卡类型'
                                                        onChange={this.onCardTypeChange}
                                                    >
                                                        {card}
                                                    </Select>
                                                )}
                                            </FormItem>
                                        </Col>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="来诊时间">
                                                {getFieldDecorator('registerDateTime', {
                                                    initialValue: '',
                                                    rules: [{ required: false, message: '请选择来诊时间' }]
                                                })(
                                                    <Input />
                                                )}
                                            </FormItem>
                                        </Col>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="电话">
                                                {getFieldDecorator('patMobile', {
                                                    initialValue: patInfo.patMobile ? patInfo.patMobile : undefined,
                                                    rules: [{ required: false, message: '请填写联系电话', }],
                                                    getValueFromEvent: (event) => {
                                                        return event.target.value.replace(/\D/g, '')
                                                    },
                                                })(
                                                    <Input
                                                        onFocus={this.onFocus.bind(this, "patMobile")}
                                                    />
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="登记号">
                                                {getFieldDecorator('patNo', {
                                                    initialValue: patInfo.patNo ? patInfo.patNo : undefined,
                                                    rules: [{ required: false, message: '请输入登记号' }]
                                                })(
                                                    <Input
                                                        onPressEnter={this.getPatBasicDataEnter}
                                                    // onPressEnter={()=>this.getPreGradeData()}
                                                    />
                                                )}
                                            </FormItem>
                                        </Col>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="姓名">
                                                {getFieldDecorator('patName', {
                                                    initialValue: patInfo.patName ? patInfo.patName : undefined,
                                                    rules: [{ required: false, message: '请填写姓名' }],
                                                })(
                                                    <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="性别">
                                                {getFieldDecorator('patSexID', {
                                                    rules: [{ required: false, message: '请选择' }],
                                                    initialValue: patInfo.patSexID ? patInfo.patSexID : undefined,
                                                })(
                                                    <Select
                                                        onFocus={this.onFocus.bind(this, "patSexID")}
                                                    >
                                                        {sexItem}
                                                    </Select>
                                                )}
                                            </FormItem>
                                        </Col>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="出生日期">
                                                {getFieldDecorator('patBirthDate', {
                                                    initialValue: '',
                                                    rules: [{ required: false, message: '请输入出生日期' }]
                                                })(
                                                    <Input />
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem  {...formItemLayout} label="身份证">
                                                {getFieldDecorator('patIDCardNo', {
                                                    initialValue: '',
                                                    rules: [{ required: false, message: '请输入身份证' }]
                                                })(
                                                    <Input
                                                        onPressEnter={this.getPatBasicDataEnter}

                                                    />
                                                )}
                                            </FormItem>
                                        </Col>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="年龄">
                                                {getFieldDecorator('patAge')(
                                                    <Input />
                                                )}
                                            </FormItem>
                                        </Col>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="民族">
                                                {getFieldDecorator('patNationID', {
                                                    initialValue: patInfo.patNationID ? patInfo.patNationID : undefined,
                                                })(
                                                    <Select >
                                                        {nationItem}
                                                    </Select>
                                                )}
                                            </FormItem>
                                        </Col>
                                        <Col span={6} style={{ paddingRight: '15px' }}>
                                            <FormItem {...formItemLayout} label="国籍">
                                                {getFieldDecorator('patCountryID', {
                                                    initialValue: patInfo.patCountryID ? patInfo.patCountryID : undefined,
                                                })(
                                                    <Select >
                                                        {countryItem}
                                                    </Select>
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={2} style={{ marginTop: '10px' }}>
                                            <span style={{ marginLeft: '18px', fontWeight: 'bold' }}>家庭住址:</span>
                                        </Col>
                                        <Col span={22} style={{ padding: '0px 6px' }}>
                                            <FormItem label="">
                                                {getFieldDecorator('patAddress', {
                                                    initialValue: '',
                                                    rules: [{ required: false, message: '请填写家庭住址' }]
                                                })(
                                                    <TextArea autosize={{ minRows: 2 }} />
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row>
                                        {/* <Col className="textR" span={2} style={{ marginTop: '10px' }}>
                                            <span style={{ fontWeight: 'bold' }}>成批就诊:</span>
                                        </Col> */}
                                        <Col span={2} {...formItemSw} style={{ marginLeft: '9px', fontWeight: 'bold' }}>
                                            <Form.Item label="成批就诊"  {...formItemLayout} className="labelR" >
                                                {getFieldDecorator('inBatchesFlag', {
                                                    initialValue: '',
                                                })(
                                                    <Switch style={{ marginLeft: '9px' }} />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={2} style={{ margin: '0px 15px 0 0' }}>
                                            <Form.Item label="总人数"  {...formItemAdd} className="labelR">
                                                {getFieldDecorator('inBatchesNumber', {
                                                    initialValue: "",
                                                })(
                                                    <Input style={{ width: '100px' }} />
                                                )}
                                            </Form.Item>
                                        </Col>
                                    </Row>
                                    <Row type="flex" justify="center">
                                        <Col span={24}>
                                            <FormItem {...radioLayout} label="既往史:">
                                                {getFieldDecorator('pastHistory', {
                                                    initialValue: ''
                                                })(
                                                    <Checkbox.Group onChange={this.handlePastHistoryInfo}>
                                                        {
                                                            this.state.pastHistory && this.state.pastHistory.map((item, key) => {
                                                                return (
                                                                    <Checkbox
                                                                        value={item.code}
                                                                        key={item.code}
                                                                        style={{ marginTop: '10px' }}
                                                                    // onClick={this.handleselect.bind(this, item.code)}
                                                                    >{item.descripts}</Checkbox>
                                                                )
                                                            })
                                                        }
                                                    </Checkbox.Group>
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row type="flex" justify="center">
                                        <Col span={24}>
                                            <FormItem {...radioLayout} label="患者来源:">
                                                {getFieldDecorator('patSource', {
                                                    initialValue: ''
                                                })(
                                                    <Radio.Group>
                                                        {
                                                            this.state.patSource && this.state.patSource.map((item, key) => {
                                                                return (
                                                                    <Radio value={item.id} style={{ marginTop: '10px' }}>{item.descripts}</Radio>
                                                                )
                                                            })
                                                        }
                                                    </Radio.Group>
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row type="flex" justify="center">
                                        <Col span={24}>
                                            <FormItem {...radioLayout} label="特殊人群:">
                                                {getFieldDecorator('specialPopulation', {
                                                    initialValue: ''
                                                })(
                                                    <Radio.Group>
                                                        {
                                                            this.state.specialPopulation && this.state.specialPopulation.map((item, key) => {
                                                                return (
                                                                    <Radio value={item.id} style={{ marginTop: '10px' }}>{item.descripts}</Radio>
                                                                )
                                                            })
                                                        }
                                                    </Radio.Group>
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row type="flex" justify="center">
                                        <Col span={24}>
                                            <FormItem {...radioLayout} label="来诊方式:">
                                                {getFieldDecorator('admMode', {
                                                    initialValue: ''
                                                })(
                                                    <Radio.Group>
                                                        {
                                                            this.state.wayOfVisiting && this.state.wayOfVisiting.map((item, key) => {
                                                                return (
                                                                    <Radio value={item.id} style={{ marginTop: '10px' }}>{item.descripts}</Radio>
                                                                )
                                                            })
                                                        }
                                                    </Radio.Group>
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row type="flex" justify="center">
                                        <Col span={24}>
                                            <FormItem {...radioLayout} label="六大病种:">
                                                {getFieldDecorator('sixMajorDiseases', {
                                                    initialValue: ''
                                                })(
                                                    <Checkbox.Group>
                                                        {
                                                            this.state.sixMajorDiseases && this.state.sixMajorDiseases.map((item, key) => {
                                                                return (
                                                                    <Checkbox value={item.id} key={item.id} style={{ marginTop: '10px' }}>{item.descripts}</Checkbox>
                                                                )
                                                            })
                                                        }
                                                    </Checkbox.Group>
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                </Row>
                                {/* <Divider /> */}
                                <Row style={{ height: "500px", overflow: 'auto' }}>
                                    <Row>
                                        {/* <Col span={24}>
                                        <span style={{ fontWeight: 'bold', padding: '0 10px' }}><span style={{ color: 'red' }}>*</span>生命体征:</span>
                                    </Col> */}
                                    </Row>
                                    <Row style={{ borderTop: '1px solid #CCC' }}>
                                        <Col span={2} style={{ margin: '0px -9px 0 0' }}>
                                            <span style={{ marginLeft: '11px', fontWeight: 'bold' }}><span style={{ color: 'red' }}>*</span>生命体征:</span>
                                        </Col>
                                        <Col span={2} style={{ margin: '-8px 15px 0 0' }}>
                                            <Form.Item label="收缩压(mmHg)">
                                                {getFieldDecorator('systolicPressure', {
                                                    initialValue: '',
                                                    getValueFromEvent: (event) => {
                                                        return event.target.value.replace(/\D/g, '')
                                                    },
                                                })(
                                                    <Input ref={this.myRef1}
                                                        onPressEnter={() => { this.handleOnSelect(1) }}

                                                        onChange={
                                                            (val, b) => {
                                                                setTimeout(() => {
                                                                    this.setState({
                                                                        systolicPressure: this.myRef1.current.props.value
                                                                    })
                                                                }, 300)

                                                            }
                                                        }
                                                        onBlur={(e) => {
                                                            this.handleVitalSignInfo('systolicPressure', this.state.systolicPressure);
                                                        }}
                                                    />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={2} style={{ margin: '-8px 15px 0 0' }}>
                                            <Form.Item label="舒张压(mmHg)">
                                                {getFieldDecorator('diastolicPressure', {
                                                    initialValue: '',
                                                    getValueFromEvent: (event) => {
                                                        return event.target.value.replace(/\D/g, '')
                                                    },
                                                })(
                                                    <Input ref={this.myRef2}
                                                        onPressEnter={() => this.handleOnSelect(2)}

                                                        onChange={
                                                            (val, b) => {
                                                                setTimeout(() => {
                                                                    this.setState({
                                                                        diastolicPressure: this.myRef2.current.props.value
                                                                    })
                                                                }, 300)

                                                            }
                                                        }
                                                        onBlur={(e) => {
                                                            this.handleVitalSignInfo('diastolicPressure', this.state.diastolicPressure);
                                                        }}
                                                    />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={2} style={{ margin: '-8px 15px 0 0' }}>
                                            <Form.Item label="SOP2(%)">
                                                {getFieldDecorator('SPO2', {
                                                    initialValue: '',
                                                    getValueFromEvent: (event) => {
                                                        return event.target.value.replace(/\D/g, '')
                                                    },
                                                })(
                                                    <Input ref={this.myRef3}
                                                        onPressEnter={() => this.handleOnSelect(3)}
                                                        onChange={
                                                            (val, b) => {
                                                                setTimeout(() => {
                                                                    this.setState({
                                                                        SPO2: this.myRef3.current.props.value
                                                                    })
                                                                }, 300)

                                                            }
                                                        }
                                                        onBlur={(e) => {
                                                            this.handleVitalSignInfo('SPO2', this.state.SPO2);
                                                        }}
                                                    />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={2} style={{ margin: '-8px 15px 0 0' }}>
                                            <Form.Item label="呼吸(次/分)">
                                                {getFieldDecorator('breath', {
                                                    initialValue: '',
                                                    getValueFromEvent: (event) => {
                                                        return event.target.value.replace(/\D/g, '')
                                                    },
                                                })(
                                                    <Input ref={this.myRef4}
                                                        onPressEnter={() => this.handleOnSelect(4)}
                                                        onChange={
                                                            (val, b) => {
                                                                setTimeout(() => {
                                                                    this.setState({
                                                                        breath: this.myRef4.current.props.value
                                                                    })
                                                                }, 300)

                                                            }
                                                        }
                                                        onBlur={(e) => {
                                                            this.handleVitalSignInfo('breath', this.state.breath);
                                                        }}
                                                    />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={2} style={{ margin: '-8px 15px 0 0' }}>
                                            <Form.Item label="体温(℃)">
                                                {getFieldDecorator('temperature', {
                                                    initialValue: '',
                                                    getValueFromEvent: (event) => {
                                                        return event.target.value.replace(/\D/g, '')
                                                    },
                                                })(
                                                    <Input ref={this.myRef5}
                                                        onPressEnter={() => this.handleOnSelect(5)}
                                                        onChange={
                                                            (val, b) => {
                                                                setTimeout(() => {
                                                                    this.setState({
                                                                        temperature: this.myRef5.current.props.value
                                                                    })
                                                                }, 300)

                                                            }
                                                        }
                                                        onBlur={(e) => {
                                                            this.handleVitalSignInfo('temperature', this.state.temperature);
                                                        }}
                                                    />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={2} style={{ margin: '-8px 15px 0 0' }}>
                                            <Form.Item label="心率(次/分)">
                                                {getFieldDecorator('heartRate', {
                                                    initialValue: '',
                                                    getValueFromEvent: (event) => {
                                                        return event.target.value.replace(/\D/g, '')
                                                    },
                                                })(
                                                    <Input ref={this.myRef6}
                                                        onPressEnter={() => this.handleOnSelect(6)}
                                                        onChange={
                                                            (val, b) => {
                                                                setTimeout(() => {
                                                                    this.setState({
                                                                        heartRate: this.myRef6.current.props.value
                                                                    })
                                                                }, 300)

                                                            }
                                                        }
                                                        onBlur={(e) => {
                                                            this.handleVitalSignInfo('heartRate', this.state.heartRate);
                                                        }}
                                                    />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={2} style={{ margin: '-8px 15px 0 0' }}>
                                            <Form.Item label="脉搏(次/分)">
                                                {getFieldDecorator('pulse', {
                                                    initialValue: '',
                                                    getValueFromEvent: (event) => {
                                                        return event.target.value.replace(/\D/g, '')
                                                    },
                                                })(
                                                    <Input ref={this.myRef7}
                                                        onPressEnter={() => this.handleOnSelect(7)}
                                                        onChange={
                                                            (val, b) => {
                                                                setTimeout(() => {
                                                                    this.setState({
                                                                        pulse: this.myRef7.current.props.value
                                                                    })
                                                                }, 300)

                                                            }
                                                        }
                                                        onBlur={(e) => {
                                                            this.handleVitalSignInfo('pulse', this.state.pulse);
                                                        }}
                                                    />
                                                )}
                                            </Form.Item>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={2} style={{ marginTop: '10px' }}>
                                            <span style={{ marginLeft: '44px', fontWeight: 'bold' }}>备注:</span>
                                        </Col>
                                        <Col span={22} style={{ padding: '0  4px' }}>
                                            <FormItem label="">
                                                {getFieldDecorator('notes', {
                                                    initialValue: '',
                                                    rules: [{ required: false, message: '请填写备注' }]
                                                })(
                                                    <TextArea autosize={{ minRows: 2 }} />
                                                )}
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row type='flex' justify='start'>
                                        <Col span={2} style={{ padding: '10px 2px' }}>
                                            <span style={{ fontWeight: 'bold', padding: '0 6px' }}><span style={{ color: 'red' }}>*</span>意识形态:</span>
                                        </Col>
                                        <Col span={22}>
                                            {this.state.ideology && this.state.ideology.map((item, i) => {
                                                return (<Button className={`${item.id === this.state.isHover ? 'btnChecked' : 'noChecked'}`}
                                                    style={{ margin: '10px 15px 10px 0' }}
                                                    value={item.descripts} key={item.id}
                                                    onClick={() => { this.setUpGrading(item) }}
                                                >{item.descripts}</Button>)
                                            })}
                                        </Col>
                                        <Col span={2} style={{ padding: '10px 2px' }}>
                                            <span style={{ fontWeight: 'bold', paddingLeft: '16px' }}>患者评分:</span>
                                        </Col>
                                        <Col span={22}>
                                            {this.state.patientScore && this.state.patientScore.map((item, i) => {
                                                return (<Button
                                                    className={`${this.state.btnStatus.indexOf(item.code) > -1 ? 'btnChecked' : 'noChecked'}`}
                                                    style={{ margin: '10px 15px 10px 0' }}
                                                    value={item.descripts} key={item.code}
                                                    onClick={this.handleTest.bind(this, item.code, item.descripts)}
                                                >{item.descripts}</Button>)
                                            })}
                                        </Col>
                                        <Col span={24}>
                                            <span style={{ fontWeight: 'bold', padding: '0 18px' }}>自动评分:</span>
                                        </Col>

                                        <Col span={24}>
                                            <Table style={{ y: '90px' }} columns={this.columns} dataSource={this.state.TableData} pagination={false} scroll={{ y: '90px' }} />
                                        </Col>
                                        {/* {console.log('this.state.TableData',this.state.TableData)} */}
                                    </Row>
                                </Row>
                            </Form>
                        </Row>
                    </div>
                    <ESIRateModel visible={this.state.eSIRate}
                        patID={this.state.patID}
                        patGradePar={this.state.patGradePar}
                        patESIGradeID={this.state.patESIGradeID}
                        onRef={(ref) => this.eSIRateChild = ref}
                        handleOk={this.handleOk.bind(this, { eSIRate: false })} />
                    <TraumaRateModel visible={this.state.traumaRate}
                        patID={this.state.patID}
                        patTraumaGradeID={this.state.patTraumaGradeID}
                        onRef={(ref) => this.traumaRateChild = ref}
                        handleOk={this.handleOk.bind(this, { traumaRate: false })} />
                    <PainScoreModel visible={this.state.painScore}
                        patID={this.state.patID}
                        patPainGradeID={this.state.patPainScoreID}
                        onRef={(ref) => this.painScoreChild = ref}
                        handleOk={this.handleOk.bind(this, { painScore: false })} />
                    <REMSRatingModal visible={this.state.rEMSRate}
                        patID={this.state.patID}
                        patREMSRateID={this.state.patREMSRateID}
                        onRef={(ref) => this.rEMSRateChild = ref}
                        handleOk={this.handleOk.bind(this, { rEMSRate: false })} />
                    <MEWSRatingModal visible={this.state.mEWSRate}
                        patID={this.state.patID}
                        patMEWSRateID={this.state.patMEWSRateID}
                        onRef={(ref) => this.mEWSRateChild = ref}
                        handleOk={this.handleOk.bind(this, { mEWSRate: false })} />
                    <PainRatingModal visible={this.state.painRate}
                        patID={this.state.patID}
                        patPainRateID={this.state.patPainRateID}
                        onRef={(ref) => this.painRateChild = ref}
                        handleOk={this.handleOk.bind(this, { painRate: false })} />
                </div>
            )
        }
    }
)
export default PreliminaryCenter;