fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.8 KiB

7 years ago
/**
* Created by User on 2017/3/22.
*/
Demo.MultiSelectCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-multi-select-combo"
},
_createMultiSelectCombo: function () {
var self = this;
var widget = BI.createWidget({
type: "bi.multi_select_combo",
7 years ago
itemsCreator: BI.bind(this._itemsCreator, this),
width: 200,
value: {
type: 1,
value: ["柳州市城贸金属材料有限责任公司", "柳州市建福房屋租赁有限公司", "柳州市迅昌数码办公设备有限责任公司"]
}
7 years ago
});
widget.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
BI.Msg.toast(JSON.stringify(this.getValue()));
});
return widget;
},
_getItemsByTimes: function (items, times) {
var res = [];
7 years ago
for (var i = (times - 1) * 10; items[i] && i < times * 10; i++) {
7 years ago
res.push(items[i]);
}
return res;
},
_hasNextByTimes: function (items, times) {
7 years ago
return times * 10 < items.length;
7 years ago
},
_itemsCreator: function (options, callback) {
var self = this;
var items = Demo.CONSTANTS.ITEMS;
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
7 years ago
items = search.match.concat(search.find);
7 years ago
});
7 years ago
if (options.selectedValues) {// 过滤
7 years ago
var filter = BI.makeObject(options.selectedValues, true);
7 years ago
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
}
if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
items: items
});
return;
}
if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
BI.delay(function () {
callback({
items: self._getItemsByTimes(items, options.times),
hasNext: self._hasNextByTimes(items, options.times)
});
}, 1000);
},
render: function () {
return {
type: "bi.vertical",
vgap: 200,
items: [this._createMultiSelectCombo(), {
type: "bi.search_multi_select_combo",
items: Demo.CONSTANTS.ITEMS,
text: "请选择",
7 years ago
width: 200,
value: {
type: 1,
value: ["1", "2", "3"]
}
7 years ago
}]
7 years ago
};
7 years ago
}
});
BI.shortcut("demo.multi_select_combo", Demo.MultiSelectCombo);