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.
 
 
 

74 lines
2.1 KiB

import { SmallTextTrigger } from "./trigger.text.small";
import { shortcut, extend, toPix, createWidget, isArray, deepContains, each, contains, Tree } from "@/core";
import { Trigger } from "@/base";
/**
* 选择字段trigger小一号的
*
* @class SmallSelectTextTrigger
* @extends Trigger
*/
@shortcut()
export class SmallSelectTextTrigger extends Trigger {
static xtype = "bi.small_select_text_trigger";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-small-select-text-trigger bi-border",
height: 20,
});
}
_init() {
super._init(...arguments);
const o = this.options;
const obj = this._digest(o.value, o.items);
this.trigger = createWidget({
type: SmallTextTrigger.xtype,
element: this,
height: toPix(o.height, 2),
text: obj.text,
cls: obj.cls,
textHgap: o.textHgap,
textVgap: o.textVgap,
textLgap: o.textLgap,
textRgap: o.textRgap,
textTgap: o.textTgap,
textBgap: o.textBgap,
});
}
_digest(vals, items) {
const o = this.options;
vals = isArray(vals) ? vals : [vals];
const result = [];
const formatItems = Tree.transformToArrayFormat(items);
each(formatItems, (i, item) => {
if (deepContains(vals, item.value) && !contains(result, item.text || item.value)) {
result.push(item.text || item.value);
}
});
if (result.length > 0) {
return {
cls: "",
text: result.join(","),
};
} else {
return {
cls: "bi-water-mark",
text: o.text,
};
}
}
setValue(vals) {
const formatValue = this._digest(vals, this.options.items);
this.trigger.element.removeClass("bi-water-mark").addClass(formatValue.cls);
this.trigger.setText(formatValue.text);
}
populate(items) {
this.options.items = items;
}
}