综合模块完成
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
15683799673
2025-06-28 22:49:40 +08:00
parent acd63bc96e
commit 54cea19b78
22 changed files with 523 additions and 571 deletions

View File

@@ -276,6 +276,43 @@ export function addFullName(
});
}
/**
*
* 添加全名 如 祖先节点-父节点-子节点
* @param treeData 已经是tree数据
* @param labelName 标签的字段名称
* @param splitStr 分隔符
* @param callback 回调函数
* @returns void 无返回值 会修改原始数据
*/
export function handleNode(
treeData: any[],
labelName = 'label',
splitStr = '-',
callback: Function,
) {
function addFullNameProperty(
node: any,
parentNames: any[] = [],
parentNode: any = null,
) {
const fullNameParts = [...parentNames, node[labelName]];
node.fullName = fullNameParts.join(splitStr);
if (callback) {
callback(node, parentNode);
}
if (node.children && node.children.length > 0) {
node.children.forEach((childNode: any) => {
addFullNameProperty(childNode, fullNameParts, node);
});
}
}
treeData.forEach((item: any) => {
addFullNameProperty(item);
});
}
/**
* https://blog.csdn.net/Web_J/article/details/129281329
* 给出节点nodeId 找到所有父节点ID