<template>
  <div   >
    <el-empty description="未查到信息" v-if="resultFlag"></el-empty>
    <div v-else>
    <div class="diagnosis-title">诊断名称：</div>
    <div class="diagnosis-name">{{titleData.clinicalName}}</div>
    <div class="diagnosis-title">ICD编码：</div>
    <div class="diagnosis-name">{{titleData.diagnosticCode}}</div>
    <el-table
      :data="tableData"
      :header-cell-style="{background:'#edf4fb'}"
      style="width: 100%"
      highlight-current-row
      class="table-current"
      @row-click="clickRow"
      ref="monthlyPlanTable"
      :row-class-name="tableRowClassName"
      v-loading="loading"
      >
      <el-table-column prop="diagnosticClassify" label="诊断状态"  :formatter="getDiagnosticClassifyText" />
      <el-table-column prop="doctorName" label="医生名" />
      <el-table-column prop="diagnosticCategory" label="诊断类型" :formatter="getDiagnosticCategoryText"/>
      <el-table-column prop="diagnosticTypeCode" label="主/副" :formatter="getDiagnosticTypologyText"/>
      <el-table-column prop="diseaseName" label="疾病诊断名称"/>
      <el-table-column prop="clinicalName" label="临床诊断名称"/>
      <el-table-column prop="diagnosticCode" label="ICD编码"/>
      <el-table-column prop="diagnosticData" label="诊断时间"/>

    </el-table>
      <div>
      <pagination
        class="card-page"
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.page"
        :limit.sync="queryParams.pageSize"
        @pagination="pageFunction(tableData)"
      />
      </div>
    </div>
  </div>
</template>

<script>
import { handlerRequestNoAuth } from '@/api/patient360'

export default {
  name: "diagnosis",
  props:{
      msg:{
        type:Object
      }
  },
  data(){
    return{
      tableData:[
        {
          status:'确定诊断',
          name:'直肠恶性肿瘤',
          ICDCode:'C20.X00',
          doctorName:'刘献'
        }
      ],
      titleData:{},
      loading:false,
      resultFlag:false,
      total: 20,
      queryParams: {
        page: 1,
        pageSize: 20
      },
    }
  },
  watch: {
  },
  mounted() {
    console.log("msg",this.msg)
    this.initMethod()
  },
  methods:{
    async initMethod(){
      console.log("初始化诊断")
      this.loading = true
      let param = {
        orgCode:this.msg.orgCode,
        jzlsh:this.msg.jzlsh
      }
      param = JSON.stringify(param)
      let data = {
        apiId : '152',
        param:param
      }
      const  res =  await handlerRequestNoAuth(data)
      if (res.code != 200 || res.data.length === 0 ){

        this.loading = false
        this.resultFlag = true
        return
      }

      this.pageFunction( res.data)
      // this.tableData =  res.data
    this.$refs.monthlyPlanTable.setCurrentRow(this.tableData[0])
      this.clickRow(this.tableData[0])
      this.loading = false
    },
    getDiagnosticClassifyText(flag) {
      console.log("flag",flag)
      switch (flag.diagnosticClassify) {
        case '0':
          return '初步诊断';
          break;
        case '1':
          return '复诊诊断';
          break;
      }
    },
    getDiagnosticCategoryText(flag) {
      console.log("flag2",flag)
      switch (flag.diagnosticCategory) {
        case '1':
          return '西医';
          break;
        case '2':
          return '中医';
          break;
      }
    },
    getDiagnosticTypologyText(flag) {
      switch (flag.diagnosticTypeCode) {
        case '1':
          return '主';
          break;
        case '2':
          return '副';
          break;
      }
    },
    clickRow(row){
      this.titleData = row
    },
    pageFunction(res){
      console.log("res",res)
      this.total =  res.length
        this.tableData = res.slice(
        (this.queryParams.page - 1) * this.queryParams.pageSize,
        this.queryParams.page * this.queryParams.pageSize
      )
      console.log("page",this.total, this.queryParams.pageSize,this.tableList)

    }

  }
}
</script>

<style scoped lang="scss">
.diagnosis-title{
  font-size: 14px;
  color: #333;
  position: relative;
  padding-left: 10px;
  line-height: 16px;
  &:before {
    position: absolute;
    content: "";
    width: 3px;
    height: 16px;
    top: 0;
    left:0;
    background: #0A69F3;
    border-radius: 10px;
  }
}
.diagnosis-name{
  font-weight: bold;
  color: #333333;
  padding-left: 10px;
  margin: 15px 0 20px 0;
  font-size: 14px;
}
.table-current {
  ::v-deep .current-row {
    background-color: black;
  }
  ::v-deep .el-table__body tr.current-row > td.el-table__cell{
    background-color: #fdf5e6 !important;
  }
}
</style>
