import { shortcut, Widget, Selection, each, contains } from "@/core"; import { SearchMultiTextValueCombo } from "@/widget"; @shortcut() export class AllValueMultiTextValueCombo extends Widget { static xtype = "bi.all_value_multi_text_value_combo"; props = { baseCls: "bi-all-value-multi-text-value-combo", width: 200, height: 24, items: [] }; static EVENT_CONFIRM = "EVENT_CONFIRM"; render() { const self = this, o = this.options; const value = this._digestValue(o.value); return { type: "bi.search_multi_text_value_combo", simple: o.simple, text: o.text, height: o.height, items: o.items, value, numOfPage: 100, valueFormatter: o.valueFormatter, warningTitle: o.warningTitle, listeners: [ { eventName: SearchMultiTextValueCombo.EVENT_CONFIRM, action () { self.fireEvent(AllValueMultiTextValueCombo.EVENT_CONFIRM); }, } ], ref () { self.combo = this; }, }; } setValue(v) { const value = this._digestValue(v); this.combo.setValue(value); } getValue() { const obj = this.combo.getValue() || {}; obj.value = obj.value || []; if (obj.type === Selection.All) { const values = []; each(this.options.items, (idx, item) => { !contains(obj.value, item.value) && values.push(item.value); }); return values; } return obj.value || []; } populate(items) { this.options.items = items; this.combo.populate(...arguments); } _digestValue(v) { return { type: Selection.Multi, value: v || [], }; } }