// 手术申请配置
import React, { Component } from 'react';
import { Form, Row, Col, Table, Select, Input, Button, Divider, message, Radio, Checkbox, Popconfirm } from 'antd';
import { $http } from '../../../containers/config/https';
import ShowCommonTableModal from '../../workstation/component/ShowCommonTableModal.jsx'
import PublicModalQueryTable from 'pages/common/PublicModalQueryTable';
import FormItem from 'antd/lib/form/FormItem';
import './style/OperationApply.less';

// 用户数据
let userData;
// 点击编辑时记录当前行数据
let tableRecord = {};
//患者信息
var scrollCount = 0;

// 创建表单
const OperationApplyConfig = Form.create()(
    class extends Component {
        constructor(props) {
            super(props);
            userData = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {}
            this.state = {
                operationApplyInfo: {},		// 手术申请信息
                operationLocData: [],		// 手术室下拉数据源
                defOperationLocID: '',
                operationRoomData: [],		// 手术间下拉数据源
                operationDocData: [],		// 主刀医师下拉数据源
                assistantDocData: [],		// 助手下拉数据源
                RHBloodTypeData: [],
                operationFrequencyData: [],	// 台次下拉数据源
                anesthesiaData: [],			// 麻醉下拉数据源
                operationData: [],			// 手术下拉数据源
                operationLevelData: [],		// 级别下拉数据源
                operationPartData: [],		// 手术部位下拉数据源
                operationCutData: [],		// 手术切口下拉数据源
                operationPostData: [],		// 手术体位下拉数据源
                bloodTpyeData: [],			// 血型下拉数据源
                classificationData: [],		// 手术分类下拉数据源
                projectTypeData: [],		// 手术项目类型下拉数据源
                motivationData: [],			// 手术动机下拉数据源
                surgicalPopulationData: [],  // 手术人群下拉数据
                triageAssociatedData: [],    // 分诊前台关联数据
                HbsAgTraitsData: [],
                defHbsAgTraitsID: '',
                HcvAbTraitsData: [],
                defHcvAbTraitsID: '',
                HivAbTraitsData: [],
                defHivAbTraitsID: '',
                syphilisTraitsData: [],
                defSyphilisTraitsID: '',
                defBloodTpyeID: '',
                defRHBloodTypeID: '',
                editingKey: '',				// 当前编辑的table数据
                removeOperation: [],		// 待删除数据
                tableData: [],
                newTabelData: [],
                locDesc: "0",
                acValue: "E",
                value: '',
                statusCode: '',				//当前手术状态
                operationPartPar: [],		//部位明细
                operationConfigID: '',
                selectedOperationUser: [],	// 已选择的医护人员（下拉框禁用使用）
                locType: '',				// 科室类型
                workDate: '',				// 上班日期(择期时判断)
                offWorkTime: '',			// 下班时间(选择时间时判断)
                EN: {},
                CN: {},
                page: 1,
                pageSize: 50,
                total: 0,
                current: 1,
                searchCode: '',
                selectIndex: 0,//当前选中行
                changename: '',
                dataSource: [],
                crystalsModelArr: [],		// 晶体型号
                crystalsStrengthArr: [],	// 晶体度数
                crystalsRepReasonArr: [],	// 晶体替换原因
                anaesthesiaDocaArr: [],		//麻醉医师数据集
                docECGDocArr: [],			//心电监护数据集
                leftEyeCrystalData: {},//左眼晶体数据
                rightEyeCrystalData: {},//右眼晶体数据
                leftEyeCrystalInventory: -1,//左眼晶体数量
                rightEyeCrystalInventory: -1,//右眼晶体数量
                historyConfigCloumns: [],
                historyConfigTableData: []
            }
            this.loadListener = this.keyDownElement.bind(this);
            this.columns = [{
                key: 1,
                title: () => this.display('OperationApplyseqNo'),
                dataIndex: 'seqNo',
                align: "center",
                width: '5%',
            }, {
                key: 2,
                title: () => this.display('OperationApplyopration'),
                dataIndex: 'operationDesc',
                align: "center",
                width: '20%',
                render: (text, record, index) => {
                    const editable = this.isEditing(record);
                    return (
                        <Input
                            allowClear={true}
                            autoFocus
                            onClick={this.handleStopPropagation}
                            id={"operation-input" + index}
                            value={record.operationDesc}
                            onFocus={this.onDiagDescFocus.bind(this, index)}
                            style={{ width: "100%", textAlign: "left" }}
                            onChange={this.handleFieldChange.bind(this, index, 'operationDesc')}
                            onPressEnter={this.getOperationData}
                            disabled={editable ? false : true}
                            autoComplete="off"
                        />
                    )
                }

            }, {
                key: 6,
                title: () => this.display('OperationApplyclassification'),
                dataIndex: 'classification',
                align: "center",
                width: '10%',
                render: (text, record, index) => {
                    const editable = this.isEditing(record);
                    return (
                        <Select
                            value={record.classification}
                            allowClear
                            style={{ width: "100%", textAlign: "left" }}
                            onChange={this.handleFieldChange.bind(this, index, 'classification')}
                            disabled={editable ? false : true}
                            showSearch
                            optionFilterProp='role'
                        >
                            {this.state.classificationData.map(data => (
                                <Select.Option
                                    role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}
                                    key={data.id}
                                >
                                    {data.descripts}
                                </Select.Option>))}
                        </Select>
                    )
                }
            }, {
                key: 7,
                title: () => this.display('OperationApplyprojectType'),
                dataIndex: 'projectType',
                align: "center",
                width: '10%',
                render: (text, record, index) => {
                    const editable = this.isEditing(record);
                    return (
                        <Select
                            value={record.projectType}
                            allowClear
                            style={{ width: "100%", textAlign: "left" }}
                            onChange={this.handleFieldChange.bind(this, index, 'projectType')}
                            disabled={editable ? false : true}
                            showSearch
                            optionFilterProp='role'
                        >
                            {this.state.projectTypeData.map(data => (
                                <Select.Option
                                    role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}
                                    key={data.id}
                                >
                                    {data.descripts}
                                </Select.Option>))}
                        </Select>
                    )
                }
            }, {
                key: 3,
                title: () => this.display('OperationApplycategory'),
                dataIndex: 'categoryID',
                align: "center",
                width: '10%',
                render: (text, record, index) => {
                    const editable = this.isEditing(record);
                    return (
                        <Select
                            value={record.categoryID}
                            allowClear
                            style={{ width: "100%", textAlign: "left" }}
                            onChange={this.handleFieldChange.bind(this, index, 'categoryID')}
                            disabled={editable ? false : true}
                            showSearch
                            optionFilterProp='role'
                        >
                            {this.state.operationLevelData.map(data => (
                                <Select.Option
                                    role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}
                                    key={data.id}
                                >
                                    {data.descripts}
                                </Select.Option>))}
                        </Select>
                    )
                }
            }, {
                key: 4,
                title: () => this.display('OperationApplyoperationPart'),
                dataIndex: 'operationPart',
                align: "center",
                width: '10%',
                render: (text, record, index) => {
                    const editable = this.isEditing(record);
                    return (
                        <Select
                            mode="multiple"
                            value={record.operationPart ? record.operationPart : ''}
                            allowClear
                            style={{ width: "100%", textAlign: "left" }}
                            onChange={this.handleFieldChange.bind(this, index, 'operationPart')}
                            disabled={editable ? false : true}
                            showSearch
                            optionFilterProp='role'
                        >
                            {this.state.operationPartData.map(data => (
                                <Select.Option
                                    role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}
                                    key={data.id}
                                >
                                    {data.descripts}
                                </Select.Option>))}
                        </Select>
                    )
                }
            }, {
                key: 5,
                title: () => this.display('OperationApplyincision'),
                dataIndex: 'incisionID',
                align: "center",
                width: '10%',
                render: (text, record, index) => {
                    const editable = this.isEditing(record);
                    return (
                        <Select
                            value={record.incisionID}
                            allowClear
                            style={{ width: "100%", textAlign: "left" }}
                            onChange={this.handleFieldChange.bind(this, index, 'incisionID')}
                            disabled={editable ? false : true}
                            showSearch
                            optionFilterProp='role'
                        >
                            {this.state.operationCutData.map(data => (
                                <Select.Option
                                    role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}
                                    key={data.id}
                                >
                                    {data.descripts}
                                </Select.Option>))}
                        </Select>
                    )
                }
            }, {
                key: 9,
                title: () => this.display('OperationApplysurgicalRremarks'),
                dataIndex: 'notes',
                align: "center",
                width: '10%',
                render: (text, record, index) => {
                    const editable = this.isEditing(record);
                    return (
                        <Input
                            onClick={this.handleStopPropagation}
                            value={record.notes}
                            style={{ width: "100%", textAlign: "left" }}
                            onChange={this.handleFieldChange.bind(this, index, 'notes')}
                            disabled={editable ? false : true}
                        />
                    )
                }
            }, {
                key: 10,
                title: () => this.display('OperationApplyoperate'),
                dataIndex: 'operate',
                align: "center",
                render: (text, record) => {
                    const { editingKey } = this.state;
                    const editable = this.isEditing(record);
                    return editable ? (
                        <span>
                            <a onClick={(e) => this.handleUpdate(record, e)}>{this.display('OperationApplyconfirm')}</a>
                            <Divider type="vertical" />
                            <a onClick={(e) => this.handleCancel(record, e)}>{this.display('OperationApplycancelT')}</a>
                        </span>
                    ) : (
                        <span>
                            <a onClick={(e) => this.handleEdit(record, e)}>{this.display('OperationApplyedit')}</a>
                            <Divider type="vertical" />
                            <a style={{ color: 'rgba(240,65,52,1)' }} onClick={(e) => this.handleDelete(record, e)}>{this.display('OperationApplydelete')}</a>
                        </span>
                    );
                }
            }];
            this.operationColumns = [{
                title: () => this.display('OperationApplyICDCode'),
                dataIndex: 'ICDCode',
                width: 80,
                align: 'left',
            }, {
                title: () => this.display('OperationApplydescripts'),
                dataIndex: 'descripts',
                width: 200,
                align: 'left',
            }, {
                title: () => this.display('OperationApplycategoryDesc'),
                dataIndex: 'categoryDesc',
                width: 200,
                align: 'left',
            }];
        }

        componentDidMount() {
            this.languageSwitch();
            this.getSelectData();
            this.getCrystalsModel();  // 获取晶体型号
            this.getCrystalsStrength();
            this.getOperationProjType('');
        }

        // 获取手术项目类型
        getOperationProjType = (classID) => {
            let data = {
                params: [{
                    classID
                }]
            }
            $http.post('urlS', this, {
                code: '04160025',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            projectTypeData: res.result
                        })
                    }
                }
            });
        }

        // 获取晶体型号
        getCrystalsModel = () => {
            let data = {
                params: [{
                    medSubCatCode: '晶体'
                }]
            }
            $http.post('urlS', this, {
                code: '04160028',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            crystalsModelArr: res.result.Data
                        })
                    }
                }
            });
        }

        // 获取晶体度数
        getCrystalsStrength = () => {
            let data = {
                params: [{}]
            }
            $http.post('urlS', this, {
                code: '02060193',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            crystalsStrengthArr: res.result.degreesList
                        })
                    }
                }
            });
        }

        keyDownElement(e) {
            if (this.state.visible) {
                if (e.keyCode == '13') {
                    this.setState({
                        newIndex: 0
                    })
                }
            }
        }

        // 中英文切换
        languageSwitch = () => {
            let data = {
                params: [{
                    reactCode: ['OperationApply']
                }]
            }
            $http.post('urlS', this, {
                code: '01040073',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            EN: res.result.language.EN,
                            CN: res.result.language.CN
                        })
                    }
                }
            })
        }

        display(name) {
            return userData.language != 'EN' ? (this.state.CN[name] && this.state.CN[name]['descripts'] ? this.state.CN[name]['descripts'] : '') : (this.state.CN[name] && this.state.EN[name]['descripts'] ? this.state.EN[name]['descripts'] : '')
        }

        // 阻止默认事件
        handleStopPropagation = (e) => {
            if (typeof e == 'object') {
                e.stopPropagation();
            }
        }

        // 获取手术下拉框数据
        getOperationData = (e) => {
            let searchCode = e.target ? e.target.value : this.state.searchCode
            if (searchCode != '') {
                this.setState({
                    searchCode: searchCode,
                })
            }
            let data = {
                params: [{
                    searchCode: searchCode ? searchCode : this.state.searchCode
                }],
                pagination: [{
                    pageSize: this.state.pageSize,
                    currentPage: this.state.page
                }]
            };
            $http.post('urlDeault', this, {
                code: '04160034',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        let rowMedID = '';
                        if ((res.result.Data) && (res.result.Data.length > 0)) {
                            rowMedID = res.result.Data[0].id
                        }
                        this.setState({
                            rowMedID: rowMedID,
                            operationData: res.result.Data,
                            total: res.result.TotalCount,
                        }, () => this.child.showModal())
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            });
        }

        changeOperationLoc = (val, opt) => {
            if (val != undefined) {
                this.setState({
                    value: val,
                    workDate: opt.props.workDate,
                    offWorkTime: opt.props.offWorkTime
                }, () => {
                    this.props.form.setFieldsValue({
                        operationRoomID: ''
                    })
                    this.getOperationRoomData(val);
                });
            } else {
                this.props.form.setFieldsValue({
                    operationRoomID: ''
                })
                this.getOperationRoomData('');
            }
        };

        //类型
        changeType = (e) => {
            this.setState({
                acValue: e.target.value,
            });
        };

        // 获取手术间下拉框数据
        getOperationRoomData = (value) => {
            let data = {
                'params': [{
                    locID: value
                }]
            };
            $http.post('urlDeault', this, {
                code: '04160005',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            operationRoomData: res.result
                        }, () => {
                            if (res.result.length > 0) {
                                this.props.form.setFieldsValue({ operationRoomID: res.result[0].id })
                            }
                        })
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            });
        }

        // 获取下拉框数据
        getSelectData = () => {
            let data = {
                'params': [{
                    hospID: userData && userData.hospID ? userData.hospID : '', // 登录医院id       
                    locID: userData.locID
                }]
            };
            $http.post('urlDeault', this, {
                code: '04160001',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            locType: res.locType,
                            operationLocData: res.locType != 'OP' ? res.OPLocArr : res.locArr,
                            defOperationLocID: res.locType != 'OP' ? res.defOperationLocID : '',
                            bloodTpyeData: res.BloodGroup.data,
                            defBloodTpyeID: res.BloodGroup.defID,
                            operationDocData: res.DoctorArr,
                            assistantDocData: res.NurseArr,
                            HbsAgTraitsData: res.HbsAgTraits.data,
                            defHbsAgTraitsID: res.HbsAgTraits.defID,
                            HcvAbTraitsData: res.HcvAbTraits.data,
                            defHcvAbTraitsID: res.HcvAbTraits.defID,
                            HivAbTraitsData: res.HivAbTraits.data,
                            defHivAbTraitsID: res.HivAbTraits.defID,
                            syphilisTraitsData: res.SyphilisTraits.data,
                            defSyphilisTraitsID: res.SyphilisTraits.defID,
                            RHBloodTypeData: res.RHBloodGroup.data,
                            defRHBloodTypeID: res.RHBloodGroup.defID,
                            operationPostData: res.OperationPosition,
                            operationCutData: res.IncisionType,
                            operationPartData: res.OperationPart,
                            operationLevelData: res.OperationCategory,
                            anesthesiaData: res.anesthesiaMode,
                            classificationData: res.operationClass,
                            motivationData: res.operationMotivation.data,
                            surgicalPopulationData: res.surgicalPopulationData,
                            crystalsRepReasonArr: res.crystalsRepReasonArr,
                            anaesthesiaDocaArr: res.anaesthesiaDocaArr,
                            docECGDocArr: res.docECGDocArr,
                            triageAssociatedData: res.triageAssociatedData,
                        }, () => {
                            if (res.defOperationLocID) {
                                this.getOperationRoomData(res.defOperationLocID)
                            }
                        })
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            });
        }

        // 表格下拉框选中
        handleFieldChange = (index, code, value, opt) => {
            let top = document.getElementById('operation-input' + index).getBoundingClientRect().top + 40
            let left = document.getElementById('operation-input' + index).getBoundingClientRect().left;
            let windowHeight = window.innerHeight;
            if ((top + 360) > windowHeight) {
                top = top - 330 - 80;
            }
            top = top + 'px';
            left = left + 'px';
            let { tableData, operationPartPar, projectTypeData } = this.state;
            if (value !== undefined) {
                if (code === 'operationPart') {
                    operationPartPar = [];
                    for (var key in value) {
                        operationPartPar.push(value[key])
                    }
                    tableData[index].operationPart = operationPartPar;
                }
                else if (code === 'notes') {
                    if (value.target.value.length > 50) {
                        message.warning('备注超长');
                        return;
                    }
                    tableData[index][code] = (typeof (value) == 'string') ? value : value.target.value;
                }
                else if (code == 'classification') {
                    tableData[index].projectType = ''
                    this.getOperationProjType(value)
                    tableData[index][code] = (typeof (value) == 'string') ? value : value.target.value;
                }
                else {
                    tableData[index][code] = (typeof (value) == 'string') ? value : value.target.value;
                }
            } else {
                tableData[index][code] = '';
                if (code == 'classification') {
                    tableData[index].projectType = ''
                    projectTypeData = []
                }
            }
            this.setState({
                tableData,
                operationPartPar,
                projectTypeData,
                top: top,
                left: left,
            })
        }

        isEditing = (record) => {
            return record.key === this.state.editingKey
        };

        // 确认手术
        handleUpdate = (record, e) => {
            e.preventDefault();
            // 未选择手术时提示
            if (record.operationID === '') {
                message.warning(this.display('OperationApplyselectOperation'));
                return;
            }
            // 未选择手术类别时提示
            if (record.categoryID === '') {
                message.warning(this.display('OperationApplyselectLevel'));
                return;
            }
            // 未选择手术部位时提示
            if (record.operationPart.length < 1) {
                message.warning(this.display('OperationApplyselectPart'));
                return;
            }
            // 未选择切口时提示
            if (record.incisionID === '') {
                message.warning(this.display('OperationApplyselectIncision'));
                return;
            }
            this.setState({
                editingKey: ''
            });
        }

        // 删除手术
        handleDelete = (record, e) => {
            e.preventDefault();
            let { tableData, removeOperation } = this.state;
            tableData.splice(record.key, 1);
            // 重新修改数据key/seqNo
            for (let i = 0; i < tableData.length; i++) {
                tableData[i].key = i;
                tableData[i].seqNo = i + 1;
            }
            if (record.configItemID !== '') {
                removeOperation.push(record.configItemID);
                removeOperation = [...removeOperation];
            }
            this.setState({
                tableData: tableData,
                removeOperation,
            })
        }

        // 编辑手术
        handleEdit = (record, e) => {
            e.preventDefault();
            tableRecord = JSON.parse(JSON.stringify(record));
            this.setState({
                editingKey: record.key
            }, () => this.getOperationProjType(record.classification));
        }

        // 取消编辑
        handleCancel = (record, e) => {
            e.preventDefault();
            let tableData = this.state.tableData;
            tableData[record.key] = tableRecord;
            this.getOperationProjType(tableRecord.classification)
            this.setState({ editingKey: '', tableData });//取消编辑
            return false;
        }

        // 复选框
        checkboxOnchange = (code) => {
            let { operationApplyInfo } = this.state
            operationApplyInfo[code] = operationApplyInfo[code] === 'Y' ? 'N' : 'Y'
            this.setState({
                operationApplyInfo: operationApplyInfo
            })
        }

        // 添加行
        addRow = () => {
            const { tableData } = this.state;
            if ((tableData.length > 0) && (tableData[tableData.length - 1]) && (tableData[tableData.length - 1]['operationID'] === '')) {
                message.warning('请先选择上一条记录的科手术');
                return;
            }
            let newData = tableData.map((item) => ({ ...item }));
            // 重新修改数据key
            for (let i = 0; i < newData.length; i++) {
                newData[i].key = i
                newData[i].seqNo = i + 1
            }
            newData.push({
                key: newData.length,
                seqNo: tableData.length + 1,
                operationDesc: '',
                operationID: '',
                categoryID: '',
                operationPart: [],
                incisionID: '',
                notes: '',
                classification: '',
                projectType: '',
                motivation: '',
                editable: true
            });
            this.setState({
                tableData: newData,
                editingKey: newData.length - 1
            });
        }

        // 获取手术单查询
        getInfo = () => {
            let data = {
                params: [{
                    operationConfigID: this.state.operationConfigID,
                    type: 'config'
                }]
            };
            $http.post('urlDeault', this, {
                code: '04160036',
                data: data,
                success: function (res) {
                    if (res.errorCode === '0') {
                        this.setState({ historyConfigTableData: res.result?.Data || [] })
                    }
                },
                error: function (error) {
                    console.log(error)
                }
            });
        }

        //保存
        save = () => {
            let { acValue } = this.state;
            let tableCount = this.state.tableData.length
            for (let i = 0; i < tableCount; i++) {
                if (this.state.tableData[i].operationID === '') {
                    message.error('第' + (Number(i) + 1) + '行，手术没有选择!');
                    return;
                }
            }
            this.setState({
                editingKey: '',
            });
            const formData = this.props.form.getFieldsValue();
            this.props.form.validateFields((err, value) => {
                if (err) {
                    message.warning('存在必填项未填写')
                } else {
                    let data = {
                        params: [{
                            applyLocID: userData.applyLocID,
                            applyDocID: userData.applyDocID,
                            id: this.state.operationConfigID ? this.state.operationConfigID : '',
                            operationLocID: formData.operationLocID ? formData.operationLocID : '',
                            operationRoomID: formData.operationRoomID ? formData.operationRoomID : '',
                            duration: formData.duration ? formData.duration : '',
                            applyNumber: formData.applyNumber ? formData.applyNumber : '',
                            operatingSurgeon: formData.operatingSurgeon ? formData.operatingSurgeon : '',
                            firstAssistant: formData.firstAssistant ? formData.firstAssistant : '',
                            secondAssistant: formData.secondAssistant ? formData.secondAssistant : '',
                            thirdAssistant: formData.thirdAssistant ? formData.thirdAssistant : '',
                            otherAssistant: formData.otherAssistant ? formData.otherAssistant : '',
                            anaesthesiaID: formData.anaesthesiaID ? formData.anaesthesiaID : '',
                            anaesthesiaDoctorID: formData.anaesthesiaDoctorID ? formData.anaesthesiaDoctorID : '',
                            ecgDoctorID: formData.ecgDoctorID ? formData.ecgDoctorID : '',
                            applyDocNotes: formData.applyDocNotes ? formData.applyDocNotes : '',
                            Motive: formData.motivation ? formData.motivation : '',
                            CrowdDr: formData.surgicalPopulation ? formData.surgicalPopulation : '',
                            type: acValue ? acValue : '',
                            specialEquipment: formData.specialEquipment ? formData.specialEquipment : '',
                            positionID: formData.positionID ? formData.positionID : '',
                            quarantine: this.state.operationApplyInfo.quarantine === 'Y' ? 'Y' : 'N',
                            CPB: this.state.operationApplyInfo.CPB === 'Y' ? 'Y' : 'N',
                            selfBloodRtn: this.state.operationApplyInfo.selfBloodRtn === 'Y' ? 'Y' : 'N',
                            bloodPrepare: this.state.operationApplyInfo.bloodPrepare === 'Y' ? 'Y' : 'N',
                            frozen: this.state.operationApplyInfo.frozen === 'Y' ? 'Y' : 'N',
                            ecg: this.state.operationApplyInfo.ecg === 'Y' ? 'Y' : 'N',
                            status: this.state.operationApplyInfo.status === 'N' ? 'N' : 'Y',
                            bloodType: formData.bloodType ? formData.bloodType : '',
                            RHBlood: formData.RHBlood ? formData.RHBlood : '',
                            HbsAg: formData.HbsAg ? formData.HbsAg : '',
                            HcvAb: formData.HcvAb ? formData.HcvAb : '',
                            HivAb: formData.HivAb ? formData.HivAb : '',
                            syphilis: formData.syphilis ? formData.syphilis : '',
                            notes: formData.notes ? formData.notes : '',
                            operationDetail: this.state.tableData,
                            removeDetail: this.state.removeOperation,
                            crystalsModelID: formData.crystalsModelID ? formData.crystalsModelID : '',
                            crystalsStrengthID: formData.crystalsStrengthID ? formData.crystalsStrengthID : '',
                            crystalsNum: formData.crystalsNum ? formData.crystalsNum : '1',
                            rcrystalsModelID: formData.rcrystalsModelID ? formData.rcrystalsModelID : '',
                            rcrystalsStrengthID: formData.rcrystalsStrengthID ? formData.rcrystalsStrengthID : '',
                            rcrystalsNum: formData.rcrystalsNum ? formData.rcrystalsNum : '1',
                            astigmatism: formData.astigmatism ? formData.astigmatism : '',
                            rastigmatism: formData.rastigmatism ? formData.rastigmatism : '',
                            descripts: formData?.descripts || undefined
                        }]
                    };
                    $http.post('urlADS', this, {
                        code: '04160035',
                        data: data,
                        success: function (res) {
                            if (res.errorCode === '0') {
                                message.success('成功');
                                let operationConfigID = res?.result || '';
                                if (operationConfigID) {
                                    this.setState({
                                        operationConfigID
                                    });
                                } else {
                                    this.handleReset();
                                }
                            }
                        },
                        error: function (error) {
                            message.error('失败：' + error);
                        }
                    });
                }
            });
        }

        // 手术基础数据弹框
        onRef = (ref) => {
            this.child = ref;
        }

        //分页切换
        changePageSize(current, pageSize) {
            if ((pageSize == this.state.pageSize) && (current == this.state.page)) {
                if (this.state.rowMedID) {
                    let oneArr = this.state.operationData && this.state.operationData.length > 0 ? this.state.operationData : [];
                    let obj = {}
                    for (var i = 0; i < oneArr.length; i++) {
                        if (oneArr[i].id === this.state.rowMedID) {
                            obj = i > 0 ? oneArr[i] : oneArr[0];
                            break;
                        }
                    }
                    this.rowClick(obj)
                }
            } else {
                this.setState({ pageSize: pageSize, page: current }, () => {
                    //	this.loadSelectData('', current, pageSize);
                    this.getOperationData(this.state.searchCode);
                });
            }
        }

        //列修改为input框，change事件处理
        handleSearchInput(name, index, data, e) {
            let tableData = this.state.tableData;
            let top = document.getElementById(name + '-input' + index).getBoundingClientRect().top + 40
            let left = document.getElementById(name + '-input' + index).getBoundingClientRect().left;
            let windowHeight = window.innerHeight;
            if ((top + 360) > windowHeight) {
                top = top - 330 - 80;
            }
            top = top + 'px';
            left = left + 'px';
            var value = e.target.value;
            tableData[index][name] = value;
            this.setState({
                top: top,
                left: left,
                selectIndex: index,
                editingKey: index,
                tableData: tableData,
                changename: name,
                changeValue: value,
                operationData: [],
                total: 0,
                page: 1,
            })
            if (value.length >= 2) {
                this.loadSelectData(value, '', '')
            } else {
                this.setState({
                    operationData: [],
                    total: 0,
                    page: 1,
                })
            }
            document.addEventListener('elementTable', this.loadListener)
        }

        //诊断名称获取焦点时触发
        onDiagDescFocus = (index, e) => {
            this.setState({
                selectIndex: index,
            })
        }

        //操作弹框
        onClickRowPublic = (record, index) => {
            return {
                onDoubleClick: () => {
                    // if (!record.categoryID) {
                    // 	message.warning('该手术无手术级别，请与医务科联系')
                    // 	return;
                    // }
                    let { tableData, editingKey } = this.state;
                    tableData[editingKey].operationID = record.id;
                    tableData[editingKey].operationDesc = record.descripts;
                    tableData[editingKey].categoryID = record.categoryID;
                    this.setState({ tableData }, () => {
                        this.child.handleCancel();
                    })
                },
                onClick: () => {
                    this.setState({
                        rowMedID: record.id
                    })
                }
            }
        }

        setRowClassNamePublic = (record) => {
            return record.id === this.state.rowMedID ? 'clickRowStyle' : '';
        }

        handleOnKeydown(e) {
            var e = window.event || e;
            let scroll_height = document.getElementsByClassName('clickRowStyle')[0] ? document.getElementsByClassName('clickRowStyle')[0].clientHeight : 26;
            if (scrollCount < 0) {
                scrollCount = 0
            }
            let id = '';
            let oneArr = this.state.operationData && this.state.operationData.length > 0 ? this.state.operationData : [];
            switch (e.keyCode) {
                case 13:
                    if ((this.state.rowMedID) && (e.target.nodeName != 'INPUT')) {
                        let obj = {}
                        for (var i = 0; i < oneArr.length; i++) {
                            if (oneArr[i].id === this.state.rowMedID) {
                                obj = i > 0 ? oneArr[i] : oneArr[0];
                                break;
                            }
                        }

                        this.rowClick(obj);

                    }
                    break;
                case 38: //上
                    if (this.state.rowMedID) {
                        for (var i = 0; i < oneArr.length; i++) {
                            if (oneArr[i].id === this.state.rowMedID) {
                                id = i > 0 ? oneArr[i - 1].id : oneArr[0].id;
                                break;
                            }
                        }
                        this.setState({ rowMedID: id }, () => {
                            scrollCount -= document.getElementsByClassName('clickRowStyle')[0].clientHeight
                            var gundong = ''
                            gundong = document.getElementsByClassName('ant-table-body')[1]
                            if (gundong) {
                                gundong.scrollTop = gundong.scrollTop - scroll_height;
                            }
                        })
                    } else {
                        this.setState({ rowMedID: oneArr[0].id })
                    }
                    break;
                case 40: //下
                    if (this.state.rowMedID) {
                        for (let i = 0; i < oneArr.length; i++) {
                            if (oneArr[i].id === this.state.rowMedID) {
                                id = i + 1 >= oneArr.length ? oneArr[oneArr.length - 1].id : oneArr[i + 1].id;
                                break;
                            }
                        }
                        this.setState({ rowMedID: id }, () => {
                            scrollCount += document.getElementsByClassName('clickRowStyle')[0].clientHeight
                            var gundong = ''
                            gundong = document.getElementsByClassName('ant-table-body')[1]
                            if (gundong) {
                                gundong.scrollTop = gundong.scrollTop + scroll_height;
                            }
                        })
                    } else {
                        this.setState({ rowMedID: oneArr[0].id })
                    }
                    break;
            }
        }

        //取消弹框显示，焦点问题
        handleFocus() {
            this.setState({
                operationData: []
            }, () => {
                if ((this['operationDesc' + this.state.selectIndex]) && (this['operationDesc' + this.state.selectIndex].current)) {
                    this['operationDesc' + this.state.selectIndex].current.focus()
                }
            })
        }

        ///下拉框双击
        rowClick = (record, index, e) => {
            let { tableData, editingKey } = this.state;
            tableData[editingKey].operationID = record.id;
            tableData[editingKey].operationDesc = record.descripts;
            tableData[editingKey].categoryID = record.categoryID;
            this.setState({ tableData }, () => {
                this.child.handleCancel();
            })
        }

        showCommonTableModal(index, data, name, e) {
            if (e.keyCode == '13') {
                if (data[name]) {
                    this.setState({
                        isShowCommonTableModal: true,
                        operationData: data,
                        search: '1',
                    }, () => {
                        // this.loadSelectData(data[name], '', '')
                        this.child.showModal();
                    })
                }
            }
        }

        handleLeftEyeInventory = (type, value, option) => {
            let leftEyeCrystalData = {}
            if (type == 'model') {
                leftEyeCrystalData.crystalModelID = value;
                leftEyeCrystalData.crystalDegreeID = this.state.leftEyeCrystalData.crystalDegreeID
            }
            else {
                leftEyeCrystalData.crystalDegreeID = value;
                leftEyeCrystalData.crystalModelID = this.state.leftEyeCrystalData.crystalModelID
            }
            this.setState({ leftEyeCrystalData })
            if ((leftEyeCrystalData.crystalModelID && leftEyeCrystalData.crystalModelID.trim().length > 0)
                && (leftEyeCrystalData.crystalDegreeID && leftEyeCrystalData.crystalDegreeID.trim().length > 0)) {
                //调用接口
                this.getEyeCrystalNum('L', leftEyeCrystalData)
            }
            else
                this.setState({ leftEyeCrystalInventory: -1 })
        }

        handleRightEyeInventory = (type, value, option) => {
            let rightEyeCrystalData = {}
            if (type == 'model') {
                rightEyeCrystalData.crystalModelID = value;
                rightEyeCrystalData.crystalDegreeID = this.state.rightEyeCrystalData.crystalDegreeID
            }
            else {
                rightEyeCrystalData.crystalDegreeID = value;
                rightEyeCrystalData.crystalModelID = this.state.rightEyeCrystalData.crystalModelID
            }
            this.setState({ rightEyeCrystalData })
            if ((rightEyeCrystalData.crystalModelID && rightEyeCrystalData.crystalModelID.trim().length > 0)
                && (rightEyeCrystalData.crystalDegreeID && rightEyeCrystalData.crystalDegreeID.trim().length > 0)) {
                //调用接口
                this.getEyeCrystalNum('R', rightEyeCrystalData)
            }
            else
                this.setState({ rightEyeCrystalInventory: -1 })
        }

        getEyeCrystalNum = (type, eyeCrystalData) => {
            // {'params':[{'medID':'2965','degrees':'213','hospID':'25'}]} 
            const userData = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {}
            let data = {
                params: [{
                    hospID: userData.hospID,
                    medID: eyeCrystalData.crystalModelID,
                    degrees: eyeCrystalData.crystalDegreeID
                }]
            }
            $http.post('urlS', this, {
                code: '02060207',
                data: data,
                success: function (res) {
                    if (res.errorCode == '0') {
                        console.log(res.count)
                        if (type == 'R')
                            this.setState({ rightEyeCrystalInventory: res.count })
                        else
                            this.setState({ leftEyeCrystalInventory: res.count })

                    }
                    else {
                        message.error('判断晶体库存异常：' + res.errorMessage);
                        if (type == 'R')
                            this.setState({ rightEyeCrystalInventory: -1 })
                        else
                            this.setState({ leftEyeCrystalInventory: -1 })
                    }
                },
                error: function (error) {
                    message.error('判断晶体库存异常：' + error);
                    if (type == 'R')
                        this.setState({ rightEyeCrystalInventory: -1 })
                    else
                        this.setState({ leftEyeCrystalInventory: -1 })
                }
            });
        }

        // 历史配置
        handleHistoricalConfig = () => {
            this.historyConfigRef && this.historyConfigRef.modifyVisible(true);
        }

        // 确认
        handleHistoryConfigOk = (dataInfo) => {
            this.getOperationRoomData(dataInfo.operationLocID);
            this.setState({
                operationConfigID: dataInfo?.id || '',
                operationApplyInfo: dataInfo,
                tableData: dataInfo.operationDetail
            }, () => {
                this.props.form.setFieldsValue({
                    operationRoomID: dataInfo.operationRoomID,
                    operationLocID: dataInfo.operationLocID ? dataInfo.operationLocID : '',
                    duration: dataInfo.duration ? dataInfo.duration : '',
                    applyNumber: dataInfo.applyNumber ? dataInfo.applyNumber : '',
                    operatingSurgeon: dataInfo.operatingSurgeon ? dataInfo.operatingSurgeon : '',
                    firstAssistant: dataInfo.firstAssistant ? dataInfo.firstAssistant : '',
                    secondAssistant: dataInfo.secondAssistant ? dataInfo.secondAssistant : '',
                    thirdAssistant: dataInfo.thirdAssistant ? dataInfo.thirdAssistant : '',
                    otherAssistant: dataInfo.otherAssistant ? dataInfo.otherAssistant : '',
                    anaesthesiaID: dataInfo.anaesthesiaID ? dataInfo.anaesthesiaID : '',
                    anaesthesiaDoctorID: dataInfo.anaesthesiaDoctorID ? dataInfo.anaesthesiaDoctorID : '',
                    ecgDoctorID: dataInfo.ecgDoctorID ? dataInfo.ecgDoctorID : '',
                    applyDocNotes: dataInfo.applyDocNotes ? dataInfo.applyDocNotes : '',
                    motivation: dataInfo.Motive ? dataInfo.Motive : '',
                    surgicalPopulation: dataInfo.CrowdDr ? dataInfo.CrowdDr : '',
                    specialEquipment: dataInfo.specialEquipment ? dataInfo.specialEquipment : '',
                    positionID: dataInfo.positionID ? dataInfo.positionID : '',
                    bloodType: dataInfo.bloodType ? dataInfo.bloodType : '',
                    RHBlood: dataInfo.RHBlood ? dataInfo.RHBlood : '',
                    HbsAg: dataInfo.HbsAg ? dataInfo.HbsAg : '',
                    HcvAb: dataInfo.HcvAb ? dataInfo.HcvAb : '',
                    HivAb: dataInfo.HivAb ? dataInfo.HivAb : '',
                    syphilis: dataInfo.syphilis ? dataInfo.syphilis : '',
                    notes: dataInfo.notes ? dataInfo.notes : '',
                    crystalsModelID: dataInfo.crystalsModelID ? dataInfo.crystalsModelID : '',
                    crystalsStrengthID: dataInfo.crystalsStrengthID ? dataInfo.crystalsStrengthID : '',
                    crystalsNum: dataInfo.crystalsNum ? dataInfo.crystalsNum : '1',
                    rcrystalsModelID: dataInfo.rcrystalsModelID ? dataInfo.rcrystalsModelID : '',
                    rcrystalsStrengthID: dataInfo.rcrystalsStrengthID ? dataInfo.rcrystalsStrengthID : '',
                    rcrystalsNum: dataInfo.rcrystalsNum ? dataInfo.rcrystalsNum : '1',
                    rastigmatism: dataInfo.rastigmatism ? dataInfo.rastigmatism : '',
                    astigmatism: dataInfo.astigmatism ? dataInfo.astigmatism : ''
                })
            })
        }

        // 重置
        handleReset = () => {
            this.props.form && this.props.form.resetFields();
            this.setState({ operationConfigID: '' });
        }

        render() {
            const { page, total, top, left, operationConfigID } = this.state;
            const { getFieldDecorator } = this.props.form;
            let operationApplyInfo = this.state.operationApplyInfo ? this.state.operationApplyInfo : {}
            const formItemLayout = {    // label 和input宽度
                labelCol: { span: 8 },
                wrapperCol: { span: 16 },
            };
            const formItemProLayout = {    // label 和input宽度
                labelCol: { span: 4 },
                wrapperCol: { span: 20 },
            };
            const formItemProLayoutAdd = {    // label 和input宽度
                labelCol: { span: 2 },
                wrapperCol: { span: 19 },
            };
            const formItemEquip = {    // label 和input宽度
                labelCol: { span: 2 },
                wrapperCol: { span: 22 },
            };
            const formItemAdd = {    // label 和input宽度
                labelCol: { span: 8 },
                wrapperCol: { span: 16 },
            };
            const formItemLayoutCheck = {
                labelCol: { span: 7 },
                wrapperCol: { span: 25 },
            }
            let formData = this.props.form.getFieldsValue();
            const selectedOperationUser = [formData.operatingSurgeon, formData.firstAssistant, formData.secondAssistant, formData.thirdAssistant, formData.otherAssistant]
            // 手术弹框参数
            let param = {
                width: '800px',
                height: 330,
                top: top,
                left: left,
                bordered: true,
                columns: this.operationColumns,
                data: this.state.operationData,
                isOnRow: true,
                TableClassName: 'tab-placeholder',
                rowClassName: true,
                showPagination: true,
                total,
                page,
                x: 600,
            }

            return (
                <div className="OperationContent" style={{ height: '100%', overflow: 'hidden' }}>
                    <div className='outpatient-station-body' style={{ width: '100%', height: '100%' }}>
                        <div style={{ height: 'calc(100% - 56px)' }}>
                            <Row style={{ height: '100%' }}>
                                <Form style={{ height: '100%', overflowX: 'hidden' }}>
                                    <div className="form-item">
                                        <Row style={{ width: '100%', padding: '18px 18px 0 0' }}>
                                            <Col span={4}>
                                                <FormItem {...formItemLayout} label="模板名称">
                                                    {getFieldDecorator('descripts', {
                                                        initialValue: operationApplyInfo.descripts ? operationApplyInfo.descripts : '',
                                                        rules: [{ required: true, message: '模板名称不能为空', }]
                                                    })(
                                                        <Input allowClear placeholder="请输入" />
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyoperationLoc')}>
                                                    {getFieldDecorator('operationLocID', {
                                                        initialValue: operationApplyInfo.operationLocID ? operationApplyInfo.operationLocID : this.state.defOperationLocID,
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select onChange={this.changeOperationLoc} showSearch allowClear optionFilterProp="role" >
                                                            {this.state.operationLocData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode} workDate={data.workDate} offWorkTime={data.offWorkTime} >{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyoperationRoom')}>
                                                    {getFieldDecorator('operationRoomID', {
                                                        initialValue: operationApplyInfo.operationRoomID ? operationApplyInfo.operationRoomID : '',
                                                        // rules: [{ required: true, message: '请选择...', }]
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.operationRoomData.map(data => (<Select.Option key={data.id + ""} value={data.id + ""} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyduration')}>
                                                    {getFieldDecorator('duration', {
                                                        initialValue: operationApplyInfo.duration ? operationApplyInfo.duration : '',
                                                    })(
                                                        <Input />
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row style={{ width: '100%', padding: '0px 18px 0 0' }}>
                                            <Col span={4} >
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyoperatingSurgeon')}>
                                                    {getFieldDecorator('operatingSurgeon', {
                                                        initialValue: operationApplyInfo.operatingSurgeon ? operationApplyInfo.operatingSurgeon : '',
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.operationDocData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode} disabled={selectedOperationUser.includes(data.id)}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} >
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyfirstAssistant')}>
                                                    {getFieldDecorator('firstAssistant', {
                                                        initialValue: operationApplyInfo.firstAssistant ? operationApplyInfo.firstAssistant : '',
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.operationDocData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode} disabled={selectedOperationUser.includes(data.id)} >{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} >
                                                <FormItem {...formItemLayout} label={this.display('OperationApplysecondAssistant')}>
                                                    {getFieldDecorator('secondAssistant', {
                                                        initialValue: operationApplyInfo.secondAssistant ? operationApplyInfo.secondAssistant : '',

                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.operationDocData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode} disabled={selectedOperationUser.includes(data.id)} >{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} >
                                                <FormItem {...formItemLayout} label={this.display('OperationApplythirdAssistant')}>
                                                    {getFieldDecorator('thirdAssistant', {
                                                        initialValue: operationApplyInfo.thirdAssistant ? operationApplyInfo.thirdAssistant : '',
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.operationDocData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode} disabled={selectedOperationUser.includes(data.id)} >{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyotherAssistant')}>
                                                    {getFieldDecorator('otherAssistant', {
                                                        initialValue: operationApplyInfo.otherAssistant ? operationApplyInfo.otherAssistant : '',
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.operationDocData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode} disabled={selectedOperationUser.includes(data.id)} >{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row style={{ width: '100%', padding: '0px 18px 0 0' }}>
                                            <Col span={4}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyapplyNumber')}>
                                                    {getFieldDecorator('applyNumber', {
                                                        initialValue: operationApplyInfo.applyNumber ? operationApplyInfo.applyNumber : '',
                                                    })(
                                                        <Input />
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyanesthesia')}>
                                                    {getFieldDecorator('anaesthesiaID', {
                                                        initialValue: operationApplyInfo.anaesthesiaID ? operationApplyInfo.anaesthesiaID : '',
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch optionFilterProp="role" allowClear placeholder="麻醉方式">
                                                            {this.state.anesthesiaData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyanaesthesiaDoctor')}>
                                                    {getFieldDecorator('anaesthesiaDoctorID', {
                                                        initialValue: operationApplyInfo.anaesthesiaDoctorID ? operationApplyInfo.anaesthesiaDoctorID : '',
                                                        rules: [{ required: false, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch optionFilterProp="role" allowClear placeholder="麻醉医师">
                                                            {this.state.anaesthesiaDocaArr.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={10}>
                                                <FormItem {...formItemProLayout} label={this.display('OperationApplyapplyDocNotes')}>
                                                    {getFieldDecorator('applyDocNotes', {
                                                        initialValue: operationApplyInfo.applyDocNotes ? operationApplyInfo.applyDocNotes : '',
                                                    })(
                                                        <Input allowClear />
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row style={{ width: '100%', padding: '0px 18px 0 0' }}>
                                            <Col span={4}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplymotivation')}>
                                                    {getFieldDecorator('motivation', {
                                                        initialValue: operationApplyInfo.motivation ? operationApplyInfo.motivation : '',
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select
                                                            allowClear
                                                            style={{ width: "100%", textAlign: "left" }}
                                                            // onChange={this.handleFieldChange.bind(this, index, 'motivation')}
                                                            showSearch
                                                            optionFilterProp='role'
                                                            placeholder="手术动机"
                                                        >
                                                            {this.state.motivationData.map(data => (
                                                                <Select.Option
                                                                    role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}
                                                                    key={data.id}
                                                                >
                                                                    {data.descripts}
                                                                </Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplysurgicalPopulation')}>
                                                    {getFieldDecorator('surgicalPopulation', {
                                                        initialValue: operationApplyInfo.surgicalPopulation ? operationApplyInfo.surgicalPopulation : '',
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select
                                                            allowClear
                                                            style={{ width: "100%", textAlign: "left" }}
                                                            // onChange={this.handleFieldChange.bind(this, index, 'surgicalPopulation')}
                                                            showSearch
                                                            optionFilterProp='role'
                                                            placeholder="手术人群"
                                                        >
                                                            {this.state.surgicalPopulationData.map(data => (
                                                                <Select.Option
                                                                    role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}
                                                                    key={data.id}
                                                                >
                                                                    {data.descripts}
                                                                </Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row>
                                            <Col span={8}>
                                                <FormItem label={this.display('OperationApplytype')} {...formItemProLayout} style={{ marginBottom: '0' }}>
                                                    {getFieldDecorator('type', {
                                                        initialValue: operationApplyInfo.type ? operationApplyInfo.type : 'E',
                                                    })(
                                                        <Radio.Group onChange={this.changeType}>
                                                            <Radio value={'E'}>择期手术</Radio>
                                                            <Radio value={'D'}>日间手术</Radio>
                                                            <Radio value={'EM'}>急诊手术</Radio>
                                                        </Radio.Group>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={2} style={{ float: 'left', paddingLeft: "31px", boxSizing: "border-box" }}>
                                                <FormItem {...formItemLayoutCheck}>
                                                    {getFieldDecorator('ecg', {

                                                    })(
                                                        <Checkbox checked={operationApplyInfo.ecg === 'Y' ? true : false} onChange={this.checkboxOnchange.bind(this, 'ecg')}>{this.display('OperationApplyecg')}</Checkbox>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyecgDoctor')}>
                                                    {getFieldDecorator('ecgDoctorID', {
                                                        initialValue: operationApplyInfo.ecgDoctorID ? operationApplyInfo.ecgDoctorID : '',
                                                        rules: [{ required: false, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch optionFilterProp="role" allowClear placeholder="心电监护医师">
                                                            {this.state.docECGDocArr.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                    </div>

                                    <div className="form-item">
                                        <Row style={{ margin: '0px 18px 0 0', paddingTop: '11px', width: '100%' }}>
                                            <Col span={24} style={{ padding: '0 24px', display: 'flex', justifyContent: 'space-between' }}>
                                                <div><span style={{ color: 'red' }}>*</span>{this.display('OperationApplysurgery')}：</div>
                                                <span style={{ color: 'rgba(247,128,93,1)' }} type='primary' size='small' onClick={this.addRow}>{this.display('OperationApplyadd')}</span>
                                            </Col>
                                            <Col span={24}>
                                                <Table
                                                    style={{ minHeight: '162px', padding: '0 24px', marginTop: '10px' }}
                                                    columns={this.columns}
                                                    scroll={{ y: 150 }}
                                                    dataSource={this.state.tableData}
                                                    pagination={false}
                                                    bordered
                                                    rowKey={record => record.key}
                                                />
                                            </Col>
                                        </Row>
                                    </div>

                                    <div className="form-item">
                                        <Row style={{ width: '100%', padding: '0px 18px 0 0' }}>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={'右眼' + this.display('OperationApplycrystalsModel')} >
                                                    {getFieldDecorator('rcrystalsModelID', {
                                                        initialValue: operationApplyInfo.rcrystalsModelID ? operationApplyInfo.rcrystalsModelID : '',
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" onChange={(value, option) => { this.handleRightEyeInventory("model", value, option) }}>
                                                            {this.state.crystalsModelArr.map(data => (
                                                                <Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode + '^' + data.spec}>{data.spec + ' [' + data.descripts + ']'}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplycrystalsStrength')}>
                                                    {getFieldDecorator('rcrystalsStrengthID', {
                                                        initialValue: operationApplyInfo.rcrystalsStrengthID ? operationApplyInfo.rcrystalsStrengthID : '',
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" onChange={(value, option) => { this.handleRightEyeInventory("degree", value, option) }}>
                                                            {this.state.crystalsStrengthArr.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={1} >
                                                <FormItem {...formItemLayout} >
                                                    {
                                                        this.state.rightEyeCrystalInventory == -1 ? "" : (this.state.rightEyeCrystalInventory == 0 ? <span style={{ color: 'red', marginLeft: '10px' }}>无库存</span> : <span style={{ color: 'blue', marginLeft: '10px' }}>有库存</span>)
                                                    }
                                                </FormItem>
                                            </Col>
                                            <Col span={4}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplycrystalsNum')}>
                                                    {getFieldDecorator('rcrystalsNum', {
                                                        initialValue: operationApplyInfo.rcrystalsNum ? operationApplyInfo.rcrystalsNum : '1',
                                                        required: false
                                                    })(
                                                        <Input allowClear />
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplycrystalsAstigmatism')}>
                                                    {getFieldDecorator('rastigmatism', {
                                                        initialValue: operationApplyInfo.rastigmatism ? operationApplyInfo.rastigmatism : '',
                                                        required: false
                                                    })(
                                                        <Input allowClear />
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row style={{ width: '100%', padding: '0px 18px 0 0' }}>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={'左眼' + this.display('OperationApplycrystalsModel')} >
                                                    {getFieldDecorator('crystalsModelID', {
                                                        initialValue: operationApplyInfo.crystalsModelID ? operationApplyInfo.crystalsModelID : '',
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" onChange={(value, option) => { this.handleLeftEyeInventory("model", value, option) }}>
                                                            {this.state.crystalsModelArr.map(data => (
                                                                <Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode + '^' + data.spec}>{data.spec + ' [' + data.descripts + ']'}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplycrystalsStrength')} >
                                                    {getFieldDecorator('crystalsStrengthID', {
                                                        initialValue: operationApplyInfo.crystalsStrengthID ? operationApplyInfo.crystalsStrengthID : '',
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" onChange={(value, option) => { this.handleLeftEyeInventory("degree", value, option) }}>
                                                            {this.state.crystalsStrengthArr.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={1} >
                                                <FormItem {...formItemLayout} >
                                                    {
                                                        this.state.leftEyeCrystalInventory == -1 ? "" : (this.state.leftEyeCrystalInventory == 0 ? <span style={{ color: 'red', marginLeft: '10px' }}>无库存</span> : <span style={{ color: 'blue', marginLeft: '10px' }}>有库存</span>)
                                                    }
                                                </FormItem>
                                            </Col>
                                            <Col span={4} >
                                                <FormItem {...formItemLayout} label={this.display('OperationApplycrystalsNum')}>
                                                    {getFieldDecorator('crystalsNum', {
                                                        initialValue: operationApplyInfo.crystalsNum ? operationApplyInfo.crystalsNum : '1',
                                                        required: false
                                                    })(
                                                        <Input allowClear />
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemLayout} label={this.display('OperationApplycrystalsAstigmatism')}>
                                                    {getFieldDecorator('astigmatism', {
                                                        initialValue: operationApplyInfo.astigmatism ? operationApplyInfo.astigmatism : '',
                                                        required: false
                                                    })(
                                                        <Input allowClear />
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row style={{ padding: '0px 18px 0px 0px', width: '100%' }}>
                                            <Col span={19}>
                                                <FormItem {...formItemEquip} label={this.display('OperationApplyspecialEquipment')}>
                                                    {getFieldDecorator('specialEquipment', {
                                                        initialValue: operationApplyInfo.specialEquipment ? operationApplyInfo.specialEquipment : '',
                                                    })(
                                                        <Input allowClear />
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5}>
                                                <FormItem {...formItemAdd} label={this.display('OperationApplyposition')}>
                                                    {getFieldDecorator('positionID', {
                                                        initialValue: operationApplyInfo.positionID ? operationApplyInfo.positionID : '',
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.operationPostData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row style={{ width: '100%', padding: '0px 18px 0 0' }}>
                                            <Col span={4}>
                                                {/* 血型 */}
                                                <FormItem {...formItemLayout} label={this.display('OperationApplybloodType')}>
                                                    {getFieldDecorator('bloodType', {
                                                        initialValue: operationApplyInfo.bloodType ? operationApplyInfo.bloodType : this.state.defBloodTpyeID,
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.bloodTpyeData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} >
                                                {/* RH血型 */}
                                                <FormItem {...formItemLayout} label={this.display('OperationApplyRHBlood')}>
                                                    {getFieldDecorator('RHBlood', {
                                                        initialValue: operationApplyInfo.RHBlood ? operationApplyInfo.RHBlood : this.state.defRHBloodTypeID,
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.RHBloodTypeData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} >
                                                <FormItem {...formItemLayout} label='HbsAg'>
                                                    {getFieldDecorator('HbsAg', {
                                                        initialValue: operationApplyInfo.HbsAg ? operationApplyInfo.HbsAg : this.state.defHbsAgTraitsID,
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.HbsAgTraitsData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} >
                                                <FormItem {...formItemLayout} label='Hcv_Ab'>
                                                    {getFieldDecorator('HcvAb', {
                                                        initialValue: operationApplyInfo.HcvAb ? operationApplyInfo.HcvAb : this.state.defHcvAbTraitsID,
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.HcvAbTraitsData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} >
                                                <FormItem {...formItemLayout} label='Hiv_Ab'>
                                                    {getFieldDecorator('HivAb', {
                                                        initialValue: operationApplyInfo.HivAb ? operationApplyInfo.HivAb : this.state.defHivAbTraitsID,
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.HivAbTraitsData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row>
                                            <Col span={4} >
                                                <FormItem {...formItemLayout} label={this.display('OperationApplysyphilis')}>
                                                    {getFieldDecorator('syphilis', {
                                                        initialValue: operationApplyInfo.syphilis ? operationApplyInfo.syphilis : this.state.defSyphilisTraitsID,
                                                        rules: [{ required: true, message: this.display('OperationApplyselect'), }]
                                                    })(
                                                        <Select showSearch allowClear optionFilterProp="role" >
                                                            {this.state.syphilisTraitsData.map(data => (<Select.Option key={data.id} value={data.id} role={data.code + '^' + data.descripts + '^' + data.descriptsSPCode}>{data.descripts}</Select.Option>))}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={20}>
                                                <FormItem {...formItemProLayoutAdd} label={this.display('OperationApplynotes')}>
                                                    {getFieldDecorator('notes', {
                                                        initialValue: operationApplyInfo.notes ? operationApplyInfo.notes : '',
                                                    })(
                                                        <Input allowClear />
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                        <Row gutter={12}>
                                            <Col style={{ float: 'left', paddingLeft: "110px", boxSizing: "border-box" }}>
                                                <FormItem {...formItemLayoutCheck}>
                                                    {getFieldDecorator('quarantine', {
                                                    })(
                                                        <Checkbox checked={operationApplyInfo.quarantine === 'Y' ? true : false} onChange={this.checkboxOnchange.bind(this, 'quarantine')} >{this.display('OperationApplyquarantine')}</Checkbox>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col style={{ float: 'left', paddingLeft: "31px", boxSizing: "border-box" }}>
                                                <FormItem  {...formItemLayoutCheck}>
                                                    {getFieldDecorator('CPB', {
                                                    })(
                                                        <Checkbox checked={operationApplyInfo.CPB === 'Y' ? true : false} onChange={this.checkboxOnchange.bind(this, 'CPB')}>{this.display('OperationApplyCPB')}</Checkbox>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col style={{ float: 'left', paddingLeft: "31px", boxSizing: "border-box" }}>
                                                <FormItem  {...formItemLayoutCheck}>
                                                    {getFieldDecorator('selfBloodRtn', {
                                                    })(
                                                        <Checkbox checked={operationApplyInfo.selfBloodRtn === 'Y' ? true : false} onChange={this.checkboxOnchange.bind(this, 'selfBloodRtn')}>{this.display('OperationApplyselfBloodRtn')}</Checkbox>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col style={{ float: 'left', paddingLeft: "31px", boxSizing: "border-box" }}>
                                                <FormItem {...formItemLayoutCheck}>
                                                    {getFieldDecorator('bloodPrepare', {
                                                    })(
                                                        <Checkbox checked={operationApplyInfo.bloodPrepare === 'Y' ? true : false} onChange={this.checkboxOnchange.bind(this, 'bloodPrepare')}>{this.display('OperationApplybloodPrepare')}</Checkbox>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col style={{ float: 'left', paddingLeft: "31px", boxSizing: "border-box" }}>
                                                <FormItem {...formItemLayoutCheck}>
                                                    {getFieldDecorator('frozen', {
                                                    })(
                                                        <Checkbox checked={operationApplyInfo.frozen === 'Y' ? true : false} onChange={this.checkboxOnchange.bind(this, 'frozen')}>{this.display('OperationApplyfrozen')}</Checkbox>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col offset={4} style={{ float: 'left', paddingLeft: "31px", boxSizing: "border-box" }}>
                                                <FormItem {...formItemLayoutCheck}>
                                                    {getFieldDecorator('status', {
                                                    })(
                                                        <Checkbox checked={operationApplyInfo.status === 'N' ? false : true} onChange={this.checkboxOnchange.bind(this, 'status')}>启用配置</Checkbox>
                                                    )}
                                                </FormItem>
                                            </Col>
                                        </Row>
                                    </div>
                                </Form>
                            </Row>
                        </div>
                        <div className="flex-center" style={{ padding: '12px 0', borderTop: '1px solid #e8e8e8' }}>
                            <Popconfirm title="确定清空填入的数据吗?" onConfirm={this.handleReset} >
                                <Button>清空</Button>
                            </Popconfirm>
                            <Button
                                type="primary"
                                onClick={this.save}
                                style={{ margin: '0 12px' }}
                            >
                                {operationConfigID ? '确认修改' : '保存'}
                            </Button>
                            <Button ghost type="primary" onClick={this.handleHistoricalConfig}>查看历史配置</Button>
                        </div>
                    </div>
                    {/**列input框新表格弹框 */}
                    <div
                        tabIndex={1}
                        onKeyDown={this.handleOnKeydown.bind(this)}
                        style={{ outline: 'none' }}
                    >
                        <ShowCommonTableModal onClickRowPublic={this.onClickRowPublic}
                            handleFocus={this.handleFocus.bind(this)}
                            setRowClassNamePublic={this.setRowClassNamePublic}
                            param={param}
                            onRef={this.onRef}
                            id="gundong"
                            search={this.state.search}
                            compilePage={this.changePageSize.bind(this)}>
                        </ShowCommonTableModal>
                    </div>
                    <PublicModalQueryTable
                        staticParams={{
                            type: 'config'
                        }}
                        title="历史配置"
                        queryCode="04160036"
                        componentName="OperationApplyHistoryConfig"
                        onRef={ref => this.historyConfigRef = ref}
                        handleOk={this.handleHistoryConfigOk}
                    />
                </div>
            )
        }
    }
);

export default OperationApplyConfig;