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.
 
 
 

103 lines
2.8 KiB

import { shortcut, Widget, Func } from "@/core";
@shortcut()
export class SingleSelectCombo extends Widget {
static xtype = "demo.single_select_combo";
props = { baseCls: "demo-single-select-combo" };
_createSingleSelectCombo() {
const self = this;
const widget = createWidget({
type: "bi.single_select_combo",
itemsCreator: bind(this._itemsCreator, this),
width: 200,
ref() {
self.SingleSelectCombo = this;
},
value: "柳州市针织总厂",
});
widget.populate();
widget.on(SingleSelectCombo.EVENT_CONFIRM, function () {
Msg.toast(JSON.stringify(this.getValue()));
});
return widget;
}
_getItemsByTimes(items, times) {
const res = [];
for (let i = (times - 1) * 100; items[i] && i < times * 100; i++) {
res.push(items[i]);
}
return res;
}
_hasNextByTimes(items, times) {
return times * 100 < items.length;
}
_itemsCreator(options, callback) {
const self = this;
let items = Demo.CONSTANTS.ITEMS;
const keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
each(keywords, (i, kw) => {
const search = Func.getSearchResult(items, kw);
items = search.match.concat(search.find);
});
if (options.selectedValues) {
// 过滤
const filter = makeObject(options.selectedValues, true);
items = filter(items, (i, ob) => !filter[ob.value]);
}
if (options.type == SingleSelectCombo.REQ_GET_ALL_DATA) {
callback({
items,
});
return;
}
if (options.type == SingleSelectCombo.REQ_GET_DATA_LENGTH) {
callback({ count: items.length });
return;
}
delay(() => {
callback({
items: self._getItemsByTimes(items, options.times),
hasNext: self._hasNextByTimes(items, options.times),
});
}, 1000);
}
render() {
const self = this;
return {
type: "bi.absolute",
scrolly: false,
items: [
{
el: this._createSingleSelectCombo(),
right: "50%",
top: 10,
},
{
el: {
type: "bi.button",
text: "setValue(\"柳州市针织总厂\")",
handler() {
self.SingleSelectCombo.setValue("柳州市针织总厂");
},
},
}
],
};
}
}