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.

105 lines
2.9 KiB

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