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 b193876a2..85fc2d7e1 100755 --- a/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue +++ b/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue @@ -606,21 +606,26 @@ function getItemType_Text(type) { return map[type] || '其他'; } function getUnitCodeOptions(row) { - const unitCodes = [ - { code: row.unitCode != null ? String(row.unitCode) : null, codeText: row.unitCode_dictText }, - { code: row.minUnitCode != null ? String(row.minUnitCode) : null, codeText: row.minUnitCode_dictText }, - ]; - // 过滤掉 code 为空的单位选项 - const validUnitCodes = unitCodes.filter(item => item.code != null && item.code !== ''); - // 使用 Set 来跟踪已经存在的 code + const unitCodes = []; + // 大单位:优先用 code,code 缺失时用字典文本兜底 + if (row.unitCode != null && String(row.unitCode) !== '') { + unitCodes.push({ code: String(row.unitCode), codeText: row.unitCode_dictText }); + } 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 }); + } else if (row.minUnitCode_dictText) { + unitCodes.push({ code: row.minUnitCode_dictText, codeText: row.minUnitCode_dictText }); + } + // 去重 const seenCodes = new Set(); - const uniqueUnitCodes = validUnitCodes.filter((item) => { - // 如果 Set 中没有这个 code,就保留它,并把它加入 Set + const uniqueUnitCodes = unitCodes.filter((item) => { if (!seenCodes.has(item.code)) { seenCodes.add(item.code); return true; } - // 如果已经存在,就过滤掉 return false; }); return uniqueUnitCodes; diff --git a/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/newfeeDetailQuery.vue b/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/newfeeDetailQuery.vue index b3a73f25a..626919646 100755 --- a/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/newfeeDetailQuery.vue +++ b/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/newfeeDetailQuery.vue @@ -463,20 +463,45 @@ function watchPatientSelection() { }, 300); } -/** 查询科室 */ +/** 查询科室(支持树形/扁平多种响应结构) */ const getLocationInfo = () => { getOrgList().then((res) => { - orgOptions.value = res.data?.records[0]?.children; + if (!res.data) { + orgOptions.value = []; + return; + } + // 尝试从树形结构取: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) { + orgOptions.value = res.data.records[0].children; + return; + } + // 如果 records[0] 有 id 和 name(非树根节点),直接用所有 records + if (res.data.records[0].id) { + orgOptions.value = res.data.records; + return; + } + } + // 兜底:如果 data 本身是数组 + if (Array.isArray(res.data)) { + orgOptions.value = res.data; + return; + } + orgOptions.value = []; + }).catch(() => { + console.warn('科室列表加载失败(可能无权限)'); + orgOptions.value = []; }); }; getLocationInfo(); -// 映射 +// 映射(查找失败时返回 '-' 而非显示内码) const selectOrg = (itemid) => { + if (!itemid) return '-'; const item = orgOptions.value.find((item) => { return item.id == itemid; }); - return item?.name; + return item?.name || '-'; }; // 重置 const onReset = () => {