From 6725cef6435ce276a3613c151011a5f079ddb214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B3=E7=BE=BD?= <关羽@gentronhealth.com> Date: Sun, 10 May 2026 23:56:09 +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 修复 examineApplication.vue 中 recursionFun 函数的空指针异常: 1. 增加 orgOptions.value 数组有效性校验,防止接口未返回数据时崩溃 2. 增加 obj.children 的 Array.isArray 检查,原代码直接访问 children.length 在 children 为 undefined 时抛 TypeError 3. 匹配成功后增加 break 提前退出循环 4. handleViewDetail 增加 targetDepartment 存在性检查,递归查找失败时回退显示原始 ID 值 --- .../applicationShow/examineApplication.vue | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 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 a915ce28..7d05e440 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 @@ -457,19 +457,26 @@ const getLocationInfo = () => { }; const recursionFun = (targetDepartment) => { + if (!targetDepartment) return ''; + if (!Array.isArray(orgOptions.value) || orgOptions.value.length === 0) 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']; - for (let index = 0; index < subObjArray.length; index++) { - const item = subObjArray[index]; - if (item.id == targetDepartment) { - name = item.name; + if (Array.isArray(subObjArray)) { + 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; }; @@ -482,7 +489,10 @@ const handleViewDetail = (row) => { if (row.descJson) { try { const obj = JSON.parse(row.descJson); - obj.targetDepartment = recursionFun(obj.targetDepartment); + if (obj.targetDepartment) { + const deptName = recursionFun(obj.targetDepartment); + obj.targetDepartment = deptName || obj.targetDepartment; + } descJsonData.value = obj; } catch (e) { console.error('解析 descJson 失败:', e);