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.

91 lines
2.8 KiB

import { NodeButton } from "../../../base/single/button/button.node";
import { shortcut, extend } from "../../../core";
@shortcut()
export class BasicTreeItem extends NodeButton {
static xtype = "bi.tree_item";
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-tree-item bi-list-item-active`,
id: "",
pId: "",
height: 24,
readonly: true,
isFirstNode: false,
isLastNode: false,
});
}
render() {
const o = this.options;
return {
type: "bi.vertical_adapt",
columnSize: ["", "fill"],
items: [
{
el: {
type: "bi.layout",
height: o.height,
width: o.height,
cls: this.getLineCls(),
},
lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
},
{
el: {
type: "bi.label",
ref: _ref => {
this.text = _ref;
},
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap || o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
py: o.py,
},
}
],
};
}
getLineCls() {
const options = this.options;
if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
return "";
} else if (options.layer === 0 && options.isFirstNode) {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-first-solid-line-conn-background" : "first-line-conn-background";
} else if (options.isLastNode) {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-last-solid-line-conn-background" : "last-line-conn-background";
} else {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-mid-solid-line-conn-background" : "mid-line-conn-background";
}
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
getId() {
return this.options.id;
}
getPId() {
return this.options.pId;
}
}