Skip to content

Commit dbfd3bf

Browse files
authored
Merge pull request #778 from ShuyunFF2E/fix-tree-zzh
Fix tree zzh
2 parents 314f951 + 84164b9 commit dbfd3bf

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/components/tree/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class Tree extends Component {
7474
onDragBefore: noop,
7575
onDragAfter: noop,
7676
customNodeTpl: noop,
77+
renderItem: noop,
7778
onLoadData: noop,
7879
showLine: false,
7980
lineType: 'default',
@@ -114,6 +115,7 @@ class Tree extends Component {
114115
onDragBefore: PropTypes.func,
115116
onDragAfter: PropTypes.func,
116117
customNodeTpl: PropTypes.func,
118+
renderItem: PropTypes.func,
117119
onLoadData: PropTypes.func,
118120
showLine: PropTypes.bool,
119121
lineType: PropTypes.oneOf(['default', 'dashed']),
@@ -718,6 +720,7 @@ class Tree extends Component {
718720
onDragMoving,
719721
onDragAfter,
720722
customNodeTpl,
723+
renderItem,
721724
isDynamicLoad,
722725
showLine,
723726
lineType,
@@ -772,6 +775,7 @@ class Tree extends Component {
772775
onDragMoving,
773776
onDragAfter,
774777
customNodeTpl,
778+
renderItem,
775779
removeNode,
776780
addNode,
777781
isDynamicLoad,

src/components/tree/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ group:
5151
| onDragMoving | 拖动过程中调用 | Function | - |
5252
| onDragAfter | 拖拽后调用 | Function | - |
5353
| supportTooltip | 是否启用tooltip,为true时将根据文本长度自动增加tooltip。如数据超大,建议设置为false以节省性能 | Boolean | true |
54-
| customNodeTpl | 自定义节点内容 | Function | - |
54+
| customNodeTpl | 添加自定义节点内容 | Function | - |
55+
| renderItem | 自定义节点内容 | Function | - |
5556
| onLoadData | 动态加载数据 | Function | - |
5657
| isDynamicLoad | 动态加载数据 | bool | false |
5758
| showLine | 线性样式 | bool | false |

src/components/tree/node.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class Node extends Component {
172172
removeNode,
173173
addNode,
174174
customNodeTpl,
175+
renderItem,
175176
isDynamicLoad,
176177
showLine,
177178
lineType,
@@ -267,6 +268,7 @@ class Node extends Component {
267268
supportCheckbox={supportCheckbox}
268269
supportTooltip={supportTooltip}
269270
onDoubleClick={() => onDoubleClick(data)}
271+
renderItem={tmp => renderItem?.(data, tmp)}
270272
/>
271273
{/* 点击菜单 */}
272274
{supportMenu && menuType !== RIGHT_MENU && !disabled && (
@@ -407,6 +409,7 @@ function ShowSelection({
407409
onDoubleClick,
408410
onHandleSelect,
409411
supportTooltip,
412+
renderItem,
410413
}) {
411414
// 显示形式,有弹框菜单的与没有弹框菜单的,是否需要tooltip的,单选与多选的
412415
let nodeClassName = 'node-name';
@@ -485,6 +488,9 @@ function ShowSelection({
485488
);
486489
}
487490
}
491+
492+
tmp = renderItem?.(tmp) || tmp;
493+
488494
const labelWidth = {
489495
width:
490496
supportMenu && menuType === DIALOG_MENU

0 commit comments

Comments
 (0)