<template>
  <div class="overView">
<!--    病史总览-->
    <div style="width: 100%;">
      <el-collapse v-model="activeNames">
        <el-collapse-item v-for="(item, index) in tableData" :key="index" :title="item.category + ' ' + item.createTime" :name="index">
          <div v-if="item.category === '住院'" style="width: 100%;padding-right: 24px;display: flex;justify-content: space-between">
            <div style="margin-right: 32px;width: 40%">
              <p class="info">
                <span class="mr16">主诉:</span>
                <span style="word-break:break-all">{{ item.zs }}</span>
              </p>
              <p class="info">
                <span class="mr16">现病史:</span>
                <span style="word-break:break-all">{{ item.xbs }}</span>
              </p>
              <p class="info">
                <span class="mr16">既往史:</span>
                <span style="word-break:break-all">{{ item.jws }}</span>
              </p>
              <p class="info">
                <span class="mr16">专科检查:</span>
                <span style="word-break:break-all">{{ item.jc }}</span>
              </p>
            </div>
            <div style="margin-right: 32px;width: 25%">
              <div class="info">
                <span class="mr16">诊断:</span>
                <p v-for="row in item.diagnoseNameList">{{ row }}</p>
              </div>
              <p class="info">
                <span class="mr16">治疗意见:</span>
                <span style="word-break:break-all">{{ item.zlyj }}</span>
              </p>
            </div>
            <div style="width: 35%">
              <div class="info">
                <span class="mr16">医嘱:</span>
                <p v-for="row in item.medicationList">{{ row }}</p>
              </div>
            </div>
          </div>
          <div v-if="item.category === '门诊'" style="width: 100%;padding-right: 24px;display: flex;justify-content: space-between">
            <div style="margin-right: 32px;width: 40%">
              <p class="info">
                <span class="mr16">主诉:</span>
                <span style="word-break:break-all">{{ item.zs }}</span>
              </p>
              <p class="info">
                <span class="mr16">现病史:</span>
                <span style="word-break:break-all">{{ item.xbs }}</span>
              </p>
              <p class="info">
                <span class="mr16">既往史:</span>
                <span style="word-break:break-all">{{ item.jws }}</span>
              </p>
              <p class="info">
                <span class="mr16">专科检查:</span>
                <span style="word-break:break-all">{{ item.jc }}</span>
              </p>
            </div>
            <div style="margin-right: 32px;width: 25%">
              <div class="info">
                <span class="mr16">诊断:</span>
                <p v-for="(row, index) in item.diagnoseNameList">{{ index + 1 }}. {{ row }}</p>
              </div>
              <p class="info">
                <span class="mr16">治疗意见:</span>
                <span style="word-break:break-all">{{ item.zlyj }}</span>
              </p>
            </div>
            <div style="width: 35%">
              <div class="info">
                <span class="mr16">医嘱:</span>
                <p v-for="(row, index) in item.medicationList">{{ index + 1 }}. {{ row }}</p>
              </div>
            </div>
          </div>
          <div v-if="item.category === '手术'">
            <p class="info">
              <span class="mr16">手术名称:</span>
              <span>{{ item.opName }}</span>
            </p>
            <p class="info">
              <span class="mr16">主刀医生:</span>
              <span>{{ item.mainDrName }}</span>
            </p>
            <p class="info">
              <span class="mr16">手术记录:</span>
              <span />
            </p>
          </div>
        </el-collapse-item>
      </el-collapse>
    </div>
  </div>
</template>
<script>
const Base64 = require('js-base64').Base64
export default {
  components: {
  },
  mixins: [],
  props: {
    patientIdNumber: {
      type: String,
      default: ''
    },
    patientId: {
      type: String,
      default: ''
    },
  },
  inject: ['refresh'],
  data() {
    return {
      tableData: [],
      activeNames: []
    }
  },
  created() {

  },
  mounted() {
    this.getHistoryData()
  },
  methods: {
    async getHistoryData() {
      const { data: res } = await this.$http.get('/patient/view/getHistory', {
        params: {
          patientId: this.patientId
        }
      })
      if (res.code === 0) {
        this.tableData = res.data || []
        this.activeNames = []
        for (let i = 0; i < this.tableData.length; i++) {
          this.activeNames.push(i)
        }
      } else {
        this.tableData = []
        this.$message.error(res.msg)
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.overView{
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  .mt15{
    margin-top: 16px;
  }
  .mr16{
    margin-right: 16px;
  }
  .vieweBox{
    width: 100%;
    padding-left: 16px;
    height: 48px;
    line-height: 48px;
    background-color: #E8F5FF;

    .title{
      font-size: 16px;
      font-weight: 500;
      color: rgba(0, 0, 0, 0.88);
      margin-right: 16px;
    }
    .time{
      color: rgba(0, 0, 0, 0.45);
    }
  }
  .info{
    width: 100%;
    font-size: 16px;
    line-height: 40px;
    padding-left: 20px;
  }
}
</style>
<style lang="scss">
.overView{
  .el-table th{
    background-color: #FAFAFA;
  }
  .el-collapse-item__header{
    background-color: #E8F5FF;
    padding-left: 12px;
    font-size: 16px;
  }
}
</style>
