forked from fanruan/fineui
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.
84 lines
2.0 KiB
84 lines
2.0 KiB
import { |
|
shortcut, |
|
Widget, |
|
extend, |
|
i18nText, |
|
emptyFn, |
|
createWidget, |
|
Controller, |
|
VerticalLayout, |
|
isArray |
|
} from "@/core"; |
|
import { MultiLayerSingleLevelTree } from "./multilayersingletree.leveltree"; |
|
|
|
@shortcut() |
|
export class MultiLayerSingleTreePopup extends Widget { |
|
static xtype = "bi.multilayer_single_tree_popup"; |
|
|
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
_defaultConfig() { |
|
return extend(super._defaultConfig(...arguments), { |
|
baseCls: "bi-multilayer-singletree-popup", |
|
tipText: i18nText("BI-No_Selected_Item"), |
|
isDefaultInit: false, |
|
itemsCreator: emptyFn, |
|
items: [], |
|
onLoaded: emptyFn, |
|
minHeight: 240, |
|
}); |
|
} |
|
|
|
_init() { |
|
super._init(...arguments); |
|
|
|
const self = this, |
|
o = this.options; |
|
|
|
this.tree = createWidget({ |
|
type: MultiLayerSingleLevelTree.xtype, |
|
isDefaultInit: o.isDefaultInit, |
|
items: o.items, |
|
itemsCreator: o.itemsCreator, |
|
keywordGetter: o.keywordGetter, |
|
value: o.value, |
|
scrollable: null, |
|
onLoaded() { |
|
self.tree.check(); |
|
o.onLoaded(); |
|
}, |
|
}); |
|
|
|
createWidget({ |
|
type: VerticalLayout.xtype, |
|
scrolly: false, |
|
scrollable: true, |
|
element: this, |
|
vgap: 5, |
|
items: [this.tree], |
|
}); |
|
|
|
this.tree.on(Controller.EVENT_CHANGE, function () { |
|
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
|
}); |
|
|
|
this.tree.on(MultiLayerSingleLevelTree.EVENT_CHANGE, () => { |
|
self.fireEvent(MultiLayerSingleTreePopup.EVENT_CHANGE); |
|
}); |
|
|
|
this.tree.css("min-height", BI.pixFormat(o.minHeight - 10)); |
|
} |
|
|
|
getValue() { |
|
return this.tree.getValue(); |
|
} |
|
|
|
setValue(v) { |
|
v = isArray(v) ? v : [v]; |
|
this.tree.setValue(v); |
|
} |
|
|
|
populate(items) { |
|
this.tree.populate(items); |
|
} |
|
}
|
|
|