Skip to content

Commit 226ffe1

Browse files
author
黄书伟
committed
优化 table 组件固定列时,固定列与非固定列之间有裂痕的问题
1 parent edc7f15 commit 226ffe1

File tree

3 files changed

+22
-35
lines changed

3 files changed

+22
-35
lines changed

packages/v-table/src/scroll-bar-control-mixin.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ export default {
2020
}
2121
},
2222

23-
// 判断右侧区域是否有横向滚动条
24-
hasBodyHorizontalScrollBar(){
25-
26-
if (this.$el){
27-
28-
let rightViewBody = this.$el.querySelector('.v-table-rightview .v-table-body'),
29-
rightColumnsWidth = Math.round(this.totalNoFrozenColumnsWidth);
30-
31-
return rightViewBody.clientWidth + 2 < rightColumnsWidth;
32-
}
33-
34-
return false;
35-
},
36-
3723
setScrollbarWidth(){
3824

3925
this.scrollbarWidth = utils.getScrollbarWidth();

packages/v-table/src/table-resize-mixin.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ export default {
5050
// 有footer 功能
5151
if (this.hasTableFooter) {
5252

53-
if (hasScrollBar){
53+
if (hasScrollBar) {
5454

5555
if (this.footerTotalHeight === this.getFooterTotalRowHeight) {
5656

5757
this.footerTotalHeight += scrollbarWidth;
5858

59-
if (!(this.height && this.height > 0)|| this.height > totalColumnsHeight){
59+
if (!(this.height && this.height > 0) || this.height > totalColumnsHeight) {
6060
this.internalHeight += scrollbarWidth;
6161
}
6262
}
63-
}else if(!hasScrollBar){
63+
} else if (!hasScrollBar) {
6464

65-
if (this.footerTotalHeight > this.getFooterTotalRowHeight){
65+
if (this.footerTotalHeight > this.getFooterTotalRowHeight) {
6666

67-
this.footerTotalHeight -=scrollbarWidth;
67+
this.footerTotalHeight -= scrollbarWidth;
6868

69-
if (!(this.height && this.height > 0)|| this.height > totalColumnsHeight){
69+
if (!(this.height && this.height > 0) || this.height > totalColumnsHeight) {
7070

71-
this.internalHeight -=scrollbarWidth;
71+
this.internalHeight -= scrollbarWidth;
7272
}
7373
}
7474
}
@@ -120,16 +120,14 @@ export default {
120120

121121
if (self.isHorizontalResize && self.internalWidth && self.internalWidth > 0 && currentWidth > 0) {
122122

123-
var newTableWidth = this.$el.clientWidth;
124-
125123
// (窗口宽度缩小 && 当前宽度大于最小宽度) ||(窗口宽度扩大 && 当前宽度小于最大宽度)
126-
if ((right <= 0 && newTableWidth > minWidth) || (right >= 0 && newTableWidth < maxWidth)) {
124+
if ((right <= 0 && currentWidth > minWidth) || (right >= 0 && currentWidth < maxWidth)) {
127125

128-
newTableWidth = newTableWidth > maxWidth ? maxWidth : newTableWidth;
129-
newTableWidth = newTableWidth < minWidth ? minWidth : newTableWidth;
126+
currentWidth = currentWidth > maxWidth ? maxWidth : currentWidth;
127+
currentWidth = currentWidth < minWidth ? minWidth : currentWidth;
130128

131-
self.internalWidth = newTableWidth;
132-
self.changeColumnsWidth(newTableWidth);
129+
self.internalWidth = currentWidth;
130+
self.changeColumnsWidth(currentWidth);
133131
}
134132
}
135133
},
@@ -174,6 +172,11 @@ export default {
174172
this.adjustHeight(false);
175173
}
176174

175+
if (this.hasFrozenColumn) {
176+
177+
differ -= 2;
178+
}
179+
177180
if (currentWidth >= initResizeWidths || differ > 0) {
178181

179182
var average = differ / this.resizeColumns.length;
@@ -186,16 +189,14 @@ export default {
186189

187190
return item;
188191
})
189-
}else{ // 最小化有滚动条时
190-
191-
this.columns.forEach((col,index)=>{
192+
} else { // 最小化有滚动条时
192193

194+
this.columns.forEach((col, index) => {
193195

194-
if (col.isResize){
196+
if (col.isResize) {
195197

196198
this.internalColumns[index].width = col.width;
197199
}
198-
199200
})
200201
}
201202
},

packages/v-table/src/table.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@
539539
540540
let result = this.internalWidth - this.leftViewWidth;
541541
542-
return this.hasFrozenColumn ? result - 2 : result;
542+
return this.hasFrozenColumn ? result -2 : result;
543543
},
544544
545545
// 左侧、右侧区域高度
@@ -840,7 +840,7 @@
840840
}
841841
}
842842
843-
this.tableResize();
843+
this.resize();
844844
},
845845
deep: true
846846
}

0 commit comments

Comments
 (0)