/*
* 排班
* */

import React, { Component } from 'react';
import { Input, Form, Select, Modal, Button, Row, message, Col, Icon } from 'antd';
import { dayFormat } from 'tools/index';
import { $http } from 'containers/config/https';
import { Util } from 'tools/index';
import AddMechanism from 'components/addMechanism';
import '../style/index.less';

const Option = Select.Option;
const FormItem = Form.Item;
const InputGroup = Input.Group;

class ShowDoctorModal extends Component {

    constructor(props) {
        var userData = JSON.parse(sessionStorage.getItem('userData'));
        super(props);
        this.state = {
            userData: userData,
            resModel: [],
            newData: {},
            dataSource: [],
            detail: [],
        }
    }

    componentWillReceiveProps(nextProp) {
        if (nextProp.isShow === true && (Util.isEmpty(this.props.isShow) || this.props.isShow === false)) {
            this.setState({
                resourceType: nextProp.resourceType,
                resourceTypeID: nextProp.resourceTypeID,
            }, () => {
                this.loadDateStr(nextProp.dateStr)
                this.getDoctor();
                this.getDoctorRoom(nextProp.noData ? nextProp.noData.locID : (nextProp.locId ? nextProp.locId : ''))
            })
            if (nextProp.addStatus === false) {
                this.setState({
                    resourceType: nextProp.resourceType,
                    resourceTypeID: nextProp.resourceTypeID,
                }, () => {
                    this.loadConsulation(nextProp.noData.depDoctorID, nextProp.noData.timeRangeID);
                })
            } else {
                this.setState({
                    resourceType: nextProp.resourceType,
                    resourceTypeID: nextProp.resourceTypeID,
                }, () => {
                    this.loadConsulation()
                })
            }
        } else if (this.props.isShow === false) {
            this.cleanInput();
        }
    }

    componentDidMount() {
        this.getDoctorRoom();
        this.loadscheduType();
    }

    loadDateStr(timeStr) {
        var params = {
            params: [
                {
                    dateStr: timeStr,
                    resourceTypeID: this.state.resourceTypeID
                }
            ],
        }
        $http.post('urlDeault', this, {
            code: "03020045",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        timeData: res.data,
                    })
                }
            }
        });
    }

    //获取坐诊类型
    loadscheduType() {
        var params = {
            params: [
                {
                    hospID: this.state.userData.hospID,
                    resourceTypeID: this.state.resourceTypeID
                }
            ],
            pagination: [{
                pageSize: 1000,
                currentPage: 1
            }]
        }
        $http.post('urlDeault', this, {
            code: "03020004",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        sumData: res.result.Data,
                    })
                }
            }
        });
    }

    loadConsulation(id, timeRangeId) {
        var params = {
            params: [{
                depDoctorID: id,//科室医生ID
                hospID: this.state.userData.hospID,//医院ID
                timeRangeID: timeRangeId || '',
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        $http.post('urlDeault', this, {
            code: "03020032",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        resModel: res.resModel,
                        roomDr: res.roomID
                    })
                }
            }
        });
    }

    //获取诊室
    getDoctorRoom(id) {
        var params = {
            params: [{
                hospID: this.state.userData.hospID,
                locID: !Util.isEmpty(this.state.deptDoctorId) ? this.state.deptDoctorId : (!Util.isEmpty(id) ? id : this.state.userData.locID),
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        // var params = []
        $http.post('urlDeault', this, {
            code: "01040023",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        doctorRoom: res.room
                    })
                }
            }
        });
    }

    //获取科室ID
    onChangeDepartId(id) {
        this.props.form.resetFields();
        this.setState({
            deptDoctorId: id,
            doctorId: undefined,
            roomDr: undefined,
        }, () => {

            this.getDoctor(id)
            this.loadConsulation();
            this.getDoctorRoom()
        })
    }

    getDoctor(id) {
        var params = {
            params: [{
                hospID: this.state.hospId ? this.state.hospId : this.state.userData.hospID,
                locID: id ? id : (this.props.addDepart ? (this.props.locId ? this.props.locId : this.state.userData.locID) : (this.props.noData ? this.props.noData.locId : (this.props.locIds ? this.props.locIds : this.state.userData.locID))),
                groupID: '',
                depDoctorID: this.state.depDoctorId,
                dateStr: this.props.addDepart ? '' : this.props.dateStr,
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        $http.post('urlDeault', this, {
            code: this.props.addDepart ? '03020047' : "03020048",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        doctorData: res.depDoctor
                    })
                }
            }
        });
    }
    //获取医生ID
    changeDoctor(e) {
        this.setState({
            doctorId: e
        })
        this.loadConsulation(e);
    }

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

    //清空输入框
    cleanInput() {
        this.props.form.resetFields();
        this.setState({
            resModel: [],
            doctorId: undefined
        })
    }

    //获取数组中，排班类型的参数
    handleSelectScheduling(data, index, name, e) {
        var { resModel } = this.state;
        this.state.saveStatus = true;
        this.state.curStatus = true;
        for (var i = 0; i < resModel.length; i++) {
            if (i == index) {
                resModel[i].regTitleID = e
            }
        }
        this.setState({
            sessionTypeId: e
        })
    }

    cleanTimeData(data, index) {
        this.changeTimeModel(data, index, '')
        var { resModel } = this.state;
        for (var i = 0; i < resModel.length; i++) {
            if (i == index) {
                resModel[i].regTitleID = ''
                resModel[i].registNum = 0
                resModel[i].appointNum = 0
            }
        }

        this.setState({
            sessionTypeId: undefined,
        })
    }

    //切换时间间隔，获取对应的具体时段
    changeTimeModel(data, index, e) {
        var params = {
            params: [{
                depDoctorID: this.props.noData ? this.props.noData.depDoctorID : this.state.doctorId,//医生ID
                timeRangeID: data.timeRangeID,//时段ID
                intervalID: e,//时间间隔id
                resModelID: data.modelID,//
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        // var params = []
        $http.post('urlDeault', this, {
            code: "03020033",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    if (data.timeRangeID == res.resModelDetail.timeRangeID) {
                        this.state.newData[index] = res.resModelDetail.data;
                        this.state.resModel[index]['statusData'] = true;
                        this.setState({
                            resModelDetail: res.resModelDetail.data,
                            newTimeRangId: res.resModelDetail.timeRangeID,
                            curStatus: true
                        })
                    }
                }
            }
        });
        //将时间间隔ID，push进dataSource中
        var { resModel } = this.state;
        for (var i = 0; i < resModel.length; i++) {
            if (i == index) {
                resModel[i].timeIntervalID = e
            }
        }
        // this.setState({})
    }


    //获取总挂号限额框参数
    changeRegistNum(data, index, code, e) {
        var regNum = 0;
        this.state.saveStatus = true;
        this.state.curStatus = true;
        var datas = e.target.value;
        if (!(/(^[1-9]\d*$)/.test(datas)) && datas.length > 0) {
            message.error('请输入整数')
            return
        }
        var { resModelDetail, resModel, newData } = this.state;
        for (var j = 0; j < resModel.length; j++) {
            if (j == index) {
                for (var i = 0; i < newData[index].length; i++) {
                    resModel[j].registNum = 0
                    if (i == code) {
                        // newData[j][i].registNum = 0
                        newData[j][i].registNum = e.target.value
                        this.state.detail.push({})
                        newData[j][i].registNum = e.target.value,
                            newData[j][i].userID = this.state.userData.userID,
                            newData[j][i].timeDetailID = newData[j][i].indexId
                    }
                    regNum += parseInt(newData[j][i].registNum ? newData[j][i].registNum : 0)
                }
                resModel[j].registNum = regNum;
                // this.state.dataSource.push({})
                resModel[j].detail = newData[j]
                // this.state.dataSource[j].details = resModel[j].defaultDataList

                this.setState({})
            }
        }
    }

    //获取总可预约限额参数
    changeAppointNum(data, index, code, e) {
        var appNum = 0;
        this.state.saveStatus = true;
        this.state.curStatus = true;
        var { resModelDetail, resModel, newData } = this.state;
        var datas = e.target.value;
        if (!(/(^[1-9]\d*$)/.test(datas)) && datas.length > 0) {
            message.error('请输入整数')
            return
        }
        for (var j = 0; j < resModel.length; j++) {
            var appNum = 0;
            if (j == index) {
                for (var i = 0; i < newData[index].length; i++) {
                    resModel[j].appointNum = 0
                    if (i == code) {
                        // newData[j][i].appointNum = 0
                        this.state.detail.push({})
                        newData[j][i].appointNum = e.target.value,
                            newData[j][i].userID = this.state.userData.userID,
                            newData[j][i].timeDetailID = newData[j][i].indexId
                    }
                    appNum += parseInt(newData[j][i].appointNum ? newData[j][i].appointNum : 0)
                }
                resModel[j].appointNum = appNum;
                // this.state.dataSource.push({details:[]})
                resModel[j].detail = newData[j]
                this.setState({})
            }
        }
    }

    //当为默认参数时
    changeDefRegistNum(data, index, code, e) {
        this.state.saveStatus = true;
        var defRegNum = 0;
        var { resModelDetail, resModel } = this.state;
        var datas = e.target.value;
        if (!(/(^[1-9]\d*$)/.test(datas)) && datas.length > 0) {
            message.error('请输入整数')
            return
        }
        for (var j = 0; j < resModel.length; j++) {
            if (j == index) {
                for (var i = 0; i < data.length; i++) {
                    resModel[j].registNum = 0
                    if (i == code) {
                        this.state.detail.push({})
                        data[i].registNum = 0,
                            data[i].registNum = e.target.value,
                            data[i].userID = this.state.userData.userID,
                            data[i].timeDetailID = data[i].indexId
                    }
                    defRegNum += parseInt(data[i].registNum ? data[i].registNum : 0)
                }
                resModel[j].detail = data
                resModel[j].registNum = defRegNum;

                this.setState({})
            }
        }
    }

    changeDefAppointNum(data, index, code, e) {
        this.state.saveStatus = true;
        var difAppNum = 0;
        var { resModelDetail, resModel } = this.state;
        var datas = e.target.value;
        if (!(/(^[1-9]\d*$)/.test(datas)) && datas.length > 0) {
            message.error('请输入整数')
            return
        }
        for (var j = 0; j < resModel.length; j++) {
            if (j == index) {
                for (var i = 0; i < data.length; i++) {
                    resModel[j].appointNum = 0
                    if (i == code) {
                        this.state.detail.push({})
                        data[i].appointNum = 0,
                            data[i].appointNum = e.target.value,
                            data[i].userID = this.state.userData.userID,
                            data[i].timeDetailID = data[i].indexId
                    }
                    difAppNum += parseInt(data[i].appointNum ? data[i].appointNum : 0)
                }
                resModel[j].appointNum = difAppNum;
                resModel[j].detail = data

                this.setState({})
            }
        }
    }
    //提交
    onSubmit() {
        var rthis = this;
        let { validateFields } = rthis.props.form;
        validateFields({ force: true }, (err, params) => {
            if(Util.isEmpty(params.roomDr)){
                message.error('坐诊诊室不能为空，请选择诊室！')
                return
            }
            let { onSubmit } = rthis.props;
            var { resModel } = rthis.state;
            for (var i = 0; i < resModel.length; i++) {
                var detail = resModel[i].detail;
                if (detail) {
                    for (var j = 0; j < detail.length; j++) {
                        if (parseInt(detail[j].appointNum) > parseInt(detail[j].registNum)) {
                            message.error('可预约数不能大于总号源数，请重新输入！')
                            return
                        }
                    }
                }
                resModel[i].depDoctorID = rthis.props.noData ? rthis.props.noData.depDoctorID : rthis.state.doctorId,
                    resModel[i].addNum = "",//空
                    // resModel[i].roomID = rthis.props.noData ? rthis.props.noData.roomID : rthis.state.roomDr,//诊室ID
                    resModel[i].roomID = rthis.state.roomDr ? rthis.state.roomDr : (rthis.props.noData ? rthis.props.noData.roomID : ''),//诊室ID
                    resModel[i]['expertiseID'] = "",//专长
                    resModel[i]['togetherSource'] = "",//空
                    resModel[i]['userID'] = rthis.state.userData.userID
                resModel[i]['modelID'] = resModel[i].modelId,
                    resModel[i]['resourceTypeID'] = this.state.resourceTypeID,
                    resModel[i].date = rthis.props.noData ? rthis.props.noData.date : rthis.state.date,
                    resModel[i].locID = rthis.state.deptDoctorId ? rthis.state.deptDoctorId : (rthis.props.addDepart ? (rthis.props.locId ? rthis.props.locId : rthis.state.userData.locID) : (rthis.props.noData ? rthis.props.noData.locID : (rthis.props.locIds ? rthis.props.locIds : rthis.state.userData.locID)))
            }
            var params = {
                params: this.state.resModel
            }
            var dpartData = {
                params: rthis.state.resModel
            }
            var newCode = rthis.state.resModel
            var code = []
            for (var i = 0; i < newCode.length; i++) {
                if (!Util.isEmpty(newCode[i].detail)) {
                    code.push(newCode[i].detail)
                }
            }
            if (Util.isEmpty(code)) {
                message.error('没有需要保存的数据！')
                return
            }

            if (rthis.props.departStatus) {
                $http.post('urlDeault', this, {
                    code: "03020044",
                    data: dpartData,
                    success: function (res) {
                        if (res.errorCode == '0') {
                            this.setState({ doctorId: undefined })
                            message.success('保存成功！')
                            onSubmit && onSubmit(params);
                        }
                    }
                });
            } else {
                $http.post('urlDeault', this, {
                    code: "03020031",
                    data: params,
                    success: function (res) {
                        if (res.errorCode == '0') {
                            this.setState({ doctorId: undefined })
                            message.success('保存成功！')
                            onSubmit && onSubmit(params);
                        }
                    }
                });
            }
        });
    }

    //焦点切换
    changeFocusRegistr(data, index, code, e) {
        // if(e.keyCode == '13') {
        //     var inputs = document.getElementsByClassName('input');
        //     console.dir(inputs)
        // }
        var inputs = document.getElementsByClassName('input');
        function init() {
            for (let i = 0; i < inputs.length; i++) {
                inputs[i].onkeydown = focus(i)
            }
        }
        var focus = function handle(i) {
            return function (event) {
                var next = (i + 1) < inputs.length ? i + 1 : 0;  // 判断是否为最后一个输入框，是则返回第一个，否则继续下一个
                var eve = event ? event : window.event;
                if (eve.keyCode === 13) {
                    if (inputs[next].tagName === 'INPUT') {
                        inputs[next].focus();    //获取焦点
                    } else {
                        console.log(22)
                    }
                }
            }
        }
        init()
    }

    render() {
        let { getFieldDecorator, getFieldValue } = this.props.form;
        let formItemLayout = {
            labelCol: { span: 4 },
            wrapperCol: { span: 19 }
        };
        let formItemDateLayout = {
            labelCol: { span: 8 },
            wrapperCol: { span: 5 }
        };

        let searchColConfig = {
            xs: { span: 24 },
            sm: { span: 12 },
            md: { span: 12 },
            lg: { span: 12 }
        }
        var { resModel } = this.state;
        let merchantOption = [];
        //坐诊医生
        let doctorOption = []
        this.state.doctorData && this.state.doctorData.map((item, index) => {
            doctorOption.push(<Option key={index} value={item.depDoctorID}>{item.descripts}</Option>)
        })
        //获取科室Department
        let departmentOption = [];
        this.props.departmentData && this.props.departmentData.map((item, index) => {
            departmentOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
        })

        let newDepartDataOption = []
        this.props.newDepartData && this.props.newDepartData.map((item, index) => {
            newDepartDataOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
        })
        var newStatus = false;
        if (this.props.newDepartData) {
            var newDepartData = this.props.newDepartData;
            for (var i = 0; i < newDepartData.length; i++) {
                if (this.props.locIds == newDepartData[i].id) {
                    newStatus = true;
                    break;
                }
            }
        }

        //坐诊诊室
        let doctorRoomOption = []
        this.state.doctorRoom && this.state.doctorRoom.map((item, index) => {
            doctorRoomOption.push(<Option key={index} value={item.id + ''}>{item.descripts}</Option>)
        })

        //坐诊类型sumData
        let sumDataOption = []
        this.state.sumData && this.state.sumData.map((item, index) => {
            sumDataOption.push(<Option key={index} value={item.id + ''}>{item.descripts}</Option>)
        })

        //获取所选时间段日期
        var timeOption = []
        this.state.timeData && this.state.timeData.map((item, index) => {
            timeOption.push(<Option key={index} disabled={item.disabled == 'Y' ? true : false} value={(item.dateDescripts).substring((item.dateDescripts).indexOf('^') + 1)}>
                {(item.dateDescripts).substring((item.dateDescripts).indexOf('^') + 1) + (item.dateDescripts).substring(0, (item.dateDescripts).indexOf('^'))}
            </Option>)
        })

        var modelDetailData = []//总开放号源
        //获取总的号源时间段，push到对应的位置
        resModel && resModel.map((item, index) => {
            modelDetailData.push(
                <FormItem label={
                    <span style={{ fontWeight: 'bold' }}>
                        <span key={index}>{item.timeRange}</span>
                        <span key={index + '-1'}>总计&nbsp;&nbsp;{item.registNum || '0'} </span>
                        <span key={index + '-3'}>预约限号&nbsp;&nbsp;{item.appointNum || '0'} </span>
                        <Icon type='close' style={{ color: '#1890ff', cursor: 'pointer' }}
                            onClick={this.cleanTimeData.bind(this, item, index)} />
                    </span>}>
                    {getFieldDecorator('5', {
                        initialValue: this.state.inputData,
                    })(
                        <div>
                            <div style={{ display: 'flex' }}>
                                <div>
                                    <div>排班类型：</div>
                                    <Select placeholder="请选择排班类型" style={{ width: '120px' }}
                                        value={this.state.sessionTypeId ? item.regTitleID : (item.regTitleID ? item.regTitleID : undefined)}
                                        onChange={this.handleSelectScheduling.bind(this, item, index, 'sessionTypeDr')}
                                        getPopupContainer={triggerNode => triggerNode.parentNode}>
                                        {sumDataOption}
                                    </Select>
                                </div>
                                <div>
                                    <div>时间间隔：</div>
                                    <Select placeholder="请选择时间间隔" style={{ width: '120px' }}
                                        value={item.timeIntervalID ? item.timeIntervalID : undefined}
                                        getPopupContainer={triggerNode => triggerNode.parentNode}
                                        onChange={this.changeTimeModel.bind(this, item, index)}
                                    >
                                        {item.intervalList && item.intervalList.map((data, index) => {
                                            return (<Option value={data.id} key={data.id + ''}>{data.timeLength || '全时段'}</Option>)
                                        })}
                                    </Select>
                                </div>

                                {item.statusData ?
                                    <div className='home-lunbo'>{this.state.newData[index] && this.state.newData[index].map((newData, code) => {
                                        return (
                                            <span className='schedulingNo'>
                                                <div>{newData.timeRangDetail}</div>
                                                <div>
                                                    <InputGroup compact style={{ width: '140px' }}>
                                                        <Input placeholder='号源数' style={{ width: '65px' }} className='input'
                                                            value={newData.registNum ? newData.registNum : ''}
                                                            onKeyDown={this.changeFocusRegistr.bind(this, newData, index, code)}
                                                            onChange={this.changeRegistNum.bind(this, newData, index, code)}
                                                        />
                                                        <Input placeholder='可预约数' style={{ width: '65px' }} className='input'
                                                            onChange={this.changeAppointNum.bind(this, newData, index, code)}
                                                            value={newData.appointNum ? newData.appointNum : ''} />
                                                    </InputGroup>
                                                </div>
                                            </span>
                                        )
                                    })}</div> :
                                    <div className='home-lunbo'>
                                        {item.detail && item.detail.map((data, code) => {
                                            return (
                                                <span className='schedulingNo'>
                                                    <div>{data.timeRangDetail}</div>
                                                    <div>
                                                        <InputGroup compact style={{ width: '140px' }}>
                                                            <Input placeholder='号源数' style={{ width: '65px' }} className='input'
                                                                onKeyDown={this.changeFocusRegistr.bind(this, item.detail, index, code)}
                                                                onChange={this.changeDefRegistNum.bind(this, item.detail, index, code)}
                                                                value={data.registNum} />
                                                            <Input placeholder='可预约数' style={{ width: '65px' }} className='input'
                                                                onChange={this.changeDefAppointNum.bind(this, item.detail, index, code)}
                                                                onKeyDown={this.changeFocusRegistr.bind(this, item.detail, index, code)}
                                                                value={data.appointNum} />
                                                        </InputGroup>
                                                    </div>
                                                </span>
                                            )
                                        })}</div>}
                            </div>
                        </div>
                    )}
                </FormItem>
            )
        })

        return <Modal className='showDoctorModal' style={{ width: '600px' }}
            title={'添加医生'}
            visible={this.props.isShow}
            onCancel={this.closeModal.bind(this)}
            onOk={this.onSubmit.bind(this)}>
            <div>
                <div className="modal-body">
                    <Form className="card-form-item">
                        <Row>
                            <Col {...searchColConfig}>
                                <FormItem {...formItemLayout} label="科室">
                                    {getFieldDecorator('HospitalDr', {
                                        initialValue: this.props.addDepart ? (this.props.locId ? this.props.departName : this.state.userData.locDesc) : (this.props.noData ? this.props.noData.locDescripts : (newStatus ? (this.props.departNames ? this.props.departNames : this.state.userData.locDesc) : undefined)),
                                    })(
                                        <Select placeholder="请选择科室" style={{ width: '150px' }}
                                            disabled={this.props.addDepart ? true : (this.props.noData ? true : false)}
                                            // defaultValue={(this.props.addDepart?this.state.userData.locDesc:(this.props.noData?this.props.noData.locDescripts:''))}
                                            onChange={this.onChangeDepartId.bind(this)}
                                            getPopupContainer={triggerNode => triggerNode.parentNode}>
                                            {this.props.addStatus ? newDepartDataOption : departmentOption}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            <Col {...searchColConfig}>
                                <FormItem {...formItemLayout} label="医生">
                                    {getFieldDecorator('doctorId', {
                                        initialValue: this.props.noData ? this.props.noData.userName :
                                            (this.state.doctorId ? this.state.doctorId : undefined)
                                    })(
                                        <Select placeholder="请选择医生" style={{ width: '150px' }}
                                            disabled={this.props.noData ? true : false}
                                            // value={this.props.noData ? this.props.noData.userName : ''}
                                            onChange={this.changeDoctor.bind(this)}
                                            dropdownMatchSelectWidth={false}
                                            getPopupContainer={triggerNode => triggerNode.parentNode}>
                                            {doctorOption}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row>
                            <Col {...searchColConfig}>
                                <FormItem {...formItemLayout} label={<span><span style={{ color: '#f5222d', fontFamily: 'SimSun', marginLeft: '10%' }}>*</span>
                                    <span>{'诊室'}</span></span>}>
                                    {getFieldDecorator('roomDr', {
                                        initialValue: this.props.noData ? this.props.noData.roomID :
                                            (this.state.roomDr ? this.state.roomDr : undefined)
                                    })(
                                        <Select placeholder="请选择坐诊诊室" style={{ width: '150px', marginTop: 10 }}
                                            onChange={Util.handleSelectChange.bind(this, 'roomDr')}
                                            // defaultValue={this.props.noData ? this.props.noData.roomId : ''}
                                            getPopupContainer={triggerNode => triggerNode.parentNode}>
                                            {doctorRoomOption}
                                        </Select>
                                    )}
                                </FormItem>
                            </Col>
                            {this.props.departStatus ?
                                <Col {...searchColConfig}>
                                    <FormItem {...formItemLayout} label="日期">
                                        {getFieldDecorator('date', {
                                            initialValue: this.props.noData ? this.props.noData.date : ''
                                        })(
                                            <Select placeholder="请选择坐诊日期" style={{ width: '170px', marginTop: 10 }}
                                                disabled={this.props.noData ? true : false}
                                                // defaultValue={this.props.noData ? this.props.noData.date : ''}
                                                onChange={Util.handleSelectChange.bind(this, 'date')}
                                                getPopupContainer={triggerNode => triggerNode.parentNode}>
                                                {timeOption}
                                            </Select>
                                        )}
                                    </FormItem>
                                </Col> : null
                            }
                        </Row>
                        <div className='close-doctor-btn'>{modelDetailData}</div>
                        {/* <AddMechanism></AddMechanism> */}
                    </Form>
                </div>
            </div>
        </Modal>
    }
}

export default Form.create()(ShowDoctorModal);