<template>
  <div style="display: flex;height: 100%;width: 100%">
    <div style="width: 150px;overflow: auto">
      <el-tree :data="tree"
               :props="defaultProps"
               @node-click="handleNodeClick"
               node-key="_id"
               ref="treeRef"
               highlight-current
               default-expand-all/>
    </div>
    <div style="height: 100%;width:calc(100% - 150px) ">
      <iframe :src="saveDocumentId" width="100%" height="100%"/>
    </div>
  </div>
</template>

<script setup name='ElectronicMedicalRecord'>
import {getPatientDataTree} from "@/api/zhu-yuan-yi-sheng/emr-patient";

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

const defaultProps = {
  children: 'children',
  label: 'name',
}

const tree = ref([])
const saveDocumentId = ref('')

const handleNodeClick = (data) => {
  saveDocumentId.value = `/emr/runtime/?documentId=${data.emrDocumentId}#/`
}

onMounted(() => {
  getPatientDataTree(props.patNo, props.times).then((res) => {
    tree.value = res
  })
})
</script>

<style scoped lang="scss">

</style>
