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.
 
 
 

148 lines
4.8 KiB

import {
shortcut,
Widget,
i18nText,
extend,
Controller,
AbsoluteLayout,
isEmptyArray
} from "@/core";
import { TreeView, PartTree } from "@/case";
import { TextButton } from "@/base";
@shortcut()
export class MultiTreeSearchInsertPane extends Widget {
static xtype = "bi.multi_tree_search_insert_pane";
props = {
baseCls: "bi-multi-tree-search-insert-pane bi-card",
el: { type: PartTree.xtype },
};
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
static EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
static EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
static EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE";
render() {
const self = this,
opts = this.options;
return {
type: AbsoluteLayout.xtype,
items: [
{
el: {
type: TextButton.xtype,
invisible: true,
ref(_ref) {
self.addTip = _ref;
},
text: i18nText("BI-Basic_Click_To_Add_Text", ""),
height: this.constants.height,
cls: "bi-high-light",
handler() {
self.fireEvent(
MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
opts.keywordGetter()
);
},
},
top: 5,
left: 0,
right: 0,
},
{
el: extend(
{
type: PartTree.xtype,
tipText: i18nText("BI-No_Select"),
itemsCreator(op, callback) {
op.keyword = opts.keywordGetter();
opts.itemsCreator(op, res => {
callback(res);
self.setKeyword(
opts.keywordGetter(),
res.items
);
});
},
ref(_ref) {
self.partTree = _ref;
},
value: opts.value,
listeners: [
{
eventName: Controller.EVENT_CHANGE,
action() {
self.fireEvent(
Controller.EVENT_CHANGE,
arguments
);
},
},
{
eventName: TreeView.EVENT_CHANGE,
action() {
self.fireEvent(
MultiTreeSearchInsertPane.EVENT_CHANGE
);
},
},
{
eventName: PartTree.EVENT_CLICK_TREE_NODE,
action() {
self.fireEvent(
MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE
);
},
}
],
},
opts.el
),
left: 0,
top: 0,
bottom: 0,
right: 0,
}
],
};
}
setKeyword(keyword, nodes) {
const isAddTipVisible = isEmptyArray(nodes);
this.addTip.setVisible(isAddTipVisible);
this.partTree.setVisible(!isAddTipVisible);
isAddTipVisible &&
this.addTip.setText(
i18nText("BI-Basic_Click_To_Add_Text", keyword)
);
}
hasChecked() {
return this.partTree.hasChecked();
}
setValue(v) {
this.setSelectedValue(v.value);
}
setSelectedValue(v) {
v || (v = {});
this.partTree.setSelectedValue(v);
}
getValue() {
return this.partTree.getValue();
}
empty() {
this.partTree.empty();
}
populate(op) {
this.partTree.stroke(...arguments);
}
}