From 6258aa2589e9377746682cacf3a4be885ee974e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B3=E7=BE=BD?= <关羽@gentronhealth.com> Date: Wed, 13 May 2026 18:19:15 +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 根因分析(与testApplication.vue对比发现): 1. getLocationInfo不是async函数,handleViewDetail中使用new Promise手动包装getDepartmentList 作为降级方案,如果API调用失败则Promise永远不resolve(缺少catch),导致后续逻辑挂起 2. recursionFun缺少空值保护和break语句,可能在找到匹配后继续无效遍历 修复: - getLocationInfo改为async/await模式(与testApplication.vue保持一致) - handleViewDetail使用await getLocationInfo()替代不可靠的Promise包装 - recursionFun增加空值提前返回和break优化 --- .../applicationShow/examineApplication.vue | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 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 fa675b9c8..94e1e7b70 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 @@ -309,49 +309,46 @@ const hasMatchedFields = computed(() => { }); /** 查询科室 */ -const getLocationInfo = () => { - getDepartmentList().then((res) => { - orgOptions.value = res.data || []; - }); +const getLocationInfo = async () => { + const res = await getDepartmentList(); + orgOptions.value = res.data || []; }; const recursionFun = (targetDepartment) => { + if (!targetDepartment) return ''; let name = ''; for (let index = 0; index < orgOptions.value.length; index++) { const obj = orgOptions.value[index]; if (obj.id == targetDepartment) { name = obj.name; + break; } const subObjArray = obj['children']; if (subObjArray && subObjArray.length > 0) { - for (let index = 0; index < subObjArray.length; index++) { - const item = subObjArray[index]; + for (let i = 0; i < subObjArray.length; i++) { + const item = subObjArray[i]; if (item.id == targetDepartment) { name = item.name; + break; } } } + if (name) break; } return name; }; const handleViewDetail = async (row) => { - console.log('targetDepartment========>', JSON.stringify(row)); + // 确保科室数据已加载,以便将 ID 解析为名称 + if (!orgOptions.value || orgOptions.value.length === 0) { + await getLocationInfo(); + } currentDetail.value = row; // 解析 descJson 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) {