提交
This commit is contained in:
1 parent
68b8feffc1
commit
fca7096e9f
30 files changed
+4049
-8
No files matched your search
@@ -2014,6 +2014,27 @@ const cloneDeptTreeNodes = (nodes: any[]): any[] => {
|
||||
});
|
||||
};
|
||||
|
||||
/** 规范化部门树节点(确保 label / originalLabel / disabled 存在),递归处理 */
|
||||
const processDeptTreeData = (nodes: any[]): any[] => {
|
||||
return (nodes || []).map((node) => {
|
||||
const processed: any = { ...node };
|
||||
|
||||
// 保留原始 label,兼容不同接口字段(label / name)
|
||||
processed.originalLabel = processed.originalLabel ?? processed.label ?? processed.name ?? '';
|
||||
processed.label = processed.label ?? processed.name ?? processed.originalLabel;
|
||||
|
||||
// 确保 disabled 字段存在,避免某些节点被意外隐藏/不可选
|
||||
processed.disabled = processed.disabled ?? false;
|
||||
|
||||
if (Array.isArray(processed.children) && processed.children.length > 0) {
|
||||
processed.children = processDeptTreeData(processed.children);
|
||||
} else {
|
||||
processed.children = [];
|
||||
}
|
||||
return processed;
|
||||
});
|
||||
};
|
||||
|
||||
/** 增强树节点(补充班级状态) */
|
||||
const enhanceDeptTreeNodes = (nodes: any[]): any[] => {
|
||||
return (nodes || []).map((node) => {
|
||||
@@ -2042,11 +2063,17 @@ const filterDeptTreeByStatus = (nodes: any[], status?: string): any[] => {
|
||||
} else {
|
||||
cloned.children = [];
|
||||
}
|
||||
// 如果开启了状态过滤,仅保留符合状态的班级节点
|
||||
if (targetStatus && isClassNode(cloned)) {
|
||||
if (cloned.classStatus !== targetStatus) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 当开启状态过滤且节点不是班级节点且没有子节点时,过滤掉该节点(和 stuRoster 行为一致)
|
||||
if (targetStatus && !isClassNode(cloned) && (!cloned.children || cloned.children.length === 0)) {
|
||||
return null;
|
||||
}
|
||||
return cloned;
|
||||
})
|
||||
.filter((item) => item !== null) as any[];
|
||||
@@ -2142,8 +2169,10 @@ const extractDeptTreeData = (payload: any): any[] => {
|
||||
|
||||
/** 构建部门树 */
|
||||
const rebuildDeptTree = async (treeData: any[], resetSelection = true) => {
|
||||
// 先规范化树结构,保证每个节点都有 label / disabled / children 字段
|
||||
const processed = processDeptTreeData(treeData);
|
||||
await ensureClassStatusMap();
|
||||
const enhanced = enhanceDeptTreeNodes(treeData);
|
||||
const enhanced = enhanceDeptTreeNodes(processed);
|
||||
rawDeptOptions.value = enhanced;
|
||||
applyClassStatusFilter(!resetSelection);
|
||||
if (resetSelection) {
|
||||
@@ -3215,7 +3244,7 @@ onMounted(() => {
|
||||
|
||||
/* 部门树组件样式 */
|
||||
.dept-tree {
|
||||
height: 600px;
|
||||
height: calc(100vh - 280px); /* 与 stuRoster 左侧树一致,随视窗高度自适应 */
|
||||
overflow-y: auto;
|
||||
overflow-x: auto;
|
||||
width: 330px; /* 固定宽度,超出时显示滚动条 */
|
||||
|
||||
Reference in new issue
Block a user