// 医生个人主页
import React from 'react';
import {Badge, List} from 'antd-mobile';
import './style/index.less';

import VisitDateAndPeriod from './component/VisitDateAndPeriod.jsx';

export default class DoctorProfile extends React.Component {
  constructor({history}) {
    super();
    this.state = {
      adminStatus: true,
      visible: false,
      admID: "2",
      userInfo: {}
    }
    this.history=history;
  }

  componentDidMount() {
    let userInfo = this.props.location&&this.props.location.state ? this.props.location.state : "";
    if (userInfo&&userInfo.doctorID) {
      this.setState({userInfo})
    } else {
      this.history.goBack();
    }
  }

  handleOnRef = ref => {
    this.modalChild = ref;
  }

  // 查询排班详情
  handleShowVisitDateAndPeriod = (item, childItem) => {
    let obj = {
      item,
      childItem: childItem&&childItem.title ? childItem : {},
    }
    this.modalChild.showModal(obj);
  }

  render() {
    let {userInfo} = this.state;
    return (
      <div className="electronic-health-card">
        <div className="doctor-profile appointment-registration paddingtop10">
          <Badge text={<span className="font12">管挂号</span>} corner size="large">
            <div className="personal-information">
              <div className="personal-information-top">
                <div className="avatar-box">
                  <i className="iconfont icon-yonghutouxiang"></i>
                </div>
                <div className="personal-info-des">
                  <p>{userInfo.doctorName || ""} <span>{userInfo.title || ""}</span></p>
                  <p>{userInfo.locDesc || "暂无数据"}</p>
                  <p>线上就诊量：49899</p>
                  <p>评价：☆☆☆☆☆</p>
                </div>
              </div>
              <div className="personal-information-title">
                副主任医师，临床医学博士，擅长心血管疑难杂症。享受国务院津贴，硕士研究生导师。深圳市先进人才。国家临床重点专科内科学科带头人。广东省中西医结合学会内科专业委员。
              </div>
            </div>
          </Badge>
          <List className="margintop10">
            {userInfo.resList&&userInfo.resList.length > 0 ? userInfo.resList.map((childItem, childIndex) => {
              return (
                <List.Item key={childIndex} onClick={() => this.handleShowVisitDateAndPeriod(userInfo, childItem)} multipleLine extra={<div>{childItem.usableNum > 0 ? "余号："+childItem.usableNum : "挂号已满"}</div>} arrow="horizontal" className={childItem.usableNum > 0 ? "" : "registered-full"}>
                  {childItem.title}
                </List.Item>
              )
            }) : ""}
          </List>
        </div>
        <VisitDateAndPeriod onRef={this.handleOnRef} history={this.history} />
      </div>
    )
  }
}