From 3f341749e5186071dcc111726faf33543cf2404c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B3=E7=BE=BD?= <关羽@gentronhealth.com> Date: Fri, 15 May 2026 01:07:50 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#507:=20[=E4=BD=8F=E9=99=A2?= =?UTF-8?q?=E6=8A=A4=E5=A3=AB=E7=AB=99-=E4=BD=8F=E9=99=A2=E8=AE=B0?= =?UTF-8?q?=E8=B4=A6-=E8=A1=A5=E8=B4=B9]=20=E9=A1=B9=E7=9B=AE=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E6=9C=AA=E8=8E=B7=E5=8F=96=E3=80=81=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=A7=91=E5=AE=A4=E6=98=BE=E7=A4=BA=E5=86=85=E7=A0=81=E4=B8=94?= =?UTF-8?q?=E7=BC=BA=E4=B9=8F=E9=BB=98=E8=AE=A4/=E6=A8=A1=E7=B3=8A?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因分析: 1. 执行科室显示内码:loadDepartmentOptions 只读取树形结构的第一层(records[0].children), 但后端返回的是多层嵌套的树形数据。修复为递归扁平化 flattenTree() 提取所有科室节点。 2. 单位字段为空:getUnitCodeOptions 中 unitCode_dictText/minUnitCode_dictText 为 null 时, option 的 codeText 为 null 导致 el-select 无法显示。修复为 fallback 到 code 值本身。 Co-Authored-By: Claude Opus 4.7 --- .../InpatientBilling/components/FeeDialog.vue | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue b/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue index b4651e4f6..55d2640bc 100755 --- a/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue +++ b/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue @@ -521,31 +521,28 @@ watch( } ); -// 加载科室选项(支持树形/扁平两种数据结构) +// 加载科室选项(递归扁平化树形结构) function loadDepartmentOptions() { getOrgList() .then((res) => { - if (res.data) { - // 尝试从树形结构中取:records[0].children - if (res.data.records && res.data.records.length > 0) { - if (res.data.records[0].children && res.data.records[0].children.length > 0) { - departmentOptions.value = res.data.records[0].children; - return; - } - // 如果 records[0] 有 id 和 name(非树根节点),直接用所有 records - if (res.data.records[0].id) { - departmentOptions.value = res.data.records; - return; - } - } - // 兜底:如果 records 不存在或为空,尝试直接使用 data 本身 - if (Array.isArray(res.data)) { - departmentOptions.value = res.data; - return; - } + if (!res?.data?.records?.length) { + departmentOptions.value = []; + return; } - // 所有方式都失败,置空 - departmentOptions.value = []; + // 递归扁平化树形结构,提取所有科室节点 + const flattenTree = (nodes) => { + const result = []; + for (const node of nodes) { + if (node?.id && node?.name) { + result.push(node); + } + if (node?.children?.length) { + result.push(...flattenTree(node.children)); + } + } + return result; + }; + departmentOptions.value = flattenTree(res.data.records); }) .catch(() => { console.warn('科室列表加载失败(可能无权限)'); @@ -611,13 +608,13 @@ function getUnitCodeOptions(row) { const unitCodes = []; // 大单位:优先用 code,code 缺失时用字典文本兜底 if (row.unitCode != null && String(row.unitCode) !== '') { - unitCodes.push({ code: String(row.unitCode), codeText: row.unitCode_dictText }); + unitCodes.push({ code: String(row.unitCode), codeText: row.unitCode_dictText || String(row.unitCode) }); } else if (row.unitCode_dictText) { unitCodes.push({ code: row.unitCode_dictText, codeText: row.unitCode_dictText }); } // 小单位:同上 if (row.minUnitCode != null && String(row.minUnitCode) !== '') { - unitCodes.push({ code: String(row.minUnitCode), codeText: row.minUnitCode_dictText }); + unitCodes.push({ code: String(row.minUnitCode), codeText: row.minUnitCode_dictText || String(row.minUnitCode) }); } else if (row.minUnitCode_dictText) { unitCodes.push({ code: row.minUnitCode_dictText, codeText: row.minUnitCode_dictText }); }