修复Bug138 系统管理-》基础数据-》病区/床位管理:关联科室字段的下拉选项

This commit is contained in:
HuangShun
2026-02-05 11:24:43 +08:00
parent 4bf74a1ff0
commit 74892ea80f
2 changed files with 34 additions and 2 deletions

View File

@@ -14,10 +14,11 @@ export function getList(queryParams) {
/** /**
* 获取科室下拉列表 * 获取科室下拉列表
*/ */
export function getOrgList() { export function getOrgList(queryParams) {
return request({ return request({
url: '/base-data-manage/organization/organization', url: '/base-data-manage/organization/organization',
method: 'get', method: 'get',
params: queryParams
}) })
} }

View File

@@ -385,10 +385,41 @@ const rules = ref({
}, },
], ],
}); });
// 递归过滤树形数据只保留classEnum包含住院(2)的科室
function filterOrgByClassEnum(orgList, targetClassEnum = '2') {
if (!orgList || !Array.isArray(orgList)) return [];
const result = [];
for (const item of orgList) {
// 深拷贝当前节点,避免修改原始数据
const newItem = { ...item };
// 检查当前节点的classEnum是否包含目标值
let isMatch = false;
if (newItem.classEnum !== null && newItem.classEnum !== undefined) {
const classEnumStr = String(newItem.classEnum);
const classEnumValues = classEnumStr.split(',').map(v => v.trim());
isMatch = classEnumValues.includes(targetClassEnum);
}
// 递归过滤子节点
if (newItem.children && newItem.children.length > 0) {
newItem.children = filterOrgByClassEnum(newItem.children, targetClassEnum);
}
// 如果当前节点匹配或者有匹配的子节点,则保留
if (isMatch || (newItem.children && newItem.children.length > 0)) {
result.push(newItem);
}
}
return result;
}
// 获取科室下啦树 // 获取科室下啦树
function init() { function init() {
getOrgList().then((res) => { getOrgList().then((res) => {
organization.value = res.data.records; const records = res.data.records || [];
// 过滤只保留住院科室(classEnum包含2)
organization.value = filterOrgByClassEnum(records, '2');
}); });
} }
/** /**