Browse Source
* commit '6c9a2e712ec45e001e932366ac107eaea1ba29b6': fix_comment fix_comment KERNEL-702 feat: 两个单选下拉树支持异步加载搜索es6
guy
6 years ago
10 changed files with 561 additions and 86 deletions
@ -0,0 +1,123 @@
|
||||
/** |
||||
* Created by Windy on 2018/2/2. |
||||
*/ |
||||
BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { |
||||
|
||||
props: { |
||||
extraCls: "bi-multi-layer-select-tree-trigger bi-border bi-focus-shadow", |
||||
height: 24, |
||||
valueFormatter: function (v) { |
||||
return v; |
||||
}, |
||||
itemsCreator: BI.emptyFn |
||||
}, |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
var content = { |
||||
type: "bi.htape", |
||||
items: [ |
||||
{ |
||||
el: { |
||||
type: "bi.searcher", |
||||
ref: function () { |
||||
self.searcher = this; |
||||
}, |
||||
isAutoSearch: false, |
||||
el: { |
||||
type: "bi.state_editor", |
||||
ref: function () { |
||||
self.editor = this; |
||||
}, |
||||
text: this._digest(o.value), |
||||
value: o.value, |
||||
height: o.height, |
||||
tipText: "" |
||||
}, |
||||
popup: { |
||||
type: "bi.multilayer_select_tree_popup", |
||||
itemsCreator: function (op, callback) { |
||||
op.keyword = self.editor.getValue(); |
||||
o.itemsCreator(op, callback); |
||||
}, |
||||
keywordGetter: function () { |
||||
return self.editor.getValue(); |
||||
}, |
||||
cls: "bi-card" |
||||
}, |
||||
onSearch: function (obj, callback) { |
||||
var keyword = obj.keyword; |
||||
if(o.itemsCreator === BI.emptyFn) { |
||||
var finding = BI.Func.getSearchResult(o.items, keyword); |
||||
var matched = finding.match, find = finding.find; |
||||
callback(find.concat(matched)); |
||||
} else { |
||||
callback(); |
||||
} |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.Searcher.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE); |
||||
} |
||||
}] |
||||
} |
||||
}, { |
||||
el: { |
||||
type: "bi.layout", |
||||
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 |
||||
}] |
||||
}; |
||||
}, |
||||
|
||||
_digest: function (v) { |
||||
return this.options.valueFormatter(v); |
||||
}, |
||||
|
||||
stopEditing: function () { |
||||
this.searcher.stopSearch(); |
||||
}, |
||||
|
||||
getSearcher: function () { |
||||
return this.searcher; |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.options.items = items; |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.editor.setState(this._digest(v[0])); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.searcher.getValue(); |
||||
} |
||||
}); |
||||
BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP"; |
||||
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START"; |
||||
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); |
@ -0,0 +1,123 @@
|
||||
/** |
||||
* Created by Windy on 2018/2/2. |
||||
*/ |
||||
BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { |
||||
|
||||
props: { |
||||
extraCls: "bi-multi-layer-single-tree-trigger bi-border bi-focus-shadow", |
||||
height: 24, |
||||
valueFormatter: function (v) { |
||||
return v; |
||||
}, |
||||
itemsCreator: BI.emptyFn |
||||
}, |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
var content = { |
||||
type: "bi.htape", |
||||
items: [ |
||||
{ |
||||
el: { |
||||
type: "bi.searcher", |
||||
ref: function () { |
||||
self.searcher = this; |
||||
}, |
||||
isAutoSearch: false, |
||||
el: { |
||||
type: "bi.state_editor", |
||||
ref: function () { |
||||
self.editor = this; |
||||
}, |
||||
text: this._digest(o.value), |
||||
value: o.value, |
||||
height: o.height, |
||||
tipText: "" |
||||
}, |
||||
popup: { |
||||
type: "bi.multilayer_single_tree_popup", |
||||
itemsCreator: function (op, callback) { |
||||
op.keyword = self.editor.getValue(); |
||||
o.itemsCreator(op, callback); |
||||
}, |
||||
keywordGetter: function () { |
||||
return self.editor.getValue(); |
||||
}, |
||||
cls: "bi-card" |
||||
}, |
||||
onSearch: function (obj, callback) { |
||||
var keyword = obj.keyword; |
||||
if(o.itemsCreator === BI.emptyFn) { |
||||
var finding = BI.Func.getSearchResult(o.items, keyword); |
||||
var matched = finding.match, find = finding.find; |
||||
callback(find.concat(matched)); |
||||
} else { |
||||
callback(); |
||||
} |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.Searcher.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE); |
||||
} |
||||
}] |
||||
} |
||||
}, { |
||||
el: { |
||||
type: "bi.layout", |
||||
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 |
||||
}] |
||||
}; |
||||
}, |
||||
|
||||
_digest: function (v) { |
||||
return this.options.valueFormatter(v); |
||||
}, |
||||
|
||||
stopEditing: function () { |
||||
this.searcher.stopSearch(); |
||||
}, |
||||
|
||||
getSearcher: function () { |
||||
return this.searcher; |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.options.items = items; |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.editor.setState(this._digest(v[0])); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.searcher.getValue(); |
||||
} |
||||
}); |
||||
BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP"; |
||||
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START"; |
||||
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger); |
Loading…
Reference in new issue