|
|
|
@ -851,6 +851,40 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
|
|
|
|
|
return this._getChildren(parentValues).length; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
assertSelectedValue: function (selectedValues, items = []) { |
|
|
|
|
if (BI.isPlainObject(selectedValues)) { |
|
|
|
|
return selectedValues; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var tree = BI.Tree.transformToTreeFormat(items); |
|
|
|
|
var value2ParentMap = {}; |
|
|
|
|
BI.Tree.traversal(tree, function (index, node, pNode) { |
|
|
|
|
value2ParentMap[node.value] = pNode; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var result = {}; |
|
|
|
|
BI.each(selectedValues, function (index, value) { |
|
|
|
|
var curr = value; |
|
|
|
|
var parentPath = []; |
|
|
|
|
while (curr) { |
|
|
|
|
parentPath.unshift(curr); |
|
|
|
|
curr = value2ParentMap[curr]?.value; |
|
|
|
|
} |
|
|
|
|
BI.each(parentPath, function (index) { |
|
|
|
|
if (BI.isNull(BI.get(result, parentPath.slice(0, index + 1)))) { |
|
|
|
|
BI.set(result, parentPath.slice(0, index + 1), {}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
// 执行完一条路径,check一下
|
|
|
|
|
var lengths = BI.size(BI.get(result, parentPath.slice(0, -1))); |
|
|
|
|
if (lengths === value2ParentMap[value]?.children?.length) { |
|
|
|
|
BI.set(result, parentPath.slice(0, -1), {}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
buildCompleteTree: function (selectedValues) { |
|
|
|
|
var self = this; |
|
|
|
|
var result = {}; |
|
|
|
|