fix: a-directory-tree error when use replaceFields (#2869)

pull/2900/head
星火燎原 4 years ago committed by GitHub
parent 8b3023e01f
commit d3d787e2b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save