fix: #JCJS-4571 滚动加载场景下treeNode无children时不设置默认值[]

This commit is contained in:
izbz wh 2020-10-12 10:34:18 +08:00
parent b4450c5bfb
commit cd432da51f
6 changed files with 3245 additions and 453 deletions

1
.gitignore vendored
View File

@ -37,3 +37,4 @@ jspm_packages
.idea/
coverage
.DS_Store
.history

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

2704
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

900
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -355,8 +355,8 @@ export function convertListToTree(treeData, attr, flatTreeKeysMap) {
let obj = {
key,
title,
isLeaf,
children: []
isLeaf
// children: []
}
tree.push(Object.assign(obj, {...otherProps}));
treeKeysMap[key] = node;
@ -371,8 +371,8 @@ export function convertListToTree(treeData, attr, flatTreeKeysMap) {
let obj = {
key: item[attr.id],
title: item[attr.name],
isLeaf: item[attr.isLeaf],
children: []
isLeaf: item[attr.isLeaf]
// children: []
};
tree.push(Object.assign(obj, {...otherProps}));
treeKeysMap[key] = item;
@ -383,7 +383,7 @@ export function convertListToTree(treeData, attr, flatTreeKeysMap) {
}
}
// console.log('resData',resKeysMap);
var run = function(treeArrs) {
var run = function(treeArrs = []) {
if (resData.length > 0) {
for (let i = 0; i < treeArrs.length; i++) {
for (let j = 0; j < resData.length; j++) {
@ -393,9 +393,12 @@ export function convertListToTree(treeData, attr, flatTreeKeysMap) {
let obj = {
key: item[attr.id],
title: item[attr.name],
isLeaf: item[attr.isLeaf],
children: []
isLeaf: item[attr.isLeaf]
// children: []
};
if(!treeArrs[i].children) {
treeArrs[i].children = [];
}
treeArrs[i].children.push(Object.assign(obj, {...otherProps}));
resData.splice(j, 1);
j--;