/*
 * Creator:     ML
 * CreatDate:   2019-09-27
 * descripts：医嘱大类设置
 * */
import React from 'react';
import moment from 'moment';
import { Form, Row, Col, Input, Table, Select, DatePicker, Button, Modal, message, Divider, Tooltip, Icon, Card, Checkbox, Radio, Badge, Fragment, Pagination, Popconfirm, Switch } from 'antd';
import { $http } from '../../containers/config/https';
import store from '../../store';
import './style/index.less';
import BaseInformation from './component/BaseInformation';
import CommonPagination from 'components/pagination/index';
import FindMajor from "./component/FindMajor";

const paddRightCol = {
    paddingRight: "0px"
}
const formItemLayoutType = {
    labelCol: { span: 9 },
    wrapperCol: { span: 15 }
}
const FormItem = Form.Item;
const Option = Select.Option;
const MajorCategoriesOfMedicalAdvice = Form.create()(
    class MajorCategoriesOfMedicalAdvice extends React.Component {
        cacheOriginData = {};
        constructor() {
            super()
            this.state = {
                leftData: [],//左边查询到的表格数据
                rightData: [],//右边双击后的表格数据
                rightUnitDr: [],
                findInfo: '请输入查询条件',//查询提示信息
                visible: false,//添加/修改医嘱大类表维护弹窗显示
                isMod: -1,//是否点击编辑
                ordTempletID: "",//编辑行id
                ordTempletDesc: "",//模板名称
                ordTempletAlias: "",//模板别名
                ordTempletCat: "",//医嘱分类
                rowId: "",//表格行id 设置颜色
                ordShow: false,//当前模板显示
                baseParentType: [],//添加医嘱大类表维护类型选择  上级分类
                baseUnit: [],//添加医嘱明细单位类型选择
                selectedData: [],//医嘱明细选中
                selectedId: [],//医嘱明细选中
                tempChildDis: false,//左侧编辑 选择类型
                btnStatus: true,
                selectedRow_right: [],
                selectrow: "",//获取行 当前选中行
                deteleOrdId: "",//选中删除行
                leftDisRow: false,
                ordTempId: 1,//医嘱大类选择值
                isAdd: false,//是否点击添加
                ordDetailValue: "",//医嘱明细输入值
                ordDetailData: [],//医嘱项表格数据
                OrdDaShow: false,//医嘱项表格数据显隐
                OrdDaRowId: "",//医嘱项表格行id
                OrdCanType: "",//医嘱项允许录入类型
                ordTemPrice: 0,//医嘱项行单价
                editDis: true,//未选中

                nowRowID: "",//医嘱明细表格行id

                initRored: {},//原始右侧表格行
                ordTempletDetailItemDesc: "",
                ordTempletDetailQty: "",
                ordTempletDetailQtyUnitDr: "",
                ordTempletDetailID: "",
                disAdd: false,//是否可新增
                newOpen: [],
                leftData: [],


                searchCategoryName: "",//输入左侧搜索分类名称
                checkAll: false,//左侧全选
                checkedList: [],//左侧可选项
                plainOptions: [],
                rightTopTableData: [],//右上小表格数据
                cbiD: "",//自定义分类 区分触发场景
                radioValue: 0,//
                rowRightId: "",//右上小表格选中
                leftInfo: {},//左侧信息回显
                rightSearchInfo: "",//右侧搜索
                canDeleteStatus: true,//能否点击删除


                // 左侧表格
                checked: true,//默认选择生效
                total: 0,//医嘱项表格总数据
                page: 1,//页数
                pageSize: 20,//显示数
                search: "",
                size: "small",
                //右侧表格
                searchRight: "",
                sizeRight: "small",
                totalRight: 0,
                pageRight: 1,
                pageSizeRight: 10,
                checkedRight: true,
                baseTempType: [],//添加医嘱大类表维护类型选择
                topInfo: {},
                centerInfo: {},
                isDefalult: false,
                canSave: true,
            }
            this.detailDeInput = React.createRef();
        }
        componentDidMount = () => {
            // 初始化设置table的高度以及表体的高度
            var x = document.querySelectorAll(".ant-table-body");
            for (var i = 0; i < x.length; i++) {
                x[0].style.height = store.getState().tableHeight.y + 14 + 'px';
                x[1].style.height = store.getState().tableHeight.y - 150 + 'px';
                x[i].style.overflow = "auto";
            }
            this.handleQuery()
            this.getHopSelect()
            this.getLocTypeSelect()
            this.getPublicLocSelect()
        }
        //获取医院下拉框
        getHopSelect = () => {
            let data = {
                params: [{
                    //   hospID:sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID:"",
                    logonGroupID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).groupID : "",
                    logonHospID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : "",
                }],
            }
            $http.post('urlS', this, {
                code: '01040001',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            hospArr: res.result
                        })
                    }
                }
            })
        }
        //获取科室类型下拉框
        getLocTypeSelect = () => {
            let data = {}
            data = {
                params: [{
                }],
            }
            $http.post('urlS', this, {
                code: '05100225',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0 && res.result.Data) {
                        let arr = res.result.Data && res.result.Data.map((item, index) => {
                            res.result.Data[index].key = Number(index)
                        })
                        this.setState({
                            locArr: res.result.Data
                        })
                    } else {

                    }
                }
            })
        }
        //获取公共科室下拉框 接收科室
        getPublicLocSelect = (hospID) => {
            let data = {}
            data = {
                params: [{
                    hospID: hospID && hospID ? hospID : "",
                }],
            }
            $http.post('urlS', this, {
                code: '01050029',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0 && res.result.Data) {
                        let arr = res.result.Data && res.result.Data.map((item, index) => {
                            res.result.Data[index].key = Number(index)
                        })
                        this.setState({
                            publicLocArr: res.result.Data,
                        })
                    } else {

                    }
                }
            })
        }
        getLast = (status, id) => {
            //定位到最后一条
            if (id) {
                let lastPage = Math.ceil((this.state.total + 1) / this.state.pageSize)
                this.setState({
                    page: lastPage,
                    rowId: id,
                })
                this.handleQuery(status)
                return
            }
        }
        againSearch = (status, values) => {
            this.setState({
                page: 1,
                search: "search"
            }, () => {
                this.handleQuery(status, values)
            })

        }
        //回车查找医嘱大类表维护数据
        handleQuery = (status, values) => {
            const { page, pageSize } = this.state
            let data = {}
            if (status) {
                this.setState({
                    checked: false
                })
            }
            let checkFlag = ""
            if (this.state.checked == true) {
                checkFlag = "Y"
            } else {
                checkFlag = "N"
            }
            data = {
                params: [{
                    code: values && values.code ? values.code : "",
                    descripts: values && values.descripts ? values.descripts : "",
                    ordTypeCode: values && values.bigType ? values.bigType : "",
                    status: status && status ? status : checkFlag,
                }],
                pagination: [{
                    pageSize: parseInt(pageSize),
                    currentPage: parseInt(page),
                }]
            }
            $http.post('urlS', this, {
                code: '05100199',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0 && res.result.Data) {
                        res.result.Data && res.result.Data.map((item, index) => {
                            res.result.Data[index].key = Number(index)
                            // return {
                            //     orderCatSeqNo: item.orderCatSeqNo,
                            //     orderCatID: item.orderCatID,
                            //     orderCatCode: item.orderCatCode,
                            //     orderCatDesc: item.orderCatDesc,
                            //     orderType: item.orderType,
                            //     orderStatus: item.orderStatus == "Y" ? "生效" : "失效",
                            //     key: Number(index),
                            // }
                        })
                        this.setState({
                            leftData: res.result.Data,
                            total: res.result.TotalCount
                        })
                    }
                    // if(res.result.Data&&res.result.Data.length==0&&res.result.TotalCount>0){
                    //     let prevPage = this.state.page - 1
                    //     this.onChange(prevPage, this.state.pageSize)
                    //   }
                }
            })
        }
        // 显示分页总条数
        showTotal(total) {
            return `共 ${total} 条`;
        }
        // // 修改page和pageSize 跳转至---
        // onChange = (e, ) => {
        //     this.setState({ page: e, pageSize: this.state.pageSize }, () => {
        //         // 重新调用查询方法
        //         this.handleQuery();
        //     })
        // }
        // 修改page和pageSize 跳转至---
        onChange = (page, pageSize) => {
            this.setState({ page: page, pageSize: pageSize }, () => {
                // 重新调用查询方法
                this.handleQuery();
            })
        }
        // // 页码改变的回调，参数是改变后的页码及每页条数
        // PageChange = (e, ) => {
        //     this.setState({ page: e, pageSize: this.state.pageSize }, () => {
        //         // 重新调用查询方法
        //         this.handleQuery();
        //     });
        // }
        // 页码改变的回调，参数是改变后的页码及每页条数
        PageChange = (page, pageSize) => {
            this.setState({ page: page, pageSize: pageSize, }, () => {
                // 重新调用查询方法
                this.handleQuery();
            });
        }
        //下拉选择页数
        onShowSizeChange = (page, pageSize) => {
            this.setState({ page: 1, pageSize: pageSize, search: "search" }, () => {
                // 重新调用查询方法
                this.handleQuery();
            })
        }
        // 调用子组件的连接事件 -- 右上基本信息
        OnChildrefs = (ref) => {
            this.child = ref
        }
        // 调用子组件的连接事件 -- 查询子类
        OnChild = (ref) => {
            this.childs = ref
        }
        //右侧
        // 显示分页总条数
        showTotalRight(total) {
            return `共 ${total} 条`;
        }
        // 修改page和pageSize 跳转至---
        onChangeRight = (page, pageSize) => {
            this.setState({ pageRight: page, pageSizeRight: pageSize }, () => {
                // 重新调用查询方法
                this.getBigLocData(this.state.rowId)
            })
        }
        //  // 修改page和pageSize 跳转至---
        //  onChangeRight = (page, pageSize) => {
        //     this.setState({ pageRight: page, pageSizeRight:pageSize }, () => {
        //         // 重新调用查询方法
        //         this.getBigLocData(this.state.rowId)
        //     })
        // }
        // // 页码改变的回调，参数是改变后的页码及每页条数
        PageChangeRight = (e,) => {
            this.setState({ pageRight: e, pageSizeRight: this.state.pageSizeRight }, () => {
                // 重新调用查询方法
                this.getBigLocData(this.state.rowId)
            });
        }
        // 页码改变的回调，参数是改变后的页码及每页条数
        // PageChangeRight = (page, pageSize) => {
        //     this.setState({ pageRight: page, pageSizeRight: pageSize }, () => {
        //         // 重新调用查询方法
        //         this.getBigLocData(this.state.rowId)
        //     });
        // }
        //下拉选择页数
        onShowSizeChangeRight = (page, pageSize) => {
            this.setState({ pageRight: 1, pageSizeRight: pageSize, searchRight: "search" }, () => {
                // 重新调用查询方法
                this.getBigLocData(this.state.rowId)
            })
        }



        //点击是否生效
        changeChecked = (e) => {
            this.setState({
                checked: e.target.checked,
                page: 1,
            }, () => {
                this.handleQuery()
            })
        }
        //点击是否生效 --右侧
        changeCheckedRight = (e) => {
            this.setState({
                checkedRight: e.target.checked,
                pageRight: 1,
                pageSizeRight: 10
            }, () => {
                this.getBigLocData(this.state.rowId)
            })
        }
        //根据医嘱大类ID获取医嘱大类接收科室
        getBigLocData = (orderCatID) => {
            const { pageRight, pageSizeRight } = this.state
            let data = {}
            data = {
                params: [{
                    orderCatID: orderCatID,
                    status: this.state.checkedRight == true ? "Y" : "N"
                }],
                pagination: [{
                    pageSize: pageSizeRight,
                    currentPage: pageRight,
                }]
            }
            $http.post('urlS', this, {
                code: '05100202',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0 && res.result.Data) {
                        res.result.Data.map((item, i) => {
                            res.result.Data.key == Number(i)
                        })
                        this.setState({
                            rightData: res.result.Data,
                            totalRight: res.result.TotalCount
                        })
                    }
                    // if(res.result.Data&&res.result.Data.length==0&&res.result.TotalCount>0){
                    //     let prevPage = this.state.page - 1
                    //     this.onChangeRight(prevPage, this.state.pageSize)
                    //   }
                }
            })
        }
        allClear = () => {
            this.setState({
                rowId: "",
                topInfo: {},
                orderCatID: ""
                //   ordShow:false
            });
            this.props.form.resetFields();
            this.child.initOrig()
        }
        //点击Row 左侧表格
        onClickRow = (record) => {
            return {
                onClick: () => {
                    this.setState({
                        orderCatID: record.orderCatID,
                        centerInfo: {},
                        rowIds: "",
                        isDefalult: false
                    })
                    this.child.initData(record)
                    if (record.orderCatID) {
                        if (this.state.rowId === "") {
                            this.setState({
                                rowId: record.orderCatID,
                                topInfo: record,
                                pageRight: 1,
                                searchRight: "search"
                            }, () => {
                                this.getBigLocData(record.orderCatID)
                            });

                        } else {
                            if (this.state.rowId !== record.orderCatID) {
                                this.setState({
                                    rowId: record.orderCatID,
                                    topInfo: record,
                                    pageRight: 1,
                                    searchRight: "search"
                                }, () => {
                                    this.handleRightCancel()
                                    this.getBigLocData(record.orderCatID)
                                });
                            } else {
                                this.setState({
                                    rowId: "",
                                    topInfo: {},
                                    orderCatID: "",
                                    pageRight: 1,
                                    searchRight: "search",
                                    totalRight: 0,
                                    //   ordShow:false
                                });
                                this.props.form.resetFields();
                                this.child.initOrig()
                            }
                        }
                    }
                },
                onDoubleClick: () => {
                    this.setState({
                        rowId: "",
                        topInfo: {},
                        orderCatID: "",
                        rightData: []
                    });
                    this.props.form.resetFields();
                    this.child.handletTopCancel()
                }
            };
        }
        //返回添加状态
        initOrigin = () => {
            this.setState({
                rowId: "",
                rowIds: "",
                orderCatID: "",
                isDefalult: false,
                centerInfo: {},
                rightData: []
            })
            this.props.form.resetFields()
        }
        //设置点击row颜色 --左侧表格
        setRowClassName = (record) => {
            return record.orderCatID === this.state.rowId ? 'clickRowStyle' : '';
        }

        //点击是否设置为默认
        handleSwithChange = (v) => {
            this.setState({
                isDefalult: v
            })
        }
        //是否默认
        onChangeSwith = (v, record) => {
            let data = {}
            data = {
                params: [{
                    updateUserID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
                    defaultFlag: v == true ? "Y" : "N",
                    orderCatRecLocID: record.orderCatRecLocID,
                }],
            }
            $http.post('urlS', this, {
                code: '05100203',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        message.success("设置成功")
                        this.setState({
                            isDefalult: v,
                            centerInfo: record,
                            rowIds: record.orderCatRecLocID,
                        })
                        this.getBigLocData(this.state.orderCatID)
                    }
                }
            })
        }
        //点击右侧表格行
        onClickRightRow = (record) => {
            const { rightData } = this.state
            return {
                onClick: () => {
                    this.setState({
                        centerInfo: {},
                        isDefalult: false,
                        hosID: record.hospitalID,
                        locID: record.locTypeID,
                    }, () => {
                        this.getPublicBaseLocSelect()
                        this.getPublicLocSelect(record.recHospID)//接收科室
                    })
                    if (record.orderCatRecLocID) {
                        if (this.state.rowIds === "") {
                            this.setState({
                                rowIds: record.orderCatRecLocID,
                                centerInfo: record,
                                isDefalult: record.defaultFlag == "Y" ? true : false
                            });
                            //   this.getBigLocData(record.orderCatID)
                        } else {
                            if (this.state.rowIds !== record.orderCatRecLocID) {
                                this.setState({
                                    rowIds: record.orderCatRecLocID,
                                    centerInfo: record,
                                    isDefalult: record.defaultFlag == "Y" ? true : false
                                });
                                // this.getBigLocData(record.orderCatID)
                            } else {
                                this.setState({
                                    rowIds: "",
                                    centerInfo: {},
                                    isDefalult: false
                                    //   ordShow:false
                                });
                                this.props.form.resetFields()
                                // this.props.form.resetFields();
                            }
                        }
                    }
                },
            }
        }
        //医院
        handleBaseHosp = (id) => {
            this.props.form.setFieldsValue({ getOpenLoc: undefined })
            if (id) {
                this.setState({
                    hosID: id
                }, () => {
                    this.getPublicBaseLocSelect()
                })
            } else {
                this.setState({
                    hosID: "",
                    publicBaseLocArr: []
                }, () => {
                    this.getPublicBaseLocSelect()
                })
            }

        }
        //科室类型
        handleBaseLoc = (id) => {
            this.props.form.setFieldsValue({ getOpenLoc: undefined })
            if (id) {
                this.setState({
                    locID: id
                }, () => {
                    this.getPublicBaseLocSelect()
                })
            } else {
                this.setState({
                    locID: "",
                    publicBaseLocArr: []
                }, () => {
                    this.getPublicBaseLocSelect()
                })
            }


        }
        //获取开单科室下拉框
        getPublicBaseLocSelect = () => {
            let data = {}
            data = {
                params: [{
                    hospID: this.state.hosID || "",
                    locTypeID: this.state.locID || ""
                }],
            }
            $http.post('urlS', this, {
                code: '01050029',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0 && res.result.Data) {
                        let arr = res.result.Data && res.result.Data.map((item, index) => {
                            res.result.Data[index].key = Number(index)
                        })
                        this.setState({
                            publicBaseLocArr: res.result.Data,
                        })
                    } else {

                    }
                }
            })
        }
        //点击右侧接收医院选项过滤接收科室
        handleHosp = (e, id) => {
            this.props.form.setFieldsValue({ getLoc: undefined })
            this.getPublicLocSelect(id)
        }
        setRowClassNames = (record) => {
            return record.orderCatRecLocID === this.state.rowIds ? 'clickRowStyle' : '';

        }
        handleLeftOk = () => {
            this.props.form.validateFields((err, values) => {

            })
        }
        handleRightCancel = () => {
            this.setState({
                centerInfo: {}
            })
            this.props.form.resetFields()
        }
        handleRightOk = () => {
            this.props.form.validateFields((err, values) => {
                if (!err) {
                    let data = {}
                    if (this.state.rowIds) {
                        data = {
                            params: [{
                                updateUserID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
                                defaultFlag: this.state.isDefalult == true ? "Y" : "N",
                                orderCatRecLocID: this.state.rowIds || "",
                                orderCatID: this.state.rowId || "",
                                hospitalID: values.getHop || "",
                                recHospID: values.recHospID || "",
                                locTypeID: values.getLocType || "",
                                locID: values.getOpenLoc || "",
                                recLocID: values.getLoc || "",
                                startDate: values.getDateFrom ? moment(values.getDateFrom).format('YYYY-MM-DD') : "",
                                stopDate: values.getDateTo ? moment(values.getDateTo).format('YYYY-MM-DD') : "",
                            }],
                        }
                    } else {
                        data = {
                            params: [{
                                updateUserID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
                                defaultFlag: this.state.isDefalult == true ? "Y" : "N",
                                orderCatID: this.state.rowId,
                                orderCatRecLocID: this.state.rowIds || "",
                                hospitalID: values.getHop,
                                recHospID: values.recHospID,
                                locTypeID: values.getLocType,
                                locID: values.getOpenLoc,
                                recLocID: values.getLoc,
                                startDate: values.getDateFrom ? moment(values.getDateFrom).format('YYYY-MM-DD') : "",
                                stopDate: values.getDateTo ? moment(values.getDateTo).format('YYYY-MM-DD') : "",
                            }],
                        }
                    }
                    $http.post('urlS', this, {
                        code: '05100203',
                        data: data,
                        success: function (res) {
                            if (+res.errorCode === 0) {
                                if (this.state.rowIds) {
                                    message.success("修改成功")
                                    if ((values.getDateFrom && values.getDateFrom) && (values.getDateTo && values.getDateTo)) {
                                        if (moment(values.getDateTo).format('YYYYMMDD') < moment().format('YYYYMMDD')) {
                                            this.setState({
                                                checkedRight: false,
                                            })
                                            this.getBigLocData(this.state.rowId)
                                            return
                                        }
                                    }
                                    this.setState({
                                        checkedRight: true,
                                    })
                                    this.getBigLocData(this.state.rowId)
                                } else {
                                    message.success("添加成功")
                                    this.props.form.resetFields()
                                    //定位到最后一条
                                    let lastPage = Math.ceil((this.state.totalRight + 1) / this.state.pageSizeRight)
                                    this.setState({
                                        pageRight: lastPage,
                                        // rowIds:res.newID,
                                        isDefalult: false,
                                        orderCatID: this.state.rowId
                                    })
                                    if ((values.getDateFrom && values.getDateFrom) && (values.getDateTo && values.getDateTo)) {
                                        if (moment(values.getDateTo).format('YYYYMMDD') < moment().format('YYYYMMDD')) {
                                            this.setState({
                                                checkedRight: false,
                                            })
                                            this.getBigLocData(this.state.rowId)
                                            return
                                        }
                                    }
                                    this.setState({
                                        checkedRight: true,
                                        orderCatID: this.state.rowId
                                    })
                                    this.getBigLocData(this.state.rowId)
                                }
                            }
                        }
                    })
                }
            })
        }
        canSave = (id) => {
            this.setState({
                canSave: false,
                orderCatID: id
            })
        }
        handleTemDaCancel = () => {
            this.setState({
                OrdDaShow: false
            })
        }
        //删除医嘱大类
        handleDelete = (e, record) => {
            let data = {}
            data = {
                params: [{
                    updateUserID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
                    orderCatID: record.orderCatID,
                }],
            }
            $http.post('urlS', this, {
                code: '05100201',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        message.success("删除成功")
                        this.initOrigin()
                        this.handleQuery();
                    }
                }
            })
        }
        //删除医嘱大类接收科室
        delate = (e, record) => {
            let data = {}
            data = {
                params: [{
                    updateUserID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
                    orderCatRecLocID: record.orderCatRecLocID,
                }],
            }
            $http.post('urlS', this, {
                code: '05100204',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        message.success("删除成功")
                        this.getBigLocData(this.state.rowId)
                    }
                }
            })
        }
        //初始化信息
        initData = () => {
            this.setState({
                isMod: -1,
                ordShow: false,
                tempChildDis: false
            })
            this.props.form.setFieldsValue({ docMesName: undefined });
            this.props.form.setFieldsValue({ othName: undefined });
            this.props.form.setFieldsValue({ docMesType: undefined });
        }
        //点击添加/修改医嘱大类表维护弹窗取消按钮
        handleCancel = () => {
            this.setState({
                visible: false
            })
            this.initData()
        }

        render() {
            //左侧查询数据表
            const leftDetailColumns = [
                {
                    align: "center",
                    title: '序号',
                    dataIndex: 'orderCatSeqNo',
                    key: '1',
                    width: '100px',

                },
                {
                    align: "center",
                    width: '100px',
                    title: '代码',
                    dataIndex: 'orderCatCode',
                    key: '2',
                }, {
                    align: "center",
                    width: '100px',
                    title: '描述',
                    dataIndex: 'orderCatDesc',
                    key: '3',
                }, {
                    align: "center",
                    width: '160px',
                    title: '开医嘱类型',
                    dataIndex: 'orderType',
                    key: '4',
                    render: (value, row, index) => {
                        if (value == "D") {
                            return "医生开嘱"
                        } if (value == "N") {
                            return "护士开嘱"
                        } if (value == "F") {
                            // return "自定价医嘱"
                            return "--"
                        }
                        return "--"
                    },
                }, {
                    align: "center",
                    width: '100px',
                    title: '状态',
                    dataIndex: 'status',
                    key: '5',
                    render: (value, row, index) => {
                        if (value == "Y") {
                            return "生效"
                        } else {
                            return "失效"
                        }

                    },
                },
                {
                    align: "center",
                    width: '160px',
                    title: '操作',
                    dataIndex: 'createdAt',
                    key: '6',
                    render: (value, row, index) => {
                        return (
                            <span>
                                <Popconfirm title="删除不可恢复，你确定要删除吗?" onCancel={this.handlePopconfirm} onConfirm={(e) => this.handleDelete(e, row)} >
                                    <span className='span' style={{ cursor: "pointer", color: 'rgba(240,65,52,1)' }}>删除</span>
                                </Popconfirm>
                            </span>
                        )
                    },
                },
            ];
            //右侧接收科室表格
            const rightColumns = [
                {
                    align: "center",
                    title: '医院',
                    dataIndex: 'hospitalDec',
                    key: '0',
                    editable: true,
                    render: (text, record, index) => {
                        return text;
                    },
                }, {
                    align: "center",
                    title: '科室类型',
                    dataIndex: 'locTypeDesc',
                    key: '1',
                    editable: true,
                    render: (text, record, index) => {
                        return text;
                    },
                }, {
                    align: "center",
                    title: '开单科室',
                    dataIndex: 'locDesc',
                    key: '2',
                    editable: true,
                    render: (text, record, index) => {
                        return text;
                    },
                }, {
                    align: "center",
                    title: '接收医院',
                    dataIndex: 'recHospDesc',
                    key: '7',
                    editable: true,
                    render: (text, record, index) => {
                        return text;
                    },
                }, {
                    align: "center",
                    title: '接收科室',
                    dataIndex: 'recLocDesc',
                    key: '3',
                    editable: true,
                    render: (text, record, index) => {
                        return text;
                    },
                }, {
                    align: "center",
                    title: '状态',
                    dataIndex: 'status',
                    key: '4',
                    editable: true,
                    render: (value, row, index) => {
                        if (value == "Y") {
                            return (
                                "生效"
                            )
                        } else {
                            return (
                                "失效"
                            )
                        }
                    },
                }, {
                    align: "center",
                    title: '默认',
                    dataIndex: 'defaultFlag',
                    key: '5',
                    editable: true,
                    render: (text, record, index) => {
                        return (
                            <Switch checkedChildren="是" unCheckedChildren="否" checked={record.defaultFlag == "Y" ? true : false} onChange={(v) => { this.onChangeSwith(v, record) }} />
                        )
                    },
                },
                {
                    title: '操作',
                    dataIndex: '',
                    key: '6',
                    align: "center",
                    width: 200,
                    render: (text, record, index) => {
                        return (
                            <span>
                                <Popconfirm title="删除不可恢复，你确定要删除吗?" onCancel={this.handlePopcon} onConfirm={(e) => this.delate(e, record)} >
                                    <span className='span' style={{ cursor: "pointer", color: 'rgba(240,65,52,1)' }}>删除</span>
                                </Popconfirm>
                            </span>
                        )


                    }
                }
            ];
            const { getFieldDecorator } = this.props.form;
            let { plainOptions, baseParentType, baseTempType, baseUnit, tempChildDis, OrdDaShow, topInfo, centerInfo } = this.state
            //医院
            let hosOp = []
            let BaseHosOp = []
            this.state.hospArr && this.state.hospArr.map(item => {
                hosOp.push(<Option key={item.id} onClick={(e,) => this.handleHosp(e, item.id)} value={String(item.id)}>{item.descripts}</Option>)
                BaseHosOp.push(<Option key={item.id} onClick={() => this.handleBaseHosp(item.id)} value={String(item.id)}>{item.descripts}</Option>)
            })
            //科室类型
            let locOp = []
            this.state.locArr && this.state.locArr.map(item => {
                locOp.push(<Option key={item.id} onClick={() => this.handleBaseLoc(item.id)} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //开单类型
            let openLocOp = []
            this.state.publicBaseLocArr && this.state.publicBaseLocArr.map(item => {
                openLocOp.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            //接收类型
            let getLocOp = []
            this.state.publicLocArr && this.state.publicLocArr.map(item => {
                getLocOp.push(<Option key={item.id} role={item.descripts + '^' + item.descriptsSPCode} title={item.descripts} value={String(item.id)}>{item.descripts}</Option>)
            })
            return (
                <div>
                    <Row gutter={60} className="majorCategoriesDom" style={{ marginRight: "0" }}>
                        <Col span={9} style={{ paddingRight: "0" }}>
                            <Card title="医嘱大类列表" bordered={false} style={{ marginRight: "4px", }} className="titleDom">
                                {/* <Row>
                                    <Col span={6} style={{ position: "absolute", right: "-20px", top: "-52px" }}>
                                        <FormItem >
                                            {getFieldDecorator('addCategories', {
                                                initialValue: undefined,
                                                rules: [{ required: false, message: '' }],
                                            })(
                                                <Checkbox checked={this.state.checked} onChange={this.changeChecked}>仅显示生效</Checkbox>
                                            )}
                                        </FormItem>
                                    </Col>
                                </Row> */}
                                <FindMajor allClear={this.allClear} FindMajorTable={this.againSearch} OnChild={this.OnChild}></FindMajor>
                                <Table
                                    className="components-table-demo-nested"
                                    columns={leftDetailColumns}
                                    pagination={false}
                                    bordered
                                    rowClassName={this.setRowClassName}
                                    onRow={this.onClickRow}
                                    rowKey={record => record.key}
                                    dataSource={this.state.leftData}
                                    style={{
                                        height: store.getState().tableHeight.y + 44 + 'px',
                                        overflow: "auto"
                                    }}
                                />
                                <CommonPagination size={this.state.size} page={this.state.page} pageSize={this.state.pageSize} current={this.state.page} total={this.state.total} search={this.state.search}
                                    onShowSizeChange={this.onShowSizeChange.bind(this)} complete={true} dataSource={this.state.leftData}
                                    onChange={this.PageChange.bind(this)} />

                                {/* {
                                    this.state.leftData && this.state.leftData.length > 0 ? <Pagination
                                        size="small"
                                        showQuickJumper
                                        showSizeChanger
                                        defaultCurrent={1}
                                        current={this.state.page}
                                        total={this.state.total}
                                        onChange={this.PageChange}
                                        onRow={this.selectID}
                                        onShowSizeChange={this.onShowSizeChange}
                                        style={{ textAlign: "right", marginTop: '10px' }}
                                        showTotal={() => this.showTotal(this.state.total)}
                                    /> : ""
                                } */}

                            </Card>
                        </Col>
                        <Col span={14} style={{ paddingLeft: "6px", paddingRight: "0" }}>
                            <Card title={this.state.orderCatID && this.state.orderCatID ? "编辑医嘱大类" : "添加医嘱大类"} bordered={false} className="moreInfoCard titleDom" style={{ paddingRight: "0" }}>
                                <div >
                                    <BaseInformation canSave={this.canSave} topInfo={topInfo} OnChildrefs={this.OnChildrefs} updataTable={this.handleQuery} getLast={this.getLast} initOrigin={this.initOrigin}></BaseInformation>
                                </div>
                                <p className="titleDom"> {this.state.rowIds && this.state.rowIds ? "编辑接收科室" : "添加接收科室"}</p>
                                <div>
                                    <Form>
                                        <Row gutter={60}>
                                            <Col span={5} style={paddRightCol}>
                                                <FormItem {...formItemLayoutType} label='医院'>
                                                    {getFieldDecorator('getHop', {
                                                        initialValue: centerInfo.hospitalID && centerInfo.hospitalID ? String(centerInfo.hospitalID) : undefined,
                                                        rules: [{ required: true, message: '请选择医院' }],
                                                    })(
                                                        <Select
                                                            allowClear
                                                            onChange={this.handleBaseHosp}
                                                        >
                                                            {BaseHosOp}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} style={paddRightCol}>
                                                <FormItem {...formItemLayoutType} label='科室类型'>
                                                    {getFieldDecorator('getLocType', {
                                                        initialValue: centerInfo.locTypeID && centerInfo.locTypeID ? centerInfo.locTypeID : undefined,
                                                        rules: [{ required: false, message: '' }],
                                                    })(
                                                        <Select
                                                            onChange={this.handleBaseLoc}
                                                            allowClear={true}
                                                            showSearch={true}
                                                            optionFilterProp="role"
                                                        >
                                                            {locOp}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} style={paddRightCol}>
                                                <FormItem {...formItemLayoutType} label='开单科室'>
                                                    {getFieldDecorator('getOpenLoc', {
                                                        initialValue: centerInfo.locID && centerInfo.locID ? centerInfo.locID : undefined,
                                                        rules: [{ required: false, message: '' }],
                                                    })(
                                                        <Select
                                                            onSelect={this.handleStatus}
                                                            allowClear
                                                            showSearch={true}
                                                            optionFilterProp="role"
                                                        >
                                                            {openLocOp}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} style={paddRightCol}>
                                                <FormItem label="设为默认" {...formItemLayoutType}>
                                                    {getFieldDecorator('isDefalult', {
                                                        initialValue: undefined,
                                                        rules: [{ required: false, message: '' }],
                                                    })(
                                                        <Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.isDefalult} onChange={(val) => this.handleSwithChange(val)} />
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={2} style={{ lineHeight: "38px" }}>
                                                <Button key="submitc" type="primary" disabled={this.state.canSave && this.state.rowId == ""} onClick={this.handleRightCancel}>清空</Button>
                                            </Col>
                                        </Row>
                                        <Row gutter={60}>
                                            <Col span={5} style={paddRightCol}>
                                                <FormItem {...formItemLayoutType} label='接收医院'>
                                                    {getFieldDecorator('recHospID', {
                                                        initialValue: centerInfo.recHospID && centerInfo.recHospID ? String(centerInfo.recHospID) : undefined,
                                                        rules: [{ required: true, message: '请选择接收医院' }],
                                                    })(
                                                        <Select
                                                            onSelect={this.handleStatus}
                                                        >
                                                            {hosOp}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} style={paddRightCol}>
                                                <FormItem {...formItemLayoutType} label='接收科室'>
                                                    {getFieldDecorator('getLoc', {
                                                        initialValue: centerInfo.recLocID && centerInfo.recLocID ? centerInfo.recLocID : undefined,
                                                        rules: [{ required: true, message: '请选择接收科室' }],
                                                    })(
                                                        <Select
                                                            onSelect={this.handleStatus}
                                                            allowClear={true}
                                                            showSearch={true}
                                                            optionFilterProp="role"
                                                        >
                                                            {getLocOp}
                                                        </Select>
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} style={paddRightCol}>
                                                <FormItem label='生效日期' {...formItemLayoutType}>
                                                    {getFieldDecorator('getDateFrom', {
                                                        initialValue: centerInfo.startDate ? moment(centerInfo.startDate, "YYYY-MM-DD") : moment(),
                                                        rules: [{ required: true, message: '请选择生效日期' }],
                                                    })(
                                                        <DatePicker style={{ width: '100%' }} placeholder={'生效日期'} disabledDate={(curDate) => {
                                                            return curDate && curDate > moment().endOf('day');
                                                        }} />
                                                    )}
                                                </FormItem>
                                            </Col>
                                            <Col span={5} style={paddRightCol}>
                                                <FormItem label='失效日期' {...formItemLayoutType}>
                                                    {getFieldDecorator('getDateTo', {
                                                        initialValue: centerInfo.stopDate ? moment(centerInfo.stopDate, "YYYY-MM-DD") : undefined,
                                                        rules: [{ required: false, message: '' }],
                                                    })(
                                                        <DatePicker style={{ width: '100%' }} placeholder={'失效日期'} />
                                                    )}
                                                </FormItem>
                                            </Col >
                                            <Col span={2} style={{ lineHeight: "38px" }}>
                                                <Button key="submits" type="primary" disabled={this.state.canSave && this.state.rowId == ""} onClick={this.handleRightOk}>保存</Button>
                                            </Col>
                                        </Row>
                                    </Form>
                                </div>
                                <Col span={24} style={{ padding: "0" }}>
                                    <Checkbox checked={this.state.checkedRight} disabled={this.state.rowId == ""} onChange={this.changeCheckedRight} style={{ marginRight: "50px", float: "right" }}>仅显示生效</Checkbox>
                                </Col>
                                <Table
                                    columns={rightColumns}
                                    pagination={false}
                                    bordered
                                    rowClassName={this.setRowClassNames}
                                    onRow={this.onClickRightRow}
                                    dataSource={this.state.orderCatID && this.state.orderCatID ? this.state.rightData : []}
                                    className="clearBackground"
                                    style={{
                                        height: store.getState().tableHeight.y - 113 + 'px'
                                    }}
                                />
                                <CommonPagination size={this.state.sizeRight} page={this.state.pageRight} current={this.state.pageRight} total={this.state.totalRight} search={this.state.searchRight}
                                    onShowSizeChange={this.onShowSizeChangeRight.bind(this)} complete={true} dataSource={this.state.rightData}
                                    onChange={this.PageChangeRight.bind(this)} />                            </Card>
                        </Col>
                    </Row>
                </div>
            )
        }
    })
export default MajorCategoriesOfMedicalAdvice