/**号
 * 挂号
 *
 */

import React from 'react';
import {
  Card, Table, Input, Tabs, Select, Row, Col, Checkbox, Badge,
  DatePicker, Button, Icon, message, Modal, Tooltip, Radio
} from 'antd';
// import ShowRegistrModal from './component/ShowRegistrModal';
import ShowInvoiceNumModal from './component/ShowInvoiceNumModal';
import ShowBackNumModal from './component/ShowBackNumModal';
import CancelOrderModal from './component/CancelOrderModal';
import ShowToOrderModal from './component/ShowToOrderModal';
import NewShowRegistrModal from './component/NewShowRegistrModal';
import ShowGetNumModal from './component/ShowGetNumModal';
import CorrelationModal from './component/CorrelationModal';
import fetchJsonp from 'fetch-jsonp';
import ShowMedicalInsuranceModal from './component/ShowMedicalInsuranceModal';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import ShowFaceRecognitionModal from 'pages/workstation/component/ShowFaceRecognitionModal';
import FaceRecognitionManual from 'pages/common/FaceRecognitionManual';
import { $loadTemplate } from '../lodop/Common/Print.js';
import ReadCard from 'components/readcard/ReadCard';
import { $http } from 'containers/config/https';
import store from 'store';
import { Util, INSUYBUtil } from 'tools/index';
import { dayFormat } from 'tools/index';
import moment from 'moment';
import './style/index.less';
import ShowLoadModal from "../../components/showLoadingModal";

const { TextArea } = Input;
const Option = Select.Option;
const Search = Input.Search;
const confirm = Modal.confirm;
const noData = require('./image/no-data1.png');
const { TabPane } = Tabs;

class NewRegistrationPage extends React.Component {
  constructor(props) {
    super(props)
    var userData = React.$getSessionData();
    var ipConfig = React.$getSessionData('ipConfig');
    var date = new Date();
    this.state = {
      dataSource: [],
      schedulData: [],
      patientData: [],
      timeRange: [],
      date: date,
      userData: userData,
      defaultId: '1',
      typeCode: '01',
      confirmLoading: false,
      birthDayDate: '',
      checked: false,
      ipConfig: ipConfig,
      activeKey: "1",
      patientMsg: {
        defaultTitle: "挂号默认置灰病人信息"
      },
      isShowResModel: false,
      resModelSelect: [],
      chooseRegTitleID: "",
      chooseDocObj: {},
      insuFlag: 'N',   // 医保结算标志
      totalWidth: 0
    }
    this.keyDownElements = this.keyDownElement.bind(this)
    this.keyDownFast = this.keyDownFastMsg.bind(this)

    this.textInput = React.createRef();
    this.textSelect = React.createRef();
    this.textCard = React.createRef();
    this.bookName = React.createRef();
    this.bookSex = React.createRef();
    this.bookCardType = React.createRef();
    this.bookCard = React.createRef();
    this.bookPhone = React.createRef();
    this.bookAddress = React.createRef();
  }

  componentDidMount() {
    this.loadTimeSolt();//获取时间段
    this.initData();
    this.loadTimeRange();
    this.loadCardType();//获取卡类型
    this.loadDepartMent();//挂号科室信息
    this.loadRegistrNumData();//号源消耗进度
    this.loadConfigFee();//配置收费
    this.loadUnawares()//获取接待人数据
    // this.textInput.current.focus()
    if (!Util.isEmpty(this.getQueryString('cardNum')) || !Util.isEmpty(this.getQueryString('posId'))) {
      this.searchBuildCardMsg()
    }
    //计算当前组件的宽度做分辨率适配
    this.clientWidth = document.body.clientWidth;
    setTimeout(() => {
      this.input && this.input.focus()
    }, 1000);
    document.addEventListener('keydown', this.keyDownFast)
    this.handleAdress();
  }

  keyDownFastMsg(e) {
    if (e && e.keyCode) {
      let currKey = 0;
      e = e || event || window.event;
      currKey = e.keyCode || e.which || e.charCode;
      //快捷键F1
      if (currKey == 90 && (e.ctrlKey)) {
        e.preventDefault();
        this.clearInput()
      }
    }
  }

  getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = this.props.location ? this.props.location.search.substr(1).match(reg) : null;
    if (r != null) {
      return decodeURIComponent(r[2]);
    }
    return null;
  }

  componentWillUnmount() {
    //组件销毁，移除键盘监听事件
    document.removeEventListener('keydown', this.keyDownElements);
    document.removeEventListener('keydown', this.keyDownFast);
    this.setState = (state, callback) => { return; };
  }

  initData() {
    let data = {
      params: [{
        compontName: "RegistrationPage",
        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({
            column: dynColumns,
            totalWidth: res.totalWidth
          })
          this.props.hanlderThis.setState({
            reload: false,
          })
        }
      }
    })
  }

  //获取时间段
  loadTimeSolt() {
    var params = {
      params: []
    }
    $http.post('urlDeault', this, {
      code: "03040001",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          var timeSolt = res.data;
          for (var i = 0; i < timeSolt.length; i++) {
            this.setState({
              timeSolt: timeSolt[i].id
            }, () => {
              this.loadSchedulingMsg();//获取挂号排班记录
            })
          }
        }
      }
    });
  }

  //获取建卡后跳转过来信息
  searchBuildCardMsg() {
    var params = {
      params: [{
        number: this.getQueryString('posId'),
        cardTypeID: this.getQueryString('cardTypeId'),
        cardNo: '',//this.getQueryString('cardNum')
        present: "Y"
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040004",
      data: params,
      success: function (res) {
        this.loadRegisterMsg(res.data);//查询患者挂号/预约记录
        if (res.errorCode == '0') {
          this.textInput.current.focus()
          message.success('患者信息查询成功！')
          this.setState({
            patientMsg: res.data,
            admReason: res.data.admReason,
            mobilephone: '',
            credNo: this.getQueryString('posId') || this.getQueryString('cardNum'),
            paitId: this.getQueryString('posId'),
            readCardNo: this.getQueryString('posId'),
            count: '',
            returnFlag: 'N',
            priorFalag: 'N',
            regFlag: 'N',
            cancleRegFlag: 'N',
            cancleAPPFlag: 'N',
            regPrintFlag: 'N',
            APPPrintFlag: 'N',
            OPInsuType: !Util.isEmpty(res.data.admReason) ? res.data.admReason[0].OPInsuType : '',
            note: res.data.note,
            visitedFlag: res.data.visitedFlag,
            adminUser: "", // 报备人员
          }, () => {
            this.currentMeter()
          })
        }
      }
    });
  }

  //获取接待人
  loadUnawares() {
    var params = {
      params: [{}]
    }
    $http.post('urlDeault', this, {
      code: "03040036",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          this.setState({
            unawaresList: res.result,
          })
        }
      }
    });
  }

  //获取卡类型
  loadCardType() {
    var params = {
      params: [{
        cardTypeFlag: '1',//卡类型
        sexFlag: '1',//性别
        credTypeFlag: '1',//证件类型
        socialStatusFlag: '1',//身份标签
        patTypeFlag: '1',//病人类型
        payMethodFlag: '1',//支付方式
      }]
    }
    $http.post('urlDeault', this, {
      code: "03030005",
      data: params,
      success: function (res) {
        var cardStatus = ''
        var replaceZero = ''
        var cardLength = 0
        var readMode = ''
        if (res.errorCode == '0') {
          if (res.cardType && res.cardType.length > 0) {
            var cardType = res.cardType;
            for (var i = 0; i < cardType.length; i++) {
              if (cardType[i].defaultFlag == 'Y') {
                cardStatus = cardType[i].id,
                  replaceZero = cardType[i].replenishZero
                cardLength = cardType[i].cardLength
                readMode = cardType[i].readMode
              }
            }
          }
          this.setState({
            cardTypeData: res.cardType,
            credTypeData: res.credType,
            patTypeData: res.patType,
            sexData: res.sex,
            socialStatusData: res.socialStatus,
            cardStatus: cardStatus,
            replenishZero: replaceZero,
            cardLength: cardLength,
            readMode: readMode
          })
        }
      }
    });
  }

  //获取挂号排班记录
  loadSchedulingMsg() {
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }
    var params = {
      params: [{
        date: moment(this.state.date).format(dayFormat),
        timeRangeID: this.state.timeRangeId ? this.state.timeRangeId : this.state.timeSolt,//timeRangeId -->timeRangeID
        docID: this.state.depDoctorId,//doctorId -->docID
        locID: this.state.locId,//locId--> locID
        admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040002",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          let schedulData = res.result && res.result.data && res.result.data.length > 0 ? res.result.data : [];
          let windowHost = window.location && window.location.origin ? window.location.origin : (window.location && window.location.protocol ? (window.location.protocol + '//' + window.location.hostname) : "");
          for (var i = 0; i < schedulData.length; i++) {
            let url = schedulData[i].image
            schedulData[i].image = url.indexOf("http") !== -1 ? url : windowHost + url;
          }
          this.setState({
            schedulData,
          })
        }
      }
    });
  }

  //查询患者预约/挂号记录
  loadRegisterMsg = (data) => {
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }
    if (this.state.paitId || (data && data.patID) || (this.state.patientMsg && this.state.patientMsg.patID)) {
      var params = {
        params: [{
          patIDCardNo: this.state.paitId,
          date: moment(this.state.date).format(dayFormat),
          patID: data ? data.patID : (this.state.patientMsg) ? this.state.patientMsg.patID : '',//patientDr --> patID
          admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
        }]
      }
      $http.post('urlDeault', this, {
        code: "03040003",
        data: params,
        success: function (res) {
          if (res.errorCode === '0') {
            this.setState({
              patientData: res.data
            })
          }
        }
      });
    }
  }


  //查询时段服务
  loadTimeRange() {
    var params = {
      params: [{
        hospID: this.state.userData.hospID
      }]
    }
    $http.post('urlDeault', this, {
      code: "01040010",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.setState({
            timeRange: res.timeRange
          })
        }
      }
    });
  }

  loadDepartMent() {
    var params = {
      params: [{
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040005",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.setState({
            departMentData: res.result.Data
          })
        }
      }
    });
  }

  //号源消耗进度
  loadRegistrNumData() {
    var date = new Date();
    var params = {
      params: [{
        date: this.state.date ? moment(this.state.date).format(dayFormat) : moment(date).format(dayFormat)
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040012",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.setState({
            registrNumData: res.data
          })
        }
      }
    });
  }

  //配置收费
  loadConfigFee() {
    const { userData } = this.state;
    var params = {
      params: [{
        logonHospID: userData?.hospID || '',
        logonGroupID: userData?.groupID || '',
        logonUserID: userData?.userID || '',
        invTypeCode: 'R',
        menuType: userData?.defaultMenuType || ''
      }]
    }
    $http.post('urlDeault', this, {
      code: "05210001",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.state.groupConfig = res.groupConfig
          this.state.sysConfig = res.sysConfig
          this.state.currentInvNoInfo = res.currentInvNoInfo
          this.state.registerInfo = res.registerInfo
          this.state.newPayWay = res.groupConfig.HBOPConfigPaymode[0].Reg
          let insuFlag = res.insuFlag
          this.setState({ insuFlag }, () => {
            var invNo = '';
            var currentInvNo = ''
            //对发票号进行截取
            if (this.state.currentInvNoInfo) {
              var currentInvNoInfo = this.state.currentInvNoInfo;
              invNo = currentInvNoInfo.substring(currentInvNoInfo.indexOf('^') + 1);
              currentInvNo = invNo.substring(invNo.indexOf('^') + 1)
            }
            if (this.state.groupConfig && this.state.groupConfig.IfInvNo == 'Y' && Util.isEmpty(currentInvNo)
              && this.state.registerInfo && this.state.registerInfo.noChargeFlag !== 'Y') {
              message.error('当前无发票号，无法进行挂号')
            }
          })
        }
      }
    });
  }

  //获取挂号医生信息
  loadDoctorId() {
    var params = {
      params: [{
        locID: this.state.locId
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040006",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.setState({
            depDoctorData: res.depDoctor
          })
        }
      }
    });
  }

  //鼠标移入card，添加挂号按钮
  addRegistrBtn(index, e) {
    this.setState({
      setBabkground: true,
      // mouseElement: true,
      rowIds: index
    })
  }

  addFloatElement(code, item) {
    // var floatOption = []
    var params = {
      params: [{
        patID: this.state.patientMsg ? (this.state.patientMsg.patID) : '',
        resDetailID: item.resDetailID
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040018",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.setState({
            orderData: res.data,
            floatStatus: true,
            floatData: item
          }, () => {
            this.loadElementDome()
          })
        }
      }
    });
    // return floatOption
  }

  loadElementDome() {
    var floatOption = []
    if (!Util.isEmpty(this.state.orderData)) {
      var resDetail = this.state.orderData.resDetail;
      resDetail && resDetail.map((item, index) => {
        floatOption.push(
          <div key={index} className='order-table-body-float' onDoubleClick={this.handleFloatToOrder.bind(this, '', item.id)}>
            <div><div className={item.workStatusCode == 'S' ? 'stop-order-num-new' :
              (item.workStatusCode == 'F' ? 'full-order-num-new' : '')}></div>
              <div className={item.workStatusCode == 'N' ? 'order-table-disable-new' : 'order-table-title-new'}>
                {item.timeDetail}</div></div>
            <div style={{ background: 'white', height: 28 }}>{item.workStatusCode == 'S' ? <span style={{ color: 'red' }}>停诊</span> :
              (item.workStatusCode == 'F' ? <span style={{ color: '#bbbbbb' }}>约满</span> :
                <span style={{ color: 'rgba(102,102,102,1)' }}>{item.regResources}</span>)
            }</div>
          </div>
        )
      })
    }
    return floatOption
  }

  handleFloatToOrder(name, code, e) {
    e.stopPropagation()//冒泡阻止多次调用点击事件
    // if (Util.isEmpty(this.state.patientMsg)) {
    //   message.error('必填信息不能为空！')
    //   return
    // }
    this.setState({
      bookStatus: true,
      isShowToOrderModal: true,
      floatStatus: false,
      bookCode: code
    }, () => {
      this.handleToOrder(this.state.floatData)
    })
  }

  //enter键去挂号
  handleRegistrBtn(index, data, e) {
    this.setState({
      floatStatus: false
    })
    if (e.keyCode == '13') {
    } else if (e.keyCode == '37') {//左方向键
      if (parseInt(this.state.rowIds) - 1 < 0) {
        this.setState({//当向左移动已无数据时，默认第一个数据
          rowIds: '0'
        })
      } else {
        this.setState({
          rowIds: parseInt(this.state.rowIds) - 1
        })
      }
    } else if (e.keyCode == '38') {//上方向键
      if (this.clientWidth < 1500) {
        if (parseInt(this.state.rowIds) - 6 < 0) {
          this.setState({//当上移已无数据时，默认当前数据
            rowIds: index
          })
        } else {
          this.setState({
            rowIds: parseInt(this.state.rowIds) - 6
          })
        }
      } else {
        if (parseInt(this.state.rowIds) - 7 < 0) {
          this.setState({//当上移已无数据时，默认当前数据
            rowIds: index
          })
        } else {
          this.setState({
            rowIds: parseInt(this.state.rowIds) - 7
          })
        }
      }
    } else if (e.keyCode == '39') {//右方向键schedulData
      if (parseInt(this.state.rowIds) + 1 == this.state.schedulData.length) {
        this.setState({//当右移大于当前数据的长度时，默认当前数据
          rowIds: index
        })
      } else {
        this.setState({
          rowIds: parseInt(this.state.rowIds) + 1
        })
      }
    } else if (e.keyCode == '40') {//下方向键
      if (this.clientWidth < 1500) {
        if (parseInt(this.state.rowIds) + 6 >= this.state.schedulData.length) {
          this.setState({//当下移大于当前数据的长度时，默认当前数据
            rowIds: index
          })
        } else {
          this.setState({
            rowIds: parseInt(this.state.rowIds) + 6
          })
        }
      } else {
        if (parseInt(this.state.rowIds) + 7 >= this.state.schedulData.length) {
          this.setState({//当下移大于当前数据的长度时，默认当前数据
            rowIds: index
          })
        } else {
          this.setState({
            rowIds: parseInt(this.state.rowIds) + 7
          })
        }
      }
    }
  }

  //鼠标离开，移除挂号按钮
  removeRegistrBtn() {
    this.setState({
      mouseElement: false,
      floatStatus: true,
      setBabkground: false//鼠标移出，title回复
    })
  }

  //双击，添加背景颜色
  addBackground(index, e) {
    this.setState({
      setBabkground: true,
      mouseElement: true,
      rowIds: index
    })
  }

  //键盘F1-F12按钮事件
  keyDownElement(e) {
    // var rthis = this;
    if (e.keyCode == '113' && this.state.regFlag == 'Y') {
      this.showGetNumModal()//F2,取号
    } else if (e.keyCode == '117' && this.state.cancleRegFlag == 'Y') {
      this.showBackNumModal()//F6，退号
    } else if (e.keyCode == '121' && this.state.cancleAPPFlag == 'Y') {
      this.showCannelOrderModal()//F10，取消预约
    } else if (e.keyCode == '119') {//重打凭条
      this.printEntrySlip()
    } else if (e.keyCode == '120') {//重打发票
      this.printInvoice()
    } else if (e.keyCode == '27') {
      this.setState({
        focusStatus: true
      }, () => {
        this.textSelect.current.focus()
      })
    }
  }

  //隐藏弹出框
  hideModal(name) {
    this.setState({
      [name]: false,//将所有参数置为false
      bookStatus: false,
      confirmLoading: false,
      qrCode: undefined,
      icCardNum: undefined,
      otherPayWayId: undefined
    });
    if (name == "isShowReadCardModal" || name == "isShowGetNumModal") {
      //将选中对象置空
      this.setState({
        chooseDocObj: {},
        chooseRegTitleID: ''
      })
    }
  }

  /**
   * @ByYQL: 结算费别内根据insuAlertBeforeAdm决定是否需要事前提醒，是否展示险种类型
   * Create 2021-12-17
   */
  handleSelectChange(name, e, code) {
    // console.log( [name], e);
    if (name == 'admReasonId') {
      this.setState({
        [name]: e,
        OPInsuType: code.props.opinsutype,
        insuAlertBeforeAdm: code.props.insuAlertBeforeAdm   // 是否展示险种类型
      }, () => {
        this.loadSchedulingMsg();
        this.loadRegisterMsg();//查询患者挂号/预约记录
        if (code.props.insuAlertBeforeAdm == 'Y') {
          this.getInsuAlertListInfo()   //获取险种类型赋值
        }
      })
    } else {
      this.setState({
        [name]: e,
      }, () => {
        this.loadSchedulingMsg();
        this.loadRegisterMsg();//查询患者挂号/预约记录
      })
    }
  }

  /**
   * @ByYQL: 获取险种类型
   * Create 2021-12-17
   */
  getInsuAlertListInfo() {
    var params = {
      params: [{ "admReasonCode": "INSUJNSYB" }]
    }
    $http.post('urlDeault', this, {
      code: "pr02900",
      data: params,
      success: function (res) {
        console.log('pr02900反参', res);
        if (res.errorCode === '0') {
          this.setState({
            insuranceData: res.result.Data
          })
        }
      }
    });
  }

  changeDepartMent(e) {
    var id = '';
    if (e) {
      id = e.substring(e.indexOf('^') + 1)
    }
    this.setState({
      locId: id,
      rowIds: '0',
      setBabkground: true,
      mouseElement: true,
      focusStatus: false
    }, () => {
      this.loadSchedulingMsg();
      this.loadDoctorId();
    })
    document.addEventListener('keydown', this.keyDownElements)
  }

  changeDepDoctor(e) {
    var id = '';
    if (e) {
      id = e.substring(e.indexOf('*') + 1);
    }
    this.setState({
      depDoctorId: id,
      rowIds: '0',
      setBabkground: true,
      mouseElement: true

    }, () => {
      this.loadSchedulingMsg();
    })
  }

  //去挂号弹框
  showRegistrModal(data) {
    // if (Util.isEmpty(this.state.deskClerk)) {
    //   message.error('无接待人员，无法挂号，请先选择接待人员！')
    //   return
    // }
    if (parseInt(data.registedNum) >= parseInt(data.registNum)) {
      message.error('挂号已满，请选择其他科室或者坐诊医生');
      return
    }
    var { registrSumData } = this.state;
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }
    if (this.state.admReason && this.state.admReason.length > 0) {
      if (this.state.patientMsg) {
        var params = {
          params: [{
            patID: this.state.patientMsg.patID,
            admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
            insuBalance: 0,
            insuSum: 0,
            resDetailID: data.resDetailID,
            greenFlag: this.state.greenFlag ? 'Y' : 'N',
            visitFlag: this.state.visitFlag ? 'Y' : 'N',
            chooseRegTitleID: this.state.chooseRegTitleID
          }]
        }
        $http.post('urlDeault', this, {
          code: "03040008",
          data: params,
          success: function (res) {
            if (res.errorCode === '0') {
              this.setState({
                registrSumData: res.data
              })
            }
          }
        });
        //选择医保计算后，进行医保读卡
        /*
        if (this.state.OPInsuType == 'Y') {
          this.setState({
            isShowReadCardModal: true,
            registrMsg: data
          })
        } else {

          this.setState({
            isNewShowRegistrModal: true,
            registrMsg: data
          })
        }
        */
        this.setState({
          isNewShowRegistrModal: true,
          registrMsg: data
        })
      } else {
        message.error('必填信息不能为空')
      }
    } else {
      message.error('结账费别不能为空')
    }
  }

  //设置发票号
  showInvoiceNumModal() {
    this.setState({
      isShowInvoiceNumModal: true
    })
  }

  changeBirthDay(e) {
    this.setState({
      birthDayDate: e
    }, () => {
      this.autoAge()
    })
  }
  autoAge() {
    let data = {}
    data = {
      params: [{
        birthday: this.state.birthDayDate ? (moment(this.state.birthDayDate).format(dayFormat)) : undefined,
        hospID: this.state.userData.hospID,
      }],
    }
    if (this.state.birthDayDate && this.state.birthDayDate != "Invalid date") {
      $http.post('urlS', this, {
        code: '03030013',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0) {
            this.setState({
              yearOld: res.result
            })
          } else {

          }
        }
      })
    } else {
      this.setState({
        yearOld: undefined
      })
    }
  }

  chengeTime(e) {
    var date = moment(new Date()).format(dayFormat);
    var afterDate = moment(e).format(dayFormat);
    if (date < afterDate) {
      this.setState({
        date: e,
        orderStatus: true
      }, () => {
        this.loadSchedulingMsg();//获取挂号排班记录
        this.loadRegisterMsg();
        this.loadRegistrNumData()
      })
    } else {
      this.setState({
        date: e,
        orderStatus: false
      }, () => {
        this.loadSchedulingMsg();//获取挂号排班记录
        this.loadRegisterMsg();
        this.loadRegistrNumData()
      })
    }
  }

  //切换卡类型
  changeCardType(e) {
    var { cardTypeData } = this.state;
    for (var i = 0; i < cardTypeData.length; i++) {
      if (e == cardTypeData[i].id) {
        this.setState({
          cardLength: cardTypeData[i].cardLength,
          replenishZero: cardTypeData[i].replenishZero,
          cardTypeId: cardTypeData[i].id,
          readMode: cardTypeData[i].readMode,
          inputStatus: true,
          equipManagerObj: cardTypeData[i].equipManagerObj
        })
      }
    }
  }

  /**
   * @ByYQL: 卡类型为医保卡时调用电子凭证DLL
   * Create 2022-9-26
   */
  readMedVoucher = async () => {
    if (this.state.cardTypeId == '8') { //合肥-8
      let userData = React.$getSessionData();
      let dllInputdata = {
        "iShowForm": 0,
        "iCardType": "01", //01：电子凭证
        "operatorId": userData?.userCode || '',
        "operatorName": userData?.userName || '',
        "officeId": userData?.locID || '',
        "officeName": userData?.locDesc || '',
        "patID": ''
      };
      var retStr = await INSUYBUtil.ReadInsuCard(dllInputdata);
      let resObj = JSON.parse(retStr);
      if (+resObj.errorCode === 0) {
        this.setState({
          medVoucherObj: resObj.result
        }, function () {
          if (resObj.result) {
            this.handleVoucherInfo(resObj.result);
          } else {
            message.warn('未获取到反参')
          }
        })
      } else {
        message.warn(resObj.errorMessage);
        this.setState({
          medVoucherObj: {}
        })
      }
    } else {  //济南-11
      this.setState({ cardShow: true, qrCode: "", areaType: "本地", cardType: this.state.cardTypeId });
    }
  };

  //输入卡号进行查询
  changeCardNum(e) {
    this.setState({
      readCardNo: e.target.value,
      clearStatus: true
    })
  }

  changePaitId(e) {
    this.setState({
      paitId: e.target.value,
      paitStatus: true
    })
  }

  handleReadCard() {
    /**
     * @ByYQL: 读卡功能，适配新读卡器华视100UC【hospID：济南-64、合肥-25、长春-62】
     * Create 2021-12-9
     */
    const { userData } = this.state;
    let hospID = userData?.hospID || '';
    let inputDirRoute = hospID == 25 || hospID == 62 ? 'ReadCard/ReadCard.dll' : 'ReadCard_UC/ReadCard.dll';
    let that = this;
    let dllParams = JSON.stringify({ 'inputDir': inputDirRoute, 'clsName': 'ReadCard.ReadCardObj', 'funcName': 'ReadIDCardInfo' });
    if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
      CefSharp.BindObjectAsync("xysCefToJavaScripts");
      setTimeout(() => {
        xysCefToJavaScripts.driveLocalHardware(dllParams).then((returnVale) => {
          var json = JSON.parse(returnVale);
          if (json.errorCode == "0") {
            that.setState({
              // parms:json.result
              sourceData: json.result,
              readStatus: 'read',
              readCardNo: !Util.isEmpty(json.result) ? json.result.IDCardNo : '',
            }, () => {
              that.loadReadCardMessage()
              // that.handleSelectPersonMsg('face', 'e')
              // sessionStorage.setItem('readCardMsg', JSON.stringify(that.state.source))
            })
            message.success('读身份证成功');
          } else {
            message.error(json.errorMessage);
          }
        })
      }, 100);
    } else {
      const frame = chrome?.webview?.hostObjects?.Bridge || ''; // 新版浏览器
      if (frame) {
        frame.DynamicLoadingDLL(dllParams)
          .then(
            data => {
              var json = JSON.parse(data);
              if (json.errorCode == "0") {
                that.setState({
                  sourceData: json.result,
                  readStatus: 'read',
                  readCardNo: !Util.isEmpty(json.result) ? json.result.IDCardNo : '',
                }, () => {
                  that.loadReadCardMessage();
                })
                message.success('读身份证成功');
              } else {
                message.error(json.errorMessage);
              }
            },
            err => {
              console.log('error', err);
            }
          )
      } else {
        let data = 'input={"inputDir":"' + inputDirRoute + '","clsName":"' + 'ReadCard.ReadCardObj' + '","funcName":"' + 'ReadIDCardInfo' + '"}';
        fetchJsonp('http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?' + '&' + data, {
          jsonpCallback: 'JsonCallback',
        })
          .then(function (response) {
            return response.json()
          }).then(function (json) {
            //返回卡号
            json = JSON.parse(json)
            if (json.errorCode == "0") {
              that.setState({
                // parms:json.result
                sourceData: json.result,
                readStatus: 'read',
                readCardNo: !Util.isEmpty(json.result) ? json.result.IDCardNo : '',
              }, () => {
                that.loadReadCardMessage()
                // that.handleSelectPersonMsg('face', 'e')
                // sessionStorage.setItem('readCardMsg', JSON.stringify(that.state.source))
              })
              message.success('读身份证成功');
            } else {
              message.error(json.errorMessage);
            }
            // return cardNo
          }).catch(function (ex) {
            console.log(ex)
          })
      }
    }
  }

  loadReadCardMessage() {
    var params = {
      params: [this.state.sourceData]
    }
    $http.post('urlS', this, {
      code: "03030115",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.setState({
            source: res.result
          }, () => {
            this.handleSelectPersonMsg('face', 'e')
            sessionStorage.setItem('readCardMsg', JSON.stringify(this.state.source))
          })
        }
      }
    });
  }
  //流调表提示
  currentMeter() {
    let { patientMsg } = this.state;
    if (patientMsg && patientMsg.currentMeter === 'Y') {
      if (patientMsg.toDayFillFlag != 'Y') {
        var that = this;
        confirm({
          title: '流调表提示',
          okText: '否-患者扫码填表',
          cancelText: '是-继续挂号',
          content: <span>{patientMsg.meterMessage}</span>,
          onOk() { that.clearInput() },
          onCancel() { }
        });
      }
    }
  }

  onAreaTypeChange = (e) => {
    this.setState({ areaType: e.target.value });
  };
  onqrCodeChange = (e) => {
    this.setState({ qrCode: e.target.value });
  };
  YBInputSure = async () => {
    let userData = React.$getSessionData();
    let dllInputdata = {
      "params": [{
        "userID": userData?.userID || '',
        "qrCode": this.state.qrCode,
        "icCardNum": "",
        "areaType": this.state.areaType,
        "hospID": userData?.hospID || '',
        "reasonCode": "INSUJNSYB",
        "patID": "",
        "patName": "",
        "xnhjgCode": ""
      }],
      "code": "05210036"
    };
    let data = await INSUYBUtil.insuYBAHSYB("ReadYBCard", dllInputdata);         //读医保病人信息
    let res = JSON.parse(data);
    console.log('ReadYBCard反', res);
    if (+res.errorCode === 0) {
      if (res.result) {
        this.handleVoucherInfo(res.result);
      } else {
        message.warn('未获取到反参');
        this.setState({ cardShow: false });
      }
    } else {
      message.warn(res.errorMessage);
      this.setState({ cardShow: false });
    }
  };

  goRegistrCard(cardTypeId, paitId, cardNum) {
    if (!Util.isEmpty(this.state.registerInfo)) {
      if (this.state.registerInfo.jumpFlag == 'Y') {
        this.props.history.push('./03030003?cardTypeId=' + cardTypeId + paitId + cardNum)
      } else {
        message.error('暂无权限建卡，请先联系管理员！')
        return
      }
    }
  }

  //电子凭证查询病人信息
  handleVoucherInfo(result) {
    var params = {
      params: [{
        medVoucherInfo: result
      }]
    };
    $http.post('urlDeault', this, {
      code: this.state.equipManagerObj?.readCardCode || "15020001",
      data: params,
      success: function (res) {
        if (+res.errorCode === 0) {
          this.setState({
            readCardNo: res.result?.idNo,
          }, function () {
            this.handleSelectPersonMsg('face', 'e');
          });
        } else {
          message.error(res.errorMessage);
        }
        this.setState({ cardShow: false });
      }
    });
  }

  //enter查询病人信息
  handleSelectPersonMsg(data, e) {
    if (e.keyCode == '13' || data == 'face') {
      if (Util.isEmpty(this.state.cardNum) && Util.isEmpty(data)) {
        message.error('请先输入您需要查询的卡号！')
        return
      }
      this.textInput.current.focus()
      if (Util.isEmpty(data)) {
        this.setState({//自动补0，渲染到组件中
          cardNum: this.state.replenishZero == 'Y' ? (Array(parseInt(this.state.cardLength)).join(0) + this.state.cardNum).slice(-parseInt(this.state.cardLength)) : this.state.cardNum
        })
      }
      // var params = {
      //     params: [{
      //         number: this.state.paitId,
      //         cardTypeID: this.state.cardTypeId ? this.state.cardTypeId : (this.state.cardStatus),//cardTypeDr -->cardTypeID
      //         // cardNo: this.state.cardNum
      //         cardNo: this.state.replenishZero == 'Y' ? (Array(parseInt(this.state.cardLength)).join(0) + this.state.cardNum).slice(-parseInt(this.state.cardLength)) : this.state.cardNum
      //     }]
      // }
      var params = {
        params: [{
          number: this.state.paitId ? this.state.paitId : (this.state.readCardNo ? this.state.readCardNo : this.getQueryString('posId')),
          cardTypeID: this.state.cardTypeId ? this.state.cardTypeId : (this.state.cardStatus ? this.state.cardStatus : this.getQueryString('cardTypeId')),//cardTypeDr -->cardTypeID
          // cardNo: this.state.cardNum
          cardNo: (this.state.cardNum ? this.state.cardNum : (this.getQueryString('cardNum') || '')),
          present: "Y"
        }]
      }
      $http.post('urlDeault', this, {
        code: "03040004",
        data: params,
        success: function (res) {
          if (res.errorCode == '0') {
            message.success('患者信息查询成功！');
            this.setState({
              patientMsg: res.data,
              admReason: res.data.admReason,
              mobilephone: '',
              credNo: '',
              count: '',
              returnFlag: 'N',
              priorFalag: 'N',
              regFlag: 'N',
              cancleRegFlag: 'N',
              cancleAPPFlag: 'N',
              regPrintFlag: 'N',
              APPPrintFlag: 'N',
              OPInsuType: !Util.isEmpty(res.data.admReason) ? res.data.admReason[0].OPInsuType : '',
              note: res.data.note,
              visitedFlag: res.data.visitedFlag,
            }, () => {
              this.currentMeter()
              this.loadRegisterMsg(res.data);// 查询患者挂号/预约记录
              this.loadSchedulingMsg()
            })
          } else {
            var that = this;
            var cardTypeId = this.state.cardTypeId ? this.state.cardTypeId : (this.state.cardStatus);
            var paitId = this.state.paitId ? ('&paitId=' + this.state.paitId) : (this.state.readCardNo ? ('&paitId=' + this.state.readCardNo) : '');
            var cardNum = this.state.cardNum ? ('&cardNum=' + this.state.cardNum) : '';
            confirm({
              title: '确认建卡',
              okText: that.state.userData.language == 'CN' ? '确定' : 'OK',
              cancelText: that.state.userData.language == 'CN' ? '取消' : 'Cannel',
              content: <span><span style={{ color: 'red' }}>当前为{res.errorMessage},</span>
                <span>确定要跳转到建卡页面吗？</span></span>,
              onOk() {
                // that.props.history.push('./03030002?cardTypeId=' + cardTypeId + paitId + cardNum)
                if (that.state.userData.defaultMenuType == '2') {
                  that.goRegistrCards(cardTypeId, paitId, cardNum)
                } else {
                  that.props.history.push('./03030003?cardTypeId=' + cardTypeId + paitId + cardNum)
                }
              },
              onCancel() {
                console.log('Cancel');
                sessionStorage.removeItem('readCardMsg')
              },
            });
            this.setState({
              patientMsg: {
                defaultTitle: "挂号默认置灰病人信息"
              }
            })
          }
        }
      });
    }
  }

  goRegistrCards(cardTypeId, paitId, cardNum) {
    if (!Util.isEmpty(this.state.registerInfo)) {
      if (this.state.registerInfo.jumpFlag == 'Y') {
        var data = {
          cardTypeId: cardTypeId,
          paitId: paitId,
          cardNum: cardNum
        }
        this.props.openWindowBySubTab({
          title: '建卡登记',
          path: '/03030003',
          Paras: {
            targetKey: '建卡登记',
            flag: 'compile',
            userInfo: data
          },
          component: "pages/registercard/RegisterPatCard.jsx"
        });
      } else {
        message.error('暂无权限建卡，请先联系管理员！')
        return
      }
    }
  }

  //清除输入框数据
  clearInput() {
    this.setState({
      patientMsg: {
        defaultTitle: '挂号默认置灰病人信息'
      },
      cardNum: '',
      paitId: '',
      patientData: [],
      bookName: '',
      bookSex: undefined,
      credType: '',
      credNo: '',
      birthDayDate: '',
      yearOld: '',
      mobilephone: '',
      personDr: undefined,
      personType: undefined,
      personMoney: '',
      patinId: '',
      returnFlag: 'N',
      priorFalag: 'N',
      regFlag: 'N',
      cancleRegFlag: 'N',
      cancleAPPFlag: 'N',
      regPrintFlag: 'N',
      APPPrintFlag: 'N',
      checkData: '',
      admReasonId: undefined,
      insuranceId: '',   //险种类别
      admReason: [],
      correCode: false,
      deskClerk: undefined,
      checked: false,
      note: '',
      patSource: '',
      adminUser: '', // 报备人员
    }, () => {
      this.input.focus()
    })
  }

  //点击预约，获取预约状态，对预约时间进行disabled操作
  showDate() {
    var { bookName, bookSex, credType, credNo, mobilephone, patientMsg } = this.state;
    // if (Util.isEmpty(patientMsg) && (Util.isEmpty(bookName) || Util.isEmpty(bookSex)
    //     || Util.isEmpty(credNo) || Util.isEmpty(mobilephone))) {
    //     message.error('病人必填信息不能为空，请先输入相关信息')
    //     return
    // }
    var date = new Date();//点击预约，日期+1
    if (this.state.showNewDate) {
      this.setState({
        showDate: false,
        date: date,
        orderStatus: false,
        showNewDate: false
      }, () => {
        this.loadSchedulingMsg()
        this.loadRegisterMsg()
        this.loadRegistrNumData()
      })
    } else {
      this.setState({
        showDate: true,
        date: moment(new Date()).add(1, 'days').format(),
        orderStatus: true,
        showNewDate: true
      }, () => {
        this.loadSchedulingMsg()
        this.loadRegisterMsg()
        this.loadRegistrNumData()
        this.bookName.current.focus()
      })
    }
  }

  showRegistrDate() {
    var date = new Date();//点击预约，日期-1
    this.setState({
      showNewDate: true,
      activeKey: "1",
      date: moment(new Date()).add(-1, 'days').format(),
      orderStatus: false,
      showDate: true
    }, () => {
      this.loadSchedulingMsg()
    })
  }

  //点击行，渲染当前行样式
  onClickRow = (record) => {
    return {
      onClick: () => {
        this.setState({
          rowId: record.admID,
          admDr: record.admID,
          payMentDr: record.recordID,
          regQueDr: record.regQueID,
          recordData: record,
          bookScheduleDr: record.bookScheduleID,
          workScheduleDr: record.resDetailID,//点击行，获取排班id
          count: record.count,
          returnFlag: record.returnFlag,//复诊标识
          priorFalag: record.priorFalag,//优先标识
          regFlag: record.regFlag,//取号标识
          cancleRegFlag: record.cancleRegFlag,//退号标识
          cancleAPPFlag: record.cancleAPPFlag,//取消预约标识
          regPrintFlag: record.regPrintFlag,//重打凭条标识
          APPPrintFlag: record.APPPrintFlag,//重打发票
          cancleRegTips: record.cancleRegTips

        });
        //点击表格后，监听键盘事件
        document.addEventListener('keydown', this.keyDownElements)
      },
    };
  }

  //点击行，渲染当前行样式
  setRowClassName = (record) => {
    return record.count === this.state.count ? 'clickRowStyle' : '';
  }

  //不结算挂号
  loadRegistration(data) {
    console.log("loadRegistration", this.state.chooseRegTitleID)
    var { registrSumData } = this.state;
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    if (!Util.isEmpty(this.state.medicalData) && Util.isEmpty(this.state.otherPayWayId)) {
      message.error('请选择支付方式!')
      return
    }
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }
    var params = {
      params: [{
        resDetailID: data.resDetailID,
        userID: this.state.userData.userID,
        groupID: this.state.userData.groupID,
        cardID: this.state.patientMsg.cardID,
        locID: this.state.userData.locID,//loc -->locID
        hospID: this.state.userData.hospID,
        patID: this.state.patientMsg.patID,//patientDr -->patID
        contractUnitID: this.state.userData.hospID,
        deskClerk: this.state.deskClerk,
        bookFlag: this.state.checked ? 'Y' : 'N',
        greenFlag: this.state.greenFlag ? 'Y' : 'N',
        visitFlag: this.state.visitFlag ? 'Y' : 'N',
        visitedFlag: this.state.visitedFlag ? 'Y' : 'N',
        bookMethodID: "Win",//写死
        admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
        paywStr: !Util.isEmpty(this.state.medicalData) ? [{
          payWayID: this.state.otherPayWayId,
          payWayAmt: this.state.medicalFee,
          hospID: ''
        }] : [],
        patSource: this.state.patSource ? this.state.patSource : '',
        // adminUser: this.state.adminUser ? this.state.adminUser : '', // 报备人员
        insuTypeCode: this.state.insuranceId,      //险种类型编码
        chooseRegTitleID: this.state.chooseRegTitleID
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040007",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          // message.config({
          //   top: '30%',
          //   duration: 2,
          //   maxCount: 3,
          // }); message.success('挂号成功！')
          let secondsToGo = this.state.userData && this.state.userData.messageTime;
          const modal = Modal.success({
            title: '挂号成功',
            content: <span>弹框将在&nbsp;<span style={{ fontSize: 16, color: 'red' }}>{secondsToGo}</span>&nbsp;秒后关闭.</span>
          });
          const timer = setInterval(() => {
            secondsToGo -= 1;
            modal.update({
              content: <span>弹框将在&nbsp;<span style={{ fontSize: 16, color: 'red' }}>{secondsToGo}</span>&nbsp;秒后关闭.</span>
            });
          }, 1000);
          setTimeout(() => {
            clearInterval(timer);
            modal.destroy();
          }, secondsToGo * 1000);
          // this.loadRegisterMsg()
          this.loadSchedulingMsg();
          this.loadRegistrNumData();
          this.loadConfigFee();
          // this.hideModal('isShowRegistrModal')
          this.hideModal('isNewShowRegistrModal')
          // $loadTemplate("Registration", res.print);
          if (!Util.isEmpty(res.print)) {
            $loadTemplate("Registration", res.print);
          }
          if (!Util.isEmpty(res.invPrint.data) && !Util.isEmpty(res.invPrint.template)) {
            $loadTemplate(res.invPrint.template, res.invPrint.data);
          }
          this.clearInput()
          this.setState({
            patientData: [],
            returnFlag: 'N',
            priorFalag: 'N',
            regFlag: 'N',
            cancleRegFlag: 'N',
            cancleAPPFlag: 'N',
            regPrintFlag: 'N',
            APPPrintFlag: 'N',
            count: '',
            medicalData: ''
          }, () => {
            setTimeout(() => {
              this.input.focus()
            }, 1000)
            if (this.props.openWindowBySubTab) {
              this.props.openWindowBySubTab({
                title: '医嘱录入',
                path: '/03050002',
                Paras: {
                  targetKey: '医嘱录入',
                  flag: 'compile',
                  userInfo: data
                },
                component: "pages/opadmReg/NewRegistrationPage.jsx"
              });
            } else {
              this.props.history.push('./030400011')
            }
          })
        }
      }
    });
    //将选中对象置空
    this.setState({
      chooseDocObj: {},
      chooseRegTitleID: ''
    })
  }

  //挂号
  onSubmitRegastr(data, payWayId, payWayMoney, realPayMoney, hospitalId, checkAccount, otherPayWayId) {
    console.log("onSubmitRegastr", this.state.chooseRegTitleID)
    var { registrSumData } = this.state;
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    this.setState({ confirmLoading: true })
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }
    var params = {
      params: [{
        resDetailID: this.state.registrMsg.resDetailID,
        userID: this.state.userData.userID,
        groupID: this.state.userData.groupID,
        cardID: this.state.patientMsg.cardID,
        locID: this.state.userData.locID,//loc -->locID
        hospID: this.state.userData.hospID,
        patID: this.state.patientMsg.patID,//patientDr -->patID
        contractUnitID: hospitalId,
        bookFlag: this.state.checked ? 'Y' : 'N',
        deskClerk: this.state.deskClerk,
        greenFlag: this.state.greenFlag ? 'Y' : 'N',
        visitFlag: this.state.visitFlag ? 'Y' : 'N',
        visitedFlag: this.state.visitedFlag ? 'Y' : 'N',
        bookMethodID: "Win",//写死
        admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
        // paywStr: (registrSumData.paywCASHID + '^' + realPayMoney + '^' + (Util.isEmpty(hospitalId) ? '' : hospitalId)) + String.fromCharCode(2) +
        //     (registrSumData.paywACCID + '^' + (checkAccount?0:data.accountFee) + '^' + (Util.isEmpty(hospitalId) ? '' : hospitalId)) + String.fromCharCode(2) +
        //     ((payWayId?payWayId:'') + '^' + payWayMoney + '^' + (Util.isEmpty(hospitalId) ? '' : hospitalId))
        paywStr: [{
          payWayID: payWayId ? payWayId : registrSumData.paywCASHID,
          payWayAmt: this.state.checked == true ? (realPayMoney + this.state.medicalFee) : realPayMoney,  // checked为病历本费 - realPayMoney为现金支付金额
          hospID: Util.isEmpty(hospitalId) ? '' : hospitalId
        }, {
          payWayID: registrSumData.paywACCID,
          payWayAmt: checkAccount ? 0 : data.accountFee,
          hospID: Util.isEmpty(hospitalId) ? '' : hospitalId
        }, {
          payWayID: otherPayWayId ? otherPayWayId : '', // 其他支付方式
          payWayAmt: Math.abs(payWayMoney.toFixed(2)), // payWayCount为其他支付方式金额
          hospID: Util.isEmpty(hospitalId) ? '' : hospitalId
        }],
        patSource: this.state.patSource ? this.state.patSource : '',
        // adminUser: this.state.adminUser ? this.state.adminUser : '', // 报备人员
        insuTypeCode: this.state.insuranceId,       //险种类型编码
        chooseRegTitleID: this.state.chooseRegTitleID
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040007",
      data: params,
      success: async (res) => {
        if (res.errorCode === '0') {
          if ((this.state.insuFlag == 'Y') && (this.state.OPInsuType == 'Y')) {
            let data = {
              params: [{
                admID: res.admID,
                patID: this.state.patientMsg.patID,
              }],
              businessType: "M2",
              operationType: 'RegisterOP',
              hospID: this.state.userData.hospID, //医院id
              session: [(this.state.userData)]
            }
            await React.$dllPost('Register', data, 'INSUNew/PTMedInsuInterface.dll', 'PTMedInsuInterface.InsuBusiness');
          }
          this.handleGoBack(res);
        } else {
          this.setState({
            confirmLoading: false
          })
        }
      }
    });
    //将选中对象置空
    this.setState({
      chooseDocObj: {},
      chooseRegTitleID: ''
    })
  }

  // 医保登记之后界面跳转
  handleGoBack = (res) => {
    let secondsToGo = this.state.userData && this.state.userData.messageTime;
    const modal = Modal.success({
      title: '挂号成功',
      content: <span>弹框将在&nbsp;<span style={{ fontSize: 16, color: 'red' }}>{secondsToGo}</span>&nbsp;秒后关闭.</span>
    });
    const timer = setInterval(() => {
      secondsToGo -= 1;
      modal.update({
        content: <span>弹框将在&nbsp;<span style={{ fontSize: 16, color: 'red' }}>{secondsToGo}</span>&nbsp;秒后关闭.</span>
      });
    }, 1000);
    setTimeout(() => {
      clearInterval(timer);
      modal.destroy();
    }, secondsToGo * 1000);
    // this.loadRegisterMsg()
    this.loadSchedulingMsg();
    this.loadRegistrNumData();
    this.loadConfigFee();
    // this.hideModal('isShowRegistrModal')
    this.hideModal('isNewShowRegistrModal')
    // $loadTemplate("Registration", res.print);
    if (!Util.isEmpty(res.print)) {
      $loadTemplate("Registration", res.print);
    }
    if (!Util.isEmpty(res.invPrint.data) && !Util.isEmpty(res.invPrint.template)) {
      $loadTemplate(res.invPrint.template, res.invPrint.data);
    }
    this.clearInput()
    this.setState({
      patientData: [],
      locId: '',
      returnFlag: 'N',
      priorFalag: 'N',
      regFlag: 'N',
      cancleRegFlag: 'N',
      cancleAPPFlag: 'N',
      regPrintFlag: 'N',
      APPPrintFlag: 'N',
      count: '',
      confirmLoading: false
    }, () => {
      setTimeout(() => {
        this.input.focus()
      }, 1000)
      if (this.props.openWindowBySubTab) {
        this.props.openWindowBySubTab({
          title: '医嘱录入',
          path: '/03050002',
          Paras: {
            targetKey: '医嘱录入',
            flag: 'compile',
            userInfo: data
          },
          component: "pages/opadmReg/NewRegistrationPage.jsx"
        });
      } else {
        this.props.history.push('./030400011')
      }
    })
  }

  //取号
  onSubmitGetNum(data, payWayId, payWayMoney, realPayMoney, hospitalId, checkAccount) {
    console.log("onSubmitGetNum", this.state.chooseRegTitleID)
    var { getRegistrData } = this.state;
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }

    var params = {
      params: [{
        resDetailID: this.state.workScheduleDr,
        userID: this.state.userData.userID,
        groupID: this.state.userData.groupID,
        cardID: this.state.patientMsg.cardID,
        locID: this.state.userData.locID,
        hospID: this.state.userData.hospID,
        patID: this.state.patientMsg.patID,
        contractUnitID: hospitalId,
        deskClerk: this.state.deskClerk,
        bookScheduleID: this.state.recordData.bookScheduleID,
        bookMethodID: "Win",//写死
        admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
        paywStr: [{
          payWayID: getRegistrData.paywCASHID,
          payWayAmt: realPayMoney,
          hospID: Util.isEmpty(hospitalId) ? '' : hospitalId
        }, {
          payWayID: getRegistrData.paywACCID,
          payWayAmt: checkAccount ? 0 : data.accountFee,
          hospID: Util.isEmpty(hospitalId) ? '' : hospitalId
        }, {
          payWayID: payWayId ? payWayId : '',
          payWayAmt: Math.abs(payWayMoney.toFixed(2)),
          hospID: Util.isEmpty(hospitalId) ? '' : hospitalId
        }],
        insuTypeCode: this.state.insuranceId,       //险种类型编码
        chooseRegTitleID: this.state.chooseRegTitleID
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040007",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          message.success('取号成功！')
          this.loadRegisterMsg()
          this.hideModal('isShowGetNumModal')
          if (!Util.isEmpty(res.print)) {
            $loadTemplate("Registration", res.print);
          }
          if (!Util.isEmpty(res.invPrint.data) && !Util.isEmpty(res.invPrint.template)) {
            $loadTemplate(res.invPrint.template, res.invPrint.data);
          }
          this.setState({
            returnFlag: 'N',
            priorFalag: 'N',
            regFlag: 'N',
            cancleRegFlag: 'N',
            cancleAPPFlag: 'N',
            regPrintFlag: 'N',
            APPPrintFlag: 'N',
            count: '',
          }, () => {
            if (this.props.openWindowBySubTab) {
              this.props.openWindowBySubTab({
                title: '医嘱录入',
                path: '/03050002',
                Paras: {
                  targetKey: '医嘱录入',
                  flag: 'compile',
                  userInfo: data
                },
                component: "pages/opadmReg/NewRegistrationPage.jsx"
              });
            } else {
              this.props.history.push('./030400011')
            }
          })
        }
      }
    });
    //将选中对象置空
    this.setState({
      chooseDocObj: {},
      chooseRegTitleID: ''
    })
  }

  //加载当日号源消耗进度
  loadRegistrNum() {
    var registrNumOption = []
    var { registrNumData } = this.state;
    registrNumData && registrNumData.map((item, index) => {
      registrNumOption.push(
        <div style={{ padding: "18px", paddingBottom: "0", width: "100%", boxSizing: "border-box", fontSize: "14px", color: "#333" }} key={index}>
          <Badge status='success' text={<div style={{ display: "inline-block", width: "calc(100% - 14px)" }}>{item.locDescripts}<span style={{ float: "right", fontSize: "12px" }}>{item.registedNumSum + '/' + item.registNumSum}</span></div>}></Badge>
          {/* <Progress percent={item.proportion} /> */}
        </div>
      )
    })
    return registrNumOption;
  }

  //退号
  showBackNumModal() {
    if (this.state.groupConfig) {
      if (this.state.groupConfig.IfAbortFlag !== 'Y' && this.state.recordData.SFlag !== 'A') {
        message.error('暂无作废权限，无法进行退号')
        return
      } else if (this.state.groupConfig.IfStrikeFlag !== 'Y' && this.state.recordData.SFlag !== 'S') {
        message.error('暂无红冲权限，无法进行退号')
        return
      }
    }
    if (((!Util.isEmpty(this.state.registerInfo) && this.state.registerInfo.noChargeFlag == 'Y')) || (Util.isEmpty(this.state.payMentDr))) {
      // if (!Util.isEmpty(this.state.registerInfo) && this.state.registerInfo.noChargeFlag == 'N') {
      this.registrBackNum()
    } else {
      var params = {
        params: [{
          recodeIDStr: this.state.payMentDr
        }]
      }
      $http.post('urlDeault', this, {
        code: "05210008",
        data: params,
        success: function (res) {
          if (res.errorCode === '0') {
            this.setState({
              registrFee: res.chargeAmtInfo[0]
            })
          }
        }
      });
      this.setState({
        isShowBackNumModal: true
      })
    }
  }

  //取号
  showGetNumModal() {
    var { registrSumData } = this.state;
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    // if (Util.isEmpty(this.state.deskClerk)) {
    //   message.error('无接待人员，无法取号，请先选择接待人员！')
    //   return
    // }
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }
    var params = {
      params: [{
        patID: this.state.patientMsg.patID,
        resDetailID: this.state.workScheduleDr,
        admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
        insuBalance: 0,
        insuSum: 0,
        greenFlag: this.state.greenFlag ? 'Y' : 'N',
        visitFlag: this.state.visitFlag ? 'Y' : 'N',
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040008",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.setState({
            getRegistrData: res.data
          })
        }
      }
    });
    if (!Util.isEmpty(this.state.registerInfo) && this.state.registerInfo.noChargeFlag == 'Y') {
      // this.setState({
      //   isShowGetNumModal: true
      // })
      this.getNumNoCharge()
    } else {
      this.setState({
        isShowGetNumModal: true
      })
    }
  }

  getNumNoCharge() {
    console.log("getNumNoCharge", this.state.chooseRegTitleID)
    var { getRegistrData } = this.state;
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }

    var params = {
      params: [{
        resDetailID: this.state.workScheduleDr,
        userID: this.state.userData.userID,
        groupID: this.state.userData.groupID,
        cardID: this.state.patientMsg.cardID,
        locID: this.state.userData.locID,
        hospID: this.state.userData.hospID,
        patID: this.state.patientMsg.patID,
        deskClerk: this.state.deskClerk,
        contractUnitID: '',
        bookScheduleID: this.state.recordData.bookScheduleID,
        bookMethodID: "Win",//写死
        admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
        paywStr: [],
        insuTypeCode: this.state.insuranceId,       //险种类型编码
        chooseRegTitleID: this.state.chooseRegTitleID
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040007",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          message.success('取号成功！')
          this.loadRegisterMsg()
          this.hideModal('isShowGetNumModal')
          if (!Util.isEmpty(res.print)) {
            $loadTemplate("Registration", res.print);
          }
          if (!Util.isEmpty(res.invPrint.data) && !Util.isEmpty(res.invPrint.template)) {
            $loadTemplate(res.invPrint.template, res.invPrint.data);
          }
          this.setState({
            returnFlag: 'N',
            priorFalag: 'N',
            regFlag: 'N',
            cancleRegFlag: 'N',
            cancleAPPFlag: 'N',
            regPrintFlag: 'N',
            APPPrintFlag: 'N',
            count: '',
          }, () => {
            if (this.props.openWindowBySubTab) {
              this.props.openWindowBySubTab({
                title: '医嘱录入',
                path: '/03050002',
                Paras: {
                  targetKey: '医嘱录入',
                  flag: 'compile',
                  userInfo: data
                },
                component: "pages/opadmReg/NewRegistrationPage.jsx"
              });
            } else {
              this.props.history.push('./030400011')
            }
          })
        }
      }
    });
    //将选中对象置空
    this.setState({
      chooseDocObj: {},
      chooseRegTitleID: ''
    })
  }

  //退号
  registrBackNum(id) {
    //显示加载框
    this.childLoadExamine.showModal();
    var params = {
      params: [{
        admID: this.state.admDr,
        repaywID: id,
        pcFlag: "Y"
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040016",
      data: params,
      success: function (res) {
        //关闭加载框
        setTimeout(() => {
          if (res.errorCode === '0') {
            message.success('退号成功！')
            this.setState({
              count: '',
              returnFlag: 'N',//复诊标识
              priorFalag: 'N',//优先标识
              regFlag: 'N',//取号标识
              cancleRegFlag: 'N',//退号标识
              cancleAPPFlag: 'N',//取消预约标识
              regPrintFlag: 'N',//重打凭条标识
              APPPrintFlag: 'N',//重打发票
            })
            this.hideModal('isShowBackNumModal')
            this.loadRegisterMsg()
          }
          this.childLoadExamine.close();
        }, 2000)
      }
    });
  }


  /**
   * @ByYQL: 退号请求展示公共组件加载等待框，
   * 避免快速操作导致数据混乱
   * Create 2021-12-6
   */
  onLoadModalRef = (ref) => {
    this.childLoadExamine = ref;
  };

  //复诊
  visitDoctor() {
    var params = {
      params: [{
        regQueID: this.state.regQueDr,
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040015",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          message.success('操作成功！')
          this.loadRegisterMsg()
        }
      }
    });
  }

  //优先
  loadPriority() {
    var params = {
      params: [{
        regQueID: this.state.regQueDr,
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040014",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          message.success('操作成功！')
          this.loadRegisterMsg()
        }
      }
    });
  }


  /**
  * @ByYQL: 挂号前,判断险种类型是否有值
  * Create 2021-12-17
  * @ByGJG： 添加是否有多个号源的判断
  */
  outPreAuditFun(data) {
    // console.log("险种类型:"+this.state.insuranceId);
    if (this.state.insuAlertBeforeAdm == 'Y') {   //为Y：需要险种类型
      if (this.state.insuranceId && this.state.insuranceId != "undefined") {
        if (data && data.resModelSelect && data.resModelSelect.length > 1) {
          this.setState({
            resModelSelect: data.resModelSelect,
            chooseDocObj: data
          }, () => {
            this.modifyVisible(true)
          })
        } else {
          this.showRegistrOrOrder(data)
        }
      } else {
        message.warning('险种类型不能为空,请在左侧选择险种类型')
      }
    } else {
      console.log("this.state.insuAlertBeforeAdm", this.state.insuAlertBeforeAdm)
      //当号源数大于一个时，弹出下拉框选择号源，否则不需选择
      if (data && data.resModelSelect && data.resModelSelect.length > 1) {
        this.setState({
          resModelSelect: data.resModelSelect,
          chooseDocObj: data
        }, () => {
          this.modifyVisible(true)
        })
      } else {
        this.showRegistrOrOrder(data)
      }

    }

  }
  // 修改弹窗状态
  modifyVisible = (visible) => {
    //选中的ID置空
    this.setState({ isShowResModel: visible, chooseRegTitleID: '' })
  }
  //确定
  handleOk = () => {
    this.setState({ isShowResModel: false })

    this.showRegistrOrOrder(this.state.chooseDocObj)
  }
  //下拉框传值
  handleSelectResModel(e) {
    console.log("handleSelectResModel", e)
    this.setState({
      chooseRegTitleID: e
    })
  }
  /**
   * @ByYQL: 原代码onDoubleClick双击事件直接调用该方法
   * 现添加事前审核逻辑，先走outPreAuditFun
   * Create 2021-12-17
   */
  showRegistrOrOrder(data) {
    var invNo = '';
    var currentInvNo = ''
    //对发票号进行截取
    if (this.state.currentInvNoInfo) {
      var currentInvNoInfo = this.state.currentInvNoInfo;
      invNo = currentInvNoInfo.substring(currentInvNoInfo.indexOf('^') + 1);
      currentInvNo = invNo.substring(invNo.indexOf('^') + 1)
    }
    if (Util.isEmpty(this.state.groupConfig) || (this.state.groupConfig && this.state.groupConfig.IfChargeFlag == 'N')) {
      message.error('无收费权限，暂时无法挂号')
      return
    }

    if (this.state.orderStatus) {
      this.handleToOrder(data)
    } else if (!Util.isEmpty(this.state.registerInfo) && this.state.registerInfo.noChargeFlag == 'Y') {
      // if (Util.isEmpty(this.state.deskClerk)) {
      //   message.error('无接待人员，无法挂号，请先选择接待人员！')
      //   return
      // }
      //判断是否收病历本费
      // if (this.state.checked == true) {
      //   this.setState({
      //     medicalData: data
      //   }, () => {
      //     this.handleMedicalRecord()
      //   })
      // } else {
      this.loadRegistration(data)
      // }
    } else if (!Util.isEmpty(this.state.registerInfo) && this.state.registerInfo.noChargeFlag == 'N') {
      // if (Util.isEmpty(this.state.deskClerk)) {
      //   message.error('无接待人员，无法挂号，请先选择接待人员！')
      //   return
      // }
      if (this.state.groupConfig && this.state.groupConfig.IfInvNo == 'Y' && Util.isEmpty(currentInvNo)) {
        message.error('当前无可用发票，无法挂号')
        return
      }
      //判断是否收病历本费
      // if (this.state.checked == true) {
      //   this.setState({
      //     medicalData: data
      //   }, () => {
      //     this.handleMedicalRecord()
      //   })
      // } else {
      this.showRegistrModal(data)
      // }
    }
  }

  //预约
  handleToOrder(data) {
    if (parseInt(data.registedNum) >= parseInt(data.registNum)) {
      message.error('号源已满，请选择其他科室或者坐诊医生');
      return
    }
    //手机号码校验
    var mobile = /^[1-9]\d{10}$/;
    var phone = this.state.mobilephone;
    if (phone && !mobile.test(phone)) {
      message.error('手机号码输入格式不正确，请重新输入')
      return
    }
    var idCard = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
    var cardNo = this.state.credNo;
    if (cardNo && !idCard.test(cardNo) && this.state.typeCode == '01') {
      message.error('身份证号码输入格式不正确，请重新输入')
      return
    }
    var { bookName, bookSex, credType, credNo, credTypeData } = this.state;
    if (this.state.patientMsg || (bookName && bookSex && (credType || (credTypeData ? credTypeData[0].id : '')) && credNo)) {
      var params = {
        params: [{
          patID: this.state.patientMsg ? (this.state.patientMsg.patID) : '',
          resDetailID: data.resDetailID,
          chooseRegTitleID: this.state.chooseRegTitleID
        }]
      }
      $http.post('urlDeault', this, {
        code: "03040018",
        data: params,
        success: function (res) {
          if (res.errorCode === '0') {
            this.setState({
              orderData: res.data,
              setRowId: res.data.resDetail[0].id,
              orderSchData: res.data.resDetail[0]
            })
          }
        }
      });
      this.setState({
        isShowToOrderModal: true,
        orderSchData: data
      })
    } else {
      this.setState({
        orderStyle: true
      })
      message.error('必填信息不能为空')
    }
  }

  //预约
  handleSubmitOrder(id, code) {
    var params = {}
    if (this.state.patientMsg && this.state.patientMsg.patID) {
      params = {
        params: [{
          patID: this.state.patientMsg ? this.state.patientMsg.patID : '',
          resDetailID: this.state.orderSchData ? this.state.orderSchData.resDetailID : '',
          userID: this.state.userData.userID,
          bookMethodID: "Win",//写死
          resTimeID: code ? code : this.state.bookCode,
          chooseRegTitleID: this.state.chooseRegTitleID
        }]
      }
    } else {
      params = {
        params: [{
          resDetailID: this.state.orderSchData ? this.state.orderSchData.resDetailID : '',
          userID: this.state.userData.userID,
          bookMethodID: "Win",//写死
          resTimeID: code ? code : this.state.bookCode,
          bookName: this.state.bookName,
          patCredTypeID: this.state.credType ? this.state.credType : (this.state.credTypeData ? this.state.credTypeData[0].id : ''),
          patCredNo: this.state.credNo,
          patMobile: this.state.mobilephone,
          patSexID: this.state.bookSex,
          patBirthDate: this.state.birthDayDate,
          patAddress: this.state.patAddress,
          chooseRegTitleID: this.state.chooseRegTitleID
        }]
      }
    }
    $http.post('urlDeault', this, {
      code: "03040011",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          var date = new Date();
          // message.success('预约成功！')
          let secondsToGo = this.state.userData && this.state.userData.messageTime;
          const modal = Modal.success({
            title: '预约成功',
            content: <span>弹框将在&nbsp;<span style={{ fontSize: 16, color: 'red' }}>{secondsToGo}</span>&nbsp;秒后关闭.</span>
          });
          const timer = setInterval(() => {
            secondsToGo -= 1;
            modal.update({
              content: <span>弹框将在&nbsp;<span style={{ fontSize: 16, color: 'red' }}>{secondsToGo}</span>&nbsp;秒后关闭.</span>
            });
          }, 1000);
          setTimeout(() => {
            clearInterval(timer);
            modal.destroy();
          }, secondsToGo * 1000);
          this.hideModal('isShowToOrderModal')
          this.clearInput()
          this.setState({
            showDate: false,
            date: date,
            showNewDate: false,
            activeKey: "2",
            patientData: [],
            orderStatus: false,
            activeKey: '1'
          }, () => {
            this.loadSchedulingMsg();
            this.loadConfigFee();
          })
        }
      }
    });
    //将选中对象置空
    this.setState({
      chooseDocObj: {},
      chooseRegTitleID: ''
    })
  }

  //取消预约弹框
  showCannelOrderModal() {
    this.setState({
      isCancelOrderModal: true
    })
  }

  //重打凭条
  printEntrySlip() {
    var params = {
      params: [{
        admID: this.state.admDr
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040027",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          message.success('操作成功！')
          if (!Util.isEmpty(res.result)) {
            $loadTemplate("Registration", res.result);
          }
        }
      }
    });
  }

  //重打发票
  printInvoice() {
    var params = {
      params: [{
        admID: this.state.admDr
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040028",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          message.success('操作成功！')
          if (!Util.isEmpty(res.result.data)) {
            $loadTemplate(res.result.template, res.result.data);
          }
        }
      }
    });
  }

  //取消预约
  cannelRegistr() {
    var params = {
      params: [{
        bookScheduleID: this.state.bookScheduleDr
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040013",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          message.success('取消预约成功！')
          this.loadRegisterMsg()
          this.hideModal('isCancelOrderModal')
        }
      }
    });
  }

  disabledDate(e) {
    var date = new Date()
    return e && e < moment(date).startOf('day');
  }

  onBlurCardNo() {
    var idCard = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
    var cardNo = this.state.credNo;
    if (!Util.isEmpty(cardNo) && !idCard.test(cardNo) && this.state.typeCode == '01') {
      message.error('身份证号码输入格式不正确，请重新输入')
      return
    }
  }

  //回车键校验录入病人信息
  checkMessage(e) {
    if (e.keyCode == '13') {
      //手机号码校验
      var mobile = /^[1-9]\d{10}$/;
      var phone = this.state.mobilephone;
      // if (!mobile.test(phone)) {
      //     message.error('手机号码输入格式不正确，请重新输入')
      //     return
      // }
      var idCard = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
      var cardNo = this.state.credNo;
      if (!Util.isEmpty(cardNo) && !idCard.test(cardNo) && this.state.typeCode == '01') {
        message.error('身份证号码输入格式不正确，请重新输入')
        return
      }
      var params = {
        params: [{
          credTypeID: (this.state.credType ? this.state.credType : (this.state.credTypeData ? this.state.credTypeData[0].id : undefined)),
          credNo: this.state.credNo
        }]
      }
      $http.post('urlDeault', this, {
        code: "03040019",
        data: params,
        success: function (res) {
          if (res.errorCode === '0') {
            if (Util.isEmpty(res.patInfo.patCredNo)) {
              message.error('当前用户不存在')
              this.bookPhone.current.focus()
            }
            this.setState({
              checkData: res.patInfo,
              isShowCorrelationModal: res.patInfo.patCredNo ? true : false,
              checkMsg: res.message
            })
          }
        }
      });
      this.getSex()
    }
  }

  //获取性别
  getSex() {
    var { credNo, sexData } = this.state;
    let sexno, sex
    if (credNo && credNo.length == 18) {
      sexno = credNo.substring(16, 17)
    } else if (credNo.length == 15) {
      sexno = credNo.substring(14, 15)
    } else {
      return false
    }
    var boyID = '', girlID = ''
    if (!Util.isEmpty(sexData)) {
      for (var i = 0; i < sexData.length; i++) {
        if (sexData[i].code == '2') {
          boyID = sexData[i].id
        } else if (sexData[i].code == '1') {
          girlID = sexData[i].id
        }
      }
    }

    var birthdayno, birthdaytemp
    if (credNo && credNo.length == 18) {
      birthdayno = credNo.substring(6, 14)
    } else if (credNo && credNo.length == 15) {
      birthdaytemp = credNo.substring(6, 12)
      credNo = "19" + birthdaytemp
    } else {
    }
    var birthday = birthdayno.substring(0, 4) + "-" + birthdayno.substring(4, 6) + "-" + birthdayno.substring(6, 8)
    var date = moment(birthday).format(dayFormat)
    var tempid = sexno % 2;
    if (tempid == 0) {
      this.setState({
        bookSex: boyID,
        birthDayDate: date
      }, () => {
        this.autoAge()
      })
    } else {
      this.setState({
        bookSex: girlID,
        birthDayDate: date
      }, () => {
        this.autoAge()
      })
    }
  }

  //跳号
  loadInvoiceNum(currentNo, jumpReason, data) {
    var params = {
      params: [{
        hospID: this.state.userData.hospID,
        userID: this.state.userData.userID,
        paytype: 'R',
        staInvNo: data[0].currentInvNo,
        endInvNo: data[0].preFix + currentNo,
        jumpReason: jumpReason
      }]
    }
    $http.post('urlDeault', this, {
      code: "05210027",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          message.success('跳号成功!')
          this.hideModal('isShowInvoiceNumModal')
          this.loadConfigFee()
        }
      }
    });
  }

  submitCorrelation() {
    var { checkData } = this.state;
    this.setState({
      patientMsg: checkData,
      correCode: true
    })
    this.hideModal('isShowCorrelationModal')
    // this.bookTime.current.focus()
  }

  onBlurPhone() {
    var mobile = /^[1-9]\d{10}$/;
    var phone = this.state.mobilephone;
    if (phone && !mobile.test(phone)) {
      message.error('手机号码输入格式不正确，请重新输入')
      return
    }
  }

  onKeyDownCheckPhone(e) {
    if (e.keyCode == '13') {
      //手机号码校验
      var mobile = /^[1-9]\d{10}$/;
      var phone = this.state.mobilephone;
      if (phone && !mobile.test(phone)) {
        message.error('手机号码输入格式不正确，请重新输入')
        return
      } else {
        this.bookAddress.current.focus()
      }
    }
  }

  onChangeSex() {
    this.bookPhone.current.focus()
  }

  onKeyDownCheckName(e) {
    if (e.keyCode == '13') {
      var reg = /^(([a-zA-Z+\.?\·?a-zA-Z+]{2,30}$)|([\u4e00-\u9fa5+\s·?\u4e00-\u9fa5+]{2,30}$))/;
      if (!reg.test(this.state.bookName)) {
        message.error('姓名格式填写错误，请重新输入！'); // 校验未通过
        return;
      } else {
        this.bookCardType.current.focus()
      }
    }
  }

  onKeyDownPatNote(e) {
    if (e.keyCode == '13') {
      // console.log(e.target.value)
      var params = {
        params: [{
          patID: !Util.isEmpty(this.state.patientMsg) ? this.state.patientMsg.patID : '',//patientDr -->patID
          userID: this.state.userData.userID,
          note: e.target.value
        }]
      }
      $http.post('urlDeault', this, {
        code: "03040046",
        data: params,
        success: function (res) {
          if (res.errorCode == '0') {

          }
        }
      });
    }
  }
  onBlurPatNote(e) {
    var params = {
      params: [{
        patID: !Util.isEmpty(this.state.patientMsg) ? this.state.patientMsg.patID : '',//patientDr -->patID
        userID: this.state.userData.userID,
        note: e.target.value
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040046",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {

        }
      }
    });
  }

  //获取证件类型的code
  onSelectCardType(e, id) {
    this.setState({
      typeCode: id.props.code
    })
    this.bookCard.current.focus()
  }

  onClickCardType(id) {
    this.setState({
      typeCode: id
    })
    this.bookCard.current.focus()
  }

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

  //医保读卡
  handleReadCardModal = async () => {
    this.hideModal('isShowReadCardModal')
    //需要医保结算
    let dllInputdata = {
      "params": [{
        "userID": this.state.userData.userID,
        qrCode: this.state.qrCode,
        icCardNum: this.state.icCardNum,
        hospID: this.state.userData.hospID
      }],
      "code": "05210036"
    }
    let data = await INSUYBUtil.insuYBHFReadCard(dllInputdata);
    // let data = "{\"errorCode\":\"0\",\"errorMessage\":\"成功\",\"result\":{\"userparams\":[{\"usernm\":\"马元新\",\"akb020\":\"0326\",\"akb021\":\"安徽医科大学第二附属医院\",\"aka101\":\"\",\"aab034\":\"\",\"aab300\":\"\"}],\"patYBparams\":[{\"aac001\":\"06471531\",\"akc020\":\"AC8822849\",\"aac002\":\"340103198403243525\",\"akc021\":\"011\",\"vvv001\":\"在职职工\",\"aab001\":\"107262\",\"aab004\":\"合肥普瑞眼科医院有限公司\",\"aac003\":\"张甦\",\"aac004\":\"2\",\"vvv002\":\"女性\",\"akc023\":\"36\",\"aab034\":\"\",\"aab300\":\"\",\"aab301\":\"340199\",\"aaa146\":\"合肥市市本级\",\"akc087\":\"587.63\",\"akc141\":\"001\",\"ska702\":\"\",\"skc111\":\"00\",\"skc112\":\"职工\",\"akb020\":\"0326\",\"akb021\":\"安徽医科大学第二附属医院\",\"skc516\":\"\",\"skc519\":\"\",\"mkc111\":\"11\",\"mkc112\":\"享受生育保险\",\"smc053\":\"\",\"smc055\":\"\",\"smc056\":\"\"}]}}"

    let res = JSON.parse(data);
    console.dir(res)
    if (res.errorCode == '0') {
      let YBPatDivdata = await INSUYBUtil.GetYBPatDivdata(res.result);
      if (YBPatDivdata.errorCode == '0') {
        let Divdata = YBPatDivdata.result;
        this.setState({
          issueData: res.result,
          Divdata: Divdata,
          isShowMedicalInsuranceModal: true//医保病人信息弹框
        })
      }
    }
    else {
      message.warn(res.errorMessage);
      return;
    }
  }

  handleSubmitMedical() {
    this.hideModal('isShowMedicalInsuranceModal')
    this.loadMedicalInsurance()//医保结算
  }

  loadMedicalInsurance() {

    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }
    var params = {
      params: [{
        userID: this.state.userData.userID,
        admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
        appointID: this.state.registrMsg && this.state.registrMsg.resDetailID,
        patID: this.state.patientMsg ? (this.state.patientMsg.patID) : '',
        hospID: this.state.userData.hospID,
        groupID: this.state.userData.groupID,
        locID: this.state.userData.locID,
        admType: "R",
        ip: this.state.ipConfig.ipv4,
        readCard: this.state.issueData
      }]
    }
    $http.post('urlDeault', this, {
      code: "05210041",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          this.setState({
            isNewShowRegistrModal: true
          })
        }
      }
    });
  }

  //病历本费
  handleCheckbox(e) {
    this.setState({
      checked: e.target.checked
    }, () => {
      if (this.state.checked == true) {
        this.loadMedicalMsg()//获取病历本费
      }
    })
  }

  handleGreenCheckbox(name, e) {
    if (e.target.checked == true) {
      this.setState({
        [name]: e.target.checked,
        visitFlag: false
      })
    } else {
      this.setState({
        [name]: e.target.checked
      })
    }
  }

  handleVisitCheckbox(name, e) {
    if (e.target.checked == true) {
      this.setState({
        [name]: e.target.checked,
        greenFlag: false
      })
    } else {
      this.setState({
        [name]: e.target.checked
      })
    }
  }

  handleVisitFlagCheckbox(name, e) {
    this.setState({
      [name]: e.target.checked
    })
  }

  loadMedicalMsg() {
    var params = {
      params: [{
        patID: !Util.isEmpty(this.state.patientMsg) ? this.state.patientMsg.patID : '',//patientDr -->patID
      }]
    }
    $http.post('urlDeault', this, {
      code: "03050252",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          this.setState({
            medicalFee: !Util.isEmpty(res.result) ? parseFloat(res.result) : 0
          })
        }
      }
    });
  }

  handleOtherSelectChange(name, e, code) {
    this.setState({
      [name]: e,
      otherPayCode: code ? code.props.code : '',
      otherPayMoney: 0
    })
  }

  handleMedicalRecord() {
    this.setState({
      isShowMedicalModal: true
    })
  }

  handleCharge() {
    console.log("handleCharge", this.state.chooseRegTitleID)
    if (Util.isEmpty(this.state.otherPayWayId)) {
      message.error('请选择支付方式!')
      return
    }
    var admReasonFlags = '';
    var admId = '';
    var defAdmId = '';
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlags = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlags = false;
          defAdmId = admReason[0].id;
        }
      }
    }
    var params = {
      params: [{
        userID: this.state.userData.userID,
        groupID: this.state.userData.groupID,
        cardID: this.state.patientMsg.cardID,
        locID: this.state.userData.locID,//loc -->locID
        hospID: this.state.userData.hospID,
        bookFlag: this.state.checked ? 'Y' : 'N',
        patID: this.state.patientMsg.patID,//patientDr -->patID
        contractUnitID: this.state.userData.hospID,
        admReasonID: this.state.admReasonId ? this.state.admReasonId : (admReasonFlags ? admId : defAdmId),
        paywStr: [{
          payWayID: this.state.otherPayWayId,
          payWayAmt: this.state.medicalFee,
          hospID: ''
        }],
        insuTypeCode: this.state.insuranceId,       //险种类型编码
        chooseRegTitleID: this.state.chooseRegTitleID
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040007",
      data: params,
      success: function (res) {
        if (res.errorCode === '0') {
          this.hideModal('isShowMedicalModal')
          message.success('操作成功！')
          this.setState({
            checked: false
          })
        }
      }
    });
    //将选中对象置空
    this.setState({
      chooseDocObj: {},
      chooseRegTitleID: ''
    })
  }

  onRef = ref => {
    this.onFace = ref
  }

  //人脸识别
  handleShowFaceRecognition() {
    this.setState({
      isShowFaceRecognitionModal: true,
      numbet: undefined
    })
  }

  loadCallBackMsg(data) {
    this.setState({
      paitId: data
    }, () => {
      this.loadFaceData()
    })
  }

  loadFaceData(data) {
    var params = {
      params: [{
        number: this.state.paitId || data,
        cardTypeID: this.state.cardTypeId ? this.state.cardTypeId : (this.state.cardStatus ? this.state.cardStatus : this.getQueryString('cardTypeId')),//cardTypeDr -->cardTypeID
        cardNo: (this.state.cardNum ? this.state.cardNum : (this.getQueryString('cardNum') || '')),
        present: "Y"
      }]
    }
    $http.post('urlDeault', this, {
      code: "03040004",
      data: params,
      success: function (res) {
        this.loadRegisterMsg(res.data);//查询患者挂号/预约记录
        if (res.errorCode === '0') {
          this.textInput.current.focus()
          message.success('患者信息查询成功！')
          this.setState({
            patientMsg: res.data,
            admReason: res.data.admReason,
            mobilephone: '',
            // credNo: this.getQueryString('cardNum'),
            // paitId: this.getQueryString('posId'),
            count: '',
            returnFlag: 'N',
            priorFalag: 'N',
            regFlag: 'N',
            cancleRegFlag: 'N',
            cancleAPPFlag: 'N',
            regPrintFlag: 'N',
            APPPrintFlag: 'N',
            note: res.data.note,
            visitedFlag: res.data.visitedFlag,
          }, () => {
            this.currentMeter()
          })

        }
      }
    });
  }

  handleTablsChange = key => {
    var date = new Date();//点击预约，日期+1
    this.setState({
      showDate: key === "1" ? false : true,
      activeKey: key,
      date: key === "1" ? date : moment(new Date()).add(1, 'days').format(),
      orderStatus: key === "1" ? false : true
    }, () => {
      this.loadSchedulingMsg()
      this.loadRegisterMsg()
      this.loadRegistrNumData()
      if (this.state.activeKey === "2") {
        this.bookName.current.focus();
      }
    })
  }

  /*************采集人像************ */

  handleAdress = () => {
    const { userData } = this.state;
    let data = {
      params: [{
        hospID: userData?.hospID || '',
        userID: userData?.userID || '',
        locID: userData?.locID || '',
      }]
    }
    $http.post('urlDeault', this, {
      code: "03030114",
      data: data,
      success: function (res) {
        if (res.errorCode == '0') {
          let windowHost = ''
          let url = ''
          if (process.env.NODE_ENV === 'production') {
            windowHost = window.location && window.location.origin ? window.location.origin : (window.location && window.location.protocol ? (window.location.protocol + '//' + window.location.hostname) : "");
            url = !Util.isEmpty(res.result) ? res.result.upLoadUrl : '';
          } else {
            windowHost = 'https://172.16.1.6'
            url = !Util.isEmpty(res.result) ? res.result.upLoadUrl : '';
          }
          this.setState({
            actionUrl: !Util.isEmpty(res.result) ? res.result.upLoadUrl : '',
            downLoadUrl: !Util.isEmpty(res.result) ? res.result.downLoadUrl : '',
            faceImgAdress: url.indexOf("http") !== -1 ? url : windowHost + url,
            imageAddress: url.indexOf("http") !== -1 ? url : windowHost
          }, () => {
            console.dir(this.state.faceImgAdress)
          })
        }
      }
    });
  }

  handleOpenPhoto() {
    if (Util.isEmpty(this.state.patientMsg) || Util.isEmpty(this.state.patientMsg.patID)) {
      message.error('请先输入病人信息，进行人脸采集')
      return
    }
    this.setState({
      tackPhoto: true
    })
  }

  //人脸特征值录入
  onRef = (ref) => {
    this.refChildFace = ref
  }

  getBase64 = (img, callback) => {
    const reader = new FileReader();
    reader.addEventListener('load', () => callback(reader.result));
    reader.readAsDataURL(img);
  }
  loadDara = (v, img) => {
    this.setState({
      faceImg: v,
    })
    let fiel = this.dataURLtoFile(img, "x.jpg")

    this.getBase64(fiel, imageUrl =>
      this.setState({
        // imageUrl,
        // loading: false,
        // fileList: info.file,
      }, () => {
        let that = this
        let formData = new FormData();
        formData.append("file", fiel);
        const option = {
          method: 'post',
          mode: 'cors',
          headers: {},
          body: formData
        };
        // http://218.17.212.34:53774/uploadFile?fileType=health
        // let url  = "http://172.18.100.86:3008/uploadFile?fileType=health";
        fetch(that.state.faceImgAdress, option).then(response => {
          if (response.ok) {
            that.refChildFace.clearVideo()
            that.setState({
              loadingDom: false,
              tackPhoto: false
            })
            return response.text();
          } else {
            that.setState({
              loadingDom: false
            })
            console.log('网络错误，请稍后再试');
            return;
          }
        }).then(data => {
          let dataS = JSON.parse(data);
          if (+dataS.errorCode == 0) {
            // let str = that.state.faceImg.match(/(\S*)\/uploadFile/)[1];
            that.setState({
              // [name]:this.state.faceImg + dataS.filePath,
              imageUrl: dataS.filePath,
              defaultImg: that.state.downLoadUrl + dataS.filePath
            }, () => {
              console.log("imageUrlimageUrl----", that.state.imageUrl)
              console.log("defaultImg----", that.state.defaultImg)
              this.handleUpdateMessage()
            })
          } else {

            message.warning(dataS.errorMessage, this.state.userData && this.state.userData.messageTime)
            that.setState({
              // [name]:this.state.faceImg + dataS.filePath,

            }, () => {

            })
          }
          // this.state.fileList.push(obj);
          // this.setState({imgList:this.state.imgList});
        }).catch(error => {
          this.setState({
            // [name]:this.state.faceImg + dataS.filePath,

          }, () => {
            message.warning("上传失败,请重新上传", this.state.userData && this.state.userData.messageTime)
          })

        })
      }),

    );
  }
  dataURLtoFile = (dataurl, filename) => {//将base64转换为文件
    var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
      bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
    while (n--) {
      u8arr[n] = bstr.charCodeAt(n);
    }
    return new File([u8arr], filename, { type: mime });
  }

  handleUpdateMessage() {
    var params = {
      params: [{
        faceValue: this.state.faceImg && this.state.faceImg || undefined,//记录人脸特征值
        patPicture: this.state.imageUrl && this.state.imageUrl || undefined,
        patID: this.state.patientMsg ? this.state.patientMsg.patID : '',
        patUpdateUserID: this.state.userData.userID,
        userID: this.state.userData.userID,
      }]
    }
    $http.post('urlS', this, {
      code: "03030012",
      data: params,
      success: function (res) {
        if (res.errorCode == '0') {
          message.success('保存成功！')
        }
      }
    });
  }

  render() {
    //时间段0000144406
    let resModelOption = []
    this.state.resModelSelect && this.state.resModelSelect.map((item, index) => {
      resModelOption.push(<Option key={index} value={item.regTitleID}>{item.regTitleDesc}</Option>)
    })
    //时间段0000144406
    let timeRangeOption = []
    this.state.timeRange && this.state.timeRange.map((item, index) => {
      timeRangeOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
    })

    //卡类型
    let cardTypeOption = []
    this.state.cardTypeData && this.state.cardTypeData.map((item, index) => {
      cardTypeOption.push(<Option key={index} value={item.id}><Tooltip title={item.descripts}>{item.descripts}</Tooltip></Option>)
    })

    //证件类型
    let credTypeOption = []
    this.state.credTypeData && this.state.credTypeData.map((item, index) => {
      credTypeOption.push(<Option key={index} value={item.id} code={item.code}
        onClick={this.onClickCardType.bind(this, item.code)}>{item.descripts}</Option>)
    })
    //性别
    let sexOption = []
    this.state.sexData && this.state.sexData.map((item, index) => {
      sexOption.push(<Option key={index} value={item.id} onClick={this.onChangeSex.bind(this)}>{item.descripts}</Option>)
    })

    //身份标签
    let socialStatusOption = []
    this.state.socialStatusData && this.state.socialStatusData.map((item, index) => {
      socialStatusOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
    })

    //病人类型
    let patTypeOption = []
    this.state.patTypeData && this.state.patTypeData.map((item, index) => {
      patTypeOption.push(<Option key={index} value={item.id + ''}>{item.descripts}</Option>)
    })

    //结算类型admReason
    let admReasonOption = []
    this.state.admReason && this.state.admReason.map((item, index) => {
      admReasonOption.push(<Option key={index} value={item.id} opinsutype={item.OPInsuType} insuAlertBeforeAdm={item.insuAlertBeforeAdm}>{item.descripts}</Option>)
    })

    //险种类型insurance
    let insuranceOption = []
    this.state.insuranceData && this.state.insuranceData.map((item, index) => {
      insuranceOption.push(<Option key={index} value={item.id} code={item.code}>{item.descripts}</Option>)
    })

    //获取科室信息
    let departMentOption = []
    this.state.departMentData && this.state.departMentData.map((item, index) => {
      departMentOption.push(<Option key={index} value={item.id} code={item.descripts}
        name={item.descriptsSPCode}>{item.descripts}</Option>)
    })

    //获取科室医生信息
    let depDoctorOption = []
    this.state.depDoctorData && this.state.depDoctorData.map((item, index) => {
      depDoctorOption.push(<Option key={index} value={item.descripts + '-' + item.code + item.descriptsSPCode + '*' + item.id + ''}>{item.descripts}</Option>)
    })

    //接待人
    let unawaresListOption = []
    this.state.unawaresList && this.state.unawaresList.map((item, index) => {
      unawaresListOption.push(<Option key={index} value={item.id} code={item.descripts} name={item.descriptsSPCode}>{item.descripts}</Option>)
    })

    //支付方式
    var payWayOtherOption = []
    this.state.newPayWay && this.state.newPayWay.map((item, index) => {
      payWayOtherOption.push(<Option key={index} value={item.paywID} code={item.paywCode}>{item.paywDesc}</Option>)
    })

    var patStatus = false
    if (!Util.isEmpty(this.state.patTypeData) && !Util.isEmpty(this.state.patientMsg)) {
      var patType = this.state.patTypeData
      for (var i = 0; i < patType.length; i++) {
        if (patType[i].id == this.state.patientMsg.patTypeID) {
          patStatus = true
          break;
        }
      }
    } else {
      if (!Util.isEmpty(this.state.patientMsg) && !Util.isEmpty(this.state.patientMsg.patTypeID)) {
        patStatus = false
      }
    }

    var admReasonFlag = '';
    var admId = '';
    var defAdmId = '';
    if (this.state.admReason) {
      var admReason = this.state.admReason;
      for (var i = 0; i < admReason.length; i++) {
        if (admReason[i].defaultFlag == 'Y') {
          admReasonFlag = true;
          admId = admReason[i].id;
          break;
        } else {
          admReasonFlag = false;
          defAdmId = admReason[0].id;
        }
      }
    }

    var { activeKey, schedulData, patientMsg, checkData, totalWidth, isShowResModel } = this.state;
    var registOption = [];
    if (this.state.schedulData && this.state.schedulData.length > 0) {
      schedulData && schedulData.map((item, index) => {
        registOption.push(
          <Col span={4} style={{ marginRight: '10px', width: '252px', marginBottom: '10px' }} key={index + 'col'}>
            <Card className={this.state.rowIds == index && this.state.setBabkground ?
              (parseInt(item.registedNum) >= parseInt(item.registNum) ? '' : 'scheduling-card-hover') : ''}

              id={this.state.rowIds == index && this.state.setBabkground ?
                (parseInt(item.registedNum) >= parseInt(item.registNum) ? 'registr-card-bgd-disabled' : 'registr-bgd-hover-id') :
                (parseInt(item.registedNum) >= parseInt(item.registNum) ? 'registr-card-bgd-disabled' : '')}

              title={<div className={this.state.rowIds == index && this.state.setBabkground ?
                (parseInt(item.registedNum) >= parseInt(item.registNum) ? 'header-class' : 'registr-bgd-hover') : ''}>
                <div style={{ display: 'flex' }}>{parseInt(item.registedNum) >= parseInt(item.registNum) ? <div className='noNum-sprite'></div> : null}
                  <div>
                    <div>
                      {/* <div style={{ fontSize: '16px' }}>{item.docName}</div> */}
                      {/* <div className={item.onLineStatusCode == 'Y' ? 'card-splice-onLine' : 'card-splice-out'}></div> */}
                      <div className={item.onLineStatusCode == 'Y' ? 'cs-bg cs-onLine' : 'cs-bg cs-out'}>
                        {item.onLineStatusCode == 'Y' ? '在线' : '离线'}
                      </div>
                    </div>
                  </div>
                </div>
              </div>}
              extra={<div style={{ fontSize: '14px' }}><span style={{ color: '#999', fontSize: '12px', marginRight: '8px' }}>已用号源/总号源</span><span style={{ color: '#007AFF' }}>{item.registedNum}</span>/<span>{item.registNum}</span></div>}
              bordered={true} key={index + 'crad'}
              tabIndex={'-1'} hoverable={true}
              // id={parseInt(item.registedNum) >= parseInt(item.registNum) ? 'registr-card-bgd-disabled' : ''}
              // className={this.state.rowIds == index && this.state.setBabkground ? 'registration-card-bg' : ''}
              onKeyDown={this.handleRegistrBtn.bind(this, index, item)}
              onMouseOver={this.addRegistrBtn.bind(this, index)}
              onMouseEnter={this.addFloatElement.bind(this, index, item)}
              onDoubleClick={this.outPreAuditFun.bind(this, item)}
              onClick={this.addBackground.bind(this, index)}
              onMouseLeave={this.removeRegistrBtn.bind(this)}>
              <div style={{ display: 'flex' }}>
                {this.state.mouseElement && index == this.state.rowIds && this.state.floatStatus && this.state.orderStatus ?
                  <Tooltip getPopupContainer={() => document.querySelector('.new-registration-body')} placement="bottom"
                    overlayStyle={{ maxHeight: '30%', maxWidth: '28%', zIndex: '10000' }}
                    title={this.loadElementDome()}>
                    <div style={{ background: '#eff9f2', width: '100%' }}>
                      <div style={{ display: 'flex', width: '100%' }}>
                        {/* <div className={item.sex == '1' ? 'card-splice-boy' : 'card-splice-girl'}></div> */}
                        {!Util.isEmpty(item.image) ? <div style={{ width: 86, height: 120 }}><img src={item.image} style={{ width: '100%', height: '100%' }} /></div> :
                          <div className={item.docSexCode == '1' ? 'card-splice-boy' : 'card-splice-girl'}></div>}
                        <div style={{ marginLeft: 10, width: 'calc(100% - 86px)' }}>
                          <div className="cart-doc-name">{item.docName}</div>
                          <div style={{ width: '100%' }} className="ellipsis">
                            <span style={{ color: '#888888', marginRight: "6x" }}><Icon className='registr-card-regtitle' /></span>
                            <span style={{ color: '#666666' }} title={item?.regTitle || ''}>{item.regTitle}</span>
                          </div>
                          <div style={{ margin: "4px 0" }}>
                            <span style={{ marginRight: "6px" }}><Icon className='registr-card-locDescripts' /></span>
                            <span style={{ color: '#13C2C2' }}>{item.locDescripts}</span>
                          </div>
                          <span style={{ color: '#888888', marginRight: "6px" }}>
                            <Icon className='registr-card-price' />
                          </span>
                          <span style={{ color: '#007AFF' }}>{item.price}</span>
                          <span style={{ color: '#666666' }}> 元/次</span>
                        </div>
                      </div>
                      {/*
                        create by SlimYi
                        2022/08/23
                      */}
                      <div style={{ marginTop: '8px' }}>
                        <span>专长：</span> {item.experise !== '' ? item.experise : '暂未维护专长项目'}
                      </div>
                    </div></Tooltip> :
                  <div style={{ /**background: '#eff9f2',**/ width: '100%' }}>
                    <div style={{ display: 'flex', width: '100%' }}>
                      {!Util.isEmpty(item.image) ? <div style={{ width: 86, height: 120 }}><img src={item.image} style={{ width: '100%', height: '100%' }} /></div> :
                        <div className={item.docSexCode == '1' ? 'card-splice-boy' : 'card-splice-girl'}></div>}
                      <div style={{ marginLeft: 10, width: 'calc(100% - 86px)' }}>
                        <div className="cart-doc-name">{item.docName}</div>
                        <div style={{ width: '100%' }} className="ellipsis">
                          <span style={{ color: '#888888', marginRight: "6px" }}><Icon className='registr-card-regtitle' /></span>
                          <span style={{ color: '#666666' }} title={item?.regTitle || ''}>{item.regTitle}</span>
                        </div>
                        <div style={{ margin: "4px 0" }}>
                          <span style={{ marginRight: "6px" }}><Icon className='registr-card-locDescripts' /></span>
                          <span style={{ color: '#13C2C2' }}>{item.locDescripts}</span>
                        </div>
                        <span style={{ color: '#888888', marginRight: "6px" }}>
                          <Icon className='registr-card-price' />
                        </span><span style={{ color: '#007AFF' }}>{item.price}</span>
                        <span style={{ color: '#666666' }}> 元/次</span>
                      </div>
                    </div>
                    {/*
                      create by SlimYi
                      2022/08/23
                    */}
                    <div className="registr-card-expertise" style={{ marginTop: 8, paddingRight: 12 }}>
                      <Tooltip placement="right" title={item.experise ? '专长：' + item.experise : ''} overlayClassName="registr-card-expertise-tooltip">
                        <div className={(item.experise ? 'registr-card-expertise-content' : '') + ' ellipsis'} style={{ width: '96%' }}>
                          <span>专长：</span>
                          {item.experise !== '' ? (
                            <span>{item.experise}</span>
                          ) : <span style={{ color: '#999' }}>暂无数据</span>}
                        </div>
                      </Tooltip>
                    </div>
                  </div>
                }
              </div>
              <div style={{ display: "none" }}>
                {this.state.rowIds == index && this.state.mouseElement ? (this.state.orderStatus ?
                  (parseInt(item.registedNum) >= parseInt(item.registNum) ?
                    <div className='registr-btn'>
                      <Button autoFocus size='small' style={{ color: '#666666', height: '5px', border: '0px' }}></Button></div> : <div className='registr-btn'
                        onClick={this.handleToOrder.bind(this, item)}>
                      <Button autoFocus size='small' style={{ color: '#007AFF', height: '5px', border: '0px' }}></Button></div>) :
                  (this.state.groupConfig && this.state.groupConfig.IfChargeFlag ?
                    (parseInt(item.registedNum) >= parseInt(item.registNum) ?
                      <div className='registr-btn'>
                        <Button autoFocus size='small' style={{ color: '#666666', height: '5px', border: '0px' }}></Button></div> : <div className='registr-btn'
                          onClick={this.showRegistrModal.bind(this, item)}>
                        <Button autoFocus size='small' style={{ color: '#007AFF', height: '5px', border: '0px' }}></Button></div>) : null)) : null}
              </div>
            </Card>
          </Col>
        )
      })
    } else {
      registOption.push(
        <div key='1' style={{ color: 'red', textAlign: 'center', fontSize: '15px' }}>
          <img src={noData} /><div>当前时间段，该科室无坐诊医生</div></div>
      )
    }

    var invNo = '';
    var currentInvNo = ''
    //对发票号进行截取
    if (this.state.currentInvNoInfo) {
      var currentInvNoInfo = this.state.currentInvNoInfo;
      invNo = currentInvNoInfo.substring(currentInvNoInfo.indexOf('^') + 1);
      currentInvNo = invNo.substring(invNo.indexOf('^') + 1)
    }

    let registerDom = (
      <div className="register-dom">
        <div className="register-inpit">
          <span className="nlb-lable">日期：</span><DatePicker placeholder='时间' style={{ width: '158px' }}
            disabledDate={this.disabledDate.bind(this)}
            disabled={!this.state.showDate}
            onChange={this.chengeTime.bind(this)}
            value={this.state.date ? moment(this.state.date, dayFormat) : ''} />
          <span className="nlb-lable" style={{ marginLeft: 20 }}>时段：</span><Select placeholder='时段' style={{ width: "158px" }}
            value={this.state.timeRangeId ? this.state.timeRangeId : this.state.timeSolt}
            onChange={this.handleSelectChange.bind(this, 'timeRangeId')}
            allowClear={true} getPopupContainer={triggerNode => triggerNode.parentNode}>
            {timeRangeOption}
          </Select>
          <span className="nlb-lable" style={{ marginLeft: 20 }}>科室：</span><Select placeholder='请选择科室' style={{ width: '158px' }}
            onChange={this.changeDepartMent.bind(this)} showSearch={true}
            filterOption={(input, option) =>
              option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
              || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
              || option.props.name.toLowerCase().indexOf(input.toLowerCase()) >= 0
            }
            value={this.state.locId ? this.state.locId : undefined}
            ref={this.textInput}
            allowClear={true} getPopupContainer={triggerNode => triggerNode.parentNode}>
            {departMentOption}
          </Select>
          <span className="nlb-lable" style={{ marginLeft: 20 }}>医生：</span><Select placeholder='请选择医生' style={{ width: '158px' }}
            onChange={this.changeDepDoctor.bind(this)} showSearch={true}
            ref={this.textSelect}
            allowClear={true} getPopupContainer={triggerNode => triggerNode.parentNode}>
            {depDoctorOption}
          </Select>
        </div>
        <Row style={{ height: store.getState().tableHeight.y - 99 + 'px', overflow: 'auto' }}>
          {registOption}
        </Row>
      </div>
    )

    return (<div className="new-registration-body">
      {/**读卡 */}
      <ReadCard ref={ref => this.readCard = ref}></ReadCard>
      <ColumnAuthoritysModel
        clientWidth='800px'
        compontName="RegistrationPage"
        configType="C"
        onRef={this.onColumnRef}
        reloadData={this.initData}
      />
      {/**收费弹窗 */}
      <NewShowRegistrModal isShow={this.state.isNewShowRegistrModal}
        patientMsg={this.state.patientMsg}
        registrMsg={this.state.registrMsg}
        newPayWay={this.state.newPayWay}
        checked={this.state.checked}
        medicalFee={this.state.medicalFee}
        confirmLoading={this.state.confirmLoading}
        onSubmitRegastr={this.onSubmitRegastr.bind(this)}
        registrSumData={this.state.registrSumData}
        onHide={this.hideModal.bind(this, 'isNewShowRegistrModal')}>
      </NewShowRegistrModal>

      {/**设置发票号  */}
      <ShowInvoiceNumModal isShow={this.state.isShowInvoiceNumModal}
        currentInvNo={currentInvNo}
        onSubmit={this.loadInvoiceNum.bind(this)}
        onHide={this.hideModal.bind(this, 'isShowInvoiceNumModal')}>
      </ShowInvoiceNumModal>

      {/**退号 */}
      <ShowBackNumModal isShow={this.state.isShowBackNumModal}
        registrFee={this.state.registrFee}
        patientMsg={this.state.patientMsg}
        recordData={this.state.recordData}
        onSubmit={this.registrBackNum.bind(this)}
        onHide={this.hideModal.bind(this, 'isShowBackNumModal')}>
      </ShowBackNumModal>

      {/**预约 , bookSex, credType, credNo, mobilephone*/}
      <ShowToOrderModal isShow={this.state.isShowToOrderModal}
        onSubmit={this.handleSubmitOrder.bind(this)}
        orderData={this.state.orderData}
        bookStatus={this.state.bookStatus}
        setRowId={this.state.setRowId}
        bookName={this.state.bookName}
        bookSex={this.state.bookSex}
        credNo={this.state.credNo}
        mobilephone={this.state.mobilephone}
        recordData={this.state.orderSchData}
        date={this.state.date}
        onHide={this.hideModal.bind(this, 'isShowToOrderModal')}>
      </ShowToOrderModal>
      {/**取消预约 */}
      <CancelOrderModal isShow={this.state.isCancelOrderModal}
        patientMsg={this.state.patientMsg}
        recordData={this.state.recordData}
        onSubmit={this.cannelRegistr.bind(this)}
        onHide={this.hideModal.bind(this, 'isCancelOrderModal')}></CancelOrderModal>

      {/**取号 */}
      <ShowGetNumModal isShow={this.state.isShowGetNumModal}
        patientMsg={this.state.patientMsg}
        recordData={this.state.recordData}
        newPayWay={this.state.newPayWay}
        onSubmitGetNum={this.onSubmitGetNum.bind(this)}
        registrSumData={this.state.getRegistrData}
        onHide={this.hideModal.bind(this, 'isShowGetNumModal')}>
      </ShowGetNumModal>

      {/**关联信息弹框 */}
      <CorrelationModal isShow={this.state.isShowCorrelationModal}
        onSubmit={this.submitCorrelation.bind(this)}
        checkData={this.state.checkMsg}
        onHide={this.hideModal.bind(this, 'isShowCorrelationModal')}>
      </CorrelationModal>

      {/**医保病人弹框 */}
      <ShowMedicalInsuranceModal isShow={this.state.isShowMedicalInsuranceModal}
        Divdata={this.state.Divdata}
        onSubmit={this.handleSubmitMedical.bind(this)}
        onHide={this.hideModal.bind(this, 'isShowMedicalInsuranceModal')}>
      </ShowMedicalInsuranceModal>

      {/**人脸识别 */}
      <ShowFaceRecognitionModal isShow={this.state.isShowFaceRecognitionModal}
        businessCode='003' onRef={this.onRef}
        onSubmit={this.loadCallBackMsg.bind(this)}
        onHide={this.hideModal.bind(this, 'isShowFaceRecognitionModal')}>
      </ShowFaceRecognitionModal>
      <Modal
        width='1120px'
        visible={this.state.tackPhoto}
        title={"采集人像标识"}
        onCancel={() => {
          this.refChildFace.clearVideo()
          this.setState({
            tackPhoto: false
          }, () => {

          })
        }}
        centered={true}
        footer={null}>
        {
          this.state.tackPhoto && this.state.tackPhoto ? <FaceRecognitionManual ref={this.onRef} loadDara={this.loadDara}></FaceRecognitionManual> : ""
        }
      </Modal>
      <div className='register-left-message'>
        <div className="nrts-left" style={{ width: '15%', float: 'left' }}>
          <div style={{ textAlign: 'center', padding: '10px 0', borderBottom: '1px solid #e8e8e8' }}>
            {!Util.isEmpty(this.state.defaultImg) || (patientMsg && patientMsg.patImage) ? <div onClick={this.handleOpenPhoto.bind(this)}><img src={this.state.defaultImg ? this.state.defaultImg :
              (patientMsg.patImage ? (this.state.imageAddress + patientMsg.patImage) : '')} style={{ width: '120px', height: '125px', cursor: 'pointer' }} />
            </div> : <div style={{
              width: '120px', height: '125px', cursor: 'pointer', textAlign: 'center',
              borderRadius: '4px', border: '2px dashed #e8e8e8', marginLeft: '25%'
            }} onClick={this.handleOpenPhoto.bind(this)}>
              <div style={{ marginTop: 40 }}><Icon type='plus' /><div style={{ marginTop: 5, fontSize: '16px' }}>采集人像</div></div>
            </div>}
          </div>
          <div className="nrts-left-top">
            <div className="nrts-left-top-content">
              <Select placeholder='请选择卡类型' getPopupContainer={triggerNode => triggerNode.parentNode}
                value={this.state.cardTypeId ? this.state.cardTypeId : (this.state.cardStatus)}
                onSelect={this.changeCardType.bind(this)} style={{ width: "100%" }}>
                {cardTypeOption}
              </Select>
              {/* <Search className={this.state.readMode == 'R' ? 'disable-input-title ' : ''}
                placeholder='身份证号码' style={{ margin: "8px 0" }}
                value={this.state.readStatus == 'read' ? this.state.readCardNo :
                  (this.state.cardNum ? this.state.cardNum : '')}
                readOnly={this.state.readMode == 'R' ? true : false}
                onChange={this.changeCardNum.bind(this)}
                enterButton="读身份证"
                onSearch={this.handleReadCard.bind(this)}
                onKeyDown={this.handleSelectPersonMsg.bind(this, 'msg')}
              /> */}
              {this.state.cardTypeId == '8' || this.state.cardTypeId == '11' ?
                <div style={{ margin: "8px 0" }}>
                  <Input placeholder='电子凭证编码' style={{ width: 'calc(100% - 96px)', marginTop: "8px", marginRight: "14px" }} ref={(input) => this.input = input}
                    value={this.state.medVoucherObj?.erQrCode || ''} />
                  <Button type='primary' onClick={() => this.readMedVoucher()} style={{ width: "82px", padding: 0 }}>电子凭证</Button>
                </div>
                : ''}

              <div style={{ margin: "8px 0" }}>
                <Input placeholder='请输入身份证号码' style={{ width: 'calc(100% - 96px)', marginRight: "14px" }}
                  onKeyDown={this.handleSelectPersonMsg.bind(this, 'msg')} ref={(input) => this.input = input}
                  value={this.state.readCardNo}
                  onChange={this.changeCardNum.bind(this)} />
                <Button type='primary' onClick={this.handleReadCard.bind(this)} style={{ width: "82px", padding: 0 }}>读身份证</Button>
              </div>

              <Input placeholder='病人ID/身份证/手机' style={{ width: 'calc(100% - 96px)', marginRight: "14px" }}
                onKeyDown={this.handleSelectPersonMsg.bind(this, 'msg')} ref={(input) => this.input = input}
                value={this.state.paitId ? this.state.paitId : ''}
                onChange={this.changePaitId.bind(this)} />
              <Button type='primary' onClick={this.handleShowFaceRecognition.bind(this)} style={{ width: "82px", padding: 0 }}>人脸识别</Button>
            </div>
          </div>
          <div className="nrts-left-bottom">
            <div className="nlb-form-item">
              <span className="nlb-lable">病人ID号：</span>
              <Input placeholder='请输入病人ID' disabled={patientMsg ? true : false} value={patientMsg ? patientMsg.patNo : this.state.patinId}
                onChange={Util.commonInputChange.bind(this, 'patinId')} style={{ width: 'calc(100% - 86px)' }} /></div>
            <div className="nlb-form-item">
              <div className="nlb-lable"><span style={{ color: '#f5222d', fontFamily: 'SimSun', marginLeft: '10%' }}>*</span>姓名：</div>
              <Input placeholder='输入姓名，回车键校验' style={{ width: 'calc(100% - 86px)' }} disabled={patientMsg ? true : false}
                onChange={Util.commonInputChange.bind(this, 'bookName')}
                ref={this.bookName}
                className={this.state.orderStyle && Util.isEmpty(patientMsg) && Util.isEmpty(checkData) && Util.isEmpty(this.state.bookName) ? 'registr-btn-style' : ''}
                onKeyDown={this.onKeyDownCheckName.bind(this)}
                value={this.state.bookName ? this.state.bookName : (this.state.correCode && checkData ? checkData.patName : (patientMsg ? patientMsg.patName : this.state.bookName))} />
            </div>
            <div className="nlb-form-item">
              <div className="nlb-lable"><span style={{ color: '#f5222d', fontFamily: 'SimSun' }}>*</span><span>证件类型：</span></div>
              <Select style={{ width: 'calc(100% - 86px)' }} getPopupContainer={triggerNode => triggerNode.parentNode}
                onChange={Util.handleSelectChange.bind(this, 'credType')}
                onSelect={this.onSelectCardType.bind(this)}
                ref={this.bookCardType}
                disabled={patientMsg ? true : false} value={patientMsg ? patientMsg.patCredTypeID :
                  (this.state.credType ? this.state.credType : (this.state.credTypeData ? this.state.credTypeData[0].id : undefined))} placeholder='请选择证件类型'>
                {credTypeOption}
              </Select></div>
            <div className="nlb-form-item">
              <div className="nlb-lable"><span style={{ color: '#f5222d', fontFamily: 'SimSun' }}>*</span><span >证件号码：</span></div>
              <Input placeholder='请输入证件号码,按回车键校验' disabled={patientMsg ? true : false} maxLength={18}
                onKeyDown={this.checkMessage.bind(this)}
                ref={this.bookCard}
                onBlur={this.onBlurCardNo.bind(this)}
                className={this.state.orderStyle && Util.isEmpty(patientMsg) && Util.isEmpty(checkData) && Util.isEmpty(this.state.credNo) ? 'registr-btn-style' : ''}
                onChange={Util.commonInputChange.bind(this, 'credNo')}
                value={this.state.credNo ? this.state.credNo : (checkData ? checkData.patCredNo : (patientMsg ? patientMsg.patCredNo : this.state.credNo))}
                style={{ width: 'calc(100% - 86px)' }} /></div>
            <div className="nlb-form-item">
              <div className="nlb-lable"><span style={{ color: '#f5222d', fontFamily: 'SimSun', marginLeft: '10%' }}>*</span>性别：</div>
              <Select style={{ width: 'calc(100% - 86px)' }} getPopupContainer={triggerNode => triggerNode.parentNode}
                placeholder='请选择性别'
                ref={this.bookSex}
                className={this.state.orderStyle && Util.isEmpty(patientMsg) && Util.isEmpty(checkData) && Util.isEmpty(this.state.bookSex) ? 'registr-btn-style' : ''}
                onChange={Util.handleSelectChange.bind(this, 'bookSex')}
                onSelect={this.onChangeSex.bind(this)}
                value={this.state.bookSex ? this.state.bookSex : (this.state.correCode && checkData ? checkData.patSexID : (patientMsg ? patientMsg.patSexID : this.state.bookSex))}
                disabled={patientMsg ? true : false}>
                {sexOption}
              </Select>
            </div>
            <div className="nlb-form-item">
              <span className="nlb-lable">出生日期：</span>
              <DatePicker placeholder='出生日期' disabled={patientMsg ? true : false} style={{ width: 'calc(100% - 138px)' }}
                onChange={this.changeBirthDay.bind(this)}
                className="nlb-picker"
                format={this.state.birthDayDate ? 'YYYY-MM-DD' : 'YYYYMMDD'}
                value={patientMsg && patientMsg.patBirthDate ? moment(patientMsg.patBirthDate, dayFormat) :
                  (this.state.birthDayDate ? moment(this.state.birthDayDate, dayFormat) : undefined)} />
              <Tooltip title={patientMsg ? patientMsg.patAge : this.state.yearOld}>
                <Input style={{ width: '48px' }} placeholder='年龄' disabled={patientMsg ? true : false}
                  onChange={Util.commonInputChange.bind(this, 'yearOld')}
                  className="picker-input"
                  value={patientMsg ? patientMsg.patAge : this.state.yearOld} /></Tooltip>
            </div>
            <div className="nlb-form-item">
              <div className="nlb-lable"><span style={{ color: '#f5222d', fontFamily: 'SimSun' }}>*</span>联系电话：</div>
              <Input style={{ width: 'calc(100% - 86px)' }} disabled={patientMsg ? true : false} maxLength={11}
                onChange={Util.commonInputChange.bind(this, 'mobilephone')}
                onBlur={this.onBlurPhone.bind(this)}
                className={this.state.orderStyle && Util.isEmpty(patientMsg) && Util.isEmpty(checkData) && Util.isEmpty(this.state.mobilephone) ? 'registr-btn-style' : ''}
                onKeyDown={this.onKeyDownCheckPhone.bind(this)}
                ref={this.bookPhone}
                value={this.state.mobilephone ? this.state.mobilephone : (this.state.correCode && checkData ? checkData.patMobile : (patientMsg ? patientMsg.patMobile : this.state.mobilephone))}
                placeholder='请输入手机号码,按回车键校验' /></div>
            <div className="nlb-form-item">
              <span className="nlb-lable">病人类型：</span>
              <Select style={{ width: 'calc(100% - 86px)' }} getPopupContainer={triggerNode => triggerNode.parentNode}
                onChange={Util.handleSelectChange.bind(this, 'personType')} allowClear
                disabled={patientMsg ? true : false} value={patientMsg ? (patStatus == true ? patientMsg.patTypeID : undefined) : this.state.personType} placeholder='请选择病人类型'>
                {patTypeOption}
              </Select></div>
            <div className="nlb-form-item">
              <span className="nlb-lable">账户余额：</span>
              <Input addonBefore='¥' style={{ width: 'calc(100% - 86px)' }} disabled={patientMsg ? true : false}
                onChange={Util.commonInputChange.bind(this, 'personMoney')}
                className="nlb-person-mone"
                value={patientMsg ? patientMsg.accountBalance : this.state.personMoney} placeholder='请输入账户余额' /></div>
            <div className="nlb-form-item">
              <span className="nlb-lable">结账费别：</span>
              <Select style={{ width: 'calc(100% - 86px)' }} getPopupContainer={triggerNode => triggerNode.parentNode}
                onChange={this.handleSelectChange.bind(this, 'admReasonId')}
                value={this.state.admReasonId ? this.state.admReasonId :
                  (admReasonFlag ? admId : (defAdmId ? defAdmId : undefined))} placeholder='请选择结账类型'>
                {admReasonOption}
              </Select></div>
            <div className="nlb-form-item">
              <span className="nlb-lable">报备人员：</span>
              <Input style={{ width: 'calc(100% - 86px)' }}
                value={patientMsg ? patientMsg.adminUser : this.state.adminUser}
                placeholder='请输入报备人员'
                disabled
                onChange={Util.commonInputChange.bind(this, 'adminUser')}
              />
            </div>
            <div className="nlb-form-item">
              <span className="nlb-lable">接待人员：</span>
              <Input style={{ width: 'calc(100% - 86px)' }}
                placeholder='请输入接待人员'
                onChange={Util.commonInputChange.bind(this, 'patSource')}
              />
            </div>

            {/**
             @ByYQL 门诊事前审核添加险种类型
             Creat：2021-12-17
             */}
            {this.state.insuAlertBeforeAdm == 'Y' ? <div className="nlb-form-item">
              <span className="nlb-lable">险种类型：</span>
              <Select style={{ width: 'calc(100% - 86px)' }} getPopupContainer={triggerNode => triggerNode.parentNode}
                onChange={this.handleSelectChange.bind(this, 'insuranceId')}
                value={this.state.insuranceId ? this.state.insuranceId : undefined} placeholder='请选择险种类型'>
                {insuranceOption}
              </Select></div> : ''}

            <div className="nlb-form-item">
              <div className="nlb-lable">备注：</div>

              <TextArea style={{ width: 'calc(100% - 86px)' }}
                autoSize={{ minRows: 1 }}
                onChange={Util.commonInputChange.bind(this, 'note')}
                ref={this.note}
                // className={this.state.orderStyle && Util.isEmpty(patientMsg) && Util.isEmpty(checkData) && Util.isEmpty(this.state.note) ? 'registr-btn-style' : ''}
                //onKeyDown={this.onKeyDownPatNote.bind(this)}
                onBlur={this.onBlurPatNote.bind(this)}
                value={this.state.note} />
            </div>
            <div style={{ textAlign: 'right' }}>
              <Checkbox checked={this.state.checked} disabled={Util.isEmpty(this.state.patientMsg)}
                onChange={this.handleCheckbox.bind(this)}>病历本费</Checkbox>
              <Checkbox checked={this.state.greenFlag} disabled={Util.isEmpty(this.state.patientMsg)}
                onChange={this.handleGreenCheckbox.bind(this, 'greenFlag')}>绿色号</Checkbox>
              <Checkbox checked={this.state.visitFlag} disabled={Util.isEmpty(this.state.patientMsg)}
                onChange={this.handleVisitCheckbox.bind(this, 'visitFlag')}>复诊号</Checkbox>
            </div>
            <div className='registr-left-button'>
              {/* <Button type='primary' size='small' style={{ marginLeft: 5 }} onClick={this.handleMedicalRecord.bind(this)}
                disabled={!this.state.checked}>确定</Button> */}
              <Checkbox checked={this.state.visitedFlag}
                onChange={this.handleVisitFlagCheckbox.bind(this, 'visitedFlag')} disabled={(Util.isEmpty(this.state.patientMsg) || this.state.visitedFlag === "Y") ? true : false}>复诊</Checkbox>
              <Button onClick={this.clearInput.bind(this)} size='small' type='danger' style={{ marginLeft: 5 }}>清空(ctrl+z)</Button>
            </div>
          </div>
        </div>
        {/**左列表 */}
        <div style={{ float: 'right', width: '84.5%' }}>
          <div className="new-registration-top-shizi">
            <div className="divider-vertical-line"></div>
            <div className="nrts-content" style={{ width: "calc(100% - 195px)", overflow: "hidden" }}>
              <Tabs activeKey={activeKey} onChange={this.handleTablsChange}>
                <TabPane tab="当日挂号" key="1">
                  {registerDom}
                </TabPane>
                <TabPane tab="预约挂号" key="2">
                  {registerDom}
                </TabPane>
              </Tabs>
              {/* </Row> */}

            </div>
            <div className="divider-vertical-line-right"></div>
            {/**进度条 */}
            <div className="nrts-right">
              <div className="nr-title">当日号源消耗进度排行</div>
              {this.loadRegistrNum()}
            </div>
          </div>

          <div className="new-registration-bottom-shizi">
            <Table
              columns={this.state.column}
              dataSource={this.state.patientData}
              className={this.state.patientData.length > 0 ? 'registr-table-lists table-body-height' : 'table-body-height'}
              // onKeyDown={this.keyDownElement.bind(this)}
              scroll={{ x: totalWidth, y: 146 }}
              tabIndex={this.state.rowId}
              onRow={this.onClickRow}
              bordered
              rowClassName={this.setRowClassName}
              rowKey={(data) => {
                return data.count
              }}
              onHeaderRow={column => {
                return {
                  onDoubleClick: () => {
                    this.columnRef.onOpenModel();
                  },
                };
              }}
              pagination={false}
              title={() => {
                return <div style={{ display: 'flex', justifyContent: "space-between", padding: "0 24px", boxSizing: "border-box" }} className='registr-header-btn'>
                  <div
                    style={{
                      display: 'flex', fontSize: "14px"
                    }}
                    className={(this.state.groupConfig && this.state.groupConfig.IfInvNo == 'Y' && !Util.isEmpty(currentInvNo)) ? "cursor" : ""}
                    onClick={(this.state.groupConfig && this.state.groupConfig.IfInvNo == 'Y' && !Util.isEmpty(currentInvNo)) ? this.showInvoiceNumModal.bind(this) : ""}
                  >
                    当前发票号：<span style={{ color: "#007AFF" }}>{currentInvNo}</span>
                  </div>
                  <div className='rgistr-btn-screen' style={{ display: 'flex' }}>
                    {/* <Button type='primary' style={{ width: "100px" }} size='small' disabled={this.state.returnFlag == 'Y' ? false : true}
                      onClick={this.visitDoctor.bind(this)}>复诊</Button>
                    <Button type='primary' style={{ marginLeft: "24px", width: "100px" }} size='small' disabled={this.state.priorFalag == 'Y' ? false : true}
                      onClick={this.loadPriority.bind(this)}>优先</Button> */}
                    <Button type='primary' style={{ marginLeft: "24px", width: "100px" }} size='small' disabled={this.state.regFlag == 'Y' ? false : true}
                      onClick={this.showGetNumModal.bind(this)}>取号(F2)</Button>
                    {this.state.cancleRegFlag == 'N' ? <Tooltip title={this.state.cancleRegTips}>
                      <Button type='primary' style={{ marginLeft: "24px", width: "100px" }} size='small' disabled={this.state.cancleRegFlag == 'Y' ? false : true}
                        onClick={this.showBackNumModal.bind(this)}>退号(F6)</Button></Tooltip> :
                      <Button type='primary' style={{ marginLeft: "24px", width: "100px" }} size='small' disabled={this.state.cancleRegFlag == 'Y' ? false : true}
                        onClick={this.showBackNumModal.bind(this)}>退号(F6)</Button>}
                    <Button type='primary' style={{ marginLeft: "24px", width: "120px" }} size='small' disabled={this.state.cancleAPPFlag == 'Y' ? false : true}
                      onClick={this.showCannelOrderModal.bind(this)}>取消预约(F10)</Button>
                    <Button type='primary' style={{ marginLeft: "24px", width: "120px" }} size='small' disabled={this.state.regPrintFlag == 'Y' ? false : true}
                      onClick={this.printEntrySlip.bind(this)}>重打凭条(F8)</Button>
                    <Button type='primary' style={{ marginLeft: "24px", width: "120px" }} size='small' disabled={this.state.APPPrintFlag == 'Y' ? false : true}
                      onClick={this.printInvoice.bind(this)}>重打发票(F9)</Button></div>
                </div>
              }}>
            </Table>
          </div>
        </div>
        <Modal
          title="读卡信息"
          visible={this.state.isShowReadCardModal}
          onOk={this.handleReadCardModal.bind(this)}
          onCancel={this.hideModal.bind(this, 'isShowReadCardModal')}
        >
          扫描码：<Input style={{ width: 200 }} value={this.state.qrCode} placeholder='请输入扫描码'
            onChange={Util.commonInputChange.bind(this, 'qrCode')} /><br />
          IC卡号：<Input style={{ width: 200, marginTop: 10 }} placeholder='请输入IC卡号' value={this.state.icCardNum}
            onChange={Util.commonInputChange.bind(this, 'icCardNum')} />
        </Modal>
        <Modal
          title="病历本费"
          visible={this.state.isShowMedicalModal}
          onOk={!Util.isEmpty(this.state.medicalData) ? this.showRegistrModal.bind(this, this.state.medicalData) : this.handleCharge.bind(this)}
          onCancel={this.hideModal.bind(this, 'isShowMedicalModal')}
        >
          <div>
            <div>支付方式：<Select placeholder='请选择支付方式' style={{ width: 160, marginLeft: 5 }}
              value={this.state.otherPayWayId}
              onChange={this.handleOtherSelectChange.bind(this, 'otherPayWayId')}>
              {payWayOtherOption}</Select></div>
            <div style={{ marginTop: 10 }}>病历本费：<span style={{ fontSize: '17px', color: 'orange' }}>{this.state.medicalFee}元</span></div>
          </div>
        </Modal>
        <Modal
          title="请选择号源"
          visible={isShowResModel}
          destroyOnClose={true}
          width="600px"
          onOk={this.handleOk}
          onCancel={() => this.modifyVisible(false, "")}
        >
          <div style={{ textAlign: 'center' }}>
            号源：
            <Select placeholder="请选择时段" style={{ width: '180px' }}
              onChange={this.handleSelectResModel.bind(this)}>
              {resModelOption}
            </Select>
          </div>
        </Modal>

        <Modal
          title="请输入医保卡号或扫描电子凭证医保码"
          visible={this.state.cardShow}
          onOk={this.YBInputSure}
          onCancel={() => this.setState({ cardShow: false })}
        >
          <div>
            电子凭证:<Input placeholder="请扫描电子凭证医保码回车" value={this.state.qrCode} onChange={(e) => this.onqrCodeChange(e)} onPressEnter={this.YBInputSure}></Input>
          </div>
          <div>
            区域类型:
            <Radio.Group style={{ marginLeft: '15px' }} onChange={(e) => { this.onAreaTypeChange(e) }} value={this.state.areaType}>
              <Radio value='本地'>本地</Radio>
              <Radio value='省内'>省内</Radio>
              <Radio value='跨省'>跨省</Radio>
              <Radio value='省直'>省直</Radio>
            </Radio.Group>
          </div>
        </Modal>

        {/*公用加载框*/}
        <ShowLoadModal
          onRef={this.onLoadModalRef}
        />
      </div>
    </div>)

  }
}

export default NewRegistrationPage;
