import React, { Component } from "react";
import style from "./index.less";
import store from "@store";
import $ from "jquery";


class Information extends Component {
  constructor(props) {
    super(props)
    this.$content = React.createRef();
  }

  componentWillReceiveProps() {
    $(this.$content.current)[0].scrollIntoView(true);
  }
  render() {
    const { baseObj } = this.props;
    let baseData = store.getState()
    let preInfo = baseData.patInfo.message;
    const noData = JSON.stringify(preInfo) == '{}';
    return <div className={style['information']}>
        <div ref={this.$content} className={style['title']}>{preInfo.hospitalName}</div>
        <table className={style['patInfo']}>
          <tr>
            <td>卡号：{baseObj ? baseObj.patientIdNo : noData ? '' : preInfo.patientIdNo}</td>
            <td>姓名：{baseObj ? baseObj.patientName : noData ? '' : preInfo.patientName}</td>
            <td>年龄：{baseObj ? baseObj.patientAge : noData ? '' : preInfo.patientAge}</td>
            <td>性别：{baseObj ? baseObj.patientSex : noData ? '' : preInfo.patientSex}</td>
          </tr>
          <tr>
            <td>就诊时间：{baseObj ? baseObj.inquiryDate : (noData ? '' : preInfo.systemTime.split(' ')[0])}</td>
            <td>科室：{baseObj ? baseObj.hospitalDeptName : (noData ? '' : preInfo.hospitalDeptName)}</td>
            <td>医生：{baseObj ? baseObj.doctorName : (noData ? '' : preInfo.doctorName)}</td>
            <td>门诊号：{baseObj ? baseObj.inquiryCode : (noData ? '' : preInfo.recordId)}</td>
          </tr>
        </table>
      </div>
  }
}

export default Information;
