src/utils/standardTree.js
@@ -1,7 +1,8 @@ /** * 标准库树通用工具 * * 层级不固定:children 为 null / undefined / 空数组的节点即为「标准」叶子。 * 标准库固定两级:code=[1] 为行业,code=[2] 为标准。 * 兼容没有 code 的旧接口数据时,再回退到 children 判断叶子。 * 树路径统一由 " - " 连接,格式与历史实现逐字节保持一致: * 顶层真实节点的 parent 是 Element UI 的虚拟根,因此根节点会进入路径。 */ @@ -9,6 +10,8 @@ // 是否叶子(标准) export function isLeaf(data) { if (!data) return true; if (data.code === '[1]') return false; if (data.code === '[2]') return true; const children = data.children; return children === null || children === undefined || children.length === 0; }