diff --git a/examples/routers/table.vue b/examples/routers/table.vue
index 733bbea6..4cbd0668 100644
--- a/examples/routers/table.vue
+++ b/examples/routers/table.vue
@@ -3,7 +3,7 @@
-
+
@@ -84,8 +84,7 @@
key: 'gender',
align: 'center',
width: 200,
- fixed: 'right',
- // fixed: 'left'
+ fixed: 'right'
}
],
columns2: [
diff --git a/src/components/table/table-head.vue b/src/components/table/table-head.vue
index b9ba46d0..436df201 100644
--- a/src/components/table/table-head.vue
+++ b/src/components/table/table-head.vue
@@ -87,7 +87,8 @@
type: [Boolean, String],
default: false
},
- columnRows: Array
+ columnRows: Array,
+ fixedColumnRows: Array
},
computed: {
styles () {
@@ -116,7 +117,11 @@
},
headRows () {
const isGroup = this.columnRows.length > 1;
- return isGroup ? this.columnRows : [this.columns];
+ if (isGroup) {
+ return this.fixed ? this.fixedColumnRows : this.columnRows;
+ } else {
+ return [this.columns];
+ }
}
},
methods: {
diff --git a/src/components/table/table.vue b/src/components/table/table.vue
index 0dbc0f0b..b149c2ff 100644
--- a/src/components/table/table.vue
+++ b/src/components/table/table.vue
@@ -45,6 +45,7 @@
:styleObject="fixedTableStyle"
:columns="leftFixedColumns"
:column-rows="columnRows"
+ :fixed-column-rows="leftFixedColumnRows"
:obj-data="objData"
:columns-width="columnsWidth"
:data="rebuildData">
@@ -68,6 +69,7 @@
:styleObject="fixedRightTableStyle"
:columns="rightFixedColumns"
:column-rows="columnRows"
+ :fixed-column-rows="rightFixedColumnRows"
:obj-data="objData"
:columns-width="columnsWidth"
:data="rebuildData">
@@ -184,7 +186,9 @@
objData: this.makeObjData(), // checkbox or highlight-row
rebuildData: [], // for sort or filter
cloneColumns: this.makeColumns(),
- columnRows: this.makeColumnRows(),
+ columnRows: this.makeColumnRows(false),
+ leftFixedColumnRows: this.makeColumnRows('left'),
+ rightFixedColumnRows: this.makeColumnRows('right'),
allColumns: getAllColumns(this.columns), // for multiple table-head, get columns that have no children
showSlotHeader: true,
showSlotFooter: true,
@@ -779,8 +783,8 @@
return left.concat(center).concat(right);
},
// create a multiple table-head
- makeColumnRows () {
- return convertToRows(this.columns);
+ makeColumnRows (fixedType) {
+ return convertToRows(this.columns, fixedType);
},
exportCsv (params) {
if (params.filename) {
@@ -858,7 +862,9 @@
// todo 这里有性能问题,可能是左右固定计算属性影响的
this.allColumns = getAllColumns(this.columns);
this.cloneColumns = this.makeColumns();
- this.columnRows = this.makeColumnRows();
+ this.columnRows = this.makeColumnRows(false);
+ this.leftFixedColumnRows = this.makeColumnRows('left');
+ this.rightFixedColumnRows = this.makeColumnRows('right');
this.rebuildData = this.makeDataWithSortAndFilter();
this.handleResize();
},
diff --git a/src/components/table/util.js b/src/components/table/util.js
index 7e7e29a9..c5746df3 100644
--- a/src/components/table/util.js
+++ b/src/components/table/util.js
@@ -1,5 +1,20 @@
import { deepCopy } from '../../utils/assist';
+const convertColumnOrder = (columns, fixedType) => {
+ let list = [];
+ let other = [];
+ columns.forEach((col) => {
+ if (col.fixed && col.fixed === fixedType) {
+ list.push(col);
+ } else {
+ other.push(col);
+ }
+ });
+ return list.concat(other);
+};
+
+export {convertColumnOrder};
+
// set forTableHead to true when convertToRows, false in normal cases like table.vue
const getAllColumns = (cols, forTableHead = false) => {
const columns = deepCopy(cols);
@@ -17,8 +32,8 @@ const getAllColumns = (cols, forTableHead = false) => {
export {getAllColumns};
-const convertToRows = (columns) => {
- const originColumns = deepCopy(columns);
+const convertToRows = (columns, fixedType = false) => {
+ const originColumns = fixedType ? fixedType === 'left' ? deepCopy(convertColumnOrder(columns, 'left')) : deepCopy(convertColumnOrder(columns, 'right')) : deepCopy(columns);
let maxLevel = 1;
const traverse = (column, parent) => {
if (parent) {
@@ -63,19 +78,4 @@ const convertToRows = (columns) => {
return rows;
};
-export {convertToRows};
-
-const convertColumnOrder = (columns, FixedType) => {
- let list = [];
- let other = [];
- columns.forEach((col) => {
- if (col.fixed && col.fixed === FixedType) {
- list.push(col);
- } else {
- other.push(col);
- }
- });
- return list.concat(other);
-};
-
-export {convertColumnOrder};
\ No newline at end of file
+export {convertToRows};
\ No newline at end of file