<template>
  <div style="height: 5px"/>
  <div class="main">
    <div class="side-class">
      <el-auto-resizer>
        <template #default="{ height }">
          <xc-table-v3 :height="height"
                       :data="sideData"
                       :columns="sideColumns"
                       @row-click="sideRow"/>
        </template>
      </el-auto-resizer>
    </div>

    <div class="main-class">
      <el-form>
        <el-form-item label="检查项目：">
          {{ record?.row?.orderName }}
        </el-form-item>
        <el-form-item label="检查所见：">
          <el-input type="textarea" v-model="record.checkWhatYouSee"/>
        </el-form-item>
        <el-form-item label="诊断意见：">
          <el-input type="textarea" v-model="record.diagnosticOpinion"/>
        </el-form-item>
        <el-form-item label="报告医生：">
          {{ record?.reportName }}
        </el-form-item>
        <el-form-item label="报告时间：">
          {{ record?.reportDate }}
        </el-form-item>
        <el-form-item label="审核医生：">
          {{ record?.confirmName }}
        </el-form-item>
        <el-form-item label="审核时间：">
          {{ record?.confirmDate }}
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup name='EmrInspect' lang="tsx">
import {getExamine} from "@/api/zhu-yuan-yi-sheng/emr-patient";
import {patInfo} from './emr-tools-store'
import {onMounted, ref} from "vue";
import XcTableV3 from "@/components/xiao-chan/xc-table-v3/XcTableV3.vue";
import {XcColumn} from "@/components/xiao-chan/xc-table-v3/XcColumn";
import {queryCheckTextResults} from '@/api/zhu-yuan-yi-sheng/jian-yan-jian-cha-shen-qing'

const sideData = ref([])
const sideColumns: XcColumn<any>[] = [
  {key: 'startTime', title: "日期", width: 135},
  {key: 'orderName', title: "名称"},
]

const record = ref({
  checkWhatYouSee: '',
  diagnosticOpinion: ''
})
const sideRow = (row) => {
  console.log(row)
  queryCheckTextResults(row.inpatientNo, row.reqNo).then((res) => {
    console.log(res)
    record.value = res.record
    record.value.row = row
  })
}

onMounted(() => {
  getExamine(patInfo.value.inpatientNo, patInfo.value.admissTimes).then(res => {
    console.log(res)
    sideData.value = res
  })
})

</script>

<style scoped lang="scss">
.main {
  display: flex;
  width: 100%;
  height: 95%;
}

.side-class {
  width: 400px;
}

.main-class {
  flex: 1;
}
</style>
