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.

124 lines
3.2 KiB

import { ArrowTreeGroupNodeCheckbox } from "../../checkbox";
import { IconLabel, Label, NodeButton } from "@/base";
import { shortcut, extend, createWidget, Controller, isNotNull, Events, LogicFactory, Direction } from "@/core";
8 years ago
/**
* Created by User on 2016/3/31.
*
8 years ago
* > + icon + 文本
* @class IconArrowNode
* @extends NodeButton
8 years ago
*/
@shortcut()
export class IconArrowNode extends NodeButton {
static xtype = "bi.icon_arrow_node";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-icon-arrow-node bi-list-item`,
8 years ago
logic: {
dynamic: false,
8 years ago
},
id: "",
pId: "",
open: false,
6 years ago
height: 24,
iconHeight: 12,
iconWidth: 12,
iconCls: "",
iconWrapperWidth: 16,
7 years ago
});
}
_init() {
super._init.apply(this, arguments);
const o = this.options;
this.checkbox = createWidget({
type: ArrowTreeGroupNodeCheckbox.xtype,
expandIcon: o.expandIcon,
collapseIcon: o.collapseIcon,
width: 24,
stopPropagation: true,
8 years ago
});
const icon = createWidget({
type: IconLabel.xtype,
width: 24,
cls: o.iconCls,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight,
8 years ago
});
createWidget({
type: Label.xtype,
8 years ago
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap,
text: o.text,
value: o.value,
py: o.py,
keyword: o.keyword,
8 years ago
});
this.checkbox.on(Controller.EVENT_CHANGE, type => {
if (type === Events.CLICK) {
if (this.checkbox.isSelected()) {
this.triggerExpand();
8 years ago
} else {
this.triggerCollapse();
8 years ago
}
}
});
const type = LogicFactory.createLogicTypeByDirection(Direction.Left);
const items = LogicFactory.createLogicItemsByDirection(
Direction.Left,
{
width: o.iconWrapperWidth,
el: this.checkbox,
},
{
width: 16,
el: icon,
},
this.text
);
createWidget(
extend(
{
element: this,
},
LogicFactory.createLogic(
type,
extend(o.logic, {
items,
rgap: 5,
})
)
)
);
}
8 years ago
doRedMark() {
this.text.doRedMark(...arguments);
}
8 years ago
unRedMark() {
this.text.unRedMark(...arguments);
}
8 years ago
doClick() {
super.doClick(...arguments);
8 years ago
this.checkbox.setSelected(this.isSelected());
}
8 years ago
setOpened(v) {
super.setOpened(...arguments);
if (isNotNull(this.checkbox)) {
8 years ago
this.checkbox.setSelected(v);
}
}
}