|
|
|
@ -13494,15 +13494,15 @@ if (!window.BI) {
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
has: function (obj, keys) { |
|
|
|
|
if (BI.isKey(keys)) { |
|
|
|
|
return _.has.apply(_, arguments); |
|
|
|
|
} |
|
|
|
|
if (!keys || BI.isEmpty(keys)) { |
|
|
|
|
return false; |
|
|
|
|
if (BI.isArray(keys)) { |
|
|
|
|
if (keys.length === 0) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return BI.every(keys, function (i, key) { |
|
|
|
|
return _.has(obj, key); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return BI.every(keys, function (i, key) { |
|
|
|
|
return _.has(obj, key); |
|
|
|
|
}); |
|
|
|
|
return _.has.apply(_, arguments); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
//数字和字符串可以作为key
|
|
|
|
@ -18448,7 +18448,7 @@ $.extend(BI, {
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
isRoot: function (node) { |
|
|
|
|
return node === this.root || node.id === this.root.id; |
|
|
|
|
return node === this.root; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getRoot: function () { |
|
|
|
@ -18825,7 +18825,7 @@ $.extend(BI, {
|
|
|
|
|
if (BI.isArray(nodes)) { |
|
|
|
|
for (var i = 0, l = nodes.length; i < l; i++) { |
|
|
|
|
var node = BI.clone(nodes[i]); |
|
|
|
|
node.pId = pId; |
|
|
|
|
node.pId = node.pId == null ? pId : node.pId; |
|
|
|
|
delete node.children; |
|
|
|
|
r.push(node); |
|
|
|
|
if (nodes[i]["children"]) { |
|
|
|
@ -18834,7 +18834,7 @@ $.extend(BI, {
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
var newNodes = BI.clone(nodes); |
|
|
|
|
newNodes.pId = pId; |
|
|
|
|
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId; |
|
|
|
|
delete newNodes.children; |
|
|
|
|
r.push(newNodes); |
|
|
|
|
if (nodes["children"]) { |
|
|
|
@ -18845,21 +18845,25 @@ $.extend(BI, {
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
arrayFormat: function (nodes, pId) { |
|
|
|
|
if (!nodes) return []; |
|
|
|
|
if (!nodes) { |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
var r = []; |
|
|
|
|
if (BI.isArray(nodes)) { |
|
|
|
|
for (var i = 0, l = nodes.length; i < l; i++) { |
|
|
|
|
var node = nodes[i]; |
|
|
|
|
node.pId = node.pId == null ? pId : node.pId; |
|
|
|
|
r.push(node); |
|
|
|
|
if (nodes[i]["children"]) { |
|
|
|
|
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id)); |
|
|
|
|
r = r.concat(BI.Tree.arrayFormat(nodes[i]["children"], node.id)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
var newNodes = nodes; |
|
|
|
|
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId; |
|
|
|
|
r.push(newNodes); |
|
|
|
|
if (nodes["children"]) { |
|
|
|
|
r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id)); |
|
|
|
|
r = r.concat(BI.Tree.arrayFormat(nodes["children"], newNodes.id)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return r; |
|
|
|
@ -18875,13 +18879,13 @@ $.extend(BI, {
|
|
|
|
|
var r = []; |
|
|
|
|
var tmpMap = []; |
|
|
|
|
for (i = 0, l = sNodes.length; i < l; i++) { |
|
|
|
|
if(BI.isNull(sNodes[i].id)) { |
|
|
|
|
if (BI.isNull(sNodes[i].id)) { |
|
|
|
|
return sNodes; |
|
|
|
|
} |
|
|
|
|
tmpMap[sNodes[i].id] = BI.clone(sNodes[i]); |
|
|
|
|
} |
|
|
|
|
for (i = 0, l = sNodes.length; i < l; i++) { |
|
|
|
|
if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) { |
|
|
|
|
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) { |
|
|
|
|
if (!tmpMap[sNodes[i].pId].children) { |
|
|
|
|
tmpMap[sNodes[i].pId].children = []; |
|
|
|
|
} |
|
|
|
@ -18897,6 +18901,37 @@ $.extend(BI, {
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
treeFormat: function (sNodes) { |
|
|
|
|
var i, l; |
|
|
|
|
if (!sNodes) { |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (BI.isArray(sNodes)) { |
|
|
|
|
var r = []; |
|
|
|
|
var tmpMap = []; |
|
|
|
|
for (i = 0, l = sNodes.length; i < l; i++) { |
|
|
|
|
if (BI.isNull(sNodes[i].id)) { |
|
|
|
|
return sNodes; |
|
|
|
|
} |
|
|
|
|
tmpMap[sNodes[i].id] = sNodes[i]; |
|
|
|
|
} |
|
|
|
|
for (i = 0, l = sNodes.length; i < l; i++) { |
|
|
|
|
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) { |
|
|
|
|
if (!tmpMap[sNodes[i].pId].children) { |
|
|
|
|
tmpMap[sNodes[i].pId].children = []; |
|
|
|
|
} |
|
|
|
|
tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]); |
|
|
|
|
} else { |
|
|
|
|
r.push(tmpMap[sNodes[i].id]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return r; |
|
|
|
|
} else { |
|
|
|
|
return [sNodes]; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
traversal: function (array, callback) { |
|
|
|
|
if (BI.isNull(array)) { |
|
|
|
|
return; |
|
|
|
|