fix tree table showChildren

This commit is contained in:
梁灏 2020-01-12 09:57:40 +08:00
parent 64298a9b0e
commit a410eb2dca

View file

@ -146,6 +146,7 @@
}, },
isTrShow (rowKey) { isTrShow (rowKey) {
let status = true; let status = true;
let child;
for (let i in this.objData) { for (let i in this.objData) {
const row = this.objData[i]; const row = this.objData[i];
const showChildren = row._isShowChildren; const showChildren = row._isShowChildren;
@ -153,25 +154,34 @@
status = status && showChildren; status = status && showChildren;
break; break;
} else if (row.children && row.children.length) { } else if (row.children && row.children.length) {
status = this.getTrStatus(rowKey, row, status && showChildren); child = this.getTrStatus(rowKey, row, status && showChildren);
return status; if (child[0] && child[0]._rowKey === rowKey) {
return child[1];
}
} }
} }
return status; return status;
}, },
getTrStatus (rowKey, data, parentStatus) { getTrStatus (rowKey, data, parentStatus) {
let status = parentStatus; let status = parentStatus;
let childData;
if (data.children && data.children.length) { if (data.children && data.children.length) {
data.children.forEach(row => { for (let i = 0; i < data.children.length; i++) {
const row = data.children[i];
const showChildren = row._isShowChildren; const showChildren = row._isShowChildren;
if (row._rowKey === rowKey) { if (row._rowKey === rowKey) {
childData = row;
status = status && showChildren; status = status && showChildren;
break;
} else if (row.children && row.children.length) { } else if (row.children && row.children.length) {
status = this.getTrStatus(rowKey, row, status && showChildren); const child = this.getTrStatus(rowKey, row, status && showChildren);
if (child[0] && child[0]._rowKey === rowKey) {
return child;
} }
});
} }
return status; }
}
return [childData, status];
}, },
getLevel (rowKey) { getLevel (rowKey) {
let level; let level;