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.

97 lines
2.7 KiB

import { shortcut, Widget, Func, createWidget, bind, each, makeObject, filter, delay } from "@/core";
import { Msg } from "@/base";
8 years ago
@shortcut()
export class MultiSelectCombo extends Widget {
static xtype = "demo.multi_select_combo";
props = { baseCls: "demo-multi-select-combo" };
_createMultiSelectCombo() {
const self = this;
const widget = createWidget({
7 years ago
type: "bi.multi_select_insert_combo",
// allowEdit: false,
itemsCreator: bind(this._itemsCreator, this),
width: 200,
value: {
type: 1,
value: [
"柳州市城贸金属材料有限责任公司",
"柳州市建福房屋租赁有限公司",
"柳州市迅昌数码办公设备有限责任公司"
],
},
8 years ago
});
widget.on(MultiSelectCombo.EVENT_CONFIRM, function () {
Msg.toast(JSON.stringify(this.getValue()));
8 years ago
});
return widget;
}
8 years ago
_getItemsByTimes(items, times) {
const res = [];
for (let i = (times - 1) * 100; items[i] && i < times * 100; i++) {
8 years ago
res.push(items[i]);
}
8 years ago
return res;
}
8 years ago
_hasNextByTimes(items, times) {
7 years ago
return times * 100 < items.length;
}
8 years ago
_itemsCreator(options, callback) {
const self = this;
let items = Demo.CONSTANTS.ITEMS;
const keywords = (options.keywords || []).slice();
8 years ago
if (options.keyword) {
keywords.push(options.keyword);
}
each(keywords, (i, kw) => {
const search = Func.getSearchResult(items, kw);
7 years ago
items = search.match.concat(search.find);
8 years ago
});
if (options.selectedValues) {
// 过滤
const filter = makeObject(options.selectedValues, true);
items = filter(items, (i, ob) => !filter[ob.value]);
8 years ago
}
if (options.type == MultiSelectCombo.REQ_GET_ALL_DATA) {
8 years ago
callback({
items,
8 years ago
});
8 years ago
return;
}
if (options.type == MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({ count: items.length });
8 years ago
return;
}
delay(() => {
8 years ago
callback({
items: self._getItemsByTimes(items, options.times),
hasNext: self._hasNextByTimes(items, options.times),
8 years ago
});
}, 1000);
}
8 years ago
render() {
8 years ago
return {
7 years ago
type: "bi.absolute",
8 years ago
scrolly: false,
items: [
{
el: this._createMultiSelectCombo(),
right: "50%",
top: 10,
}
],
7 years ago
};
8 years ago
}
}