// 服务协议书
import React from 'react';
import './style/index.less';
import { $http } from "containers/config/https";
// import { List } from 'antd-mobile';

import fwxyNoDataImg from 'assets/images/fwxy-nodata.png';

export default class ServiceAgreement extends React.Component {
  constructor() {
    super();
    let userData = localStorage.getItem("userData") ? JSON.parse(localStorage.getItem("userData")) : {};
    this.state = {
      userData,
      signRecordID: "",
      signingRecordInformation: {},
      subscriptionInformation: {}
    }
  }

  componentDidMount() {
    let signRecordID = this.props.location&&this.props.location.state ? this.props.location.state : "";
    if (signRecordID) {
      this.getSigningRecordInformation(signRecordID);
    }
  }

  // 查询签约记录信息
  getSigningRecordInformation = (signRecordID) => {
    let {userData} = this.state;
    let data = {
			params: [{
        signRecordID,
        patientID: userData&&userData.hisPatID ? userData.hisPatID : ""
			}]
		}
		$http.post("urlS", this, {
			code: "03070059",
      data: data,
      namespace: "HIS",
			success: function(res) {
				if (+res.errorCode === 0) {
          let signingRecordInformation = res.result.data instanceof Array &&res.result.data.length > 0 ? res.result.data[0] : {};
          this.setState({signingRecordInformation, signRecordID}, () => {
            this.getSubscriptionInformation()
          })
				} else {
          this.setState({signingRecordInformation: {}, signRecordID})
        }
			}
    });
  }

  // 查询
  getSubscriptionInformation = () => {
    let {userData, signingRecordInformation} = this.state;
    let data = {
			params: [{
        doctorID: signingRecordInformation&&signingRecordInformation.docID ? signingRecordInformation.docID : "",
        hospID: signingRecordInformation&&signingRecordInformation.hospID ? signingRecordInformation.hospID : "",
        patID: userData&&userData.hisPatID ? userData.hisPatID : ""
			}]
		}
		$http.post("urlS", this, {
			code: "03070057",
      data: data,
      namespace: "HIS",
			success: function(res) {
				if (+res.errorCode === 0) {
          this.setState({subscriptionInformation: res.result})
				} else {
          this.setState({subscriptionInformation: {}})
        }
			}
    });
  }

  render() {
    let {subscriptionInformation, signingRecordInformation, signRecordID} = this.state;
    // console.log(signRecordID)
    let agreementData = [
      {
        type: "describe",
        desc: "根据深圳市《家庭医生服务规范》规定，甲、乙、丙三方协商，乙方自愿聘请甲方家庭医生团队，接受甲方家庭医生团队服务。"
      },
      {
        type: "title",
        desc: "一、甲方(家庭医生团队)职责："
      },
      {
        type: "content",
        desc: "1、建立健康档案，为档案隐私尽保护责任。为乙方提供电子病历、保健体检信息等资料的存储和查询，提供健康教育资料信息的索阅和网络阅读（发放健康处方）、个体化健康教育。在工作时间为乙方提供健康咨询服务，和履行健康信息的告知义务。"
      },
      {
        type: "content",
        desc: "2、对常住非户籍≥65岁和户籍≥60岁居民，开展每年一次免费健康评估和中医健康指导。（健康评估内容包括：医学、功能、心理、社会评估）"
      },
      {
        type: "content",
        desc: "3、为0～3岁的儿童开展系统保健管理指导服务（定期健康体检、发育评价、保健指导、预防接种、中医健康指导），为新生儿进行家庭访视。"
      },
      {
        type: "content",
        desc: "4、为中孕期妇女提供5次孕期指导及2次产后访视指导、为妇女提供保健咨询指导（计划生育的咨询指导、孕前保健、生殖健康、心理健康指导等）。"
      },
      {
        type: "content",
        desc: "5、为家庭成员提供中医药特色服务。"
      },
      {
        type: "content",
        desc: "6、为高血压、糖尿病等慢性病患者提供健康系统管理及转介服务。"
      },
      {
        type: "content",
        desc: "7、为严重精神障碍患者进行管理随访和康复指导。"
      },
      {
        type: "content",
        desc: "8、为结核病患者进行督导服药和管理随访。"
      },
      {
        type: "content",
        desc: "9、对传染病及突发公共卫生事件报告和处理服务。"
      },
      {
        type: "content",
        desc: "10、提供预约就诊、优先转诊、居家护理服务等。乙方及家庭有需要时，经过医师评估、签订家庭病床服务协议后，提供家庭病床服务。"
      },
      {
        type: "content",
        desc: "11、提供常见病、多发病的诊断和治疗服务，对危、急、重症患者提供抢救和转诊服务。"
      },
      {
        type: "title",
        desc: "二、乙方(社区居民)责任与义务："
      },
      {
        type: "content",
        desc: "1、提供详实的个人及家庭成员信息，提供真实的个人健康资料。"
      },
      {
        type: "content",
        desc: "2、对预约上门服务的家庭医生团队给予足够的便利。"
      },
      {
        type: "content",
        desc: "3、配合所签约的家庭医生团队，定期管理和维护个人及家庭的信息。按照家庭医生团队要求进行健康管理。"
      },
      {
        type: "content",
        desc: "4、在家庭医生团队服务过程中，服从甲方安排，及时按规定付费。"
      },
      {
        type: "title",
        desc: "三、丙方（社区健康服务中心）责任："
      },
      {
        type: "content",
        desc: "加强对甲方的管理，并对甲方在为乙方服务过程提供支持和后勤保障。"
      },
      {
        type: "title",
        desc: "四、合约期内，乙方对甲方不满意，可请丙方协商解决，也可申请重新选择家庭医生团队。乙方对甲方不提供家庭及成员真实信息的，或拒不配合家庭医生团队管理的，甲方有权终止服务协议。"
      },
      {
        type: "content",
        desc: "本协议书一式两份，甲、乙双方各执一份，自签订之日起生效，有效期为一年。期满后如甲、乙双方无终止协议意向，默认为自动续约。"
      },
    ]
    return (
      <div className="service-agreement">
        {signRecordID ? (<div className="sa-position">
          <div className="sa-header border-bottom-after">
            <div>
              <h3>
                甲方：<span>{subscriptionInformation.docName || ""}</span>
              </h3>
              <span>联系电话：{subscriptionInformation.docMobile || ""}</span>
            </div>
            <div>
              <h3>
                乙方：<span>{subscriptionInformation.patName || ""}</span>
              </h3>
              <span>联系电话：{subscriptionInformation.patMobile || ""}</span>
            </div>
            <div>
              <h3>
                丙方：<span>{subscriptionInformation.hospDesc || ""}</span>
              </h3>
              <span>地址：{subscriptionInformation&&subscriptionInformation.hospProvince ? subscriptionInformation.hospProvince : ""}{subscriptionInformation.hospCity || ""}{subscriptionInformation.hospArea || ""}</span>
            </div>
          </div>
          <div className="sa-content">
            {agreementData&&agreementData.map((item, index) => {
              return <div key={index} className={item.type === "title" ? "agreement-title" : (item.type === "content" ? "agreement-content" : "agreement-describe")}>{item.desc}</div>
            })}
            {/* <div className="sac-table">
              <table border="0" cellSpacing="1" cellPadding="0">
                <tbody>
                  <tr>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>关系</th>
                    <th>身份证号</th>
                    <th>联系电话</th>
                    <th>人群分类</th>
                    <th>医保卡号</th>
                  </tr>
                  {subscriptionInformation.data instanceof Array&&subscriptionInformation.data.map((item, index) => {
                    return ( <tr key={index}>
                      <td>{item.name}</td>
                      <td>{item.sexDesc}</td>
                      <td>{item.relaDesc}</td>
                      <td>{item.iDCardNo}</td>
                      <td>{item.phone}</td>
                      <td>{item.sexDesc}</td>
                      <td>{item.sexDesc}</td>
                    </tr>)
                  })}
                </tbody>
              </table>
            </div> */}
            <p className="sac-list-title">附件：</p>
            {subscriptionInformation.data&&subscriptionInformation.data instanceof Array&&subscriptionInformation.data.map((item, index) => {
              return (
                <div key={index} className={index === 0 ? "sac-content border-bottom-after border-top-before" : "sac-content border-bottom-after"}> 
                  <div className="sac-list">
                    <div>
                      姓名：{item.patName}
                    </div>
                    <div>
                      联系电话：{item.patMobile}
                    </div>
                  </div>
                  <div className="sac-list">
                    <div>
                      性别：{item.patSexDesc}
                    </div>
                    <div>
                      身份证号：{item.patCredNo}
                    </div>
                  </div>
                  <div className="sac-list">
                    <div>
                      关系：{item.relaDesc}
                    </div>
                    <div>
                      人群分类：{item.classify}
                    </div>
                  </div>
                  <div className="sac-list">
                    <div>
                      社保类型：
                    </div>
                    <div>
                      医保卡号：{item.patInsuNo}
                    </div>
                  </div>
                </div>
              )
            })}
          </div>
          <div className="sa-footer border-top-before">
            乙方本人确认签名：<img src={signingRecordInformation.signName || ""} alt=""></img>
          </div>
        </div>) : <div className="record-nodata"><img src={fwxyNoDataImg} alt="" /><span>暂无服务协议书</span></div>}
      </div>
    )
  }
}