<template>
  <el-container>
    <el-aside>
      <xc-table :local-data="consultationData" layout='total, prev,  next'
                :height="200"
                @rowClick="rowClick">
        <el-table-column label="申请时间" prop="inputDate" width="70">
          <template #default="scope">
            {{ scope.row.inputDate + '_' + scope.row.reqTimes }}
          </template>
        </el-table-column>
        <el-table-column label="科室" prop="deptName"></el-table-column>
        <el-table-column label="接受日期" prop="hzDate" show-overflow-tooltip></el-table-column>
        <el-table-column label="接受医生" prop="hzDoctor2Name"></el-table-column>
        <el-table-column label="申请人" prop="inputName" width="60"></el-table-column>
        <el-table-column label="申请科室" prop="reqDeptName"></el-table-column>
        <el-table-column label="类别" prop="hzLevelName"></el-table-column>
        <el-table-column label="医生" prop="hzDoctor1Name"></el-table-column>
        <el-table-column label="级别" prop="hzType">
          <template #default="scope">
            <span>{{ hzTypeName(scope.row.hzType) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="接受意见" prop="hzComment" show-overflow-tooltip></el-table-column>
      </xc-table>
    </el-aside>
    <el-main>
      <el-form inline label-position="right" label-width="120px">
        <el-form-item label="住院号">
          {{ huanZheXinXi.inpatientNo }}
        </el-form-item>
        <el-form-item label="姓名">
          {{ huanZheXinXi.name }}
        </el-form-item>
        <el-form-item label="性别">
          {{ cptSex(huanZheXinXi.sex) }}
        </el-form-item>
        <el-form-item label="年龄">
          {{ huanZheXinXi.age }}
        </el-form-item>
        <el-form-item label="科室">
          {{ huanZheXinXi.deptCodeName }}
        </el-form-item>
        <el-form-item label="床号">
          {{ huanZheXinXi.bedNo }}
        </el-form-item>
        <el-form-item label="会诊科室">
          {{ huanZheXinXi.reqDept1Name }}
        </el-form-item>
        <el-form-item label="会诊类别">
          {{ hzLeiBie(huanZheXinXi.hzType) }}
        </el-form-item>
        <el-form-item label="请求会诊科室">
          {{ huanZheXinXi.deptCodeName }}
        </el-form-item>
        <el-form-item label="会诊申请医师">
          {{ huanZheXinXi.reqDoctor }}
        </el-form-item>
        <el-form-item label="申请时间">
          {{ huanZheXinXi.reqDate }}
        </el-form-item>
        <el-form-item label="会诊科室">
          {{ huanZheXinXi.reqDept1Name }}
        </el-form-item>
        <el-form-item label="医师">
          {{ huanZheXinXi.hzDoctor2Name }}
        </el-form-item>
        <el-form-item label="会诊时间">
          {{ huanZheXinXi.hzDate }}
        </el-form-item>
      </el-form>
      <el-form label-position="right" label-width="120px">
        <el-form-item label="病情简介">
            <textarea v-model="huanZheXinXi.reqComment" readonly
                      style="height: 154px;width: 100%"></textarea>
        </el-form-item>
        <el-form-item label="目前主要诊断">
          <textarea v-model="huanZheXinXi.hzZd" readonly style="height: 50px;width: 100%"></textarea>
        </el-form-item>
        <el-form-item label="会诊目的">
          <textarea v-model="huanZheXinXi.hzMd" readonly style="height: 50px;width: 100%"></textarea>
        </el-form-item>
        <el-form-item label="会诊意见">
          <textarea v-model="huanZheXinXi.hzComment" readonly style="height: 50px;width: 100%"></textarea>
        </el-form-item>
      </el-form>
    </el-main>
  </el-container>
</template>

<script setup name='GroupConsultation'>
import {chaKanHuiZhenShenQing} from "@/api/case-front-sheet";
import XcTable from "@/components/xiao-chan/xc-table/XcTable.vue";
import {getHuanZheXinXi} from "@/api/case-front-sheet/jie-shou-hui-zhen";
import {ref} from "vue";
import {cptSex} from "../../utils/computed";

const props = defineProps({
  patNo: '',
  times: ''
})

const consultationData = ref([])

onMounted(() => {
  chaKanHuiZhenShenQing(props.patNo, props.times).then((res) => {
    consultationData.value = res
  })
})

const huanZheXinXi = ref({})
const rowClick = (val) => {
  getHuanZheXinXi(val.admissTimes, val.reqTimes, val.inpatientNo).then((res) => {
    huanZheXinXi.value = res
  })
}


function hzTypeName(val) {
  switch (val) {
    case '1':
      return '主治医师'
    case '2':
      return '副主任医生'
    case '3':
      return '主任医生'
  }
}

function hzLeiBie(val) {
  switch (val) {
    case '1':
      return '常规会诊'
    case '2':
      return '疑难病例会诊'
    case '3':
      return '急救会诊'
  }
}
</script>

<style scoped lang="scss">

</style>
