From 8c5854785aafcf299a1b184c6998fbe7d7bcdc3e Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 27 Aug 2021 14:00:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AEchildren=E6=89=80=E5=9C=A8key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/structure/tree.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/core/structure/tree.js b/src/core/structure/tree.js index 44c258461..32e7665b4 100644 --- a/src/core/structure/tree.js +++ b/src/core/structure/tree.js @@ -387,17 +387,18 @@ }; BI.extend(BI.Tree, { - transformToArrayFormat: function (nodes, pId) { + transformToArrayFormat: function (nodes, pId, childKey) { if (!nodes) return []; var r = []; + childKey = childKey || "children"; if (BI.isArray(nodes)) { for (var i = 0, l = nodes.length; i < l; i++) { var node = BI.clone(nodes[i]); node.pId = node.pId == null ? pId : node.pId; delete node.children; r.push(node); - if (nodes[i]["children"]) { - r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id)); + if (nodes[i][childKey]) { + r = r.concat(BI.Tree.transformToArrayFormat(nodes[i][childKey], node.id)); } } } else { @@ -405,8 +406,8 @@ newNodes.pId = newNodes.pId == null ? pId : newNodes.pId; delete newNodes.children; r.push(newNodes); - if (nodes["children"]) { - r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id)); + if (nodes[childKey]) { + r = r.concat(BI.Tree.transformToArrayFormat(nodes[childKey], newNodes.id)); } } return r; @@ -466,7 +467,7 @@ return r; } return [sNodes]; - + }, treeFormat: function (sNodes) { @@ -497,7 +498,7 @@ return r; } return [sNodes]; - + }, traversal: function (array, callback, pNode) {