修复Bug138 系统管理-》基础数据-》病区/床位管理:关联科室字段的下拉选项
This commit is contained in:
@@ -14,10 +14,11 @@ export function getList(queryParams) {
|
||||
/**
|
||||
* 获取科室下拉列表
|
||||
*/
|
||||
export function getOrgList() {
|
||||
export function getOrgList(queryParams) {
|
||||
return request({
|
||||
url: '/base-data-manage/organization/organization',
|
||||
method: 'get',
|
||||
params: queryParams
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
getOrgList().then((res) => {
|
||||
organization.value = res.data.records;
|
||||
const records = res.data.records || [];
|
||||
// 过滤只保留住院科室(classEnum包含2)
|
||||
organization.value = filterOrgByClassEnum(records, '2');
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user