<template>
  <div class="surgical" v-loading="loading">
    <el-empty description="未查到信息" v-if="resultFlag"></el-empty>
    <div v-else>
    <div class="content-head">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick" style="width: 90%" >
        <el-tab-pane :label="item.checkType+item.inspectDate"
                     :name="item" v-for=" (item,index) in infoData"
        >
          <el-tooltip slot="label" effect="dark"
                      :content="item.checkType+item.inspectDate"
                      placement="bottom-start"
          >
            <span class="tmp"
            > {{ item.checkType+item.inspectDate}}</span>
          </el-tooltip>

        </el-tab-pane>
      </el-tabs>
      <!--     <div class="content-head-title">血常规</div>-->
      <div class="content-head-right">
<!--        <div class="content-head-btn">-->
<!--          <i class="el-icon-download"/>-->
<!--          <div>下载</div>-->
<!--        </div>-->
        <div class="content-head-btn" @click="ShowImage">
          <svg-icon icon-class="pdf"/>
          <div>查看报告</div>
        </div>
      </div>
    </div>
    <div class="surgical-title" >
      <div class="hospital-name">{{activeName.checkKindName}}</div>
      <div class="surgical-name">{{"报告时间："+activeName.inspectDate}}</div>
    </div>
    <div class="surgical-top">
      <div>姓名︰{{msg.patientName}}</div>
      <div>性别:女</div>
      <div>年龄:{{msg.age}}岁</div>
<!--      <div>科室:肝胆科</div>-->
      <div>{{msg.clinicClass ==="1"?"就诊号:"+msg.jzlsh :"住院号:"+msg.jzlsh }}</div>
    </div>
    <div class="surgical-des">
      <div class="surgical-item">
        <span class="des-label">报告时间∶</span>
        <span class="des-val" style="margin-right: 20px">{{activeName.inspectDate}}</span>
        <span class="des-label">报告医生∶</span>
        <span class="des-val">{{activeName.reportDoctorCode}}</span>
      </div>
      <div class="surgical-item">
        <span class="des-label">影像描述∶</span>
        <span class="des-val">{{activeName.inspectResultSee}}</span>
      </div>
      <div class="surgical-item">
        <span class="des-label">影像诊断:</span>
        <span class="des-val">{{activeName.inspectSuggestion}}</span>
      </div>
    </div>
    <div class="surgical-footer">
      <div class="surgical-item">
        <span class="des-label">审核医生:</span>
        <span class="des-val">{{activeName.verifyPersonCode}}</span>
      </div>
      <div class="surgical-item">
        <span class="des-label">审核时间:</span>
        <span class="des-val">{{activeName.verifyDate}}</span>
      </div>
    </div>

    </div>
  </div>
</template>

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

export default {
  name: "caseFile",
  props:{
    msg:{
      type:Object
    }
  },
  data() {
    return{
      loading:false,
      infoData:[],
      activeName:"",
      resultFlag:false,
      src:""

    }
  },
  methods:{
    async initMethod(){
      console.log("初始化诊断")
      this.loading = true
      let param = {
        orgCode:this.msg.orgCode,
        registeredId:this.msg.jzlsh
      }
      param = JSON.stringify(param)
      let data = {}
      if(this.msg.clinicClass === '2'){
        data = {
          apiId : '188',
          param:param
        }
      }else {
        data = {
          apiId : '136',
          param:param
        }
      }

      const  res =  await handlerRequestNoAuth(data)
      if (res.code != 200 || res.data.length === 0 ){

        this.loading = false
        this.resultFlag = true
        return
      }
      this.infoData =  res.data
      this.activeName = this.infoData[0]
      console.log(this.infoData)
      this.loading = false
    },
    async ShowImage(index) {
      // debugger
      console.log("active_Name",this.active_Name)
      if(this.activeName.checkType != "心电图"){
      let param = {
        key:"056cdb2251816934c09f1123b3c2dd65",
        readerId:"360",
        userCode:this.formatDate(new Date()) ,
        reportCode:this.activeName.orderNo
      }
      //取接口转换apicode
      let apiCode = ''
      apiCode =  '430'
      param = JSON.stringify(param)
      let data = {
        apiId : apiCode,
        param:param,
        charsetValue:"clob"
      }

      const  res =  await handlerRequestNoAuth(data)
      if (res.data[0].data.data.data == null){
        this.$message.error("文档未注册！")
        return
      }
      this.src =res.data[0].data.data.data['DE01.00.018.08']
      console.log(this.src+"!")

      var applySn = this.activeName.applySn;
      // let href = 'http://172.16.9.178:8060//HisReportList.aspx?RepGuid=cfda5324-832b-48a4-9a63-30c36937d436';
      // shell.openExternal(href);
      //window.open("http://172.16.9.178:8060//HisReportList.aspx?RepGuid=cfda5324-832b-48a4-9a63-30c36937d436","_blank",'height=350,left=200,width=1200')

        window.open(this.src,"_blank",'')

      }else{
        window.open(this.activeName.reportAddress,"_blank",'')
       // window.open("http://172.16.9.162:8090/WebPacs-app/webpacs/dicomview?applyid="+this.activeName.applySn+"&view=report","_blank",'')
      }


    },
    formatDate(time) {
      return moment(time).format('YYYY/MM/DD ')
    },

  },
  mounted() {
    this.initMethod()
  }
}
</script>

<style scoped lang="scss">
.item-title{
  text-align: center;
  margin: 10px 0;
  font-size: 14px;
  font-weight: bold;
  color: #333333;
}
.item-flex{
  display: flex;
  font-size: 14px;
  color: #666666;
  margin-bottom: 8px;
  span{
    margin-right: 15px;
  }
}
.item-table{
  margin: 10px 0;
  font-size: 14px;
  color: #666666;
  .item-table-head,.item-table-row{
    margin-bottom: 8px;
    display: flex;
    div{
      width: 100px;
    }
  }
}
</style>
