/**
 * 生成排班
 * 
 */

import React from 'react';
import {
    Card, Table, Input, Form, Select, Row, Col, DatePicker, Button, Checkbox,
    Popconfirm, Divider, Icon, Pagination, message, Tooltip, Spin
} from 'antd';
import { Util } from 'tools/index';
import { $http } from 'containers/config/https';
import ShowDepartModal from './component/ShowDepartModal';
import ConfirmModal from './component/ConfirmModal';
import ShowStopMedicalModal from './component/ShowStopMedicalModal';
import ShowDoctorModal from './component/ShowDoctorModal';
import ShowDisableModal from './component/ShowDisableModal';
import store from 'store';
import './style/index.less';
import moment from 'moment';

const Option = Select.Option;

//全局申明时间
const now = new Date(); //当前日期
const nowDayOfWeek = now.getDay(); //今天本周的第几天
const nowDay = now.getDate(); //当前日
const nowMonth = now.getMonth(); //当前月
const nowYear = now.getFullYear(); //当前年
class DepartScheduling extends React.Component {
    constructor(props) {
        var userData = JSON.parse(sessionStorage.getItem('userData'));
        var date = new Date();
        var year = date.getFullYear();
        super(props)
        this.state = {
            dataSource: [],
            subrateData: [],
            userData: userData,
            span: {},
            orderSpan: {},
            addStatus: false,
            loading: false
        }
    }

    componentDidMount() {
        this.initData()
        this.loadSchedulingTitleType()
    }

    loadSchedulingTitleType() {
        var params = {
            params: [{
                // hospitalId:this.state.userData.hospDr,
                hospID: this.state.userData.hospID,
                active: 'Y',
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040160",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    var data = res.result.data;
                    var resourceTypeID = ''
                    if (!Util.isEmpty(data)) {
                        resourceTypeID = data[0].id
                    }
                    this.setState({
                        resourceType: res.result.data,
                        resourceTypeID: resourceTypeID
                    }, () => {
                        this.getDepartment()
                        this.getDoctor();
                        this.loadSchedulingTime()
                    })
                }
            }
        });
    }

    loadSchedulingTime() {
        var params = {
            params: [{
                beforNumber: '4',
                afterNumber: '4',
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        $http.post('urlS', this, {
            code: "03020060",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    var data = res.result
                    var dateStr = ''
                    if (!Util.isEmpty(data)) {
                        for (var i = 0; i < data.length; i++) {
                            if (data[i].defaultFlag && data[i].defaultFlag == 'Y') {
                                dateStr = data[i].id
                            }
                        }
                    }
                    this.setState({
                        schedulingTime: res.result,
                        dateStr: dateStr
                    }, () => {
                        this.loadData()
                        this.loadColumn();
                    })
                }
            }
        })
    }

    //获取科室信息
    getDepartment(e) {
        var params = {
            params: [{
                hospID: this.state.userData.hospID,
                userID: this.state.userData.userID,
                resourceTypeID: this.state.resourceTypeID
                // type: 'O',
            }]
        }
        $http.post('urlS', this, {
            code: "03020057",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({ departmentData: res.data })
                }
            }
        })
    }

    //获取坐诊医生
    getDoctor(id) {
        var params = {
            params: [{
                hospID: this.state.hospId ? this.state.hospId : this.state.userData.hospID,
                locID: id ? id : this.state.userData.locID,
                groupID: '',
                depDoctorID: this.state.depDoctorId,
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        $http.post('urlDeault', this, {
            code: "03020049",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        doctorData: res.depDoctor
                    })
                }
            }
        });
    }

    loadColumn() {
        var params = {
            params: [{
                hospID: this.state.userData.hospID,
                dateStr: this.state.dateStr,
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        $http.post('urlDeault', this, {
            code: "03020035",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        columns: res.data
                    })
                }
            }
        });
    }


    initData() {
        this.columns = [
            {
                title: '医生',
                dataIndex: 'name',
                width: 120,
                align: 'center',
                render: (text) => {
                    return {
                        props: {
                            className: text == '刘德华' ? 'aaaaa' : '',
                        },
                        children: text,
                    };
                }
            }
        ]
    }

    loadData() {
        this.loadColumn()
        this.setState({ loading: true })
        var params = {
            params: [{
                hospID: this.state.userData.hospID,
                userID: this.state.userData.userID,
                dateStr: this.state.dateStr,
                locID: this.state.locId,
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        $http.post('urlDeault', this, {
            code: "03020039",
            data: params,
            success: function (res) {
                let orderSpan = {};
                res.data.data.map(item => {
                    orderSpan[item.locID] = Util.isEmpty(orderSpan[item.locID]) ? 1 : orderSpan[item.locID] + 1;
                });
                if (res.errorCode === '0') {
                    this.setState({
                        dataSource: res.data.data,
                        orderSpan: orderSpan,
                        disableBtn: res.data.disabled,
                        loading: false
                    })
                } else {
                    this.setState({ loading: false });
                }
            },
            error: function (error) {
                this.setState({ loading: false });
            }
        });
    }

    showScheduModal() {
        this.setState({
            showConfirmModal: true
        })
    }

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

    //修改pageSize
    changePageSize(e) {
        this.setState({ pageSize: e }, () => {
            this.loadData(1);
        });
    }

    //保存
    onSubmit(params) {
        $http.post('urlDeault', this, {
            code: "03020042",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    message.success('保存成功！')
                    this.loadData()
                    this.hideModal('isShowDepartModal')
                }
            }
        });
    }

    //生成排班
    onConfirm() {
        var params = {
            userID: this.state.userData.userID,
            dateStr: this.state.dateStr,
            params: this.state.dataSource,
            resourceTypeID: this.state.resourceTypeID
        }
        $http.post('urlDeault', this, {
            code: "03020040",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    message.success('保存成功！')
                    this.loadData()
                    this.hideModal('showConfirmModal')
                }
            }
        });
    }

    onSelectChange(ids) {
        this.setState({
            ids
        })
    }

    onSelectChangeSubId(subId) {
        this.setState({
            subId
        })
    }

    //获取当前年的当前周
    getWeekOfYear() {
        var today = new Date();
        var firstDay = new Date(today.getFullYear(), 0, 1);
        var dayOfWeek = firstDay.getDay();
        var spendDay = 1;
        if (dayOfWeek != 0) {
            spendDay = 7 - dayOfWeek + 1;
        }
        firstDay = new Date(today.getFullYear(), 0, 1 + spendDay);
        var d = Math.ceil((today.valueOf() - firstDay.valueOf()) / 86400000);
        var result = Math.ceil(d / 7);
        return result + 1;
    };

    changeWeek(e) {
        this.setState({
            dateStr: e
        })
    }
    //获得上周的开始日期
    getLastWeekStartDate(day) {
        var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek - day);
        return this.formatDate(weekStartDate);
    }
    //获得上周的结束日期
    getLastWeekEndDate(day) {
        var weekEndDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek - day);
        return this.formatDate(weekEndDate);
    }


    //获得下周开始时间
    getNextWeekStartDate(day) {
        var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek + day);
        return this.formatDate(weekStartDate);
    }

    //获得下周结束时间
    getNextWeekEndDate(day) {
        var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek) + day);
        return this.formatDate(weekEndDate);
    }

    //格式化日期：yyyy-MM-dd
    formatDate(date) {
        var myyear = date.getFullYear();
        var mymonth = date.getMonth() + 1;
        var myweekday = date.getDate();
        if (mymonth < 10) {
            mymonth = "0" + mymonth;
        }
        if (myweekday < 10) {
            myweekday = "0" + myweekday;
        }
        return (myyear + "-" + mymonth + "-" + myweekday);
    }

    //获取科室ID
    changeDepartment(name, e) {
        var id = '';
        var departName = '';
        var { departmentData } = this.state;
        for (var i = 0; i < departmentData.length; i++) {
            if (id == departmentData[i].id) {
                departName = departmentData[i].descripts
            }
        }
        this.setState({
            [name]: e,
            departNames: departName,
            depDoctorId: ''
        })
        this.getDoctor(id, '')
    }

    //获取坐诊医生ID
    changeDoctorId(e) {
        var id = '';
        if (e) {
            id = e.substring(e.indexOf('^') + 1);
        }
        this.setState({
            depDoctorId: id,
            deptDrName: e ? (e.substring(0, e.indexOf('-'))) : ''
        })
    }

    //双击单元格弹窗
    handlescheduling(text, data, index) {
        this.setState({
            isShowDepartModal: true,
            modalData: text,
            locResDetailId: text.locResDetailID,
            locResModDetailId: text.locResModDetailID,
            clickIndex: text.indexId,
            clickStatus: true
        })
    }

    showDoctorModal(text, data, index) {
        this.setState({
            isShowDoctorModal: true,
            timeRangId: text.timeRangeID,
            departStatus: true,
            noData: text,
            clickIndex: text.indexId,
            clickStatus: true
        })
    }

    //新增医生
    addDoctorModal() {
        this.loadNewDepartData()
        this.setState({
            isShowDoctorModal: true,
            departStatus: true,
            addStatus: true
        })
    }

    loadNewDepartData() {
        var params = {
            params: [{
                hospID: this.state.userData.hospID,
                dateStr: this.state.dateStr,
                resourceTypeID: this.state.resourceTypeID
            }]
        }
        $http.post('urlS', this, {
            code: "03020053",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({ newDepartData: res.result.Data })
                }
            }
        })
    }

    //停诊后的点击事件
    handleStopscheduling(text, data, index) {
        this.setState({
            isShowStopMedicalModal: true,
            medicalData: text,
            medcialId: text.locResDetailID,
            clickStatus: true,
            clickIndex: text.indexId
        })
    }

    //保存新增医生
    saveDoctorData() {
        this.hideModal('isShowDoctorModal')
        this.loadData()
    }

    hendlePassModal(text) {
        let locDisId = text?.locResDetailID || '';
        let loDisDetailId = text?.locResModDetailID || '';
        if (locDisId || loDisDetailId) {
            this.setState({
                clickStatus: true,
                clickIndex: text.indexId,
                isShowDisableModal: true,
                disableData: text,
                locDisId,
                loDisDetailId,
            })
        } else {
            message.error('当前排班时间已过期，无法修改，请重新选择!');
        }
    }

    handleConflictFlag(text) {
        this.setState({
            clickStatus: true,
            clickIndex: text.indexId
        })
        message.error('当前排班存在排班冲突，无法修改，请重新选择')
        return
    }

    stopMedical(params, showKey) {
        if (showKey == '1') {
            $http.post('urlDeault', this, {
                code: "03020042",
                data: params,
                success: function (res) {
                    if (res.errorCode === '0') {
                        message.success('保存成功！')
                        this.loadData()
                        this.hideModal('isShowStopMedicalModal')
                    }
                }
            });
        } else {
            $http.post('urlDeault', this, {
                code: "03020043",
                data: params,
                success: function (res) {
                    if (res.errorCode === '0') {
                        message.success('保存成功！')
                        this.loadData()
                        this.hideModal('isShowStopMedicalModal')
                    }
                }
            });
        }
    }

    changeRecorceType(data) {
        this.setState({
            resourceTypeID: data.id
        }, () => {
            this.getDepartment()
            this.getDoctor();
            this.loadSchedulingTime()
        })
    }

    onClickRow = (record) => {
        return {
            onClick: () => {
                if (this.state.tabIndex !== record.index) {
                    this.setState({
                        tabIndex: record.index
                    })
                } else {
                    this.setState({
                        tabIndex: undefined
                    })
                }
            }
        }
    }

    //设置点击row颜色 --左侧表格
    setRowClassName = (record) => {
        // return record.statusID == '2' ? 'backStyle' : (record.index == this.state.tabIndex ? 'clickRowStyle' : '');
        if (record.index == this.state.tabIndex) {
            return 'clickRowStyle'
        }
        if (record.statusID == '2') {
            return 'backStyle'
        }
    }

    render() {
        let hospitalOption = []
        let searchColConfig = {
            xs: { span: 24 },
            sm: { span: 12 },
            md: { span: 12 },
            lg: { span: 5 }
        }
        let searchColWeekConfig = {
            xs: { span: 24 },
            sm: { span: 12 },
            md: { span: 12 },
            lg: { span: 12 }
        }
        let { ids } = this.state;
        const rowSelection = {
            selectedRowKeys: ids, //end
            onChange: this.onSelectChange.bind(this),
        };

        const columnData = [
            {
                title: '科室',
                dataIndex: 'locDescripts',
                width: 130,
                className: 'loc-style',
                align: 'center',
                fixed: 'left',
                rowSpan: 1,
                children: [{
                    title: '',
                    dataIndex: 'locDescripts',
                    width: 130,
                    className: 'loc-style',
                    align: 'center',
                }]
                // render: (value, data, index) => {
                //     if (index === 0) {
                //         this.state.span = {};
                //     }
                //     const obj = {
                //         children: value,
                //         props: {}
                //     }
                //     if (Util.isEmpty(this.state.span[data.locID])) {
                //         obj.props.rowSpan = this.state.orderSpan[data.locID];
                //         this.state.span[data.locID] = 1;
                //     } else {
                //         obj.props.rowSpan = 0;
                //     }
                //     return obj;
                // },
            },
            {
                title: '医生',
                dataIndex: 'doctorName',
                className: 'loc-style',
                width: 100,
                align: 'center',
                fixed: 'left',
                rowSpan: 1,
                children: [{
                    title: '',
                    dataIndex: 'doctorName',
                    className: 'loc-style',
                    width: 100,
                    align: 'center',
                }]
            },
        ]
        var { columns } = this.state;
        var columnOption = [];
        var newColumn = [];
        if (columns) {
            var newOption = []
            for (var i = 0; i < columns.length; i++) {
                newColumn = []
                for (var j = 0; j < columns[i].children.length; j++) {
                    let indexJ = j;
                    newColumn.push({
                        title: (columns[i].children)[j].title,
                        dataIndex: (columns[i].children)[j].dataIndex,
                        width: 80,
                        align: (columns[i].children)[j].align,
                        render: (text, data, index) => {
                            if (text && text.statusID == '2') {
                                if (Util.isEmpty(text.locResDetailID)) {
                                    return {
                                        props: {
                                            className: text && text.workStatusID == '2' ? (indexJ === 0 ? "first-element-td stopStyle" : 'stopStyle') : (text && text.tempFlag == '1' ? (indexJ === 0 ? "first-element-td" : 'newAddStyle') : (indexJ === 0 ? "first-element-td" : "")),
                                            id: text && text.partWorkStatusID == '1' ? 'partStyle' : '',
                                        },
                                        children: <Tooltip placement="top" title={'双击单元格设置'}><span className={this.state.clickStatus && this.state.clickIndex == text.indexId ? 'doubleStyle' : ''}
                                            onDoubleClick={Util.isEmpty(text && text.editFlag) ? this.hendlePassModal.bind(this, text) :
                                                (Util.isEmpty(text && text.conflictFlag) ? this.handleConflictFlag.bind(this, text) : (this.showDoctorModal.bind(this, text, data, index)))}>
                                            {text && text.registNum || '/'}
                                        </span></Tooltip>,
                                    };
                                } else {
                                    return {
                                        props: {
                                            className: text && text.workStatusID == '2' ? (indexJ === 0 ? "first-element-td stopStyle" : 'stopStyle') : (text && text.tempFlag == '1' ? (indexJ === 0 ? "first-element-td" : 'newAddStyle') : (indexJ === 0 ? "first-element-td" : "")),
                                            id: text && text.partWorkStatusID == '1' ? 'partStyle' : ''
                                        },
                                        children: <Tooltip placement="top" title={'双击单元格设置'}><span className={this.state.clickStatus && this.state.clickIndex == text.indexId ? 'doubleStyle' : ''}
                                            onDoubleClick={Util.isEmpty(text && text.editFlag) ? this.hendlePassModal.bind(this, text) :
                                                (Util.isEmpty(text && text.conflictFlag) ? this.handleConflictFlag.bind(this, text) : (this.handleStopscheduling.bind(this, text, data, index)))}>
                                            {text ? text.registNum : ''}
                                        </span></Tooltip>,
                                    };
                                }
                            } else {
                                return {
                                    props: {
                                        className: text && text.workStatusID == '2' ? (indexJ === 0 ? "first-element-td stopStyle" : 'stopStyle') : (text && text.tempFlag == '1' ? (indexJ === 0 ? "first-element-td" : 'newAddStyle') : (indexJ === 0 ? "first-element-td" : "")),
                                        id: text && text.partWorkStatusID == '1' ? 'partStyle' : ''
                                    },
                                    children: <Tooltip placement="top" title={'双击单元格设置'}><span className={((this.state.clickStatus && this.state.clickIndex == text.indexId)) ? 'doubleStyle' : ''}
                                        onDoubleClick={Util.isEmpty(text && text.editFlag) ? this.hendlePassModal.bind(this, text) : (text && text.registNum ? this.handlescheduling.bind(this, text, data, index) : '')}>
                                        {text ? text.registNum : ''}
                                    </span></Tooltip>,
                                };
                            }
                        }
                    })
                }
                newOption.push(newColumn)
            }
            for (var i = 0; i < columns.length; i++) {
                columnOption.push({
                    title: <div><div>{(columns[i].title).substring(0, (columns[i].title).indexOf('^'))}
                        <span style={{ color: 'white', background: '#1999db', marginLeft: 5 }}>
                            {columns[i].today == 'Y' ? <span>&nbsp;{'今'}&nbsp;</span> : ''}</span>
                    </div>
                        <div>{(columns[i].title).substring((columns[i].title).indexOf('^') + 1)}</div>
                    </div>,
                    children: newOption[i]
                })
            }
        }
        var column = columnData.concat(columnOption)
        //获取年份、月、日
        var date = new Date();
        var year = date.getFullYear();
        var month = moment(date).format('MM-DD');

        //获取科室Department
        let departmentOption = [];
        this.state.departmentData && this.state.departmentData.map((item, index) => {
            departmentOption.push(<Option key={index} value={item.id} code={item.descripts} name={item.descriptsSPCode}>{item.descripts}</Option>)
        })
        var depStatus = false;
        if (this.state.departmentData) {
            var departData = this.state.departmentData;
            for (var i = 0; i < departData.length; i++) {
                if (this.state.userData.locID == departData[i].id) {
                    depStatus = true;
                    break;
                }
            }
        }

        //坐诊医生
        let doctorOption = []
        this.state.doctorData && this.state.doctorData.map((item, index) => {
            doctorOption.push(<Option key={index} value={item.descripts + '-' + item.code + item.descriptsSPCode + '^' + item.deptDoctorId + ''}>{item.descripts}</Option>)
        })

        let schedulingTimeOption = []
        this.state.schedulingTime && this.state.schedulingTime.map((item, index) => {
            schedulingTimeOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
        })

        var resourceTypeOption = []
        this.state.resourceType && this.state.resourceType.map((item, index) => {
            resourceTypeOption.push(<Button key={index} value={item.id} size="large" style={{ marginRight: 5 }}
                className={item.id == this.state.resourceTypeID ? 'resource-btn-bgd' : ''}
                onClick={this.changeRecorceType.bind(this, item)}>{item.descripts}</Button>)
        })

        return (
            <Spin tip='加载中...' spinning={this.state.loading}>
                <div style={{ background: '#F1F1F1' }} className='departScheduStyle'>
                    {/**编辑排班 */}
                    <ShowDepartModal
                        resourceType={this.state.resourceType}
                        resourceTypeID={this.state.resourceTypeID}
                        isShow={this.state.isShowDepartModal}
                        modalData={this.state.modalData}
                        locResDetailId={this.state.locResDetailId}
                        locResModDetailId={this.state.locResModDetailId}
                        onHide={this.hideModal.bind(this, 'isShowDepartModal')}
                        onSubmit={this.onSubmit.bind(this)}>
                    </ShowDepartModal>
                    {/**确定生成排班 */}
                    <ConfirmModal isShow={this.state.showConfirmModal}
                        onHide={this.hideModal.bind(this, 'showConfirmModal')}
                        onSubmit={this.onConfirm.bind(this)}
                    ></ConfirmModal>
                    {/**编辑排班后信息 */}
                    <ShowStopMedicalModal isShow={this.state.isShowStopMedicalModal}
                        resourceType={this.state.resourceType}
                        resourceTypeID={this.state.resourceTypeID}
                        medcialId={this.state.medcialId}
                        medicalData={this.state.medicalData}
                        onHide={this.hideModal.bind(this, 'isShowStopMedicalModal')}
                        onSubmit={this.stopMedical.bind(this)}>
                    </ShowStopMedicalModal>
                    {/**添加临时医生*/}
                    <ShowDoctorModal
                        isShow={this.state.isShowDoctorModal}
                        noData={this.state.noData}
                        locIds={this.state.locId}
                        resourceType={this.state.resourceType}
                        resourceTypeID={this.state.resourceTypeID}
                        depStatus={depStatus}
                        departNames={this.state.departNames}
                        dateStr={this.state.dateStr}
                        departStatus={this.state.departStatus}
                        doctorData={this.state.doctorData}
                        addStatus={this.state.addStatus}
                        timeRangId={this.state.timeRangId}
                        departmentData={this.state.departmentData}
                        newDepartData={this.state.newDepartData}
                        onHide={this.hideModal.bind(this, 'isShowDoctorModal')}
                        onSubmit={this.saveDoctorData.bind(this)}>
                    </ShowDoctorModal>

                    {/**查看号源 */}
                    <ShowDisableModal isShow={this.state.isShowDisableModal}
                        modalData={this.state.disableData}
                        resourceType={this.state.resourceType}
                        resourceTypeID={this.state.resourceTypeID}
                        locResDetailId={this.state.locDisId}
                        locResModDetailId={this.state.loDisDetailId}
                        onHide={this.hideModal.bind(this, 'isShowDisableModal')}>
                    </ShowDisableModal>
                    <div className='scheduling-broad-title'>
                        <Card>
                            {resourceTypeOption}
                        </Card>
                    </div>
                    <Card style={{ height: '14%' }}>
                        <Row>
                            <Col span={4}>
                                选择科室：<Select placeholder="请选择科室" style={{ width: '170px' }}
                                    showSearch
                                    allowClear
                                    defaultValue={depStatus ? (this.state.userData.locDesc) : undefined}
                                    onChange={this.changeDepartment.bind(this, 'locId')}

                                    filterOption={(input, option) =>
                                        option.props.name.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                        || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    }
                                    getPopupContainer={triggerNode => triggerNode.parentNode}>
                                    {departmentOption}
                                </Select>
                            </Col>

                            {/* <Col {...searchColConfig}>
                            科室医生：<Select placeholder="请选择科室医生" style={{ width: '170px'}}
                                showSearch
                                allowClear
                                value={this.state.depDoctorId?this.state.deptDrName:undefined}
                                onChange={this.changeDoctorId.bind(this)}
                                getPopupContainer={triggerNode => triggerNode.parentNode}>
                                {doctorOption}
                            </Select>
                        </Col> */}
                            <Col span={5}>
                                排班周期：<Select placeholder="请选择排班周期" style={{ width: '230px' }}
                                    onChange={this.changeWeek.bind(this)}
                                    value={this.state.dateStr}
                                    defaultActiveFirstOption={false}
                                    getPopupContainer={triggerNode => triggerNode.parentNode}>
                                    {schedulingTimeOption}
                                </Select>
                            </Col>
                            <Col span={2}>
                                <Button style={{ background: '#108EE9', color: 'white' }} onClick={this.loadData.bind(this)}>查询</Button>
                            </Col>
                            <div style={{ textAlign: 'right' }}>
                                <Button type='primary' style={{ marginRight: 10, marginLeft: 10 }}
                                    disabled={this.state.disableBtn == 'Y' ? true : false}
                                    onClick={this.showScheduModal.bind(this)}>生成排班</Button>
                            </div>
                        </Row>
                    </Card>

                    {/* <Card style={{ marginTop: '10px' }}> */}
                    <Table columns={column} style={{ width: '100%', marginTop: '10px', background: 'white', height: '84%' }}
                        dataSource={this.state.dataSource}
                        loadData={this.loadData.bind(this)}
                        rowClassName={this.setRowClassName}
                        onRow={this.onClickRow}
                        bordered
                        rowKey={(data) => {
                            return data.index
                        }}
                        scroll={{ y: store.getState().tableHeight.y - 65, x: '100%' }}
                        footer={() => {
                            return this.state.statusID == '2' ? null : <span style={{ marginLeft: '10px', cursor: 'pointer', color: '#1890FF' }}
                                onClick={this.addDoctorModal.bind(this)}>
                                <Icon type='plus' />添加医生到排班</span>
                        }
                        }
                        // rowClassName={(data) => {
                        //     if (data.statusID == '2') {
                        //         return 'backStyle'
                        //     }
                        // }}
                        title={() => {
                            return <div className='totalScheduling' style={{ display: 'flex', float: 'right', marginTop: 10 }}>
                                <div className='headerBuild' style={{ display: 'flex' }}>
                                    <div className='rightBtn'></div><div style={{ marginLeft: '10px' }}>正常生成</div>
                                </div>
                                <div className='headerUnBuild' style={{ display: 'flex' }}>
                                    <div className='whiteBtn'></div><div style={{ marginLeft: '10px' }}>全部停诊</div>
                                </div>
                                <div className='headerUpdate' style={{ display: 'flex' }}>
                                    <div className='redBtn'></div><div style={{ marginLeft: '10px' }}>部分停诊</div>
                                </div>
                                <div className='headerUpdate' style={{ display: 'flex' }}>
                                    <div className='grayBtn'></div><div style={{ marginLeft: '10px' }}>未生成排班</div>
                                </div>
                                <div className='headerUpdate' style={{ display: 'flex' }}>
                                    <div className='timeBtn'></div><div style={{ marginLeft: '10px' }}>临时新增</div>
                                </div>
                            </div>
                        }}
                        pagination={false}
                    >
                    </Table>
                    {/* <Pagination
                        size="small"
                        showQuickJumper
                        showSizeChanger
                        defaultCurrent={1}
                        current={this.state.page}
                        total={this.state.total}
                        onChange={this.changePageSize.bind(this)}
                        style={{ textAlign: "right", marginTop: '13px' }}
                    /> */}
                    {/* </Card> */}
                </div></Spin>
        )
    }
}

export default DepartScheduling;