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.
 
 
 

128 lines
3.4 KiB

import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
Events,
nextTick
} from "@/core";
import { Switcher } from "@/base";
import { MultiSelectCheckSelectedButton } from "./button.checkselected";
import { MultiSelectCheckPane } from "../check/multiselect.check.pane";
@shortcut()
export class MultiSelectCheckSelectedSwitcher extends Widget {
static xtype = "bi.multi_select_check_selected_switcher";
static EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
static EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-multi-select-check-selected-switcher",
itemsCreator: emptyFn,
valueFormatter: emptyFn,
el: {},
popup: {},
adapter: null,
masker: {},
});
}
_init() {
super._init(...arguments);
const self = this,
o = this.options;
this.button = createWidget(o.el, {
type: MultiSelectCheckSelectedButton.xtype,
itemsCreator: o.itemsCreator,
value: o.value,
});
this.button.on(Events.VIEW, function () {
self.fireEvent(Events.VIEW, arguments);
});
this.switcher = createWidget({
type: Switcher.xtype,
toggle: false,
element: this,
el: this.button,
popup: extend(
{
type: MultiSelectCheckPane.xtype,
valueFormatter: o.valueFormatter,
itemsCreator: o.itemsCreator,
onClickContinueSelect() {
self.switcher.hideView();
},
ref(_ref) {
self.checkPane = _ref;
},
value: o.value,
},
o.popup
),
adapter: o.adapter,
masker: o.masker,
});
this.switcher.on(Switcher.EVENT_TRIGGER_CHANGE, () => {
self.fireEvent(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE
);
});
this.switcher.on(Switcher.EVENT_BEFORE_POPUPVIEW, () => {
self.fireEvent(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW
);
});
this.switcher.on(Switcher.EVENT_AFTER_HIDEVIEW, () => {
self.fireEvent(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW
);
});
this.switcher.on(Switcher.EVENT_AFTER_POPUPVIEW, function () {
const me = this;
nextTick(() => {
me._populate();
});
});
}
adjustView() {
this.switcher.adjustView();
}
hideView() {
this.switcher.empty();
this.switcher.hideView();
}
setAdapter(adapter) {
this.switcher.setAdapter(adapter);
}
setValue(v) {
this.switcher.setValue(v);
}
updateSelectedValue(v) {
this.checkPane.setValue(v);
}
setButtonChecked(v) {
this.button.setValue(v);
}
getValue() {
}
populate(items) {
this.switcher.populate.apply(this.switcher, arguments);
}
populateSwitcher() {
this.button.populate.apply(this.button, arguments);
}
}