<template>
    <div style="height: 5px"/>
    <div class="main">
        <div class="side-class">
            <el-auto-resizer>
                <template #default="{ height }">
                    <vxe-table :data="sideData"
                               :height="height"
                               show-overflow
                               :row-config="{isHover : true, isCurrent: true,height: 24}"
                               @cell-click="sideRow">
                        <vxe-column title="日期" field="startTime" width="135"/>
                        <vxe-column title="名称" field="orderName"/>
                    </vxe-table>
                </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" rows="5" v-model="record.checkWhatYouSee"/>
                </el-form-item>
                <el-form-item label="诊断意见：">
                    <el-input type="textarea" rows="5" v-model="record.diagnosticOpinion"/>
                </el-form-item>
                <el-form-item label="">
                    <el-button type="primary"
                               @click="elementReplication(record.diagnosticOpinion, 'CT检查结果')">
                        CT检查结果
                    </el-button>
                    <el-button type="primary"
                               @click="elementReplication(record.diagnosticOpinion, '磁共振检查结果')">
                        磁共振检查结果
                    </el-button>
                </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'>
import {getExamine} from "@/api/zhu-yuan-yi-sheng/emr-patient";
import {onMounted, ref} from "vue";
import XcTableV3 from "@/components/xiao-chan/xc-table-v3/XcTableV3.vue";
import {queryCheckTextResults} from '@/api/zhu-yuan-yi-sheng/jian-yan-jian-cha-shen-qing'
import {
    elementReplication
} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";

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

const sideData = ref([])

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

onMounted(() => {
    getExamine(props.patNo, props.times).then(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>
