⚡ 优化用户组织树展示与客商档案编辑锁定

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-09 22:55:12 +08:00
co-authored by Cursor
parent 1663b2d910
commit d2f756bc21
4 changed files with 49 additions and 20 deletions
+28 -10
View File
@@ -492,17 +492,35 @@ export const treeOption = {
nodeKey: 'id',
lazy: true,
treeLoad: function (node, resolve) {
const parentId = node.level === 0 ? 0 : node.data.id;
getDeptLazyTree(parentId).then(res => {
resolve(
res.data.data.map(item => {
return {
...item,
leaf: !item.hasChildren,
};
})
);
const toTreeNode = item => ({
...item,
leaf: !item.hasChildren,
});
// 用户管理组织树从第二级开始展示:根层隐藏一级组织,直接展示其子节点
if (node.level === 0) {
getDeptLazyTree(0)
.then(res => {
const roots = res.data.data || [];
if (!roots.length) {
resolve([]);
return;
}
return Promise.all(roots.map(root => getDeptLazyTree(root.id))).then(childResults => {
const secondLevel = [];
childResults.forEach(childRes => {
(childRes.data.data || []).forEach(item => secondLevel.push(toTreeNode(item)));
});
resolve(secondLevel);
});
})
.catch(() => resolve([]));
return;
}
getDeptLazyTree(node.data.id)
.then(res => {
resolve((res.data.data || []).map(toTreeNode));
})
.catch(() => resolve([]));
},
addBtn: false,
menu: false,