//申请单录入自定义分类设置
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 } from 'antd';
import { $http } from '../../containers/config/https';
import store from '../../store';
import './css/OrderTemple.less';
import './css/ApplicationSetting.less';
import { Util } from 'tools/index';
import CommonPagination from 'components/pagination/index';

const renderContent = function (value, row, index) {
  const obj = {
    children: value,
    props: {},
  };
  if (!row.ordTempletDesc) {
    obj.props.colSpan = 0;
  }
  return obj;
};

const formItemLayout = { // label 和input宽度
  labelCol: { span: 9 },
  wrapperCol: { span: 12 }
}

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

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


        searchCategoryName: "",//输入左侧搜索分类名称
        checkAll: false,//左侧全选
        checkedList: [],//左侧可选项
        plainOptions: [],
        rightTopTableData: [],//右上小表格数据
        cbiD: "",//自定义分类 区分触发场景
        // hbiD:"",//子级id
        radioValue: "",//
        rowRightId: "",//右上小表格选中
        leftInfo: {},//左侧信息回显
        rightSearchInfo: "",//右侧搜索
        canDeleteStatus: true,//能否点击删除
        Atext: "",
        Btext: "",
        Ctext: "",
        search: "",
        size: "small",
        medCatID: "",
        childID: "",//二级id
        fID: "",//选择父级下拉框
        faID: "",
        cID: "",//子级
        mainCode: "",
        fcID: ""
      }
      this.detailDeInput = React.createRef();
    }
    componentDidMount = () => {
      // 初始化设置table的高度以及表体的高度
      var x = document.querySelectorAll('.ant-table-body')
      x[1].style.height = store.getState().tableHeight.y + 'px';
      this.handleQuery()
      // this.getParentSelect()
      this.getRadio()
    }
    //获取radio
    getRadio = () => {
      let data = {}
      data = {
        params: [{
          CBid: "",
        }],
      }
      $http.post('urlS', this, {
        code: '03010003',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0) {
            this.setState({
              plainOptions: res.data,
              // baseTempType:res.orderTemplItemType,
              // baseUnit:res.unit
            })
          }
        }
      })
    }
    //获取上级分类下拉框
    getParentSelect = (CBid) => {
      let data = {}
      data = {
        params: [{
          CBid: CBid ? CBid : "",
          hospID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : "",
        }],
      }
      $http.post('urlS', this, {
        code: '03010005',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0) {
            this.setState({
              baseParentType: res.data,
              // baseTempType:res.orderTemplItemType,
              // baseUnit:res.unit
            })
          }
        }
      })
    }
    //获取左侧搜索输入框值
    changeInfo = (e) => {
      this.setState({
        searchCategoryName: e.target.value
      })
    }
    //回车查找分类设置数据
    handleQuery = (Cbid) => {
      // console.log("Cbid",Cbid)
      let data = {}
      data = {
        params: [{
          hospID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : "",
          CBid: Cbid || "",
          searchCode: this.state.searchCategoryName,
        }],
      }
      $http.post('urlS', this, {
        code: '03010004',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0 && res.data) {
            let newOpen = []
            let arr = res.data && res.data.map((item, index) => {
              res.data[index].key = Number(index)
              newOpen.push(Number(index))
              return {
                id: item.CBid,
                descripts: item.descripts,
                code: item.mainCode,
                key: Number(index),
                children: item.children && item.children.map((childItem, childIndex) => {
                  return {
                    key: childItem.code,
                    mainID: item.CBid,
                    mainCode: item.mainCode,
                    ...childItem,
                    children: childItem.children && childItem.children.map((childI, childIndex) => {
                      return {
                        mainID: item.CBid,
                        key: childI.code,
                        mainCode: item.mainCode,
                        ...childI,
                      }
                    })
                  }
                })
              }
            })
            this.setState({
              newOpen,
              leftData: arr,
              text: arr[0],
              findInfo: res.data && res.data.length == 0 ? '未查询到满足条件的病人信息，请核对信息' : ''
            })
            // console.log(newOpen)
          } else {

          }
        }
      })
    }
    //添加分类设置弹出
    openDocMes = () => {
      this.props.form.setFieldsValue({ overTime: undefined, })
      this.setState({
        isMod: -1,
        visible: true
      })
      this.getParentSelect(this.state.faID,)
    }
    onSelectOp = (item, id) => {
      this.setState({
        fcID: id
      })
      if (item.CBid) {
        this.setState({
          fID: id,
          cID: "",
        })
      } else {
        this.setState({
          fID: "",
          cID: id
        })
      }
    }
    //点击添加/修改分类设置弹窗确认按钮
    handleOk = (e) => {
      this.props.form.validateFields((err, values) => {
        if (!err) {
          let data = {}
          data = {
            params: [{
              id: this.state.isMod == 1 ? this.state.ordTempletID : "",
              CBid: this.state.fID || "",
              HBid: this.state.cID || "",
              userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
              hospID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : "",
              code: values.docMesName,
              descripts: values.othName,
              printModel: values.application || "",
              startDate: moment(moment()).format('YYYY-MM-DD'),
              stopDate: ""
            }],
          }
          $http.post('urlS', this, {
            code: '03010006',
            data: data,
            success: function (res) {
              if (+res.errorCode === 0) {
                if (this.state.isMod == 1) {
                  message.success("修改成功")
                  this.initData()
                } else {
                  message.success("新建成功")
                  this.initData()
                }
                this.setState({
                  visible: false,
                  // cbiD:""
                })
                this.handleQuery()

              } else {

              }
            }
          })
        }
      })
    }
    //点击Row 左侧表格
    onClickRow = (record) => {
      return {
        onClick: () => {
          // console.log("--",record)
          if (record.id) {
            // console.log("1",record)
            if (this.state.rowId === "") {
              this.setState({
                rowId: record.id,
                faID: record.id,
                childID: "",
                cbiD: record.id,
                Atext: record.descripts,
                selectedRowKeys_right: [],
                rightData: [],
                rightTopTableData: [],
              });
              this.props.form.setFieldsValue({ "projectUnitPrice": undefined, "specification": undefined })
            } else {
              if (this.state.rowId !== record.id) {
                this.setState({
                  rowId: record.id,
                  faID: record.id,
                  childID: "",
                  Atext: record.descripts,
                  cbiD: record.id,
                  selectedRowKeys_right: [],
                  rightData: [],
                  rightTopTableData: []
                });
                this.props.form.setFieldsValue({ "projectUnitPrice": undefined, "specification": undefined })
              } else {
                this.setState({
                  rowId: "",
                  // Cbid:"",
                  cbiD: "",
                  Atext: "",
                  selectedRowKeys_right: [],
                  rightData: [],
                  rightTopTableData: []
                });
                this.props.form.setFieldsValue({ "projectUnitPrice": undefined, "specification": undefined })
              }
            }
          }
          if (record.HBid) {
            // console.log("2",record)
            if (this.state.rowId === "") {
              this.setState({
                rowId: record.HBid,
                childID: record.HBid,
                mainCode: record.mainCode,
                faID: record.mainID,
                cbiD: "",
                Atext: record.breadcrumb,
                selectedRowKeys_right: [],
              });
              this.getRightDeatil(record.HBid)
            } else {
              if (this.state.rowId !== record.HBid) {
                this.setState({
                  rowId: record.HBid,
                  childID: record.HBid,
                  mainCode: record.mainCode,
                  faID: record.mainID,
                  cbiD: "",
                  Atext: record.breadcrumb,
                  selectedRowKeys_right: [],
                  rightTopTableData: []
                });
                this.getRightDeatil(record.HBid)
                this.props.form.setFieldsValue({ "projectUnitPrice": undefined, "specification": undefined })
              } else {
                this.setState({
                  rowId: "",
                  mainCode: "",
                  faID: "",
                  cbiD: "",
                  childID: "",
                  Atext: "",
                  selectedRowKeys_right: [],
                  rightData: [],
                  rightTopTableData: []
                });
                this.props.form.setFieldsValue({ "projectUnitPrice": undefined, "specification": undefined })
              }
            }
          }
        },
        onDoubleClick: () => {

        }
      };
    }
    getRightDeatil = (HBid) => {
      let data = {}
      data = {
        params: [{
          searchCode: "",
          HBid: HBid,
        }],
      }
      $http.post('urlS', this, {
        code: '03010010',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0 && res.data) {
            // console.log("获取分类设置明细信息",res)
            // for (var i = 0; i < res.result.length; i++) {
            //   res.result[i].key = res.result[i].ordTempletDetailID
            //   this.setState({
            //     rightUnitDr:res.result[i].ordTempletDetailQtyUnitDr,
            //     selectedRowKeys_right:[]
            //   })
            // }
            if (!Util.isEmpty(res.data)) {
              var data = res.data
              for (var i = 0; i < data.length; i++) {
                data['key'] = i
              }
            }
            this.setState({
              rightData: res.data
            })

          }
        }
      })
    }
    //设置点击row颜色 --左侧表格
    setRowClassName = (record) => {
      if (record.id === this.state.rowId) {
        return 'clickRowStyle'
      } else if (record.HBid === this.state.rowId) {
        return 'clickRowStyle'
      } else {
        return ''
      }
    }
    //点击右侧表格行
    onClickRightRow = (record) => {
      const { rightData } = this.state
      return {
        onClick: () => {
          this.setState({
            initRored: record
          })
          if (this.state.selectrow === "") {
            this.setState({
              selectrow: record.ordTempletDetailID,
            }, () => {
            });
          } else {
            if (this.state.selectrow !== record.ordTempletDetailID) {
              this.setState({
                // selectrow: record.ordTempletDetailID,
              }, () => {
              });
            } else {
              this.setState({
                selectrow: "",
              });
            }
          }
        },
      }
    }
    setRowClassNames = (record) => {
      return (("^" + this.state.selectedRowKeys_right.join("^") + "^").indexOf("^" + record.ordTempletDetailID + "^") > -1) ? 'clickRowStyle' : '';
      // return record.ordTempletDetailTemplItemTypeID === this.state.selectedRowKeys_right ? 'clickRowStyle' : '';
    }
    //编辑分类设置
    editDocMes = (data, num) => {
      if (num == "1") {
        console.log("data", data)
        this.props.form.resetFields()
        this.props.form.setFieldsValue({ docMesName: data.code, othName: data.descripts, application: data.printModel });
        this.props.form.setFieldsValue({});
        this.props.form.setFieldsValue({})
        this.setState({
          isMod: 1,
          visible: true,
          ordTempletID: data.HBid,
        })
        if (!data.ordTempletChildFlag == "Y") {
          this.setState({
            tempChildDis: true
          })
        }
      } else {
        //删除分类设置
        let arr = []
        arr.push(data.HBid)
        let datas = {}
        datas = {
          params: [{
            userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
            id: arr,
          }],
        }
        $http.post('urlS', this, {
          code: '03010007',
          data: datas,
          success: function (res) {
            if (+res.errorCode === 0) {
              message.success("删除成功");
              this.handleQuery()
            }
          }
        })
      }
    }
    //输入 医嘱项查询
    changeRightSearch = (e) => {
      this.setState({
        rightSearchInfo: e.target.value
      })
    }
    //查询 医嘱项模板
    handleRightSearch = () => {
      let data = {
        params: [{
          searchCode: this.state.rightSearchInfo,
          HBid: this.state.rowId
        }]
      }
      $http.post('urlS', this, {
        code: '03010010',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0) {
            if (!Util.isEmpty(res.data)) {
              var data = res.data
              for (var i = 0; i < data.length; i++) {
                data['key'] = i
              }
            }
            this.setState({
              rightData: res.data
            })
          }
        }
      })
    }
    //删除医嘱项模板 单个   ---右下表格
    delate = (e, key, record) => {
      let arr = []
      arr.push(record.id)
      let data = {
        params: [{
          userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
          id: arr
        }]
      }
      $http.post('urlS', this, {
        code: '03010009',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0) {
            message.success('删除成功');
            this.setState({
              selectedRowKeys_right: [],
              // btnStatus:true,
              // canDeleteStatus:true
            })
            this.getRightDeatil(this.state.rowId)
          }
        }
      })
    }

    //删除医嘱项模板 多选   ---右下表格
    handleDetele = () => {
      const { selectedRow_right } = this.state
      let arr = []
      if (selectedRow_right && selectedRow_right.length > 0) {
        selectedRow_right.map(item => {
          arr.push(item.id)
        })
        let data = {
          params: [{
            userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
            id: arr
          }]
        }
        $http.post('urlS', this, {
          code: '03010009',
          data: data,
          success: function (res) {
            if (+res.errorCode === 0) {
              message.success('删除成功');
              this.setState({
                selectedRowKeys_right: [],
                // btnStatus:true,
                // canDeleteStatus:true
              })
              //获取分类设置明细
              this.getRightDeatil(this.state.rowId)
            }
          },
          error: function (error) {
            message.error('删除失败：' + error);
          }
        })
      }
    }
    openTemp = (data) => {
      this.setState({
        ordTempId: data
      })
    }
    // 显示分页总条数
    showTotal(total) {
      return `共 ${total} 条`;
    }
    // 修改page和pageSize 跳转至---
    onChange = (page, pageSize) => {
      this.setState({ page: page, pageSize: this.state.pageSize }, () => {
        // 重新调用查询方法
        this.searchRightDetail();
      })
    }
    //下拉选择页数
    onShowSizeChange = (page, pageSize) => {
      this.setState({ page: 1, pageSize: pageSize }, () => {
        // 重新调用查询方法
        this.searchRightDetail("search");
      })
    }
    handleTemDaCancel = () => {
      this.setState({
        OrdDaShow: false
      })
    }
    //初始化信息
    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()
    }

    //左侧全选
    onCheckAllChange = e => {
      this.setState({
        checkedList: e.target.checked ? this.state.plainOptions : [],
        indeterminate: false,
        checkAll: e.target.checked,
      });
    };
    //左侧单选
    // onChange = checkedList => {
    //   console.log("checkedList",checkedList)
    //   this.setState({
    //     checkedList,
    //     checkAll: checkedList.length === this.state.plainOptions.length,
    //   });
    // };

    radioOnChange = e => {
      this.setState({
        radioValue: e.target.value,
      }, () => {
        this.handleQuery(e.target.value)
      });
    }
    findApp = () => {
      this.handleQuery()
    }
    //右侧搜索项目名称 规格
    searchRightDetail = (e) => {
      const { pageSize, page } = this.state
      this.props.form.validateFields((err, values) => {
        let data = {}
        data = {
          params: [{
            hospID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : "",
            findCode: values.specification ? values.specification : "",
            // ordCatID:1,
            detailFlag: 1,
            // medCatID:this.state.medCatID=="L"?5:(this.state.medCatID=="B"?"":(this.state.medCatID=="E"?4:""))
          }],
          pagination: [{
            pageSize: pageSize,
            currentPage: page,
          }]
        }
        $http.post('urlS', this, {
          code: this.state.mainCode == "E" ? "01010011" : (this.state.mainCode == "L" ? "01010012" : "01010012"),
          data: data,
          success: function (res) {
            if (+res.errorCode === 0 && res.result.Data && res.result.Data.length > 0) {
              this.setState({
                rightTopTableData: res.result.Data,
                total: res.result.TotalCount,
                search: e
              })
            }
          }
        })
      })
    }
    //右侧小表格 点击选中 信息回显左侧
    handleToLeftInfo = (record) => {
      return {
        onClick: () => {
          if (record) {
            let self = this
            if (record.medID) {
              if (this.state.rowRightId === "") {
                this.setState({
                  rowRightId: record.medID,
                });
              } else {
                if (this.state.rowRightId !== record.medID) {
                  this.setState({
                    rowRightId: record.medID,
                  });
                } else {
                  this.setState({
                    rowRightId: "",
                  });
                }
              }
            }
            this.props.form.setFieldsValue({ specification: record.medDesc })
            this.props.form.setFieldsValue({ projectUnitPrice: "￥" + record.medPrice })
            // console.log( this.props.form.getFieldValue("specification"))
          }

        },
      };


    }
    //设置点击row颜色 --右上表格
    setRightClassName = (record) => {
      if (record.medID === this.state.rowRightId) {
        return 'clickRowStyle'
      } else {
        return ''
      }
    }
    //清空 --右上表格
    handleLeftCancel = () => {
      this.props.form.resetFields();
      // this.setState({
      //   rightTopTableData:[],
      //   rowRightId:"",
      //   page:1,
      // })
    }
    //确认 --右上表格
    handleLeftOk = () => {
      if (this.props.form.getFieldValue('specification') && this.props.form.getFieldValue('specification').length == 0) {
        message.warning("请输入规格*名称回车检索")
      } else {
        let data = {}
        data = {
          params: [{
            HBid: this.state.rowId,
            userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
            medID: this.state.rowRightId,
          }]
        }
        $http.post('urlS', this, {
          code: '03010008',
          data: data,
          success: function (res) {
            if (+res.errorCode === 0) {
              message.success("添加医嘱项成功")
              this.getRightDeatil(this.state.rowId)
              this.setState({
                selectedRowKeys_right: [],
              })
            }
          }
        })
      }

    }

    //上移
    handleUpSort() {
      var keys = this.state.selectedRowKeys_right
      var data = this.state.rightData
      var newKeys = []
      keys = keys.sort(function (m, n) {
        if (m < n) return -1
        else if (m > n) return 1
        else return 0
      });
      for (var i = 0; i < keys.length; i++) {
        if (keys[i] === 0) {
          newKeys.push(keys[i])
          continue
        }
        var curRowData = data[keys[i]]
        var curRowKey = curRowData.key
        var upRowData = data[keys[i] - 1]
        var upRowKey = upRowData.key
        upRowData.key = curRowKey
        curRowData.key = upRowKey
        data[keys[i]] = upRowData
        data[keys[i] - 1] = curRowData
        newKeys.push(keys[i] - 1)
      }
      this.setState(
        {
          rightData: data,
          selectedRowKeys_right: newKeys
        }
      )
    }

    handleDownSort() {
      var keys = this.state.selectedRowKeys_right
      var data = this.state.rightData
      var newKeys = []
      keys = keys.sort(function (m, n) {
        if (m < n) return -1
        else if (m > n) return 1
        else return 0
      });
      for (var i = keys.length - 1; i >= 0; i--) {
        if (keys[i] === data.length - 1) {
          newKeys.push(keys[i])
          continue
        }
        var curRowData = data[keys[i]]
        var upRowData = data[keys[i] + 1]
        var curRowKey = curRowData.key
        var upRowKey = upRowData.key
        upRowData.key = curRowKey
        curRowData.key = upRowKey
        data[keys[i]] = upRowData
        data[keys[i] + 1] = curRowData
        newKeys.push(keys[i] + 1)
      }
      this.setState(
        {
          rightData: data,
          selectedRowKeys_right: newKeys
        }
      )
    }

    handleSaveMessage() {
      var ids = []
      if (!Util.isEmpty(this.state.rightData)) {
        var data = this.state.rightData;
        for (var i = 0; i < data.length; i++) {
          ids.push(data[i].id)
        }
      }
      var params = {
        params: [{
          userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
          orderData: ids
        }]
      }
      $http.post('urlS', this, {
        code: '03010116',
        data: params,
        success: function (res) {
          if (res.errorCode == '0') {
            message.success("保存成功！")
            this.setState({
              selectedRowKeys_right:[]
            },()=>{
              this.handleRightSearch()
            })
          }
        }
      })
    }

    render() {
      // console.log("------",this.state.text)
      const { getFieldDecorator } = this.props.form;
      let { plainOptions, baseParentType, baseTempType, baseUnit, tempChildDis, OrdDaShow } = this.state
      let parentType = []
      baseParentType && baseParentType.map(item => {
        if (item.CBid) {
          parentType.push(<Option key={item.CBid} onClick={() => this.onSelectOp(item, item.CBid)} value={String(item.CBid)}>{item.descripts}</Option>)
        } else {
          parentType.push(<Option key={item.HBid} onClick={() => this.onSelectOp(item, item.HBid)} value={String(item.HBid)}>{item.descripts}</Option>)
        }
      })
      let ordTemp = []
      baseTempType && baseTempType.map(item => {
        ordTemp.push(<Option key={item.id} value={String(item.id)}>{item.descripts}</Option>)
      })
      let ordUnit = []
      baseUnit && baseUnit.map(item => {
        ordUnit.push(<Option key={item.id} value={String(item.id)}>{item.descripts}</Option>)
      })
      let cOp = []
      plainOptions && plainOptions.map(item => {
        cOp.push(<Radio key={item.id} value={String(item.id)}>{item.descripts}</Radio>)
      })
      //右上小表格
      const columns = [{
        key: '1',
        title: '代码',
        dataIndex: 'medCode',
        align: "center",
        width: 80,
      }, {
        width: 160,
        key: '2',
        title: '名称*规格',
        dataIndex: 'medDesc',
        align: 'center'
      }, {
        width: 80,
        key: '3',
        title: '数量',
        dataIndex: 'medDurQty',
        align: "center",
      }, {
        width: 80,
        key: '4',
        title: '单价',
        dataIndex: 'medPrice',
        align: "center",
      },]
      //左侧查询数据表
      const leftDetailColumns = [
        {
          // align: "center",
          title: '类型',
          dataIndex: 'descripts',
          key: '1',
          width: '100px',
          render(text, row, index) {
            if (row.descripts) {
              return text;
            }
            return {
              children: text,
              props: {
                colSpan: 6,
              },
            };
          },
        },
        {
          align: "center",
          width: '100px',
          title: '名称',
          dataIndex: 'descripts',
          key: '2',
          render: renderContent,
        },
        {
          align: "center",
          width: '160px',
          title: '操作',
          dataIndex: 'createdAt',
          key: '6',
          render: (value, row, index) => {
            const obj = {
              children: (
                <span>
                  <span className='span' style={{ cursor: "pointer" }} onClick={() => this.editDocMes(row, "1")}>编辑</span>
                  {/* 分割线 */}
                  <Divider type="vertical" />
                  <Popconfirm title="删除不可恢复，你确定要删除吗?" onConfirm={() => this.editDocMes(row, "2")} >
                    <span className='span' style={{ cursor: "pointer" }} style={{ color: 'rgba(240,65,52,1)' }}>删除</span>
                  </Popconfirm>
                </span>
              ),
              props: {},
            };
            if (!row.descripts) {
              obj.props.colSpan = 0;
            }
            if (row.HBid) {
              return obj;
            }
          },
        },
      ];
      //右侧医嘱明细表
      const rightColumns = [
        {
          align: "left",
          title: '医嘱项代码',
          dataIndex: 'medCode',
          width: '200px',
        },
        {
          align: "left",
          title: '医嘱项名称',
          dataIndex: 'medDesc',
          key: 'ordTempletDetailItemDesc',
          editable: true,
          render: (text, record, index) => {
            return <span style={{ paddingLeft: "100px" }}>{text}</span>;
          },
        },
        
        // {
        //   width: 100,
        //   align: "center",
        //   title: '医嘱项价格',
        //   dataIndex: 'ordTempletDetailQty', 
        //   key: 'ordTempletDetailQty' ,
        //   editable: true,
        //   render: (text, record, index) => {
        //     return text;
        //   },  
        // },
        {
          title: '操作',
          dataIndex: 'operation',
          key: 'action',
          align: "center",
          key: 'ordTempletEdit',
          width: 200,
          render: (text, record, index) => {
            if (!record.editable) {
              return (
                <span style={{ textAlign: "center" }}>
                  <a style={{ color: "red" }} onClick={(e) => this.delate(e, record.key, record)}>删除</a>
                </span>
              )
            }


          }
        }
      ];
      //右侧查询医嘱项明细表
      const OrdDaColumns = [
        {
          align: "center",
          title: '编码',
          dataIndex: 'medCode',
          key: '1'
        },
        {
          align: "center",
          title: '名称*规格',
          dataIndex: 'medDesc',
          key: '2'
        },
        {
          align: "center",
          title: '大类',
          dataIndex: 'medCatDesc',
          key: '3'
        },
        {
          align: "center",
          title: '子类',
          dataIndex: 'medSubCatDesc',
          key: '4'
        },
        // { 
        //   align: "center",
        //   title: '供应商',
        //   dataIndex: '',
        //   key: '5' 
        // },
        // { 
        //   align: "center",
        //   title: '产地', 
        //   dataIndex: '', 
        //   key: '6',
        //  },
      ];
      const { selectedRow_right } = this.state
      const rowSelection_right = {
        selectedRowKeys: this.state.selectedRowKeys_right,
        onChange: (selectedRowKeys, selectedRows) => {
          let canDeleteStatus = false;
          let selectrow = "";
          if (selectedRowKeys.length === 0) {
            canDeleteStatus = true;
          } else {
            selectrow = selectedRowKeys[selectedRowKeys.length - 1];
          }
          this.setState({ canDeleteStatus: canDeleteStatus, selectrow: selectrow, selectedRow_right: selectedRows, selectedRowKeys_right: selectedRowKeys });
        },
        onSelectAll: (selected, selectedRows, changeRows) => {
          if (selectedRows.length > 0) {
            this.setState({
              canDeleteStatus: false,
            })
          } else {
            this.setState({
              canDeleteStatus: true,
            })
          }
          this.setState({ selectedRow_right: selectedRows });
        }
      };
      return (
        <div>
          <Row gutter={60} className="applicationDom" style={{ marginRight: "0" }}>
            <Col span={6} style={{ paddingRight: "0" }}>
              <Card title="申请单分类" bordered={false} style={{ marginRight: "4px", }}>
                <Row>
                  <Col span={24} style={{ marginRight: '10px' }}>
                    <Input allowClear placeholder='输入分类名称后回车查询' onChange={this.changeInfo} onPressEnter={this.findApp} autoFocus />
                  </Col>
                  <Col span={2} style={{ position: "absolute", right: "31px", top: "-41px" }}>
                    <FormItem >
                      {getFieldDecorator('addCategories', {
                        initialValue: undefined,
                        rules: [{ required: false, message: '' }],
                      })(
                        <Button style={{ background: '#fff', color: '#1890ff', height: "26px" }} onClick={this.openDocMes}>+分类</Button>
                      )}
                    </FormItem>
                  </Col>
                </Row>
                <Row>
                  <p style={{ margin: "4px 0", color: "#1890ff" }}>说明：选择某个分类后，点击“+分类”添加子类，最多三层结构</p>
                </Row>
                <Row>
                  <Radio.Group onChange={this.radioOnChange} value={this.state.radioValue}>
                    {cOp}
                  </Radio.Group>
                </Row>
                <Table
                  className="components-table-demo-nested"
                  columns={leftDetailColumns}
                  pagination={false}
                  rowClassName={this.setRowClassName}
                  onRow={this.onClickRow}
                  rowKey={record => record.key}
                  expandRowByClick={true}
                  showHeader={false}
                  onExpand={this.onClickRow}
                  // expandedRowRender={expandedRowRender}
                  // defaultExpandedRowKeys={this.state.newOpen&&this.state.newOpen.length > 0 ? this.state.newOpen : [0]} 
                  // defaultExpandAllRows={true}
                  // defaultExpandAllRows={true}
                  dataSource={this.state.leftData}
                />
                <div className="ordTempDateil">
                  <Modal
                    key='3'
                    width='800px'
                    visible={OrdDaShow}
                    closable={false}
                    title={false}
                    centered={true}
                    pagination={false}
                    footer={null}
                    onCancel={this.handleTemDaCancel}>
                    {/* <Table
                                  columns={OrdDaColumns}
                                  pagination={false}
                                  rowClassName={this.setOrdDaRowClassName}
                                  onRow={this.onClickOrdDaRow}
                                  rowKey={record => record.key}
                                  // expandedRowRender={expandedRowRender}
                                  dataSource={this.state.ordDetailData}
                                  style={{
                                    height: '500px',
                                    overflow: 'auto'
                                  }}
                                  /> */}
                    {/* <Pagination
                                  showTotal={() => this.showTotal(this.state.total)}
                                  size="small"
                                  showQuickJumper
                                  showSizeChanger
                                  defaultCurrent={1}
                                  current={this.state.page ? this.state.page : 1}
                                  total={this.state.total ? this.state.total : 0}
                                  onChange={this.onChange}
                                  onShowSizeChange={this.onShowSizeChange}
                                  style={{ textAlign: "right", marginTop: '13px' }}
                                />     */}
                  </Modal>
                </div>

              </Card>
            </Col>
            <Col span={18} style={{ paddingLeft: "6px", paddingRight: "0" }}>
              <Card title={this.state.Atext && this.state.Atext ? this.state.Atext.split(">>>")[0] : "请选择左侧目录"} bordered={false} className="moreInfoCard" style={{ paddingRight: "0" }}>
                <p className="titleDom"> 添加医嘱项</p>
                <div style={{ display: "flex", paddingBottom: "8px" }}>
                  <div>
                    <p style={{ paddingLeft: "12px", margin: "0" }}><span style={{ marginRight: "10px" }}>当前分类目录</span><span style={{ color: "#40a9ff" }}>{this.state.Atext ? this.state.Atext : ""}</span></p>
                    <Form>
                      <Row gutter={60}>
                        <Col span={24} style={{ position: "relative" }}>
                          <FormItem label="项目名称*规格"  {...formItemLayoutR}>
                            {getFieldDecorator('specification', {
                              initialValue: undefined,
                              rules: [{ required: false, message: '' }],
                            })(
                              <Input
                                onPressEnter={this.searchRightDetail}
                                disabled={!this.state.childID}
                              />
                            )}
                          </FormItem>
                          <span className="star">
                          </span>
                        </Col>
                      </Row>
                      <Row gutter={60}>
                        <Col span={24}>
                          <FormItem label="项目单价"  {...formItemLayoutR}>
                            {getFieldDecorator('projectUnitPrice', {
                              initialValue: undefined,
                              rules: [{ required: false, message: '' }],
                            })(
                              <Input disabled style={{ border: "0" }} />
                            )}
                          </FormItem>
                        </Col>
                      </Row>
                      <Col style={{ textAlign: "right", marginTop: "18px" }}>
                        <Button key="submitc" type="primary" size="small" disabled={!this.state.childID} onClick={this.handleLeftCancel}>清空</Button>
                        <Button key="submits" type="primary" size="small" disabled={!this.state.childID && !this.state.rowRightId} onClick={this.handleLeftOk}>确定</Button>
                      </Col>
                    </Form>
                  </div>
                  <Divider type="vertical" style={{ height: "184px", width: "4px", background: "rgb(24, 144, 255)", height: "168px", marginRight: "30px" }} />
                  <div style={{ flex: "1", paddingRight: "30px", paddingRight: "0" }} className="applicationDetailDom">
                    <p className="titleDom">医嘱项明细</p>
                    <Table
                      pagination={false}
                      columns={columns}
                      dataSource={this.state.rightTopTableData}
                      // rowKey={record => record.key}
                      rowClassName={this.setRightClassName}
                      onRow={this.handleToLeftInfo}
                      size="small"
                      style={{
                        height: '132px',
                        overflow: "auto",
                      }}
                    />
                    <CommonPagination style={{ textAlign: "right", marginTop: '0px', display: (this.state.rightTopTableData && this.state.rightTopTableData.length > 0 ? "inline-block" : "none") }} size={this.state.size} current={this.state.page} total={this.state.total} search={this.state.search}
                      onShowSizeChange={this.onShowSizeChange.bind(this)} complete={true} dataSource={this.state.rightTopTableData}
                      onChange={this.onChange.bind(this)} />
                    {/* <Pagination
                                showTotal={() => this.showTotal(this.state.total)}
                                size="small"
                                showQuickJumper
                                showSizeChanger
                                defaultCurrent={1}
                                current={this.state.page ? this.state.page : 1}
                                total={this.state.total ? this.state.total : 0}
                                onChange={this.onChange}
                                onShowSizeChange={this.onShowSizeChange}
                                style={{ textAlign: "right", marginTop: '0px' }}
                            />    */}
                  </div>
                </div>
                <p className="titleDom"> 申请单项目列表</p>
                <Row>
                  <Col span={8} style={{ marginRight: '10px' }}>
                    <FormItem>
                      {getFieldDecorator('info', {
                        initialValue: undefined,
                      })(
                        <Input allowClear placeholder='输入项目名称后回车查询' disabled={!this.state.childID} onPressEnter={this.handleRightSearch} onChange={this.changeRightSearch} />
                      )}
                    </FormItem>
                  </Col>
                </Row>
                <Button onClick={this.handleDetele} disabled={this.state.canDeleteStatus} size="small" style={{ top: "-4px" }} type="danger">批量删除</Button>
                <Button onClick={this.handleUpSort.bind(this)} disabled={this.state.canDeleteStatus} size="small" style={{ marginLeft: "10px", top: "-4px" }}>上移</Button>
                <Button onClick={this.handleDownSort.bind(this)} disabled={this.state.canDeleteStatus} size="small" style={{ marginLeft: "10px", top: "-4px" }}>下移</Button>
                <Button onClick={this.handleSaveMessage.bind(this)} type='primary' size="small" style={{ marginLeft: "10px", top: "-4px" }}>保存</Button>
                <Table
                  columns={rightColumns}
                  pagination={false}
                  rowClassName={this.setRowClassNames}
                  bordered={true}
                  // onRow={this.f}
                  // expandedRowRender={expandedRowRender}
                  dataSource={this.state.rightData}
                  // rowKey={(data) => {
                  //   return data.id
                  // }}
                  rowSelection={rowSelection_right}
                  className="clearBackground"
                  style={{
                    height: (store.getState().tableHeight.y - 252 + "px"),
                    overflow: "auto", width: "100%"
                  }}
                />
              </Card>
            </Col>
          </Row>
          <Modal
            key='2'
            width='416px'
            visible={this.state.visible}
            title={this.state.isMod == 1 ? "修改分类" : "添加分类"}
            onOk={this.handleOk}
            onCancel={this.handleCancel}
            footer={[
              <Button key="submitc" type="primary" onClick={this.handleCancel}>取消</Button>,
              <Button key="submits" type="primary" onClick={this.handleOk}>确定</Button>,
            ]}>
            <div>
              <Form>
                <Row gutter={60}>
                  <Col span={24}>
                    <FormItem label='代码' {...formItemLayout}>
                      {getFieldDecorator('docMesName', {
                        initialValue: undefined,
                        rules: [{ required: this.state.visible ? true : false, message: '请输入代码' }],
                      })(
                        <Input placeholder="不能超过15字" maxLength={15} style={{ width: "100%" }} />
                      )}
                    </FormItem>
                  </Col>
                </Row>
                <Row gutter={60}>
                  <Col span={24}>
                    <FormItem label='名称'  {...formItemLayout}>
                      {getFieldDecorator('othName', {
                        initialValue: undefined,
                        rules: [{ required: this.state.visible ? true : false, message: '请输入名称' }],
                      })(
                        <Input placeholder="不能超过15字" maxLength={15} />
                      )}
                    </FormItem>
                  </Col>
                </Row>
                <Row gutter={60}>
                  <Col span={24}>
                    <FormItem label='上级分类'  {...formItemLayout}>
                      {getFieldDecorator('docMesType', {
                        initialValue: undefined,
                        rules: [{ required: this.state.isMod == 1 ? false : (this.state.visible ? true : false), message: '请选择上级分类' }],
                      })(
                        <Select style={{ width: "100%" }} disabled={this.state.isMod == 1}>
                          {parentType}
                        </Select>
                      )}
                    </FormItem>
                  </Col>
                </Row>
                <Row gutter={60}>
                  {/* <Col span={24}>
                                <FormItem label='录入页面模板类型'  {...formItemLayout}>
                                {getFieldDecorator('docMesType', {
                                    initialValue: undefined,
                                    rules: [{ required: false, message: '' }],
                                })(
                                  <Select style={{width:"100%"}} disabled={tempChildDis}>
                                    {parentType}
                                  </Select>
                                )}
                                </FormItem>
                        </Col> */}
                </Row>
                <Row>
                  <Col span={24}>
                    <FormItem label='申请单打印模板' {...formItemLayout}>
                      {getFieldDecorator('application', {
                        initialValue: undefined,
                        rules: [{ required: false, message: '' }],
                      })(
                        <Input placeholder="不能超过15字" maxLength={15} />
                      )}
                    </FormItem>
                  </Col>
                </Row>
              </Form>
            </div>
          </Modal>
        </div>
      )
    }
  })
export default ApplicationSetting