@hopeio/utils
Version:
javascript utils
45 lines (44 loc) • 1.63 kB
TypeScript
/**
* @description 提取菜单树中的每一项uniqueId
* @param tree 树
* @returns 每一项uniqueId组成的数组
*/
export declare const extractPathList: (tree: any[]) => any;
/**
* @description 如果父级下children的length为1,删除children并自动组建唯一uniqueId
* @param tree 树
* @param pathList 每一项的id组成的数组
* @returns 组件唯一uniqueId后的树
*/
export declare const deleteChildren: (tree: any[], pathList?: any[]) => any;
/**
* @description 创建层级关系
* @param tree 树
* @param pathList 每一项的id组成的数组
* @returns 创建层级关系后的树
*/
export declare const buildHierarchyTree: (tree: any[], pathList?: any[]) => any;
/**
* @description 广度优先遍历,根据唯一uniqueId找当前节点信息
* @param tree 树
* @param uniqueId 唯一uniqueId
* @returns 当前节点信息
*/
export declare const getNodeByUniqueId: (tree: any[], uniqueId: number | string) => any;
/**
* @description 向当前唯一uniqueId节点中追加字段
* @param tree 树
* @param uniqueId 唯一uniqueId
* @param fields 需要追加的字段
* @returns 追加字段后的树
*/
export declare const appendFieldByUniqueId: (tree: any[], uniqueId: number | string, fields: object) => any;
/**
* @description 构造树型结构数据
* @param data 数据源
* @param id id字段 默认id
* @param parentId 父节点字段,默认parentId
* @param children 子节点字段,默认children
* @returns 追加字段后的树
*/
export declare const handleTree: (data: any[], id?: string, parentId?: string, children?: string) => any;