From 3d6fa54b39a82960b0d981e3e000973f9c9974ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=81=8F?= Date: Thu, 5 Jan 2017 13:15:26 +0800 Subject: [PATCH] update Table update Table --- src/components/table/mixin.js | 13 +- src/components/table/table-body.vue | 2 +- src/components/table/table-head.vue | 2 +- src/components/table/table.vue | 30 ++- test/routers/table.vue | 315 ++++++++++++++++++++++------ 5 files changed, 288 insertions(+), 74 deletions(-) diff --git a/src/components/table/mixin.js b/src/components/table/mixin.js index cef16e83..eedc904f 100644 --- a/src/components/table/mixin.js +++ b/src/components/table/mixin.js @@ -11,15 +11,22 @@ export default { isPopperShow (column) { return column.filters && ((!this.fixed && !column.fixed) || (this.fixed === 'left' && column.fixed === 'left') || (this.fixed === 'right' && column.fixed === 'right')); }, - setCellWidth (column) { - // return column.width ? column.width : this.columnsWidth[index]; + setCellWidth (column, index, top) { let width = ''; if (column.width) { width = column.width; } else if (this.columnsWidth[column._index]) { width = this.columnsWidth[column._index].width; } - // return this.columnsWidth[column._index] ? this.columnsWidth[column._index].width : ''; + // when browser has scrollBar,set a width to resolve scroll position bug + if (this.columns.length === index + 1 && top) { + width += this.$parent.scrollBarWidth; + } + // when fixed type,reset first right fixed column's width + if (this.fixed === 'right') { + const firstFixedIndex = this.columns.findIndex((col) => col.fixed === 'right'); + if (firstFixedIndex === index) width += this.$parent.scrollBarWidth; + } return width; } } diff --git a/src/components/table/table-body.vue b/src/components/table/table-body.vue index cf694d0a..bb736857 100644 --- a/src/components/table/table-body.vue +++ b/src/components/table/table-body.vue @@ -1,7 +1,7 @@