mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-01-23 11:50:20 +08:00
fix(BasicTree): 修复升级antdv3.x后产生的问题
1. BasicTree组件无法正确使用插槽的问题 2. 无法递归遍历的问题 Closes #1453
This commit is contained in:
parent
8480454b73
commit
8523afd512
@ -20,7 +20,7 @@
|
||||
import { omit, get, difference, cloneDeep } from 'lodash-es';
|
||||
import { isArray, isBoolean, isEmpty, isFunction } from '/@/utils/is';
|
||||
import { extendSlots, getSlot } from '/@/utils/helper/tsxHelper';
|
||||
import { filter, treeToList } from '/@/utils/helper/treeHelper';
|
||||
import { filter, treeToList, eachTree } from '/@/utils/helper/treeHelper';
|
||||
import { useTree } from './useTree';
|
||||
import { useContextMenu } from '/@/hooks/web/useContextMenu';
|
||||
import { CreateContextOptions } from '/@/components/ContextMenu';
|
||||
@ -355,7 +355,7 @@
|
||||
|
||||
const treeData = computed(() => {
|
||||
const data = cloneDeep(getTreeData.value);
|
||||
data.forEach((item) => {
|
||||
eachTree(data, (item, _parent) => {
|
||||
const searchText = searchState.searchText;
|
||||
const { highlight } = unref(props);
|
||||
const {
|
||||
@ -397,6 +397,7 @@
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
return item;
|
||||
});
|
||||
return data;
|
||||
});
|
||||
@ -426,9 +427,7 @@
|
||||
</TreeHeader>
|
||||
)}
|
||||
<ScrollContainer style={scrollStyle} v-show={!unref(getNotFound)}>
|
||||
<Tree {...unref(getBindValues)} showIcon={false} treeData={treeData.value}>
|
||||
{extendSlots(slots)}
|
||||
</Tree>
|
||||
<Tree {...unref(getBindValues)} showIcon={false} treeData={treeData.value} />
|
||||
</ScrollContainer>
|
||||
<Empty v-show={unref(getNotFound)} image={Empty.PRESENTED_IMAGE_SIMPLE} class="!mt-4" />
|
||||
</div>
|
||||
|
@ -187,3 +187,18 @@ export function treeMapEach(
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归遍历树结构
|
||||
* @param treeDatas 树
|
||||
* @param callBack 回调
|
||||
* @param parentNode 父节点
|
||||
*/
|
||||
export function eachTree(treeDatas: any[], callBack: Fn, parentNode = {}) {
|
||||
treeDatas.forEach((element) => {
|
||||
const newNode = callBack(element, parentNode) || element;
|
||||
if (element.children) {
|
||||
eachTree(element.children, callBack, newNode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user