|
|
@ -14,6 +14,10 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { |
|
|
|
|
|
|
|
|
|
|
|
render: function () { |
|
|
|
render: function () { |
|
|
|
var self = this, o = this.options; |
|
|
|
var self = this, o = this.options; |
|
|
|
|
|
|
|
if(o.itemsCreator === BI.emptyFn) { |
|
|
|
|
|
|
|
this.tree = new BI.Tree(); |
|
|
|
|
|
|
|
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items)))); |
|
|
|
|
|
|
|
} |
|
|
|
var content = { |
|
|
|
var content = { |
|
|
|
type: "bi.htape", |
|
|
|
type: "bi.htape", |
|
|
|
items: [ |
|
|
|
items: [ |
|
|
@ -68,7 +72,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { |
|
|
|
if(o.itemsCreator === BI.emptyFn) { |
|
|
|
if(o.itemsCreator === BI.emptyFn) { |
|
|
|
var finding = BI.Func.getSearchResult(o.items, keyword); |
|
|
|
var finding = BI.Func.getSearchResult(o.items, keyword); |
|
|
|
var matched = finding.match, find = finding.find; |
|
|
|
var matched = finding.match, find = finding.find; |
|
|
|
callback(find.concat(matched)); |
|
|
|
callback(self._fillTreeStructure4Search(find.concat(matched))); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
callback(); |
|
|
|
callback(); |
|
|
|
} |
|
|
|
} |
|
|
@ -110,6 +114,29 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将搜索到的节点进行补充,构造成一棵完整的树
|
|
|
|
|
|
|
|
_fillTreeStructure4Search: function (leaves) { |
|
|
|
|
|
|
|
var result = BI.map(leaves, "id"); |
|
|
|
|
|
|
|
var queue = leaves.reverse() || []; |
|
|
|
|
|
|
|
while (BI.isNotEmptyArray(queue)) { |
|
|
|
|
|
|
|
var node = queue.pop(); |
|
|
|
|
|
|
|
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); |
|
|
|
|
|
|
|
if (pNode != null) { |
|
|
|
|
|
|
|
queue.push(pNode); |
|
|
|
|
|
|
|
result.push(pNode.id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var nodes = []; |
|
|
|
|
|
|
|
BI.each(this.options.items, function (idx, item) { |
|
|
|
|
|
|
|
if(BI.contains(result, item.id)) { |
|
|
|
|
|
|
|
nodes.push(BI.extend({}, item, { |
|
|
|
|
|
|
|
open: true |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return nodes; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_digest: function (v) { |
|
|
|
_digest: function (v) { |
|
|
|
var o = this.options; |
|
|
|
var o = this.options; |
|
|
|
return o.valueFormatter(v) || o.text; |
|
|
|
return o.valueFormatter(v) || o.text; |
|
|
|