forked from fanruan/fineui
75 lines
2.5 KiB
75 lines
2.5 KiB
import { shortcut, extend, emptyFn, createWidget, bind, isNotNull } from "@/core"; |
|
import { AbstractTreeValueChooser } from "./abstract.treevaluechooser"; |
|
import { MultiSelectTree } from "@/widget/multiselecttree/multiselecttree"; |
|
import { MultiSelectTreePopup } from "@/widget/multiselecttree/multiselecttree.popup"; |
|
|
|
@shortcut() |
|
export class TreeValueChooserPane extends AbstractTreeValueChooser { |
|
static xtype = "bi.tree_value_chooser_pane"; |
|
|
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
_defaultConfig() { |
|
return extend(super._defaultConfig(...arguments), { |
|
baseCls: "bi-tree-value-chooser-pane", |
|
items: null, |
|
itemsCreator: emptyFn, |
|
showLine: true, |
|
showIcon: false, |
|
//searcherPaneAutoShrink和searcherPaneIsSelectedAny同时为false时,返回值和非搜索状态下的树逻辑一致 |
|
searcherPaneAutoShrink: true,//其搜索树是否会判别子结点全选则取父结点的值 |
|
searcherPaneIsSelectedAny: true, //其搜索树是否返回所有被checked的结点(包括被checked的结点的子结点) |
|
}); |
|
} |
|
|
|
_init() { |
|
super._init(...arguments); |
|
const o = this.options; |
|
this.pane = createWidget({ |
|
type: o.hideSearch ? MultiSelectTreePopup.xtype : MultiSelectTree.xtype, |
|
element: this, |
|
showLine: o.showLine, |
|
showIcon: o.showIcon, |
|
searcherPaneIsSelectedAny: o.hideSearch || o.searcherPaneIsSelectedAny, |
|
itemsCreator: (options, callback) => { |
|
options.searcherPaneAutoShrink = o.hideSearch || o.searcherPaneAutoShrink; |
|
this._itemsCreator.call(this, options, callback); |
|
}, |
|
}); |
|
|
|
this.pane.on(MultiSelectTree.EVENT_CHANGE, () => { |
|
this.fireEvent(TreeValueChooserPane.EVENT_CHANGE); |
|
}); |
|
if (isNotNull(o.value)) { |
|
const selectedValues = this.assertSelectedValue(o.value, o.items); |
|
this.pane.setSelectedValue(selectedValues); |
|
} |
|
if (isNotNull(o.items)) { |
|
this._initData(o.items); |
|
this.pane.populate(); |
|
} |
|
} |
|
|
|
setSelectedValue(v) { |
|
this.pane.setSelectedValue(v); |
|
} |
|
|
|
setValue(v) { |
|
this.pane.setValue(v); |
|
} |
|
|
|
getValue() { |
|
return this.pane.getValue(); |
|
} |
|
|
|
getAllValue() { |
|
return this.buildCompleteTree(this.pane.getValue()); |
|
} |
|
|
|
populate(items) { |
|
if (isNotNull(items)) { |
|
this._initData(items); |
|
} |
|
this.pane.populate(); |
|
} |
|
}
|
|
|