|
|
|
@ -3,7 +3,7 @@
|
|
|
|
|
*/ |
|
|
|
|
BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { |
|
|
|
|
|
|
|
|
|
props: function() { |
|
|
|
|
props: function () { |
|
|
|
|
return { |
|
|
|
|
extraCls: "bi-multi-layer-select-tree-trigger", |
|
|
|
|
height: 24, |
|
|
|
@ -16,11 +16,12 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
|
|
|
|
|
render: function () { |
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
if(o.itemsCreator === BI.emptyFn) { |
|
|
|
|
if (o.itemsCreator === BI.emptyFn) { |
|
|
|
|
this._initData(); |
|
|
|
|
} |
|
|
|
|
var content = { |
|
|
|
|
type: "bi.htape", |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
type: "bi.horizontal_fill", |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
el: { |
|
|
|
@ -86,7 +87,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
}, |
|
|
|
|
onSearch: function (obj, callback) { |
|
|
|
|
var keyword = obj.keyword; |
|
|
|
|
if(o.itemsCreator === BI.emptyFn) { |
|
|
|
|
if (o.itemsCreator === BI.emptyFn) { |
|
|
|
|
callback(self._getSearchItems(keyword)); |
|
|
|
|
o.allowInsertValue && self.popup.setKeyword(keyword); |
|
|
|
|
} else { |
|
|
|
@ -99,51 +100,37 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE); |
|
|
|
|
} |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
width: "fill", |
|
|
|
|
}, { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.layout", |
|
|
|
|
width: 24 |
|
|
|
|
type: "bi.trigger_icon_button", |
|
|
|
|
cls: "trigger-icon-button", |
|
|
|
|
ref: function (_ref) { |
|
|
|
|
self.triggerBtn = _ref; |
|
|
|
|
}, |
|
|
|
|
width: 24, |
|
|
|
|
}, |
|
|
|
|
width: 24 |
|
|
|
|
width: 24, |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return o.allowEdit ? content : { |
|
|
|
|
type: "bi.absolute", |
|
|
|
|
items: [{ |
|
|
|
|
el: content, |
|
|
|
|
left: 0, |
|
|
|
|
right: 0, |
|
|
|
|
top: 0, |
|
|
|
|
bottom: 0 |
|
|
|
|
}, { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.layout" |
|
|
|
|
}, |
|
|
|
|
left: 0, |
|
|
|
|
right: 24, |
|
|
|
|
top: 0, |
|
|
|
|
bottom: 0 |
|
|
|
|
}] |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_initData: function() { |
|
|
|
|
_initData: function () { |
|
|
|
|
var o = this.options; |
|
|
|
|
this.tree = new BI.Tree(); |
|
|
|
|
this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); |
|
|
|
|
this.tree.initTree(this.nodes); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_getSearchItems: function(keyword) { |
|
|
|
|
_getSearchItems: function (keyword) { |
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
// 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索
|
|
|
|
|
var items = []; |
|
|
|
|
this.tree.traverse(function (node) { |
|
|
|
|
var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); |
|
|
|
|
if(find.find.length > 0 || find.match.length > 0) { |
|
|
|
|
if (find.find.length > 0 || find.match.length > 0) { |
|
|
|
|
items.push(node); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -151,7 +138,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
return this._fillTreeStructure4Search(items, "id"); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_createJson: function(node, open) { |
|
|
|
|
_createJson: function (node, open) { |
|
|
|
|
return { |
|
|
|
|
id: node.id, |
|
|
|
|
pId: node.pId, |
|
|
|
@ -159,10 +146,10 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
value: node.value, |
|
|
|
|
isParent: BI.isNotEmptyArray(node.children), |
|
|
|
|
open: open |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_getChildren: function(node) { |
|
|
|
|
_getChildren: function (node) { |
|
|
|
|
var self = this; |
|
|
|
|
node.children = node.children || []; |
|
|
|
|
var nodes = []; |
|
|
|
@ -179,7 +166,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
var result = []; |
|
|
|
|
var queue = []; |
|
|
|
|
BI.each(leaves, function (idx, node) { |
|
|
|
|
queue.push({pId: node.pId}); |
|
|
|
|
queue.push({ pId: node.pId }); |
|
|
|
|
result.push(node); |
|
|
|
|
result = result.concat(self._getChildren(node)); |
|
|
|
|
}); |
|
|
|
@ -188,7 +175,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); |
|
|
|
|
if (pNode != null) { |
|
|
|
|
pNode.open = true; |
|
|
|
|
queue.push({pId: pNode.pId}); |
|
|
|
|
queue.push({ pId: pNode.pId }); |
|
|
|
|
result.push(pNode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -259,4 +246,4 @@ BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
|
|
|
|
|
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START"; |
|
|
|
|
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
|
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; |
|
|
|
|
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); |
|
|
|
|
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); |
|
|
|
|