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.
 
 
 

173 lines
4.7 KiB

import { shortcut, extend, VerticalAdaptLayout, Layout, compact, isKey, SIZE_CONSANTS, STYLE_CONSTANTS } from "@/core";
import { NodeButton, Label, IconLabel } from "@/base";
@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,
layer: 0,
iconWidth: null,
iconHeight: null,
iconCls: "",
});
}
render() {
const {
layer,
height,
hgap,
textHgap,
textVgap,
textLgap,
textRgap,
text,
value,
py,
keyword,
iconCls,
} = this.options;
const indent = {
el: {
type: Layout.xtype,
height,
width: height,
cls: this.getLineCls(),
},
lgap: layer * SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
width: "",
};
const icon = isKey(iconCls) ? {
el: {
type: IconLabel.xtype,
// iconWidth,
// iconHeight,
cls: iconCls,
},
// width: 24,
} : null;
return {
type: VerticalAdaptLayout.xtype,
items: compact([
indent,
icon,
{
el: {
type: Label.xtype,
ref: _ref => {
this.text = _ref;
},
textAlign: "left",
whiteSpace: "nowrap",
textHeight: height,
height,
hgap: hgap || textHgap,
vgap: textVgap,
lgap: textLgap,
rgap: textRgap,
text,
value,
keyword,
py,
},
width: "fill",
}
]),
};
}
getLineCls() {
const options = this.options;
if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
return "";
} else if (options.layer === 0 && options.isFirstNode) {
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-first-solid-line-conn-background" : "first-line-conn-background";
} else if (options.isLastNode) {
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-last-solid-line-conn-background" : "last-line-conn-background";
} else {
return 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;
}
}
export class FirstTreeLeafItem extends BasicTreeItem {
static xtype = "bi.first_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-first-tree-leaf-item",
isFirstNode: true,
isLastNode: false,
});
}
}
@shortcut()
export class MidTreeLeafItem extends BasicTreeItem {
static xtype = "bi.mid_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-mid-tree-leaf-item",
isFirstNode: false,
isLastNode: false,
});
}
}
@shortcut()
export class LastTreeLeafItem extends BasicTreeItem {
static xtype = "bi.last_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-last-tree-leaf-item",
isFirstNode: false,
isLastNode: true,
});
}
}
@shortcut()
export class RootTreeLeafItem extends BasicTreeItem {
static xtype = "bi.root_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-root-tree-leaf-item",
isFirstNode: false,
isLastNode: false,
});
}
}