// 患者病历数据查询
import React, { Component } from 'react';
import { Card, Row, Col, Input, Select, Button, Table, message, DatePicker } from 'antd';
import { $http } from 'containers/config/https';
import { httpConfig } from 'containers/config/httpConfig';
import { dayFormat } from 'tools/index';
import { handleExcel } from 'tools/handleExcel.js';
import store from 'store';
import Moment, { relativeTimeThreshold } from 'moment';
import iconListvisits from 'assets/images/icon_listvisits.png';
import CommonPagination from 'components/pagination/index';
import RangeDatePicker from 'components/rangePicker/index';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import $ from 'pages/workstation/component/js/jquery-3.2.1.min.js';

const { Option } = Select;

class PatientMedicalRecordInquiry extends Component {
  constructor(props) {
    super(props);
    var userData = JSON.parse(sessionStorage.getItem('userData'));
    this.state = {
      userData,
      patientColumns: [],
      tableData: [],
      total: 0,
      page: 1,
      pageSize: 20,
      patientWidth: 0,
      basicHeight: 0,
      loading: false,
      detailTableData: [],
      detailPage: 1,
      detailPageSize: 20,
      detailTotal: 0,
      detailLoading: false,
      patMessage: undefined, // 人员标识
      medicalNo: undefined, // 住院号
      bedID: undefined, // 床号
      locID: userData && userData.locID ? userData.locID : "", // 科室名称
      selectedRowKeys: [],
      selectedRows: [],
      detailSelectedRowKeys: [],
      detailSelectedRows: [],
      locSelectData: [],
      bedData: [],
      medicalRecordTemplateSelectData: [],
      medicalRecordTemplateID: undefined,
      rowId: "",
      admStatusCode: "A",
      admissionDate: undefined,
      admStatusSelectData: [{
        id: "A",
        descripts: "在院",
        descriptsSPCode: "zy"
      }, {
        id: "D",
        descripts: "出院",
        descriptsSPCode: "cy"
      }],
      dateFrom: undefined,
      dateTo: undefined,
      medicalRecordSubmissionStatus: [], // 病历提交状态基础数据
      medicalRecordSubmissionStatusID: undefined,
      isExpPatListLoading:false,  //患者列表导出按钮加载状态
      isExpExcelLoading:false,  //病历列表导出Excel按钮加载状态
      isExpBDFLoading:false,   //病历列表导出BDF按钮加载状态
      outHospMaxDays:60,    //患者病历数据查询出院日期间隔最大值
    };

    this.detailColumns = [
      {
        key: 1,
        title: '输入域编码',
        dataIndex: 'internalCode',
        align: 'center',
        width: "220px"
      }, {
        key: 2,
        title: '输入域名称',
        dataIndex: 'fieldName',
        align: 'center',
        width: "200px"
      }, {
        key: 3,
        title: '输入域值',
        dataIndex: 'fieldData',
        align: 'center',
      }
    ];
    this.myRef1 = React.createRef();
  }

  componentDidMount() {
    this.setState({ basicHeight: document.getElementById("patient-medical-record-inquiry-basic").clientHeight }, () => {
      setTimeout(() => {
        this.myRef1.current.focus();
      }, 300)
    });
    this.initDefaultValue()
    this.getPatientColumns();
    this.handleQuery();
    this.getLocSelectData();
    this.loadBedData();
    this.getMedicalRecordTemplateSelectData();
    this.getMedicalRecordSubmissionStatus();
  }

  // 获取病历模板下拉数据
  getMedicalRecordTemplateSelectData = () => {
    var params = {
      params: [{
        findTemp: "RELEASED"
      }]
    }
    $http.post('urlDeault', this, {
      code: "06050018",
      data: params,
      success: function (res) {
        if (+res.errorCode === 0) {
          let medicalRecordTemplateSelectData = res.result && res.result.data.length > 0 ? res.result.data : [];
          let medicalRecordTemplateID = res.result && res.result.defaultData && res.result.defaultData.DefaultTemplate ? res.result.defaultData.DefaultTemplate : (medicalRecordTemplateSelectData && medicalRecordTemplateSelectData.length > 0 ? medicalRecordTemplateSelectData[0].id : undefined);
          this.setState({
            medicalRecordTemplateSelectData,
            medicalRecordTemplateID
          })
        }
      }
    });
  }


    /**查询默认数据
     *
     */
    initDefaultValue = () => {
      let data = {
        params: [{
          defaultAppObj: {
            EMRBaseConfiger: ['BasicCaseInformationFormLocType','PatientMedicalRecordInquiryMaxDays'],
          }
        }]
      }
      $http.post('urlS', this, {
        code: "04110023",
        data: data,
        success: (res) => {
          if (+res.errorCode === 0) {
            const regex = /@/g;
            this.setState({
              // defaultValueObj: res.result,
              // locType: res.result.BasicCaseInformationFormLocType ? (res.result.BasicCaseInformationFormLocType.replace(regex, '^')) : this.state.locType,
              outHospMaxDays:res.result.PatientMedicalRecordInquiryMaxDays ? (res.result.PatientMedicalRecordInquiryMaxDays.replace(regex, '^')) : this.state.outHospMaxDays,
            })
          }
        }
      })
    }

  // 查询病历提交状态基础数据
  getMedicalRecordSubmissionStatus = () => {
    let data = {
      params: [{}]
    }
    $http.post('urlS', this, {
      code: "06080005",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          let medicalRecordSubmissionStatus = res.result && res.result.data && res.result.data.length > 0 ? res.result.data : [];
          let medicalRecordSubmissionStatusID = medicalRecordSubmissionStatus && medicalRecordSubmissionStatus.length > 0 ? medicalRecordSubmissionStatus[0].code : undefined;
          this.setState({ medicalRecordSubmissionStatus, medicalRecordSubmissionStatusID })
        } else {
          this.setState({ medicalRecordSubmissionStatus: [] })
        }
      }
    })
  }

  //获取护理分组
  getLocSelectData = () => {
    let { userData } = this.state;
    let data = {
      params: [{
        hospID: userData && userData.hospID ? userData.hospID : "",
        type: "I^W^OI"
      }]
    }
    $http.post('urlS', this, {
      code: "04020008",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          this.setState({ locSelectData: res.result.Data })
        } else {
          this.setState({ locSelectData: [] })
        }
      }
    })
  }

  loadBedData = () => {
    let { locID } = this.state;
    var params = {
      params: [{
        locID, // userData && userData.locID ? userData.locID : ""
      }]
    }
    $http.post('urlDeault', this, {
      code: "03060005",
      data: params,
      success: function (res) {
        if (+res.errorCode === 0) {
          this.setState({
            bedData: res.data
          })
        }
      }
    });
  }

  // 获取患者表头数据
  getPatientColumns = () => {
    let data = {
      params: [{
        compontName: "PreviewOfPatEMRPatList",
        type: "C",
      }]
    }
    $http.post('urlDeault', this, {
      code: "01040073",
      data: data,
      success: (res) => {
        if (+res.errorCode === 0) {
          var columns = res.result.C;
          var dynColumns = []
          for (var i = 0; i < columns.length; i++) {
            dynColumns.push({
              title: columns[i].title,
              dataIndex: columns[i].dataIndex,
              width: parseInt(columns[i].width),
              align: columns[i].align || 'center'
            })
          }
          this.setState({
            patientColumns: dynColumns,
            patientWidth: res.totalWidth
          })
        }
      }
    })
  }

  onColumnRef = (ref) => {
    this.columnRef = ref;
  }

  // 查询条件 --- 人员标识
  handlePatMessageChange = e => {
    this.setState({ patMessage: e.target.value })
  }

  // 查询条件 --- 住院号
  handleMedicalNoChange = e => {
    this.setState({ medicalNo: e.target.value })
  }

  // 查询条件 --- 床号
  handleBedIDChange = e => {
    this.setState({ bedID: e }, () => {
      this.handleQuery();
    })
  }

  // 查询条件 --- 科室名称
  handleLocIDChange = e => {
    this.setState({ locID: e }, () => {
      this.handleQuery();
      this.loadBedData();
    })
  }

  // 查询
  handleQuery = () => {
    this.setState({ page: 1 }, () => {
      this.getTableData();
    })
  }

  // 获取患者列表数据
  getTableData = () => {
    let { userData, patMessage, bedID, medicalNo, locID, page, pageSize, admStatusCode, admissionDate, dateFrom, dateTo, medicalRecordSubmissionStatusID, medicalRecordTemplateID } = this.state;
    let arrLocID = [];
    if (locID === "all") {
      arrLocID = ["20", "21"]
    } else {
      arrLocID.push(locID)
    }
    let data = {
      params: [{
        locID: arrLocID, // userData && userData.locID ? userData.locID : "",
        // userID: 164, // userData && userData.userID ? userData.userID : "",
        hospID: userData && userData.hospID ? userData.hospID : "",
        patMessage,
        bedID,
        medicalNo,
        admStatusCode,
        admissionDate: admissionDate ? Moment(admissionDate).format('YYYY-MM-DD') : undefined,
        dateFrom: admStatusCode === 'D' ? dateFrom : '',
        dateTo: admStatusCode === 'D' ? dateTo : '',
        EMRStatusCode: medicalRecordSubmissionStatusID,
        templateID: medicalRecordTemplateID
      }],
      pagination: [{
        pageSize,
        currentPage: page
      }]
    }
    $http.post('urlDeault', this, {
      code: "06080002",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          this.setState({
            tableData: res.result.data,
            total: res.result.totalCount,
            rowId: "",
            selectedRowKeys: [],
            selectedRows: [],
            detailTableData: [],
            detailTotal: 0,
            detailSelectedRowKeys: [],
            detailSelectedRows: []
          })
        } else {
          this.setState({
            tableData: [],
            total: 0,
            rowId: "",
            detailTableData: [],
            detailTotal: 0,
            selectedRowKeys: [],
            selectedRows: [],
            detailSelectedRowKeys: [],
            detailSelectedRows: []
          })
        }
      }
    });
  }

  // 患者列表 -- 条数改变的回调
  handleLeftShowSizeChange = (current, size) => {
    this.setState({ page: 1, pageSize: size }, () => {
      this.getTableData();
    });
  }

  // 患者列表 -- 页码改变的回调
  handleLeftChange = (page, pageSize) => {
    this.setState({ page, pageSize }, () => {
      this.getTableData();
    });
  }

  // 查询明细列表
  handleQueryDetail = () => {
    this.setState({ detailPage: 1 }, () => {
      this.getDetailTableData();
    })
  }

  // 获取患者病历列表数据
  getDetailTableData = (isExport) => {
    let { detailPage, detailPageSize, rowId, medicalRecordTemplateID } = this.state;
    let admID = [];
    if (rowId) {
      admID.push(rowId);
    }
    let data = {
      params: [{
        admID,
        templateID: medicalRecordTemplateID,
      }],
      pagination: [{
        pageSize: isExport === "export" ? 10000 : detailPageSize,
        currentPage: detailPage
      }]
    }
    $http.post('urlDeault', this, {
      code: "06050017",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          let detailTableData = res.result && res.result.data && res.result.data.length > 0 ? res.result.data : []
          if (isExport === "export") {
            if (detailTableData && detailTableData.length > 0) {
              handleExcel.exportExcel(this.detailColumns, detailTableData, '患者病历列表')
            } else {
              message.error("没有可导出的数据。")
            }
          } else {
            this.setState({
              detailTableData,
              detailTotal: res.result.totalCount,
              detailSelectedRowKeys: [],
              detailSelectedRows: []
            })
          }
        } else {
          this.setState({
            detailTableData: [],
            detailTotal: 0,
            detailSelectedRowKeys: [],
            detailSelectedRows: []
          })
        }
      }
    });
  }

  // 患者列表 -- 条数改变的回调
  handleRightShowSizeChange = (current, size) => {
    this.setState({ detailPage: 1, detailPageSize: size }, () => {
      this.getDetailTableData();
    });
  }

  // 患者列表 -- 页码改变的回调
  handleRightChange = (page, pageSize) => {
    this.setState({ detailPage: page, detailPageSize: pageSize }, () => {
      this.getDetailTableData();
    });
  }

  // 导出病历列表
  handleExportMedicalRecordList = () => {
    let { detailSelectedRows } = this.state;
    if (detailSelectedRows && detailSelectedRows.length > 0) {
      handleExcel.exportExcel(this.detailColumns, detailSelectedRows, '患者病历列表')
    } else {
      this.handleBatchExport("single")
    }
  }

  // 病历模板
  handleMedicalRecordTemplateIDChange = e => {
    this.setState({ medicalRecordTemplateID: e }, () => {
      this.handleQueryDetail();
    })
  }

  // 操作行 --- 患者列表
  onClickRowPublic = (record) => {
    return {
      // 单击行选中
      onClick: () => {
        if (this.state.rowId === '') {
          // 保存行数据以及ID
          this.setState({ rowId: record.admID }, () => {
            this.handleQueryDetail()
          })
        } else {
          if (this.state.rowId !== record.admID) {
            this.setState({ rowId: record.admID }, () => {
              this.handleQueryDetail()
            })
          }
        }
      }
    }
  }

  setRowClassNamePublic = (record) => {
    return record.admID === this.state.rowId ? 'clickRowStyle' : "";
  }

  handleAdmStatusCodeChange = e => {
    this.setState({ admStatusCode: e }, () => {
      this.handleQuery();
    })
  }

  handleAdmissionDateChange = e => {
    this.setState({ admissionDate: e })
  }

  // 批量导出   type === "single"为单个导出，不传则为批量导出
  /**
   *
   * @param {按钮类型} type
   * EXPORTADMLISTEXCEL:导出患者列表信息
   * EXPORTEXCEL：导出患者病历打散数据Excel
   * Multiple：导出患者病历打散数据BDF
   */
  handleBatchExport = (type) => {
    let {outHospMaxDays, isExpPatListLoading,isExpExcelLoading,isExpBDFLoading,rowId, userData, patMessage, bedID, medicalNo, locID, admStatusCode, admissionDate, dateFrom, dateTo, selectedRowKeys, medicalRecordTemplateID, medicalRecordSubmissionStatusID } = this.state;
    // let _this=this
    let admID = [];
    if (rowId) {
      admID.push(rowId);
    }
    outHospMaxDays=parseInt(outHospMaxDays)
    let dateRange=""
    if ((dateFrom !== "")&&(dateTo !== "")&&(dateFrom !== undefined)&&(dateTo !== undefined)){
      dateRange=((new Date(dateTo))-(new Date(dateFrom)))/ 1000 / 60 / 60 / 24
    }
    console.log("dateRange:",dateRange)
    if (type==="EXPORTADMLISTEXCEL"){
      this.setState({isExpPatListLoading:true})
    }else if(type==="EXPORTEXCEL"){
      if ((dateRange!=="")&&(dateRange>outHospMaxDays)){
        message.info("出院日期间隔超过"+outHospMaxDays+"天数据量过大会导致错误，建议小于"+outHospMaxDays+"天")
        return
      }
      this.setState({isExpExcelLoading:true})
    }else if(type==="Multiple"){
      if ((dateRange!=="")&&(dateRange>outHospMaxDays)){
        message.info("出院日期间隔超过"+outHospMaxDays+"天数据量过大会导致错误，建议小于"+outHospMaxDays+"天")
        return
      }
      this.setState({isExpBDFLoading:true})
    }else{}
    let arrLocID = [];
    if (locID === "all") {
      arrLocID = ["20", "21"]
    } else {
      arrLocID.push(locID)
    }

    let data = {
      params: [{
        admID: type === "single" ? admID : selectedRowKeys,
        exportType: type ? type : undefined,
        templateID: medicalRecordTemplateID,
        locID: arrLocID, // userData && userData.locID ? userData.locID : "",
        // userID: 164, // userData && userData.userID ? userData.userID : "",
        hospID: (userData && userData.hospID ? userData.hospID : ""),
        patMessage: patMessage,
        bedID: bedID,
        medicalNo: medicalNo,
        admStatusCode: admStatusCode,
        admissionDate: admissionDate ? Moment(admissionDate).format('YYYY-MM-DD'): undefined,
        dateFrom: admStatusCode === 'D' ? dateFrom : '',
        dateTo: admStatusCode === 'D' ? dateTo : '',
        EMRStatusCode: medicalRecordSubmissionStatusID,
      }]
    }
    // if ($ && $.ajax) {
		//   let url = httpConfig.ipDeault + httpConfig.urlAddress;
		// 	let userData = JSON.parse(sessionStorage.getItem('userData'));
    //   let formData = Object.assign({}, data);
		// 	let windowHost = window.location && window.location.protocol && window.location.host ? (window.location.protocol + '//' + window.location.host) : (window.location && window.location.origin ? window.location.origin : "");
		// 	windowHost = windowHost + "/bdhealth/";
		// 	// 判断是否是本地，如果是本地的话取https配置地址，线上则取地址栏地址 （内外网）
		// 	url = windowHost && windowHost.indexOf("localhost") !== -1 ? url : windowHost;
		// 	let { ipConfig } = window.sessionStorage
		// 	formData.code = "06080001";
		// 	if (userData) {
		// 		let ip = React.$getSessionData('ipConfig');
		// 		formData.session = [{
		// 			"userID": userData.userID || '',
		// 			"locID": userData.locID || '',
		// 			"groupID": userData.groupID || '',
		// 			"hospID": userData.hospID || '',
		// 			"sessionID": userData.sessionID || '',
		// 			"hostName": ip.hostName || '',
		// 			"ipv4": ip.ipv4 || '',
		// 			"ipv6": ip.ipv6 || '',
		// 			"mac": ip.mac || '',
		// 		}]
		// 	}
    //   $.ajax({
		// 		type: 'post',                          //请求方式
		// 		url,     //请求地址
		// 		data: JSON.stringify(formData),                         //发送的数据，这里是json对象
		// 		dataType: 'json',                      //数据类型
		// 		// contentType: 'application/json;charset=utf-8',
		// 		async: false,
		// 		success: function (res) {
    //       if (+res.errorCode === 0) {
    //         let url = res.result && res.result.url ? res.result.url : "";
    //         _this.downloadFile(url,type)
    //       }else{
    //         message.error(res.errorMessage);
    //       }
    //       if (type==="EXPORTADMLISTEXCEL"){
    //         _this.setState({isExpPatListLoading:false})
    //       }else if(type==="EXPORTEXCEL"){
    //         _this.setState({isExpExcelLoading:false})
    //       }else if(type==="Multiple"){
    //         _this.setState({isExpBDFLoading:false})
    //       }else{}
    //   },
		// 		error: function (XMLHttpRequest, textStatus, errorThrown) {
		// 			// console.log(XMLHttpRequest, textStatus, errorThrown)
		// 			error && error(errorThrown);
    //       if (type==="EXPORTADMLISTEXCEL"){
    //         _this.setState({isExpPatListLoading:false})
    //       }else if(type==="EXPORTEXCEL"){
    //         _this.setState({isExpExcelLoading:false})
    //       }else if(type==="Multiple"){
    //         _this.setState({isExpBDFLoading:false})
    //       }else{}
    //       },
    //     timeout:300000,
		// 		headers: {
		// 			'Accept': 'application/json',
		// 			'Content-Type': 'application/json',
		// 			"Authorization": httpConfig.authorizationToken,
		// 			"Access-Control-Allow-Origin": httpConfig.ipDeault
		// 		},
		// 	});


    // }



    $http.post('urlDeault', this, {
      code: "06080001",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          let url = res.result && res.result.url ? res.result.url : "";
          this.downloadFile(url,type)
        }
        if (type==="EXPORTADMLISTEXCEL"){
          this.setState({isExpPatListLoading:false})
        }else if(type==="EXPORTEXCEL"){
          this.setState({isExpExcelLoading:false})
        }else if(type==="Multiple"){
          this.setState({isExpBDFLoading:false})
        }else{}
      }
    });
  }

  downloadFile = (url,type) => {
    if (!url) {
      message.error("导出异常。");
      return;
    }
    var windowHost = window.location && window.location.host.indexOf("localhost") !== -1 ? "https://172.16.1.6" : (window.location && window.location.origin ? window.location.origin : (window.location && window.location.protocol ? (window.location.protocol + '//' + window.location.hostname) : ""));
    try {
      var elemIF = document.createElement('iframe');

      elemIF.src = windowHost + url;

      elemIF.style.display = 'none';

      document.body.appendChild(elemIF);

      // 防止下载两次

      setTimeout(function () {

        document.body.removeChild(elemIF)
        // this.setState({rowId: "", selectedRowKeys: [], selectedRows: [],})
      }, 1000);
  } catch (e) {

      console.log(e);

    }
  }

  startChange = (e) => {
    this.setState({
      dateFrom: e ? Moment(e).format(dayFormat) : ''
    })
  }

  endChange = (e) => {
    this.setState({
      dateTo: e ? Moment(e).format(dayFormat) : ''
    })
  }

  // 病历提交状态基础数据
  handleMedicalRecordSubmissionStatusChange = e => {
    this.setState({ medicalRecordSubmissionStatusID: e })
  }

  render() {
    let { patientColumns, tableData, total, page, basicHeight, loading, detailTableData, medicalRecordSubmissionStatus, medicalRecordSubmissionStatusID, detailLoading, patMessage, medicalNo, bedID, locID,
      patientWidth, selectedRows, detailSelectedRowKeys, detailSelectedRows, bedData, locSelectData, medicalRecordTemplateSelectData, medicalRecordTemplateID, rowId,
      selectedRowKeys, admStatusCode, admissionDate, admStatusSelectData,isExpPatListLoading,isExpExcelLoading,isExpBDFLoading
    } = this.state;

    // 床号
    var bedDataOption = []
    bedData && bedData.map((item, index) => {
      bedDataOption.push(<Option key={index} value={item.bedID} title={item.bedNo} seatchprop={item.bedNo}>
        {item.bedNo}
      </Option>)
    })

    //
    var locOption = []
    locSelectData && locSelectData.map((item, index) => {
      locOption.push(<Option key={index} code={item.descriptsSPCode} value={item.id} seatchprop={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}>{item.descripts}</Option>)
    })

    // 病历模板
    var medicalRecordTemplateOption = [];
    medicalRecordTemplateSelectData && medicalRecordTemplateSelectData.map((item, index) => {
      medicalRecordTemplateOption.push(<Option key={index} code={item.descriptsSPCode} value={item.id} seatchprop={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}>{item.descripts}</Option>)
    })

    // 患者类型
    let admStatusOption = [];
    admStatusSelectData && admStatusSelectData.map((item, index) => {
      admStatusOption.push(<Option key={index} code={item.descriptsSPCode} value={item.id} seatchprop={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}>{item.descripts}</Option>)
    })

    // 病历提交状态基础数据
    let medicalRecordSubmissionStatusOption = [];
    medicalRecordSubmissionStatus && medicalRecordSubmissionStatus.map((item, index) => {
      medicalRecordSubmissionStatusOption.push(<Option key={index} code={item.code} value={item.code} seatchprop={item.descripts + '^' + item.code} title={item.descripts}>{item.descripts}</Option>)
    })

    // 患者列表列选择
    const rowSelection = {
      selectedRowKeys,
      selectedRows,
      onChange: (selectedRowKeys, selectedRows) => {
        this.setState({ selectedRowKeys, selectedRows }, () => {
          // this.handleQueryDetail();
        })
      },
    };

    // 患者病历列表选中
    const detailRowSelection = {
      selectedRowKeys: detailSelectedRowKeys,
      selectedRows: detailSelectedRows,
      onChange: (selectedRowKeys, selectedRows) => {
        this.setState({ detailSelectedRowKeys: selectedRowKeys, detailSelectedRows: selectedRows })
      }
    };

    // const btnMenu = (
    //   <Menu>
    //     <Menu.Item>
    //       <span>季度</span>
    //     </Menu.Item>
    //     <Menu.Item>
    //       <a target="_blank" rel="noopener noreferrer" href="http://www.taobao.com/">
    //         2nd menu item
    //       </a>
    //     </Menu.Item>
    //     <Menu.Item>
    //       <a target="_blank" rel="noopener noreferrer" href="http://www.tmall.com/">
    //         3rd menu item
    //       </a>
    //     </Menu.Item>
    //   </Menu>
    // );

    return (
      <div className="patient-medical-record-inquiry">
        <Row id="patient-medical-record-inquiry-basic" style={{ padding: '0 24px' }}>
          <Col span={18} className="input-padding-right">
            <Row style={{ marginBottom: '20px' }}>
              <span className="custom-form-item-label" style={{ width: "82px", border: 0 }}>科室名称：</span>
              <Select value={locID} onChange={this.handleLocIDChange}
                showSearch optionFilterProp="seatchprop" allowClear placeholder="科室请选择名称"
                style={{ width: '150px', margin: '22px 10px 0 0' }}
              >
                <Option key="all" value="all" seatchprop='全部^qb' title="全部">全部</Option>
                {locOption}
              </Select>

              <span className="custom-form-item-label" style={{ width: "82px", border: 0 }}>患者类型：</span>
              <Select value={admStatusCode} onChange={this.handleAdmStatusCodeChange} showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '150px', margin: '22px 10px 0 0' }}>
                {admStatusOption}
              </Select>

              <span className="custom-form-item-label" style={{ width: "82px", border: 0 }}>床号：</span>
              <Select value={bedID} onChange={this.handleBedIDChange} showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '150px', margin: '22px 10px 0 0' }}>
                {bedDataOption}
              </Select>

              <span className="custom-form-item-label" style={{ width: "110px", border: 0 }}>病历提交状态：</span>
              <Select value={medicalRecordSubmissionStatusID} onChange={this.handleMedicalRecordSubmissionStatusChange} showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '150px', margin: '22px 10px 0 0' }}>
                {medicalRecordSubmissionStatusOption}
              </Select>

              <span className="custom-form-item-label" style={{ width: "82px", border: 0 }}>病历模板：</span>
              <Select value={medicalRecordTemplateID} onChange={this.handleMedicalRecordTemplateIDChange} showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '250px', margin: '22px 10px 0 0' }}>
                {medicalRecordTemplateOption}
              </Select>
              <div style={{ display: "inline-block" }}>

                <span className="custom-form-item-label" style={{ width: "82px", border: 0 }}>住院号：</span>
                <Input value={medicalNo} allowClear
                  onChange={this.handleMedicalNoChange}
                  placeholder='请输入'
                  onPressEnter={this.handleQuery}
                  style={{ width: '150px', margin: '8px 12px 0 0' }}
                />

                <span className="custom-form-item-label" style={{ width: "82px", border: 0 }}>人员标识：</span>
                <Input value={patMessage} allowClear
                  onChange={this.handlePatMessageChange}
                  ref={this.myRef1}
                  onPressEnter={this.handleQuery}
                  placeholder='请输入'
                  style={{ width: '150px', margin: '8px 12px 0 0' }}
                />

                <span className="custom-form-item-label" style={{ width: "82px", border: 0 }}>入院日期：</span>
                <DatePicker value={admissionDate} style={{ width: '150px', margin: '8px 0 0 0' }}
                  placeholder='请选择' onChange={this.handleAdmissionDateChange} />
                {admStatusCode === 'D' ? (<div style={{ display: 'inline-block', margin: '8px 0 0 12px' }}>
                  <RangeDatePicker label={'出院日期：'} format='YYYY-MM-DD' width='270px'
                    startChange={this.startChange} endChange={this.endChange} />
                </div>) : ""}
                <Button style={{ marginTop: '12px', marginLeft: "22px" }} onClick={this.handleQuery}>查询</Button>
              </div>
            </Row>
          </Col>
          <Col span={6} style={{ textAlign: 'right' }}>
            <Button
              type="primary"
              loading={isExpPatListLoading}
              style={{ marginTop: '22px', marginRight: '12px' }}
              onClick={() => this.handleBatchExport("EXPORTADMLISTEXCEL")}
              // disabled={!(selectedRowKeys && selectedRowKeys.length > 0)}
            >导出患者列表Excel</Button>
            <Button
              type="primary"
              loading={isExpExcelLoading}
              style={{ marginTop: '22px', marginRight: '12px' }}
              onClick={() => this.handleBatchExport("EXPORTEXCEL")}
              // disabled={!(selectedRowKeys && selectedRowKeys.length > 0)}
            >导出Excel</Button>
            <Button
              type="primary"
              loading={isExpBDFLoading}
              onClick={() => this.handleBatchExport("Multiple")}
            >导出BDF</Button>
          </Col>
        </Row>
        <div style={{ height: '6px', background: 'rgba(240, 242, 245, 1)', width: '100%' }}></div>
        <Row>
          <Col span={10}>
            <div style={{ paddingRight: '6px', position: 'relative' }}>
              <Card
                size="small"
                title={<div className="card-title-left-img" style={{ height: "32px" }}><img src={iconListvisits} alt="" />患者列表</div>}
              >
                <div>
                  <Table
                    columns={patientColumns && patientColumns.length > 0 ? patientColumns : []}
                    dataSource={tableData}
                    style={{ height: store.getState().tableHeight.y + 125 - basicHeight + 'px', }}
                    scroll={{ x: patientWidth, y: store.getState().tableHeight.y + 79 - basicHeight }}
                    rowSelection={rowSelection}
                    onRow={this.onClickRowPublic}
                    rowClassName={this.setRowClassNamePublic}
                    onHeaderRow={() => {
                      return {
                        onDoubleClick: () => {
                          this.columnRef.onOpenModel();
                        },
                      };
                    }}
                    bordered
                    rowKey={(data) => {
                      return data.admID
                    }}
                    pagination={false}
                    className="table-body-height" />
                  <CommonPagination current={page} total={total} search="search" pageSize="20"
                    onShowSizeChange={this.handleLeftShowSizeChange} complete={true} dataSource={tableData} size='small'
                    loading={loading} onChange={this.handleLeftChange} />
                </div>
              </Card>
              <div style={{ width: '6px', background: 'rgba(240, 242, 245, 1)', position: 'absolute', top: 0, right: 0, height: '100%' }}></div>
            </div>
          </Col>
          <Col span={14}>
            <Card
              size="small"
              title={<div style={{ display: "flex", alignItems: "center", height: "32px" }}>
                <div className="card-title-left-img"><img src={iconListvisits} alt="" />患者病历列表</div>
                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginLeft: "200px" }}>
                  {/* 病历模板：
                  <Select value={medicalRecordTemplateID} onChange={this.handleMedicalRecordTemplateIDChange} showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '300px' }}>
                    {medicalRecordTemplateOption}
                  </Select> */}
                  {/* <Button style={{ marginLeft: '24px' }} onClick={this.handleQueryDetail}>查询</Button> */}
                  {/* <Button
                    type="primary"
                    style={{ marginLeft: '120px', marginRight: '12px' }}
                    onClick={() => this.handleBatchExport("")}
                    disabled={!(selectedRowKeys && selectedRowKeys.length > 0)}
                  >导出</Button>
                  <Button
                    type="primary"
                    onClick={() => this.handleBatchExport("Multiple")}
                  >批量导出</Button> */}
                </div>
              </div>}
            >
              <div>
                <Table
                  columns={this.detailColumns}
                  dataSource={detailTableData}
                  style={{ height: store.getState().tableHeight.y + 125 + 38 - basicHeight + 'px', }}
                  scroll={{ x: 800, y: store.getState().tableHeight.y + 79 - basicHeight }}
                  // rowSelection={detailRowSelection}
                  bordered
                  rowKey={(data) => {
                    return data.key
                  }}
                  pagination={false}
                  className="table-body-height" />
                {/* <CommonPagination current={detailPage} total={detailTotal} search="search" pageSize="20"
                  onShowSizeChange={this.handleRightShowSizeChange} complete={true} dataSource={detailTableData} size='small'
                  loading={detailLoading} onChange={this.handleRightChange} /> */}
              </div>
            </Card>
          </Col>
        </Row>
        <ColumnAuthoritysModel
          clientWidth='800px'
          compontName="PreviewOfPatEMRPatList"
          configType="C"
          onRef={this.onColumnRef}
          reloadData={this.getPatientColumns}
        />
      </div>
    );
  }
}

export default PatientMedicalRecordInquiry;
