// 分配科室
import React from 'react';
import { Form, Row, Col, Select, Table, DatePicker, Switch, Input, Button, Icon, message, Popconfirm, Divider, } from 'antd';
import { $http } from '../../../containers/config/https';
import { Util } from '../../../tools';
import Moment from 'moment';
import OfficePanelModel from './OfficePanelModel'
import store from '../../../store';
import DatePickerFormat from '../../../components/datePicker/DatePickerFormat'


// 组件const
const { Option } = Select;



const formItemLayout = {    // label 和input宽度
    labelCol: { span: 14 },
    wrapperCol: { span: 8, offset: 2 },
};

class DistributionDepartment extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            // 表格数据
            tableData: [],
            hospitalData: [], // 医院集合
            deptDrData: [], // 科室集合
            deptGrpData: [], // 分组集合
            dataSource: [],// 编辑科室数据
            // medData: [],// 专长集合
            deptLocId: '', // 科室id
            defaultHos: JSON.parse(window.sessionStorage.userData).hospDrID,   // 医院
            userExperAry: [], // 专长请求数组
            medGroupIdIs: '', // 分组值是否变化
            beforMedGrpUserId: '', // 所选用户分组记录主键
            medGroupIdDefault: '', //  分组记录主键
            locData: [], // 回显专长数组
            deptDocId: '',// 回显科室人员主键
            userID: '',// 用户主键
            userCode: '',// 用户主键工号
            // medDataIs: '', // 外层专长是否变化
            // medExperId: '', // 外层专长主键
            medDis: [], // 专长不可选数组
            removeUserExperAry: [], // 专长删除数组
        };

        this.columns = [
            {
                key: 1,
                title: '所属医院',
                dataIndex: 'hospDesc',
                align: "center",
                width: 200,
            },
            {
                key: 2,
                title: '所属科室',
                dataIndex: 'locDesc',
                align: "center",
                width: 150,
            },
            {
                key: 3,
                title: '所属分组',
                dataIndex: 'medGroupDesc',
                align: "center",
                width: 150,
            },
            {
                key: 6,
                title: '处方权',
                dataIndex: 'deptPrescriberFlag',
                align: "center",
                width: 100,
                render(deptPrescriberFlag) {
                    let config = {
                        'Y': '是',
                        'N': '否'
                    }
                    return config[deptPrescriberFlag];
                }
            },
            {
                key: 7,
                title: '无医嘱权',
                dataIndex: 'deptNoOrders',
                align: "center",
                width: 100,
                render(deptNoOrders) {
                    let config = {
                        'Y': '是',
                        'N': '否'
                    }
                    return config[deptNoOrders];
                }

            },
            {
                key: 8,
                title: '无病历权',
                dataIndex: 'deptNoEMR',
                align: "center",
                width: 100,
                render(deptNoEMR) {
                    let config = {
                        'Y': '是',
                        'N': '否'
                    }
                    return config[deptNoEMR];
                }
            },
            {
                key: 9,
                title: '无诊断权',
                dataIndex: 'deptNoDiagnosis',
                align: "center",
                width: 100,
                render(deptNoDiagnosis) {
                    let config = {
                        'Y': '是',
                        'N': '否'
                    }
                    return config[deptNoDiagnosis];
                }
            },
            {
                key: 10,
                title: '抗生素处方权',
                dataIndex: 'deptAntibiotic',
                align: "center",
                width: 150,
                render(deptAntibiotic) {
                    let config = {
                        'Y': '是',
                        'N': '否'
                    }
                    return config[deptAntibiotic];
                }
            },
            {
                key: 11,
                title: '毒麻药品处方权',
                dataIndex: 'deptAnaesthesia',
                align: "center",
                width: 150,
                render(deptAnaesthesia) {
                    let config = {
                        'Y': '是',
                        'N': '否'
                    }
                    return config[deptAnaesthesia];
                }
            },
            {
                title: '操作',
                key: 13,
                align: "center",
                width: 150,
                fixed: 'right',
                render: (text, record) => (
                    <span>
                        <Icon type="edit" style={{ color: '#108EE9' }}></Icon>
                        <span className='span' onClick={() => this.handleCompile(record)}>编辑</span>
                        {/* 分割线 */}
                        <Divider type="vertical" />
                        <Icon type="delete" style={{ color: 'rgba(240,65,52,1)' }}></Icon>
                        <Popconfirm title="删除不可恢复，你确定要删除吗?" onConfirm={() => this.handleDelete(record)} >
                            <span className='span' style={{ color: 'rgba(240,65,52,1)' }}>删除</span>
                        </Popconfirm>
                    </span>
                ),
            }
        ]
    }

    componentDidMount() {
        this.props.onRef(this)

        // 医院列表加载
        this.searachHospDr()

        // 科室加载
        this.hospDrChange(this.state.defaultHos)

        this.callback()

    }

    callback = () => {

        if (this.props.userCode) {
            this.setState({
                userID: this.props.userID, //  用户主键
                userCode: this.props.userCode, //  用户主键
            }, () => {
                // 初始化列表数据
                this.handleQuery()
                this.defaultQx() //获取用户默认权限

            })
        } else {
            this.setState({
                userID: store.getState().userRedux.userID, //  用户主键
                userCode: store.getState().userRedux.userCode, //  用户主键
            }, () => {
                // 初始化列表数据
                this.handleQuery()
                this.defaultQx() //获取用户默认权限

            })
        }

    }


    //获取用户默认权限
    defaultQx = () => {
        let userData = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {}
        let { userID } = this.state
        var data = {
            params: [{
                hospID: userData.hospID, // 医院id
                locID: userData.locID, //登录角色id
                userID: userID, // 登录医院id
            }]
        }
        $http.post('urlS', this, {
            code: "01040213",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    let record = res.result
                    this.props.form.setFieldsValue({
                        anaesthesia: record.anaesthesia === 'Y' ? true : false,
                        antibiotic: record.antibiotic === 'Y' ? true : false,
                        departmentHead: record.departmentHead === 'Y' ? true : false,
                        emergency: record.emergency === 'Y' ? true : false,
                        herbalPresc: record.herbalPresc === 'Y' ? true : false,
                        inpatient: record.inpatient === 'Y' ? true : false,
                        noDiagnosis: record.noDiagnosis === 'Y' ? true : false,
                        noEMR: record.noEMR === 'Y' ? true : false,
                        noOrders: record.noOrders === 'Y' ? true : false,
                        notReadResults: record.notReadResults === 'Y' ? true : false,
                        outpatient: record.outpatient === 'Y' ? true : false,
                        ownPatientsOnly: record.ownPatientsOnly === 'Y' ? true : false,
                        prescriberFlag: record.prescriberFlag === 'Y' ? true : false,
                        schedule: record.schedule === 'Y' ? true : false,
                        triageNurse: record.triageNurse === 'Y' ? true : false,
                        userleaderFlag: record.userleaderFlag === 'Y' ? true : false,

                    });
                }
            }
        });
    }



    // 医院列表加载
    searachHospDr = () => {
        let user = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        var data = {
            params: [{
                hospID: '', // 医院id
                logonGroupID: user.groupID, //登录角色id
                logonHospID: user.hospID, // 登录医院id
            }]
        }
        $http.post('urlS', this, {
            code: "01040001",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        hospitalData: res.depDoctor, //  医院列表
                    })
                }
            }
        });
    }

    // 医院切换
    hospDrChange = (value) => {
        this.props.form.setFieldsValue({
            locId: '',
        });
        this.setState({
            userExperAry: [],   //清空专长数组
            deptGrpData: [], //清空下拉框
            // medData: [], //清空下拉框
            deptDrData: [], //清空下拉框
        })

        if (!value) {
            return false
        }
        let data = {
            "params": [{
                hospID: value,
            }]
        };
        $http.post('urlDeault', this, {
            code: "04020008",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        deptDrData: res.result.Data, // 科室集合
                    })
                }
            }
        });
    }

    // 科室切换
    hospLocChange = (value) => {

        this.props.form.setFieldsValue({
            medGroupId: '',
            // medData: '',
        });

        this.setState({
            userExperAry: [],   //清空专长数组
            deptGrpData: [], //清空下拉框
            // medData: [], //清空下拉框
        })

        if (!value) {
            return false
        }


        let data = {
            "params": [{
                locID: value,
            }]
        };
        $http.post('urlS', this, {
            code: "01040044",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        deptLocId: value,
                        deptGrpData: res.result, // 分组集合
                    })
                }
            }
        });

        // let data2 = {
        //     params: [{
        //         locDr: value
        //     }]
        // }
        // $http.post('urlS', this, {
        //     code: "01050017",
        //     data: data2,
        //     success: function (res) {
        //         let errorCode = res.errorCode;
        //         if (errorCode === '0') {
        //             this.setState({ medData: res.result.Data ? res.result.Data : [] })
        //         }
        //     }
        // })
    }
    // medChange = (value) => {
    //     let { medDis } = this.state
    //     let index = medDis.indexOf(this.props.form.getFieldValue('medData'));

    //     medDis.push(value) // 不可选数组
    //     if (index > -1) {
    //         medDis.splice(index, 1);
    //     }
    // }

    // 查询
    handleQuery = () => {
        if (this.state.userID && this.state.userID !== '') {
            let data = {
                params: [{
                    userID: this.state.userID
                }]
            };
            $http.post('urlS', this, {
                code: "01040050",
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    if (errorCode === '0') {
                        if (res.result) {
                            for (var i = 0; i < res.result.length; i++) {
                                res.result[i].key = i;
                            }
                        }

                        this.setState({
                            tableData: res.result || [],
                        })
                    } else {
                        this.setState({
                            tableData: [],
                        })
                    }
                }
            });
        }

    }

    // 编辑
    handleCompile = (record) => {
        let { medDis } = this.state

        this.handleClone() // 清空

        this.hospDrChange(record.hospID) // 医院切换
        this.hospLocChange(record.locID) // 科室切换


        this.props.form.setFieldsValue({
            'locId': record.locID || "",        //科室主键
            'hospId': record.hospID || "",   //医院主键
            'medGroupId': record.medGrpUserAry[0] ? record.medGrpUserAry[0].medGroupLogID : "",      //所属分组主键
            "departmentHead": record.deptDepartmentHead === 'Y' ? true : false,       //部门领导
            "inpatient": record.deptInpatient === 'Y' ? true : false,     //住院病人
            "outpatient": record.deptOutpatient === 'Y' ? true : false,   //门诊病人
            "emergency": record.deptEmergency === 'Y' ? true : false,  //急诊病人
            "ownPatientsOnly": record.deptOwnPatientsOnly === 'Y' ? true : false,       //只看本病人可用
            "deptDocStDate": record.deptDocStartDate !== '' ? Moment(record.deptDocStartDate, 'YYYY-MM-DD') : undefined,        // 科室配置生效日期
            "deptDocSpDate": record.deptDocEndDate !== '' ? Moment(record.deptDocEndDate, 'YYYY-MM-DD') : undefined,    //科室配置失效日期
            'prescriberFlag': record.deptPrescriberFlag === 'Y' ? true : false,    //处方权
            'noOrders': record.deptNoOrders === 'Y' ? true : false,      //无医嘱权
            'noEMR': record.deptNoEMR === 'Y' ? true : false,         //无病历权
            'noDiagnosis': record.deptNoDiagnosis === 'Y' ? true : false,     //无诊断权
            'notReadResults': record.deptNotReadResults === 'Y' ? true : false,        // 不看检查结果
            'herbalPresc': record.herbalPresc === 'Y' ? true : false,        // herbalPresc  
            'anaesthesia': record.deptAnaesthesia === 'Y' ? true : false,     //毒麻药品处方权
            'antibiotic': record.deptAntibiotic === 'Y' ? true : false,      //抗生素处方权
            'triageNurse': record.deptTriageNurse === 'Y' ? true : false,       //是否是分诊护士
            'userleaderFlag': record.medGrpUserLeaderFlag === 'Y' ? true : false,     //是否为所属分组组长
            // 'medData': record.userFirstExperiseAry[0] ? record.userFirstExperiseAry[0].userFirstCBExperId.toString() : "",     //外层专长
            'schedule': record.deptSchedule === 'Y' ? true : false,     //排班
            // 'active': record.active === 'Y' ? true : false,     //激活
        });
        if (record.userExperAry.length > 0) {
            record.userExperAry.map((item) => {
                medDis.push(item.CBExperID)
            })
        }

        // if (record.userFirstExperiseAry.length > 0) {
        //     record.userFirstExperiseAry.map((item) => {
        //         medDis.push(item.userFirstCBExperId)
        //     })
        // }


        this.setState({
            medGroupIdIs: record.medGroupLogID,  //medGroupIdIs是否有变化
            medGrpUserId: record.medGrpUserAry[0] ? record.medGrpUserAry[0].medGrpUserLogID : '', //medGrpUserId是否有变化
            locData: record.userExperAry,  //专长数组 弹框传值
            userExperAry: record.userExperAry,  //专长数组 值
            deptDocId: record.deptDocLogID, //科室人员主键
            // medDataIs: record.userFirstExperiseAry[0] ? record.userFirstExperiseAry[0].userFirstCBExperId.toString() : "",  //medData是否有变化
            // medExperId: record.userFirstExperiseAry[0] ? record.userFirstExperiseAry[0].userFirstExperId.toString() : "",     //外层专长主键
            medDis: medDis  //专长不可选
        });



    }

    // 清空表单
    handleClone = () => {
        this.props.form.resetFields();
        this.setState({
            userExperAry: [],// 专长数组
            locData: [],//专长数组 弹框传值
            deptDocId: '', //科室人员主键
            removeUserExperAry: [], // 删除专长数组
            medGroupIdIs: '',  //medGroupIdIs是否有变化
            medGrpUserId: '',//medGrpUserId是否有变化
            // medDataIs: '',//medData是否有变化
            // medExperId: "",     //外层专长主键
            medDis: [],// 专长不可选数组
        });

    }

    // 删除分配科室
    handleDelete = (record) => {
        let data = {
            "params": [{
                "deptDocLogID": record.deptDocLogID,
                "updateUserID": JSON.parse(window.sessionStorage.userData).userID,
            }]
        };
        $http.post('urlADS', this, {
            code: "01040026",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    message.success(res.errorMessage);
                    this.handleQuery() // 查询
                }
            }
        });
    }

    // 调用子组件公共库导入的连接事件
    onRef = (ref) => {
        this.libraryChild = ref
    }

    // 点击公共库导入显示弹框
    handleLibraryImport = () => {
        this.libraryChild.showModal();
    }

    // 子组件传值回来
    callbackModal = (data, removeUserExperAry, medDis) => {
        this.setState({
            userExperAry: data,
            removeUserExperAry: removeUserExperAry,
            medDis: medDis
        });

    }


    // 保存用户信息表单提交
    handleSubmit = (e) => {
        e.preventDefault();

        this.props.form.validateFields((err, values) => {
            if (!err) {  //!err

                let { userExperAry, removeUserExperAry, medDataIs, medExperId } = this.state
                const userExperAryHttp = []   // 请求数据



                userExperAry.map((item) => {
                    let obj = {
                        userExperID: item.userExperID || '',
                        locID: this.state.deptLocId,
                        CBExperID: item.CBExperID,
                    }
                    userExperAryHttp.push(obj)
                })
                // if (exp[0]) {
                //     userExperAryHttp.push({
                //         userExperId: medExperId || '',
                //         userExperLocId: this.state.deptLocId || '',
                //         userCBExperId: exp[0].CBExpDr || '',
                //     })

                // }

                // 判断分组是否有变化
                if (this.state.medGroupIdIs !== values.medGroupId) {
                    let { beforMedGrpUserId, medGrpUserId } = this.state

                    this.setState({
                        beforMedGrpUserId: medGrpUserId,
                        medGrpUserId: '',
                    });
                }

                // // 判断外层专长是否有变化
                // if (!values.medData) {
                //     removeUserExperAry.push(medExperId)
                // }
                if (removeUserExperAry.length > 0) {
                    removeUserExperAry = removeUserExperAry.filter(value => Object.keys(value).length !== 0); // 去空
                }



                let data = {
                    "params": [{
                        'deptDocLogID': this.state.deptDocId, //科室人员主键
                        'userID': this.state.userID || "",   //人员主键
                        'locID': values.locId || "",        //科室主键
                        'hospID': values.hospId || "",   //医院主键
                        "deptDepartmentHead": Util.replaceTrueFalse(values.departmentHead) || "",       //部门领导
                        "deptInpatient": Util.replaceTrueFalse(values.inpatient) || "",    //住院病人
                        "deptOutpatient": Util.replaceTrueFalse(values.outpatient) || "",   //门诊病人
                        "deptEmergency": Util.replaceTrueFalse(values.emergency) || "",    //急诊病人
                        "deptOwnPatientsOnly": Util.replaceTrueFalse(values.ownPatientsOnly) || "",       //只看本病人可用
                        "deptDocStartDate": values.deptDocStDate ? Moment(values.deptDocStDate).utcOffset(480).format('YYYY-MM-DD') : "",        // 科室配置生效日期
                        "deptDocEndDate": values.deptDocSpDate ? Moment(values.deptDocSpDate).utcOffset(480).format('YYYY-MM-DD') : "",     //科室配置失效日期
                        'updateUserID': JSON.parse(window.sessionStorage.userData).userID,     //当前用户
                        'deptPrescriberFlag': Util.replaceTrueFalse(values.prescriberFlag) || "",   //处方权
                        'deptNoOrders': Util.replaceTrueFalse(values.noOrders) || "",      //无医嘱权
                        'deptNoEMR': Util.replaceTrueFalse(values.noEMR) || "",        //无病历权
                        'deptNoDiagnosis': Util.replaceTrueFalse(values.noDiagnosis) || "",      //无诊断权
                        'deptNotReadResults': Util.replaceTrueFalse(values.notReadResults) || "",       // 不看检查结果
                        'herbalPresc': Util.replaceTrueFalse(values.herbalPresc) || "",       // 不看检查结果
                        'deptAnaesthesia': Util.replaceTrueFalse(values.anaesthesia) || "",      //毒麻药品处方权
                        'deptAntibiotic': Util.replaceTrueFalse(values.antibiotic) || "",       //抗生素处方权
                        'deptTriageNurse': Util.replaceTrueFalse(values.triageNurse) || "",      //是否是分诊护士
                        'medGrpUserLeaderFlag': Util.replaceTrueFalse(values.userleaderFlag) || "",      //是否为所属分组组长
                        'deptSchedule': Util.replaceTrueFalse(values.schedule) || "",      //排班
                        // 'active': Util.replaceTrueFalse(values.active) || "",      //激活
                        'medGroupLogID': values.medGroupId || "",      //所属分组主键
                        'beforMedGrpUserID': this.state.beforMedGrpUserId || "",  //所选用户原有人员分组中人员记录主键
                        'medGrpUserLogID': this.state.medGrpUserId || "", //人员分组中人员记录主键
                        'removeUserExperAry': removeUserExperAry || [],        //专长数组删除的
                        "userExperAry": userExperAryHttp || [],        //专长数组

                    }]
                };
                $http.post('urlADS', this, {
                    code: "01040025",
                    data: data,
                    success: function (res) {
                        let errorCode = res.errorCode;
                        if (errorCode === '0') {
                            message.success(res.errorMessage);
                            this.setState({
                                deptLocId: 'relive' // 提交成功 置空
                            })
                            this.handleClone() // 清空表单
                            this.handleQuery() // 查询
                        }
                    }
                });
            }

        });
    }


    render() {
        const { getFieldDecorator } = this.props.form;
        return (
            <div style={{ padding: 24, paddingBottom: '0' }}>
                <Form layout="vertical" className="userForm" onSubmit={this.handleSubmit}  >
                    <Row>
                        <Col className=" textR floatL formRequired" style={{ width: '80px', marginRight: '20px' }}  >
                            <span >所属医院:</span>
                        </Col>
                        <Col span={3} style={{ marginRight: '20px' }}>
                            <Form.Item >
                                {getFieldDecorator('hospId', {
                                    initialValue: this.state.defaultHos,
                                    rules: [{ required: true, message: '请选择所属医院' }],
                                })(
                                    <Select showSearch allowClear onChange={(event) => { this.hospDrChange(event) }} placeholder="所属医院" optionFilterProp="title1" >
                                        {this.state.hospitalData.map(item => <Option title={item.descripts} title1={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                    </Select>
                                )}
                            </Form.Item>
                        </Col>
                        <Col className=" textR floatL formRequired" style={{ width: '80px', marginRight: '20px' }} >
                            <span>所属科室:</span>
                        </Col>
                        <Col span={3} style={{ marginRight: '20px' }}>
                            <Form.Item >
                                {getFieldDecorator('locId', {
                                    initialValue: '',
                                    rules: [{ required: true, message: '请选择所属科室' }],
                                })(

                                    <Select showSearch allowClear placeholder="所属科室" onChange={(event) => { this.hospLocChange(event) }} optionFilterProp="title1"  >
                                        {this.state.deptDrData.map(item => <Option title={item.descripts} title1={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                    </Select>

                                )}
                            </Form.Item>
                        </Col>
                        <Col className=" textL floatL " style={{ marginRight: '20px' }}>
                            <span>所属小组:</span>
                        </Col>
                        <Col span={3} style={{ marginRight: '20px' }}>
                            <Form.Item  >
                                {getFieldDecorator('medGroupId', {
                                    initialValue: '',
                                    rules: [],
                                })(
                                    <Select showSearch allowClear placeholder="所属小组" optionFilterProp="title1" >
                                        {this.state.deptGrpData.map(item => <Option title={item.descripts} title1={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                    </Select>
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={2} className=" textL" style={{ marginRight: '20px' }}>
                            <Form.Item label="组长"  {...formItemLayout} className="labelR" >
                                {getFieldDecorator('userleaderFlag', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        {/* 
                        <Col className=" textL  floatL " style={{ marginRight: '20px' }} >
                            <span>专长:</span>
                        </Col>
                        <Col span={3} style={{ marginRight: '20px' }}>
                            <Form.Item  >
                                {getFieldDecorator('medData', {
                                    initialValue: '',
                                    rules: [],
                                })(
                                    <Select allowClear placeholder="专长" optionFilterProp="title1" onChange={(event) => { this.medChange(event) }}  >
                                        {this.state.medData.map(item => <Option title={item.descripts} title1={item.descripts + '^' + item.descriptsSPCode} disabled={this.state.medDis.includes(item.CBExpDr)} key={item.CBExpDr} value={item.CBExpDr}  >{item.descripts}</Option>)}
                                    </Select>
                                )}
                            </Form.Item>
                        </Col> */}
                        <Col className="textL floatL">
                            <span className="addHref" style={{ marginTop: '0' }} onClick={this.handleLibraryImport}>+管理其他专长</span>
                        </Col>
                    </Row>
                    <Row>

                        <Col className=" textR floatL " style={{ width: '80px', marginRight: '20px' }}  >
                            <span >人员类型:</span>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="科室领导"  {...formItemLayout} className="labelR" >
                                {getFieldDecorator('departmentHead', {
                                    valuePropName: 'checked',

                                    initialValue: false
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="分诊护士"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('triageNurse', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    <Row>

                        <Col className=" textR floatL " style={{ width: '80px', marginRight: '20px' }}  >
                            <span >可查看病人:</span>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="住院病人"  {...formItemLayout} className="labelR" >
                                {getFieldDecorator('inpatient', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="门诊病人"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('outpatient', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="急诊病人"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('emergency', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="只看本人病人"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('ownPatientsOnly', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    <Row>
                        <Col className="textR floatL " style={{ width: '80px', marginRight: '20px' }}  >
                            <span >处方权等:</span>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="处方权"  {...formItemLayout} className="labelR" >
                                {getFieldDecorator('prescriberFlag', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="无医嘱权"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('noOrders', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="无病历权"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('noEMR', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="无诊断权"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('noDiagnosis', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="毒麻药品处方权"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('anaesthesia', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="抗生素处方权"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('antibiotic', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="不看检查结果"  {...formItemLayout} className="labelR">
                                {getFieldDecorator('notReadResults', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                        <Col span={4}>
                            <Form.Item label="中草药处方权"  {...formItemLayout} className="labelR" >
                                {getFieldDecorator('herbalPresc', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    <Row>

                        <Col className=" textR floatL " style={{ width: '80px', marginRight: '20px' }}  >
                            <span >状态:</span>
                        </Col>
                        {/* <Col span={3}>
                            <Form.Item label="激活"  {...formItemLayout} className="labelR" >
                                {getFieldDecorator('active', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col> */}
                        <Col span={4}>
                            <Form.Item label="排班"  {...formItemLayout} className="labelR" >
                                {getFieldDecorator('schedule', {
                                    valuePropName: 'checked',
                                    initialValue: false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    <Row>
                        <Col className=" textR floatL formRequired" style={{ width: '80px', marginRight: '20px' }}  >
                            <span style={{ lineHeight: '30px' }}>生效日期:</span>
                        </Col>
                        <Col span={4} style={{ marginRight: '20px' }}>
                            <Form.Item className="dpW100"  >
                                {getFieldDecorator('deptDocStDate', {
                                    rules: [{ required: true, message: '请输入生效日期' }],
                                    initialValue: Moment(Moment().format('L'), 'YYYY-MM-DD'),
                                })(
                                    <DatePickerFormat />
                                )}
                            </Form.Item>
                        </Col>

                        <Col className=" textR floatL " style={{ width: '80px', marginRight: '20px' }} >
                            <span style={{ lineHeight: '30px' }}>失效日期:</span>
                        </Col>
                        <Col span={4} className="dpW100"  >
                            <Form.Item   >
                                {getFieldDecorator('deptDocSpDate', {
                                    rules: [],
                                    initialValue: undefined,
                                })(
                                    <DatePickerFormat />
                                )}
                            </Form.Item>
                        </Col>
                    </Row>
                    <Row >
                        <Col span={24}>
                            <Row style={{ width: '100%', textAlign: 'center', marginBottom: '10px' }}>
                                <Button onClick={this.handleSubmit} style={{ marginRight: '30px', background: 'rgba(66,185,131,1)', color: '#fff' }}>保存</Button>
                                <Button onClick={this.handleClone} style={{ color: '#000' }}>清空</Button>
                            </Row>
                        </Col>

                    </Row>
                </Form>
                <Row>
                    <Col span={24}>
                        <Table
                            bordered
                            dataSource={this.state.tableData}
                            columns={this.columns}
                            pagination={false}
                            scroll={{ x: 1200, y: 240 }}
                            onRow={(record) => {
                                return {
                                    onDoubleClick: (event) => {
                                        this.handleCompile(record)
                                    },
                                };
                            }}
                        />
                    </Col>
                </Row>

                <OfficePanelModel
                    onRef={this.onRef}
                    locid={this.state.deptLocId}
                    hideModal={() => this.setState({ visible: false })}
                    callbackModal={this.callbackModal.bind(this)}
                    locData={this.state.locData}
                    medDis={this.state.medDis}
                />
            </div>
        )
    }
}
const DistributionDepartmentFrom = Form.create()(DistributionDepartment);

export default DistributionDepartmentFrom 