update Table tree

This commit is contained in:
梁灏 2020-01-06 11:17:09 +08:00
parent 6885f5ec49
commit 1e2341aa5d
4 changed files with 44 additions and 24 deletions

View file

@ -698,7 +698,7 @@
const data = this.getDataByRowKey(rowKey);
data._isShowChildren = !data._isShowChildren;
},
getDataByRowKey (rowKey, objData = this.rebuildData) {
getDataByRowKey (rowKey, objData = this.objData) {
let data = null;
for (let i in objData) {
const thisData = objData[i];
@ -962,11 +962,6 @@
row._index = index;
row._rowKey = (typeof this.rowKey) === 'string' ? row[this.rowKey] : rowKey++;
if (row.children && row.children.length) {
if (row._showChildren) {
row._isShowChildren = row._showChildren;
} else {
row._isShowChildren = false;
}
row.children = this.makeChildrenData(row);
}
});
@ -977,12 +972,7 @@
return data.children.map((row, index) => {
const newRow = deepCopy(row);
newRow._index = index;
newRow._rowKey = (typeof this.rowKey) === 'string' ? row[this.rowKey] : rowKey++;
if (newRow._showChildren) {
newRow._isShowChildren = newRow._showChildren;
} else {
newRow._isShowChildren = false;
}
newRow._rowKey = (typeof this.rowKey) === 'string' ? newRow[this.rowKey] : rowKey++;
if (newRow.children && newRow.children.length) {
newRow.children = this.makeChildrenData(newRow);
}
@ -1022,6 +1012,9 @@
makeObjBaseData (row) {
const newRow = deepCopy(row);
newRow._isHover = false;
if ((typeof this.rowKey) === 'string') {
newRow._rowKey = newRow[this.rowKey];
}
if (newRow._disabled) {
newRow._isDisabled = newRow._disabled;
} else {
@ -1049,12 +1042,11 @@
this.data.forEach((row, index) => {
const newRow = this.makeObjBaseData(row);
if (newRow.children && newRow.children.length) {
// todo objData _isShowChildren rebuildData rowKey
// if (newRow._showChildren) {
// newRow._isShowChildren = newRow._showChildren;
// } else {
// newRow._isShowChildren = false;
// }
if (newRow._showChildren) {
newRow._isShowChildren = newRow._showChildren;
} else {
newRow._isShowChildren = false;
}
newRow.children = this.makeChildrenObjData(newRow);
}
data[index] = newRow;
@ -1065,6 +1057,11 @@
if (data.children && data.children.length) {
return data.children.map(row => {
const newRow = this.makeObjBaseData(row);
if (newRow._showChildren) {
newRow._isShowChildren = newRow._showChildren;
} else {
newRow._isShowChildren = false;
}
if (newRow.children && newRow.children.length) {
newRow.children = this.makeChildrenObjData(newRow);
}