import { NodeButton } from "../../../base/single/button/button.node"; import { shortcut, extend } from "../../../core"; @shortcut() export class BasicTreeNode extends NodeButton { static xtype = "bi.tree_node"; _defaultConfig(props) { const conf = super._defaultConfig.apply(this, arguments); return extend(conf, { baseCls: `${conf.baseCls || ""} bi-tree-node ${props.selectable ? "bi-list-item-active" : "bi-list-item"}`, id: "", pId: "", open: false, height: 24, readonly: true, isFirstNode: false, isLastNode: false, switcherIcon: {}, selectable: true, disabled: false, // disabled不会影响展开收起功能 }); } render() { const o = this.options; const checkbox = { type: "bi.tree_node_switcher", ref: _ref => { this.switcher = _ref; }, iconHeight: o.height, iconWidth: o.iconWrapperWidth || o.height, open: o.open, isFirstNode: o.isFirstNode, isLastNode: o.isLastNode, layer: o.layer, ...o.switcherIcon, stopPropagation: o.selectable, mounted () { this.setEnable(true); }, listeners: [ { eventName: "EVENT_CHANGE", action: () => { if (!this.isEnabled() || o.selectable) { this.isOpened() ? this.triggerCollapse() : this.triggerExpand(); } }, } ], }; return { type: "bi.vertical_adapt", columnSize: [o.iconWrapperWidth || o.height, "fill"], items: [ { el: checkbox, 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, }, } ], }; } doRedMark() { this.text.doRedMark(...arguments); } unRedMark() { this.text.unRedMark(...arguments); } doClick() { if (this.options.selectable) { return; } super.doClick(...arguments); } setOpened(v) { super.setOpened(...arguments); this.switcher.setOpened(v); } setValue() { super.setValue(...arguments); } }