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

3
.gitignore vendored
View File

@ -36,4 +36,5 @@ jspm_packages
.idea/ .idea/
coverage coverage
.DS_Store .DS_Store
.history

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

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