Fix Bug #477: 住院医生工作站-检查申请详情弹窗中"发往科室"字段显示为短横线

根因: examineApplication.vue 的 handlePrint 函数调用了未定义的 recursionFun 方法
(ReferenceError),handleViewDetail 使用 findTreeItem 但该方法对后端返回的扁平
科室列表解析不够健壮。与 testApplication.vue 对比后,发现缺少 recursionFun 函数定义。

修复策略: 新增 recursionFun 函数(与 testApplication.vue 一致实现),并在
handleViewDetail 和 handlePrint 中统一使用该方法将 targetDepartment ID 转换为科室名称。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
荀彧
2026-05-14 14:20:50 +08:00
parent f4aa45be89
commit 1dca0cf988

View File

@@ -513,6 +513,30 @@ const findTreeItem = (list, id) => {
return null;
};
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 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) => {
// 确保科室数据已加载,以便将 ID 解析为名称
if (!orgOptions.value || orgOptions.value.length === 0) {
@@ -526,8 +550,7 @@ const handleViewDetail = async (row) => {
const obj = JSON.parse(row.descJson);
// 将发往科室 ID 转换为名称
if (obj.targetDepartment) {
const deptItem = findTreeItem(orgOptions.value, obj.targetDepartment);
obj.targetDepartment = deptItem ? deptItem.name : obj.targetDepartment;
obj.targetDepartment = recursionFun(obj.targetDepartment);
}
descJsonData.value = obj;
} catch (e) {