Fix Bug #507: [住院护士站-住院记账-补费] 项目单位未获取、执行科室显示内码且缺乏默认/模糊搜索逻辑
1. FeeDialog.vue - getUnitCodeOptions 修复:当 unitCode/minUnitCode 为 null 但对应字典文本存在时,使用文本作为选项值兜底,确保单位下拉框不显示为空 2. newfeeDetailQuery.vue - getLocationInfo 修复:从单一 records[0].children 解析改为支持树形/扁平/数组多种响应结构,并添加 catch 兜底置空数组 3. newfeeDetailQuery.vue - selectOrg 修复:查找失败时返回 '-' 而非显示原始 orgId 内码,空值同样返回 '-' **后端开发重点**:优先搜索 Java/Spring 后端代码。 关键词:Controller, Service, Mapper, API, 接口, 数据查询 搜索目录:openhis-server-new/src/, his-repo/src/
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
Reference in New Issue
Block a user