mirror of https://github.com/ElemeFE/element
Table: Fix error in cacluating hidden in `table-header` and `table-body`
parent
ba3315a728
commit
d8dd114a16
|
@ -136,6 +136,14 @@ export default {
|
||||||
return this.store.states.columns.length;
|
return this.store.states.columns.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
leftFixedLeafCount() {
|
||||||
|
return this.store.states.fixedLeafColumnsLength;
|
||||||
|
},
|
||||||
|
|
||||||
|
rightFixedLeafCount() {
|
||||||
|
return this.store.states.rightFixedLeafColumnsLength;
|
||||||
|
},
|
||||||
|
|
||||||
leftFixedCount() {
|
leftFixedCount() {
|
||||||
return this.store.states.fixedColumns.length;
|
return this.store.states.fixedColumns.length;
|
||||||
},
|
},
|
||||||
|
@ -170,11 +178,11 @@ export default {
|
||||||
|
|
||||||
isColumnHidden(index) {
|
isColumnHidden(index) {
|
||||||
if (this.fixed === true || this.fixed === 'left') {
|
if (this.fixed === true || this.fixed === 'left') {
|
||||||
return index >= this.leftFixedCount;
|
return index >= this.leftFixedLeafCount;
|
||||||
} else if (this.fixed === 'right') {
|
} else if (this.fixed === 'right') {
|
||||||
return index < this.columnsCount - this.rightFixedCount;
|
return index < this.columnsCount - this.rightFixedLeafCount;
|
||||||
} else {
|
} else {
|
||||||
return (index < this.leftFixedCount) || (index >= this.columnsCount - this.rightFixedCount);
|
return (index < this.leftFixedLeafCount) || (index >= this.columnsCount - this.rightFixedLeafCount);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,14 @@ export default {
|
||||||
return this.store.states.rightFixedColumns.length;
|
return this.store.states.rightFixedColumns.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
leftFixedLeafCount() {
|
||||||
|
return this.store.states.fixedLeafColumnsLength;
|
||||||
|
},
|
||||||
|
|
||||||
|
rightFixedLeafCount() {
|
||||||
|
return this.store.states.rightFixedLeafColumnsLength;
|
||||||
|
},
|
||||||
|
|
||||||
columns() {
|
columns() {
|
||||||
return this.store.states.columns;
|
return this.store.states.columns;
|
||||||
},
|
},
|
||||||
|
@ -234,16 +242,17 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
isCellHidden(index, columns) {
|
isCellHidden(index, columns) {
|
||||||
|
let start = 0;
|
||||||
|
for (let i = 0; i < index; i++) {
|
||||||
|
start += columns[i].colSpan;
|
||||||
|
}
|
||||||
|
const after = start + columns[index].colSpan - 1;
|
||||||
if (this.fixed === true || this.fixed === 'left') {
|
if (this.fixed === true || this.fixed === 'left') {
|
||||||
return index >= this.leftFixedCount;
|
return after >= this.leftFixedLeafCount;
|
||||||
} else if (this.fixed === 'right') {
|
} else if (this.fixed === 'right') {
|
||||||
let before = 0;
|
return start < this.columnsCount - this.rightFixedLeafCount;
|
||||||
for (let i = 0; i < index; i++) {
|
|
||||||
before += columns[i].colSpan;
|
|
||||||
}
|
|
||||||
return before < this.columnsCount - this.rightFixedCount;
|
|
||||||
} else {
|
} else {
|
||||||
return (index < this.leftFixedCount) || (index >= this.columnsCount - this.rightFixedCount);
|
return (after < this.leftFixedLeafCount) || (start >= this.columnsCount - this.rightFixedLeafCount);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ const TableStore = function(table, initialState = {}) {
|
||||||
columns: [],
|
columns: [],
|
||||||
fixedColumns: [],
|
fixedColumns: [],
|
||||||
rightFixedColumns: [],
|
rightFixedColumns: [],
|
||||||
|
leafColumns: [],
|
||||||
|
fixedLeafColumns: [],
|
||||||
|
rightFixedLeafColumns: [],
|
||||||
isComplex: false,
|
isComplex: false,
|
||||||
_data: null,
|
_data: null,
|
||||||
filteredData: null,
|
filteredData: null,
|
||||||
|
@ -322,8 +325,19 @@ TableStore.prototype.updateColumns = function() {
|
||||||
_columns[0].fixed = true;
|
_columns[0].fixed = true;
|
||||||
states.fixedColumns.unshift(_columns[0]);
|
states.fixedColumns.unshift(_columns[0]);
|
||||||
}
|
}
|
||||||
states.originColumns = [].concat(states.fixedColumns).concat(_columns.filter((column) => !column.fixed)).concat(states.rightFixedColumns);
|
|
||||||
states.columns = doFlattenColumns(states.originColumns);
|
const notFixedColumns = _columns.filter(column => !column.fixed);
|
||||||
|
states.originColumns = [].concat(states.fixedColumns).concat(notFixedColumns).concat(states.rightFixedColumns);
|
||||||
|
|
||||||
|
const leafColumns = doFlattenColumns(notFixedColumns);
|
||||||
|
const fixedLeafColumns = doFlattenColumns(states.fixedColumns);
|
||||||
|
const rightFixedLeafColumns = doFlattenColumns(states.rightFixedColumns);
|
||||||
|
|
||||||
|
states.leafColumnsLength = leafColumns.length;
|
||||||
|
states.fixedLeafColumnsLength = fixedLeafColumns.length;
|
||||||
|
states.rightFixedLeafColumnsLength = rightFixedLeafColumns.length;
|
||||||
|
|
||||||
|
states.columns = [].concat(fixedLeafColumns).concat(leafColumns).concat(rightFixedLeafColumns);
|
||||||
states.isComplex = states.fixedColumns.length > 0 || states.rightFixedColumns.length > 0;
|
states.isComplex = states.fixedColumns.length > 0 || states.rightFixedColumns.length > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue