/**
 * 
 * 部位弹框
 */

import React, { Component } from 'react';
import {
    Input, Form, Select, Modal, Button, Icon, Table, message, Radio,
    Tooltip, Card, Tree, Checkbox, Row, Col
} from 'antd';
import { Util, dayFormat } from 'tools/index';
import { $http } from 'containers/config/https';
import ShowUseTemplateModal from './ShowUseTemplateModal';
import '../style/index.less';
import moment from 'moment';

const Option = Select.Option;
const RadioGroup = Radio.Group;
const { TextArea } = Input;
const RadioButton = Radio.Button;
const { TreeNode } = Tree;

class ShowExamlistModal extends Component {

    constructor(props) {
        super(props);
        var date = new Date();
        var userData = JSON.parse(sessionStorage.getItem('userData'));
        var patientData = JSON.parse(sessionStorage.getItem('patientData'))
        this.state = {
            leftData: [],
            rightData: [],
            userData: userData,
            patientData: patientData,
            autoExpandParent: true,
            expandedKeys: [],
            selectedKeys: [],
            dataSource: [],
            sourceList: [],
            templateName: '',
            checked: [],
            chiefComplaint: '',
            appPurpose: '',
            HPIllness: '',
            sign: '',
        }
    }
    componentWillReceiveProps(nextProp) {
        if (nextProp.isShow === true) {
            var examList = []
            var data = nextProp.examList
            if (!Util.isEmpty(data)) {
                for (var i = 0; i < data.length; i++) {
                    examList.push({
                        ordDesc: data[i].ordDesc,
                        tabIndex: data[i].tabIndex,
                        ordDose: data[i].ordDose,
                        appItemStatusCode: data[i].appItemStatusCode,
                        ordDate: data[i].ordDate,
                        ordPrice: data[i].ordPrice,
                        ordSpecID: data[i].ordSpecID,
                        ordEMFlag: data[i].ordEMFlag,
                        ordPriorityID: data[i].ordPriorityID,
                        ordAdmReasonID: data[i].ordAdmReasonID,
                        ordRecLocID: data[i].ordRecLocID,
                        ordQtyUomID: data[i].ordQtyUomID,
                        recLocList: data[i].recLocList,
                        medID: data[i].medID,
                        ordMedItemDesc: data[i].ordMedItemDesc,
                        ordMedItemID: data[i].ordMedItemID,
                        indexModal: i
                    })
                }
            }
            this.setState({
                examList: examList,
                medID: nextProp.examList ? nextProp.examList[0].medID : '',
                tabIndex: nextProp.examList ? nextProp.examList[0].tabIndex : '',
                tableIndex: nextProp.examList ? 1 : '',
            }, () => {
                this.loadDoctorActive()
                this.loadCommonModal()
                this.loadDetailOfDoctor()
                this.initData();
            })
        } else if (this.props.isShow === false) {
            this.cleanInput();
        }
    }

    componentDidMount() {
        this.initData();
    }

    loadDetailOfDoctor() {
        var params = {
            params: [{
                admID: this.state.patientData.admID
            }]
        }
        $http.post('urlDeault', this, {
            code: "03050099",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        applicationMessage: res.result
                    })
                }
            }
        });
    }

    loadCommonModal() {
        let data = {
            params: [{
                compontName: "ApplicationForm",
                type: "C",
                reactCode: ['ApplicationForm']
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040073",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    this.setState({
                        localeProvider: this.state.userData.language == 'EN' ? res.result.language.EN : res.result.language.CN
                    }, () => {
                        this.initData()
                    })
                }
            }
        })
    }

    //获取主项部位的数据
    loadDoctorActive() {
        var params = {
            params: [{
                medID: this.state.medID,
                hospID: this.state.userData.hospID
            }]
        }
        $http.post('urlDeault', this, {
            code: "03050146",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        partData: res.result,
                        partList: !Util.isEmpty(res.result) ? res.result.partList : '',
                        positionList: !Util.isEmpty(res.result) ? res.result.positionList : '',
                        rowMedID: !Util.isEmpty(res.result) ? res.result.partList[0].id : ''
                    }, () => {
                        // this.loadData()
                        this.handleOnClickPart()
                    })
                }
            }
        });
    }

    //国际化
    setMessage(name, message) {
        return this.state.localeProvider ? this.state.localeProvider[name][message] : ''
    }

    initData() {
        this.columns = [
            {
                title: this.setMessage('ApplicationFormPart', 'descripts') || '部位',
                dataIndex: 'title',
                width: 140,
                align: 'center',
            }, {
                title: this.setMessage('ApplicationFormAsana', 'descripts') || '体位',
                dataIndex: 'qty',
                width: 140,
                align: 'center',
                render: (text, data, index) => {
                    var partOption = []
                    data && data.bodyPart && data.bodyPart.map((item, index) => {
                        partOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
                    })
                    return <Select onChange={this.handleSelectChange.bind(this, 'positionID', index)}
                        value={data.positionID} mode="multiple"
                        style={{ width: '100%' }}>{partOption}</Select>
                }
            }, {
                title: this.setMessage('ApplicationFormoperate', 'descripts') || '操作',
                dataIndex: '4',
                width: 120,
                align: 'center',
                render: (text, data, index) => {
                    return <span style={{ color: 'red', cursor: 'pointer' }}
                        onClick={this.handleDel.bind(this, index, data)}>{this.setMessage('ApplicationFormDelete', 'descripts')}</span>
                }
            }
        ]
        this.leftColumns = [
            {
                title: this.setMessage('ApplicationFormStatus', 'descripts') || '状态',
                dataIndex: 'appItemStatus',
                key: '7',
                width: '80px',
                align: 'center'
            },
            {
                title: this.setMessage('ApplicationFormdates', 'descripts') || '开单日期',
                dataIndex: 'ordDate',
                key: '1',
                width: '120px',
                align: 'center'
            }, {
                title: this.setMessage('ApplicationFormpro', 'descripts') || '项目名称',
                dataIndex: 'ordMedItemDesc',
                key: '2',
                width: '160px',
                align: 'left'
            }, {
                title: this.setMessage('ApplicationFormPart', 'descripts') || '部位',
                dataIndex: 'address',
                key: '3',
                width: '120px',
                align: 'left',
                render: (text, data, index) => {
                    data.tableIndex = index + 1
                    // var partListOption = []
                    // data && !Util.isEmpty(data.partList) && data.partList.map((item, index) => {
                    //     partListOption.push(<span style={{ marginLeft: 5, color: item.status == 'CO' ? 'gray' : 'rgb(64, 169, 255)' }}
                    //         key={index} value={!Util.isEmpty(data.appItemID) ? index : item.id}>
                    //         {!Util.isEmpty(data.appItemID) ? item.partDesc : item.title}</span>)
                    // })
                    // return <span>{partListOption}</span>
                    var partListOption = []
                    var groupOption = []
                    data && data.partList && data.partList.map((item, index) => {
                        partListOption.push(<span style={{ marginLeft: 5, color: item.status == 'CO' ? 'gray' : 'rgb(64, 169, 255)' }}
                            key={index} value={!Util.isEmpty(data.appItemID) ? index : item.id}>
                            {!Util.isEmpty(data.appItemID) ? item.partDesc : item.descripts}</span>)
                    })

                    data && data.partList && data.partList.map((item, index) => {
                        groupOption.push(<Option key={index} value={item.id} partid={item.id} mutexflag={item.mutexFlag} ordprice={Number(item.ordPrice)}
                            title={item.descripts} number={item.number}>{item.descripts}</Option>)
                    })
                    return !Util.isEmpty(data.appItemID) ? <span style={{ cursor: 'pointer' }}
                        onClick={this.showRevocationModal.bind(this, data, index)}>{partListOption}</span> :
                        <Select style={{ width: '100%' }} placeholder='请选择部位' mode='tags' value={data.partListID} showArrow
                            onChange={this.handleSelectMessage.bind(this, data, index)}>{groupOption}</Select>
                }
            }, {
                title: this.setMessage('ApplicationFormPrice', 'descripts') || '价格',
                dataIndex: 'ordPrice',
                key: '4',
                width: '80px',
                align: 'right',
                // render: (text, data) => {
                //     return <span>{((data.number || 1) * data.ordPrice).toFixed(2)}</span>
                // }
                render: (text, data) => {
                    var price = 0;
                    var source = data.priceData;
                    source && source.map((item, index) => {
                        price += Number(item)
                    })
                    //data.nunmber
                    return <span>{!Util.isEmpty(data.appItemID) ? ((data.ordQty || 1) * data.ordPrice).toFixed(2) :
                        ((data.ordQty || 1) * (data.priceData ? price : data.ordPrice)).toFixed(2)}</span>
                }
            }, {
                title: this.setMessage('ApplicationFormexp', 'descripts') || '是否加急',
                dataIndex: 'ordEMFlag',
                key: '6',
                width: '80px',
                align: 'center',
                render: (text, data, index) => {
                    // return <span>{data.ordEMFlag == 'Y' ? '是' : '否'}</span>
                    return !Util.isEmpty(data.appItemID) ? <span>{data.ordEMFlag == 'Y' ? '是' : '否'}</span> :
                        <Checkbox checked={data.ordEMFlag == 'Y' ? true : (data.ordEMFlag == 'Y' ? true : false)}
                            onChange={this.changeCheckFlagBox.bind(this, 'ordEMFlag', index)} />
                }
            }, {
                title: this.setMessage('ApplicationFormdep', 'descripts') || '执行科室',
                dataIndex: 'ordRecLocID',
                key: '5',
                width: '120px',
                align: 'left',
                render: (text, data, index) => {
                    var reclocListOption = []
                    data && data.recLocList && data.recLocList.map((item, index) => {
                        reclocListOption.push(<Option key={index} value={item.recLocID}>{item.recLocDesc}</Option>)
                    })
                    return !Util.isEmpty(data.appItemID) ? <span>{data.ordRecLocDesc}</span> : (<Select style={{ width: '100%' }}
                        value={data.ordRecLocID}
                        onChange={this.changeCommonSelect.bind(this, 'ordRecLocID', index)}>{reclocListOption}</Select>)
                }
            },
        ]
    }

    handleSelectMessage(data, index, e, code) {
        //取选中得数组，渲染到对应得数据去
        var partData = []
        var priceData = []
        if (!Util.isEmpty(code)) {
            for (var i = 0; i < code.length; i++) {
                //眼部互斥
                if (code[i].props.mutexflag == 'Y') {
                    var bodyPart = []
                    var priceMsg = []
                    this.state.examList[index]['partListID'] = [code[i].props.value]
                    if (data.partListID[0] == code[i].props.value) {
                        bodyPart.push({
                            partID: code[i].props.partid,
                            number: code[i].props.number,
                            title: code[i].props.title,
                            bodyPart: []
                        })
                        priceMsg.push(code[i].props.ordprice)
                        this.state.examList[index]['bodyPart'] = bodyPart
                        this.state.examList[index]['priceData'] = priceMsg
                    }
                } else {
                    this.state.examList[index]['partListID'] = e
                    partData.push({
                        partID: code[i].props.partid,
                        number: code[i].props.number,
                        title: code[i].props.title,
                        bodyPart: []
                    })
                    priceData.push(code[i].props.ordprice)
                    this.state.examList[index]['bodyPart'] = partData
                    this.state.examList[index]['priceData'] = priceData
                }
            }
        } else {
            this.state.examList[index]['partListID'] = e
        }
        // this.state.tableData[index]['partListID'] = e
        this.setState({}, () => { console.dir(this.state.examList) })
    }

    //删除
    handleDel(index, data) {
        var { checked, groupData } = this.state;
        if (!Util.isEmpty(groupData)) {
            for (var i = 0; i < groupData.length; i++) {
                if (groupData[i].id == data.id) {
                    this.state.groupData[i]['checked'] = false
                }
            }
        }
        var checkOne = []
        if (!Util.isEmpty(checked)) {
            for (var i = 0; i < checked.length; i++) {
                if (checked[i] !== data.id) {
                    checkOne.push(checked[i])
                }
            }
        }
        this.state.dataSource.splice(index, 1);
        this.setState({ checked: checkOne })
    }

    changeCommonSelect(name, index, e) {
        this.state.examList[index][name] = e
        this.setState({})
    }

    changeCheckFlagBox(name, index, e) {
        this.state.examList[index][name] = e.target.checked ? 'Y' : 'N'
        this.setState({})
    }

    handleSelectChange(name, index, e) {
        this.state.dataSource[index][name] = e
        this.setState({})
    }

    handleOnClickPart() {
        var { examList } = this.state;
        for (var i = 0; i < examList.length; i++) {
            if (!Util.isEmpty(examList[i].medID)) {
                this.loadData(examList[i].medID, i)
            }
        }
    }

    loadData(medID, index) {
        var params = {
            params: [{
                medID: medID,
                areaID: this.state.rowMedID,
                hospID: this.state.userData.hospID,
                searchCode: this.state.templateName
            }]

        }
        $http.post('urlDeault', this, {
            code: "03050147",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.state.examList[index]['partList'] = res.result
                    this.setState({
                        groupData: res.result
                    })
                    // var groupData = res.result;
                    // var { dataSource } = this.state;
                    // if (!Util.isEmpty(dataSource) && !Util.isEmpty(groupData)) {
                    //     for (var i = 0; i < groupData.length; i++) {
                    //         for (var j = 0; j < dataSource.length; j++) {
                    //             if (groupData[i].id == dataSource[j].id) {
                    //                 groupData[i]['checked'] = true
                    //             }
                    //         }
                    //     }
                    //     this.setState({
                    //         groupData: res.result,
                    //     })
                    // } else {
                    //     this.setState({
                    //         groupData: res.result,
                    //     })
                    // }
                }
            }
        });
    }

    closeModal(name) {
        let { onHide } = this.props;
        onHide && onHide();
        this.cleanInput();
    }

    //清空输入框
    cleanInput() {
        this.setState({
            dataSource: [],
            newCode: [],
            sourceList: [],
            examList: [],
            chiefComplaint: '',
            appPurpose: '',
            HPIllness: '',
            sign: '',
        })
    }

    //点击按钮，获取对应的id
    changeRadio(e) {
        this.setState({
            rowMedID: e.target.value
        }, () => {
            // this.loadData()
        })
    }

    //鼠标移动添加样式
    addMouseOverStyle(name, e) {
        this.setState({
            addMouseStyle: true,
            indexStyle: name
        })
    }
    addMouseLeaveStyle() {
        this.setState({
            addMouseStyle: false,
            indexStyle: ''
        })
    }

    onChangeData(data, index, e) {
        var { dataSource, groupData, examList } = this.state;
        var sourceMap = []
        if (e.target.checked) {

            if (!Util.isEmpty(dataSource)) {
                for (var i = 0; i < dataSource.length; i++) {
                    if (data.id == dataSource[i].id) {
                        message.error(this.setMessage('ApplicationFormyy', 'descripts'), this.state.userData && this.state.userData.messageTime)
                        return
                    }
                }
            }
            this.state.groupData[index]['checked'] = true
            for (var i = 0; i < groupData.length; i++) {
                if (data.id == groupData[i].id) {
                    this.state.dataSource.push({
                        title: groupData[i].descripts,
                        id: groupData[i].id,
                        partID: groupData[i].id,
                        number: groupData[i].number,
                        bodyPart: this.state.partData ? this.state.partData.positionList : []
                    })
                }
                // this.setState({})
            }
            if (!Util.isEmpty(examList)) {
                for (var i = 0; i < examList.length; i++) {
                    if (examList[i].tabIndex == this.state.tabIndex) {
                        examList[i]['partList'] = this.state.dataSource
                    }
                }
                this.setState({})
            }
        } else {
            this.state.groupData[index]['checked'] = false
            for (var i = 0; i < dataSource.length; i++) {
                if (data.id !== dataSource[i].id) {
                    sourceMap.push(dataSource[i])
                }
                this.setState({ dataSource: sourceMap })
            }
            var partData = []
            //先取出对应行数据的partlist
            if (!Util.isEmpty(examList)) {
                for (var i = 0; i < examList.length; i++) {
                    if (examList[i].tabIndex == this.state.tabIndex) {
                        partData = examList[i].partList
                    }
                }
            }
            if (!Util.isEmpty(sourceMap)) {
                for (var i = 0; i < sourceMap.length; i++) {
                    for (var j = 0; j < partData.length; j++) {
                        if (sourceMap[i].id == partData[j].id) {
                            this.state.examList[this.state.tableIndex - 1]['partList'] = sourceMap
                        }
                    }
                }
                this.setState({})
            } else {
                for (var i = 0; i < examList.length; i++) {
                    if (examList[i].tabIndex == this.state.tabIndex) {
                        this.state.examList[this.state.tableIndex - 1]['partList'] = []
                    }
                }
                this.setState({})
            }
        }
    }

    onDoubleClickMsg(data, index) {
        var { dataSource, groupData, examList } = this.state;
        var sourceMap = []
        if (this.state.groupData[index]['checked'] === true) {

            this.state.groupData[index]['checked'] = false
            for (var i = 0; i < dataSource.length; i++) {
                if (data.id !== dataSource[i].id) {
                    sourceMap.push(dataSource[i])
                }
                this.setState({ dataSource: sourceMap })
            }
            var partData = []
            //先取出对应行数据的partlist
            if (!Util.isEmpty(examList)) {
                for (var i = 0; i < examList.length; i++) {
                    if (examList[i].tabIndex == this.state.tabIndex) {
                        partData = examList[i].partList
                    }
                }
            }
            //当体位数据存在时
            if (!Util.isEmpty(sourceMap)) {
                for (var i = 0; i < sourceMap.length; i++) {
                    for (var j = 0; j < partData.length; j++) {
                        if (sourceMap[i].id == partData[j].id) {
                            this.state.examList[this.state.tableIndex - 1]['partList'] = sourceMap
                        }
                    }
                }
                this.setState({})
            } else {
                for (var i = 0; i < examList.length; i++) {
                    if (examList[i].tabIndex == this.state.tabIndex) {
                        this.state.examList[this.state.tableIndex - 1]['partList'] = []
                    }
                }
                this.setState({})
            }
        } else {
            if (!Util.isEmpty(dataSource)) {
                for (var i = 0; i < dataSource.length; i++) {
                    if (data.id == dataSource[i].id) {
                        message.error(this.setMessage('ApplicationFormyy', 'descripts'), this.state.userData && this.state.userData.messageTime)
                        return
                    }
                }
            }
            this.state.groupData[index]['checked'] = true
            for (var i = 0; i < groupData.length; i++) {
                if (data.id == groupData[i].id) {
                    this.state.dataSource.push({
                        title: groupData[i].descripts,
                        id: groupData[i].id,
                        number: groupData[i].number,
                        partID: groupData[i].id,
                        bodyPart: this.state.partData ? this.state.partData.positionList : []
                    })
                }
            }
            if (!Util.isEmpty(examList)) {
                for (var i = 0; i < examList.length; i++) {
                    if (examList[i].tabIndex == this.state.tabIndex) {
                        examList[i]['partList'] = this.state.dataSource
                    }
                }
                this.setState({})
            }
        }
    }

    //获取调用模版
    showUseTemplateModal(name) {
        this.setState({
            template: name,
            isShowUseTemplateModal: true
        })
    }

    loadTemplate(data) {
        var { applicationMessage } = this.state;
        if (this.state.template == 'chiefComplaint') {
            this.setState({
                chiefComplaint: (this.state.chiefComplaint || this.state.chiefComplaint.length == 0) ? (this.state.chiefComplaint + ';' + data) :
                    (applicationMessage ? (applicationMessage.chiefComplaint + ';' + data) : data)
            }, () => {
                this.hideModal('isShowUseTemplateModal')
            })
        } else if (this.state.template == 'appPurpose') {
            this.setState({
                appPurpose: (this.state.appPurpose || this.state.appPurpose.length == 0) ? (this.state.appPurpose + ';' + data) :
                    (applicationMessage ? (applicationMessage.appPurpose + ';' + data) : data)
            }, () => {
                this.hideModal('isShowUseTemplateModal')
            })
        } else if (this.state.template == 'HPIllness') {
            this.setState({
                HPIllness: (this.state.HPIllness || this.state.HPIllness.length == 0) ? (this.state.HPIllness + ';' + data) :
                    (applicationMessage ? (applicationMessage.HPIllness + ';' + data) : data)
            }, () => {
                this.hideModal('isShowUseTemplateModal')
            })
        } else if (this.state.template == 'sign') {
            this.setState({
                sign: (this.state.sign || this.state.sign.length == 0) ? (this.state.sign + ';' + data) :
                    (applicationMessage ? (applicationMessage.sign + ';' + data) : data)
            }, () => {
                this.hideModal('isShowUseTemplateModal')
            })
        }
    }

    //隐藏弹出框
    hideModal(name) {
        this.setState({
            [name]: false,//将所有参数置为false
        });
    }

    //保存模版
    saveTemplate(name) {
        var { applicationMessage } = this.state;
        var desp = ''
        var code = ''
        if (name == 'chiefComplaint') {
            desp = this.state.chiefComplaint ? this.state.chiefComplaint :
                (applicationMessage ? applicationMessage.chiefComplaint : '')
            code = '03050114'
        } else if (name == 'appPurpose') {
            desp = this.state.appPurpose ? this.state.appPurpose :
                (applicationMessage ? applicationMessage.appPurpose : '')
            code = '03050117'
        } else if (name == 'HPIllness') {
            desp = this.state.HPIllness ? this.state.HPIllness :
                (applicationMessage ? applicationMessage.HPIllness : '')
            code = '03050120'
        } else if (name == 'sign') {
            desp = desp = this.state.sign ? this.state.sign :
                (applicationMessage ? applicationMessage.sign : '')
            code = '03050123'
        }
        var params = {
            params: [{
                userID: this.state.userData.userID,
                descripts: desp
            }]
        }
        $http.post('urlDeault', this, {
            code: code,
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    message.success(this.setMessage('ApplicationFormsuces', 'descripts'), this.state.userData && this.state.userData.messageTime)
                    this.hideModal('isSHowUseTemplateModal')
                }
            }
        });
    }

    commonInputChange(name, code, e) {
        if (name == 'chiefComplaint' && this.state.userData.language == 'EN') {
            var str = e.target.value
            if (str.split(' ').length > 19) {
                return
            }
        }
        this.setState({
            [name]: e.target.value,
            [code]: true
        })
    }

    onSubmit() {
        var { onSubmit } = this.props;
        var { dataSource, examList, applicationMessage } = this.state;
        // if (Util.isEmpty(this.state.chiefComplaint) && Util.isEmpty(applicationMessage.chiefComplaint)) {
        //     message.error(this.setMessage('ApplicationFormtmc', 'descripts'),this.state.userData && this.state.userData.messageTime)
        //     return
        // }
        // if (Util.isEmpty(this.state.appPurpose) && Util.isEmpty(applicationMessage.appPurpose)) {
        //     message.error(this.setMessage('ApplicationFormcnt', 'descripts'),this.state.userData && this.state.userData.messageTime)
        //     return
        // }
        var partData = []
        if (!Util.isEmpty(dataSource)) {
            for (var i = 0; i < dataSource.length; i++) {
                partData.push({
                    partID: dataSource[i].id,
                    positionID: dataSource[i].positionID
                })
            }
        }
        var bodyPart = []
        var dataCode = []
        if (!Util.isEmpty(examList)) {
            for (var i = 0; i < examList.length; i++) {
                bodyPart.push({
                    tabIndex: examList[i].tabIndex,
                    bodyPart: examList[i].bodyPart
                })
            }
        }
        var appMessage = {
            appPurpose: this.state.appPurpose ? this.state.appPurpose : applicationMessage.appPurpose,
            HPIllness: this.state.HPIllness ? this.state.HPIllness : applicationMessage.HPIllness,
            sign: this.state.sign ? this.state.sign : applicationMessage.sign,
            chiefComplaint: this.state.chiefComplaint ? this.state.chiefComplaint : applicationMessage.chiefComplaint,
            bodyPart: bodyPart
        }

        onSubmit && onSubmit(appMessage, examList)
    }

    setElement = (record) => {
        return {
            onClick: () => {
                //当切换医嘱时，先将dataSource的数据清空
                if (record.medID !== this.state.medID && record.tabIndex !== this.state.tabIndex) {
                    this.state.dataSource = !Util.isEmpty(record.partList) ? record.partList : []
                }
                this.setState({
                    medID: record.medID,
                    tabIndex: record.tabIndex,
                    tableIndex: record.tableIndex,
                }, () => {
                    this.loadDoctorActive()
                })
            }
        }
    }
    setRowClassName = (record) => {
        return record.tabIndex === this.state.tabIndex ? 'clickRowStyle' : '';
    }

    handleTemplateNameChange = e => {
        this.setState({
            templateName: e.target.value,
        });
    }

    onKeyDownList(e) {
        if (e.keyCode == '13') {
            this.loadData()
        }
    }

    render() {
        var { templateName, partList, groupData, dataSource, checked } = this.state;
        var CheckOption = []
        groupData && groupData.map((item, index) => {
            // CheckOption.push(<Col span={8}onClick={this.onChangeCheck.bind(this,item)}>
            //   <Checkbox key={index} value={item.id}><span style={{ fontSize: 18 }}
            //   >{item.descripts}</span></Checkbox></Col>)

            CheckOption.push(<Col span={12}>
                <Checkbox key={index} value={item.id} onChange={this.onChangeData.bind(this, item, index)}
                    checked={item.checked} /><span style={{ fontSize: 16, marginLeft: 5, cursor: 'pointer' }}
                        onClick={this.onDoubleClickMsg.bind(this, item, index)}
                    >{item.descripts}</span></Col>)
        })

        var partOption = []
        partList && partList.map((item, index) => {
            partOption.push(<RadioButton key={index} value={item.id}>{item.descripts}</RadioButton>)
        })

        return <div>
            {/**获取调用模版 */}
            <ShowUseTemplateModal isShow={this.state.isShowUseTemplateModal}
                onHide={this.hideModal.bind(this, 'isShowUseTemplateModal')}
                onSubmit={this.loadTemplate.bind(this)}
                template={this.state.template}>
            </ShowUseTemplateModal>
            <Modal className='part-detail-modal'
                title={'选择检查部位/体位'}
                maskClosable={false}
                visible={this.props.isShow}
                okText={this.state.userData.language == 'EN' ? 'Submit' : '确定'}
                cancelText={this.state.userData.language == 'EN' ? 'Cancel' : '取消'}
                onOk={this.onSubmit.bind(this)}
                onCancel={this.closeModal.bind(this)}>
                <div className='examlist-modal'>
                    <Card style={{ float: 'left', width: '69%', height: '55vh' }}>
                        {/* <div style={{ height: '25vh' }} className='show-examlist-table'>
                            <RadioGroup buttonStyle="solid" value={this.state.rowMedID}
                                onChange={this.changeRadio.bind(this)}>{partOption}</RadioGroup>
                            <div style={{ display: 'flex' }}>
                                <Row style={{ width: '40vh', height: '22vh', border: '1px solid #e8e8e8' }}>
                                    <Input style={{ width: '34vh', marginLeft: 5, marginTop: 5 }} size='small'
                                        prefix={<Icon type="search" style={{ color: 'rgba(0,0,0,.25)' }} />}
                                        onKeyDown={this.onKeyDownList.bind(this)}
                                        placeholder={this.setMessage('ApplicationFormquery', 'descripts')} value={templateName} onChange={this.handleTemplateNameChange} />
                                    <div style={{ height: '19vh', overflowY: 'auto' }}>{CheckOption}</div>
                                </Row>
                                <Row style={{ width: '40vh', marginLeft: 5 }}>
                                    <Table columns={this.columns} bordered
                                        dataSource={this.state.dataSource}
                                        rowKey={(data) => {
                                            return data.id
                                        }}
                                        pagination={false}></Table>
                                </Row>
                            </div>
                        </div> */}
                        <div className='exam-modal-body'>
                            <Table columns={this.leftColumns}
                                dataSource={this.state.examList}
                                scroll={{ y: '45vh' }}
                                onRow={this.setElement}
                                rowClassName={this.setRowClassName}
                                bordered
                                rowKey={(data) => {
                                    return data.tabIndex
                                }} pagination={false}></Table>
                        </div>
                    </Card>

                    <Card size="small" style={{ float: 'right', width: '30%', height: '55vh', }}
                        title={<div>{this.setMessage('ApplicationFormdeatil', 'descripts')}</div>}
                        headStyle={{ background: 'linear-gradient(0deg,rgba(238,238,238,0.8) 0%,rgba(238,238,238,0.5) 50%,rgba(238,238,238,0.1) 100%)', color: ' rgba(102,102,102,1)' }}
                        className="medical-advice-list ">
                        <div style={{ padding: '5px 8px' }}>
                            <div><div style={{ float: 'left' }}>
                                {/* <span style={{ color: '#f5222d', fontFamily: 'SimSun' }}>*</span> */}
                                {this.setMessage('ApplicationFormnas', 'descripts')}</div>
                                <div style={{ float: 'right', cursor: 'pointer' }}>
                                    <span className={this.state.indexStyle == '1' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onClick={this.saveTemplate.bind(this, 'chiefComplaint')}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '1')}>{this.setMessage('ApplicationFormasd', 'descripts')}</span>
                                    <span style={{ padding: '0 10px' }} className={this.state.indexStyle == '2' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onClick={this.showUseTemplateModal.bind(this, 'chiefComplaint')}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '2')}>{this.setMessage('ApplicationFormqvf', 'descripts')}</span></div>
                            </div>
                            {/* <div style={{height: '86px', background: 'rgba(242, 242, 242, 1)'}}></div> */}
                            <TextArea onChange={this.commonInputChange.bind(this, 'chiefComplaint', 'chiefStatus')}
                                maxLength={this.state.userData.language == 'CN' && this.setMessage('ApplicationFormComplaintLength', 'legth')}
                                value={this.state.chiefComplaint ? this.state.chiefComplaint :
                                    (this.state.chiefStatus ? undefined : (this.state.applicationMessage ? this.state.applicationMessage.chiefComplaint : undefined))} />
                        </div>
                        <div style={{ padding: '5px 8px' }}>
                            <div><div style={{ float: 'left' }}>
                                {/* <span style={{ color: '#f5222d', fontFamily: 'SimSun' }}>*</span> */}
                                {this.setMessage('ApplicationFormPurpose', 'descripts')}</div>
                                <div style={{ float: 'right', cursor: 'pointer' }}>
                                    <span className={this.state.indexStyle == '3' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onClick={this.saveTemplate.bind(this, 'appPurpose')}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '3')}>{this.setMessage('ApplicationFormasd', 'descripts')}</span>
                                    <span style={{ padding: '0 10px' }} className={this.state.indexStyle == '4' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onClick={this.showUseTemplateModal.bind(this, 'appPurpose')}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '4')}>{this.setMessage('ApplicationFormqvf', 'descripts')}</span></div>
                            </div>
                            {/* <div style={{height: '86px', background: 'rgba(242, 242, 242, 1)'}}></div> */}
                            <TextArea onChange={this.commonInputChange.bind(this, 'appPurpose', 'appStatus')}
                                value={this.state.appPurpose ? this.state.appPurpose :
                                    (this.state.appStatus ? undefined : (this.state.applicationMessage ? this.state.applicationMessage.appPurpose : undefined))} />
                        </div>
                        <div style={{ padding: '5px 8px' }}>
                            <div><div style={{ float: 'left' }}>{this.setMessage('ApplicationFormgff', 'descripts')}</div>
                                <div style={{ float: 'right', cursor: 'pointer' }}>
                                    <span className={this.state.indexStyle == '5' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onClick={this.saveTemplate.bind(this, 'HPIllness')}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '5')}>{this.setMessage('ApplicationFormasd', 'descripts')}</span>
                                    <span style={{ padding: '0 10px' }} className={this.state.indexStyle == '6' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onClick={this.showUseTemplateModal.bind(this, 'HPIllness')}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '6')}>{this.setMessage('ApplicationFormqvf', 'descripts')}</span></div>
                            </div>
                            {/* <div style={{height: '86px', background: 'rgba(242, 242, 242, 1)'}}></div> */}
                            <TextArea onChange={this.commonInputChange.bind(this, 'HPIllness', 'hpilStatus')}
                                value={this.state.HPIllness ? this.state.HPIllness :
                                    (this.state.hpilStatus ? undefined : (this.state.applicationMessage ? this.state.applicationMessage.HPIllness : undefined))} />
                        </div>
                        <div style={{ padding: '5px 8px' }}>
                            <div><div style={{ float: 'left' }}>{this.setMessage('ApplicationFormac', 'descripts')}</div>
                                <div style={{ float: 'right', cursor: 'pointer' }}>
                                    <span className={this.state.indexStyle == '7' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onClick={this.saveTemplate.bind(this, 'sign')}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '7')}>{this.setMessage('ApplicationFormasd', 'descripts')}</span>
                                    <span style={{ padding: '0 10px' }} className={this.state.indexStyle == '8' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onClick={this.showUseTemplateModal.bind(this, 'sign')}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '8')}>{this.setMessage('ApplicationFormqvf', 'descripts')}</span></div>
                            </div>
                            {/* <div style={{height: '86px', background: 'rgba(242, 242, 242, 1)'}}></div> */}
                            <TextArea onChange={this.commonInputChange.bind(this, 'sign', 'signStatus')}
                                value={this.state.sign ? this.state.sign :
                                    (this.state.signStatus ? undefined : (this.state.applicationMessage ? this.state.applicationMessage.sign : undefined))} />
                        </div>
                        <div style={{ padding: '5px 8px' }}>
                            <div><div style={{ float: 'left' }}>{this.setMessage('ApplicationFormrtf', 'descripts')}</div>
                                <div style={{ float: 'right', cursor: 'pointer' }}>
                                    <span className={this.state.indexStyle == '9' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '9')}>{this.setMessage('ApplicationFormasd', 'descripts')}</span>
                                    <span style={{ padding: '0 10px' }} className={this.state.indexStyle == '10' ? 'mouse-add-Style' : ''}
                                        onMouseLeave={this.addMouseLeaveStyle.bind(this)}
                                        onMouseOver={this.addMouseOverStyle.bind(this, '10')}>{this.setMessage('ApplicationFormqvf', 'descripts')}</span></div>
                            </div>
                            {/* <div style={{height: '86px', background: 'rgba(242, 242, 242, 1)'}}></div> */}
                            <TextArea onChange={Util.commonInputChange.bind(this, 'other')}
                                value={this.state.other ? this.state.other :
                                    (this.state.applicationMessage ? this.state.applicationMessage.other : undefined)} />
                        </div>
                    </Card>
                </div>
            </Modal></div>
    }
}

export default Form.create()(ShowExamlistModal);