fix: a-directory-tree error when use replaceFields (#2869)
parent
8b3023e01f
commit
d3d787e2b0
|
@ -66,7 +66,7 @@ export default {
|
|||
// Expanded keys
|
||||
if (defaultExpandAll) {
|
||||
if (props.treeData) {
|
||||
state._expandedKeys = getFullKeyListByTreeData(props.treeData);
|
||||
state._expandedKeys = getFullKeyListByTreeData(props.treeData,props.replaceFields);
|
||||
} else {
|
||||
state._expandedKeys = getFullKeyList(children);
|
||||
}
|
||||
|
|
|
@ -88,13 +88,14 @@ export function convertDirectoryKeysToNodes(rootChildren, keys) {
|
|||
return nodes;
|
||||
}
|
||||
|
||||
export function getFullKeyListByTreeData(treeData) {
|
||||
export function getFullKeyListByTreeData(treeData,replaceFields) {
|
||||
let keys = [];
|
||||
const {key='key',children='children'} = replaceFields
|
||||
|
||||
(treeData || []).forEach(item => {
|
||||
keys.push(item.key);
|
||||
if (item.children) {
|
||||
keys = [...keys, ...getFullKeyListByTreeData(item.children)];
|
||||
keys.push(item[key]);
|
||||
if (item[children]) {
|
||||
keys = [...keys, ...getFullKeyListByTreeData(item[children],replaceFields)];
|
||||
}
|
||||
});
|
||||
return keys;
|
||||
|
|
Loading…
Reference in New Issue