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);