From 4092abfce9997fee0972178d495f6a396dd4cf7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=A3=9E?= <张飞@gentronhealth.com> Date: Wed, 13 May 2026 00:05:11 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#477:=20=E4=BD=8F=E9=99=A2=E5=8C=BB?= =?UTF-8?q?=E7=94=9F=E5=B7=A5=E4=BD=9C=E7=AB=99-=E4=BD=8F=E9=99=A2?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E7=94=B3=E8=AF=B7=E8=AF=A6=E6=83=85=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E4=B8=AD"=E5=8F=91=E5=BE=80=E7=A7=91=E5=AE=A4"?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA=E4=B8=BA=E7=9F=AD=E6=A8=AA?= =?UTF-8?q?=E7=BA=BF=EF=BC=88-=EF=BC=89=EF=BC=8C=E6=9C=AA=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因分析: 1. 前端组件使用了错误的API获取科室列表:表单使用getDepartmentList(/app-common/department-list) 保存的targetDepartment ID,但详情弹窗使用getOrgList(/base-data-manage/organization/organization) 查询,两个接口返回的数据结构和ID不同,导致recursionFun无法匹配到科室名称 2. recursionFun中obj.children可能为null/undefined,直接遍历会抛TypeError 3. getLocationInfo是异步调用,handleViewDetail可能在科室数据加载完成前被调用 修复: - 统一使用getDepartmentList(@/api/public.js)获取科室数据,与表单组件保持一致 - recursionFun增加children空值保护 - handleViewDetail改为async,打开详情前确保科室数据已加载 --- .../applicationShow/examineApplication.vue | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue index 236145846..1bfbc95e0 100755 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue @@ -168,7 +168,7 @@ import {computed, getCurrentInstance, ref, watch} from 'vue'; import {Refresh, Search} from '@element-plus/icons-vue'; import {patientInfo} from '../../store/patient.js'; import {getCheck} from './api'; -import {getOrgList} from '@/views/doctorstation/components/api.js'; +import {getDepartmentList} from '@/api/public.js'; const { proxy } = getCurrentInstance(); @@ -293,8 +293,8 @@ const hasMatchedFields = computed(() => { /** 查询科室 */ const getLocationInfo = () => { - getOrgList().then((res) => { - orgOptions.value = res.data.records; + getDepartmentList().then((res) => { + orgOptions.value = res.data || []; }); }; @@ -306,17 +306,19 @@ const recursionFun = (targetDepartment) => { name = obj.name; } const subObjArray = obj['children']; - for (let index = 0; index < subObjArray.length; index++) { - const item = subObjArray[index]; - if (item.id == targetDepartment) { - name = item.name; + if (subObjArray && subObjArray.length > 0) { + for (let index = 0; index < subObjArray.length; index++) { + const item = subObjArray[index]; + if (item.id == targetDepartment) { + name = item.name; + } } } } return name; }; -const handleViewDetail = (row) => { +const handleViewDetail = async (row) => { console.log('targetDepartment========>', JSON.stringify(row)); currentDetail.value = row; @@ -324,6 +326,15 @@ const handleViewDetail = (row) => { if (row.descJson) { try { const obj = JSON.parse(row.descJson); + // 确保科室数据已加载 + if (!orgOptions.value || orgOptions.value.length === 0) { + await new Promise((resolve) => { + getDepartmentList().then((res) => { + orgOptions.value = res.data || []; + resolve(); + }); + }); + } obj.targetDepartment = recursionFun(obj.targetDepartment); descJsonData.value = obj; } catch (e) {