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