Skip to content

Commit 01ea9cd

Browse files
author
黄书伟
committed
fixed bug
1 parent 0ea8e63 commit 01ea9cd

File tree

9 files changed

+135
-38
lines changed

9 files changed

+135
-38
lines changed

libs/v-table/src/checkbox-selection-mixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ exports.default = {
7777
}
7878
}
7979
}
80-
81-
this.selectAll && this.selectAll(this.getCheckedTableRow);
8280
} else {
8381

8482
this.checkboxGroupModel = this.disabledChecked();
8583
}
8684

85+
this.selectAll && this.selectAll(this.getCheckedTableRow);
86+
8787
this.setIndeterminateState();
8888
},
8989
handleCheckChange: function handleCheckChange(rowData) {

libs/v-table/src/scroll-control-mixin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ exports.default = {
2020
var scrollHeight = e1.wheelDelta || e1.detail * -1;
2121
body2.scrollTop = body2.scrollTop - scrollHeight;
2222
},
23+
bodyScrollTop: function bodyScrollTop() {
24+
25+
var view2 = this.$el.querySelector('.v-table-rightview');
26+
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
27+
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
28+
29+
if (body1) {
30+
body1.scrollTop = body2.scrollTop = 0;
31+
}
32+
},
2333
body2Scroll: function body2Scroll(e) {
2434

2535
var view2 = this.$el.querySelector('.v-table-rightview');

libs/v-table/src/table-row-mouse-events-mixin.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,25 @@ exports.default = {
3333

3434
this.rowMouseLeave && this.rowMouseLeave(rowIndex);
3535
},
36-
onCellClick: function onCellClick(rowIndex, rowData, column) {
36+
titleCellClick: function titleCellClick(field, title) {
3737

38+
this.titleClick && this.titleClick(title, field);
39+
},
40+
titleCellDblClick: function titleCellDblClick(field, title) {
41+
42+
this.titleDblclick && this.titleDblclick(title, field);
43+
},
44+
rowCellClick: function rowCellClick(rowIndex, rowData, column) {
3845
if (this.rowClickColor && this.rowClickColor.length > 0) {
3946

4047
this.clickRowIndex = rowIndex;
4148
}
4249

43-
this.onRowClick && this.onRowClick(rowIndex, rowData, column);
50+
this.rowClick && this.rowClick(rowIndex, rowData, column);
51+
},
52+
rowCellDbClick: function rowCellDbClick(rowIndex, rowData, column) {
53+
54+
this.rowDblclick && this.rowDblclick(rowIndex, rowData, column);
4455
},
4556
getHighPriorityBgColor: function getHighPriorityBgColor(rowIndex) {
4657

libs/v-table/src/table.vue

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
<td v-for="col in row"
1717
:class="[col.titleCellClassName]"
1818
:colspan="col.colspan" :rowspan="dealTitleRowspan(row,col.rowspan)"
19+
1920
@mousemove.stop="handleTitleMouseMove($event,col.fields)"
2021
@mousedown.stop="handleTitleMouseDown($event)"
21-
@mouseout.stop="handleTitleMouseOut()">
22+
@mouseout.stop="handleTitleMouseOut()"
23+
@click.stop="titleCellClick(col.fields,col.title);"
24+
@dblclick.stop="titleCellDblClick(col.fields,col.title)">
2225
<div :class="['v-table-title-cell',showVerticalBorder?'vertical-border':'',showHorizontalBorder?'horizontal-border':'']"
2326
:style="{'width':titleColumnWidth(col.fields)+'px','height':titleColumnHeight(col.rowspan)+'px','text-align':col.titleAlign}">
2427
<span class="table-title">
@@ -40,7 +43,9 @@
4043
:class="[col.titleCellClassName]"
4144
@mousemove.stop="handleTitleMouseMove($event,col.field)"
4245
@mousedown.stop="handleTitleMouseDown($event)"
43-
@mouseout.stop="handleTitleMouseOut()">
46+
@mouseout.stop="handleTitleMouseOut()"
47+
@click.stop="titleCellClick(col.field,col.title);"
48+
@dblclick.stop="titleCellDblClick(col.field,col.title)">
4449
<div :class="['v-table-title-cell',showVerticalBorder?'vertical-border':'',showHorizontalBorder?'horizontal-border':'']"
4550
:style="{'width':col.width+'px','height':titleRowHeight+'px','text-align':col.titleAlign}">
4651
<span class="table-title">
@@ -90,7 +95,8 @@
9095
:class="['v-table-body-cell',showVerticalBorder ? 'vertical-border':'',showHorizontalBorder?'horizontal-border':'']"
9196
:style="{'width':getRowWidthByColSpan(rowIndex,col.field,item)+'px','height': getRowHeightByRowSpan(rowIndex,col.field,item)+'px','line-height':getRowHeightByRowSpan(rowIndex,col.field,item)+'px','text-align':col.columnAlign}"
9297
:title="col.overflowTitle ? overflowTitle(item,col) :''"
93-
@click.stop="onCellClick(rowIndex,item,col);cellEditClick($event,col.isEdit,item,col.field,rowIndex)"
98+
@click.stop="rowCellClick(rowIndex,item,col);cellEditClick($event,col.isEdit,item,col.field,rowIndex)"
99+
@dblclick.stop="rowCellDbClick(rowIndex,item,col)"
94100
>
95101
<span v-if="cellMergeContentType(rowIndex,col.field,item).isComponent">
96102
<component :rowData="item" :field="col.field ? col.field : ''"
@@ -105,7 +111,8 @@
105111
:class="['v-table-body-cell',showVerticalBorder ? 'vertical-border':'',showHorizontalBorder?'horizontal-border':'']"
106112
:style="{'width':col.width+'px','height': rowHeight+'px','line-height':rowHeight+'px','text-align':col.columnAlign}"
107113
:title="col.overflowTitle ? overflowTitle(item,col) :''"
108-
@click.stop="onCellClick(rowIndex,item,col);cellEditClick($event,col.isEdit,item,col.field,rowIndex)"
114+
@click.stop="rowCellClick(rowIndex,item,col);cellEditClick($event,col.isEdit,item,col.field,rowIndex)"
115+
@dblclick.stop="rowCellDbClick(rowIndex,item,col)"
109116
>
110117
<span v-if="typeof col.componentName ==='string' && col.componentName.length > 0">
111118
<component :rowData="item" :field="col.field ? col.field : ''"
@@ -164,7 +171,9 @@
164171
:colspan="col.colspan" :rowspan="dealTitleRowspan(row,col.rowspan)"
165172
@mousemove.stop="handleTitleMouseMove($event,col.fields)"
166173
@mousedown.stop="handleTitleMouseDown($event)"
167-
@mouseout.stop="handleTitleMouseOut()">
174+
@mouseout.stop="handleTitleMouseOut()"
175+
@click.stop="titleCellClick(col.fields,col.title);"
176+
@dblclick.stop="titleCellDblClick(col.fields,col.title)">
168177
<div :class="['v-table-title-cell',showVerticalBorder?'vertical-border':'',showHorizontalBorder?'horizontal-border':'']"
169178
:style="{'width':titleColumnWidth(col.fields)+'px','height':titleColumnHeight(col.rowspan)+'px','text-align':col.titleAlign}">
170179
<span class="table-title">
@@ -187,7 +196,9 @@
187196
:class="[col.titleCellClassName]"
188197
@mousemove.stop="handleTitleMouseMove($event,col.field)"
189198
@mousedown.stop="handleTitleMouseDown($event)"
190-
@mouseout.stop="handleTitleMouseOut()">
199+
@mouseout.stop="handleTitleMouseOut()"
200+
@click.stop="titleCellClick(col.field,col.title);"
201+
@dblclick.stop="titleCellDblClick(col.field,col.title)">
191202
<div :class="['v-table-title-cell',showVerticalBorder?'vertical-border':'',showHorizontalBorder?'horizontal-border':'']"
192203
:style="{'width':col.width+'px','height':titleRowHeight+'px','text-align':col.titleAlign}">
193204
<span class="table-title">
@@ -238,7 +249,8 @@
238249
:class="['v-table-body-cell',showVerticalBorder ? 'vertical-border':'',showHorizontalBorder?'horizontal-border':'']"
239250
:style="{'width':getRowWidthByColSpan(rowIndex,col.field,item)+'px','height': getRowHeightByRowSpan(rowIndex,col.field,item)+'px','line-height':getRowHeightByRowSpan(rowIndex,col.field,item)+'px','text-align':col.columnAlign}"
240251
:title="col.overflowTitle ? overflowTitle(item,col) :''"
241-
@click.stop="onCellClick(rowIndex,item,col);cellEditClick($event,col.isEdit,item,col.field,rowIndex)"
252+
@click.stop="rowCellClick(rowIndex,item,col);cellEditClick($event,col.isEdit,item,col.field,rowIndex)"
253+
@dblclick.stop="rowCellDbClick(rowIndex,item,col)"
242254
>
243255
<span v-if="cellMergeContentType(rowIndex,col.field,item).isComponent">
244256
<component :rowData="item" :field="col.field ? col.field : ''" :index="rowIndex"
@@ -253,7 +265,8 @@
253265
:class="['v-table-body-cell',showVerticalBorder ? 'vertical-border':'',showHorizontalBorder?'horizontal-border':'']"
254266
:style="{'width':col.width+'px','height': rowHeight+'px','line-height':rowHeight+'px','text-align':col.columnAlign}"
255267
:title="col.overflowTitle ? overflowTitle(item,col) :''"
256-
@click.stop="onCellClick(rowIndex,item,col);cellEditClick($event,col.isEdit,item,col.field,rowIndex)"
268+
@click.stop="rowCellClick(rowIndex,item,col);cellEditClick($event,col.isEdit,item,col.field,rowIndex)"
269+
@dblclick.stop="rowCellDbClick(rowIndex,item,col)"
257270
>
258271
<span v-if="typeof col.componentName ==='string' && col.componentName.length > 0">
259272
<component :rowData="item" :field="col.field ? col.field : ''" :index="rowIndex"
@@ -362,7 +375,7 @@
362375
// 最大宽度(当width:'max'时)
363376
maxWidth: 5000,
364377
hasFrozenColumn: false,// 是否拥有固定列(false时最后一列的右边border无边框)
365-
resizeTimer:null
378+
resizeTimer: null
366379
}
367380
},
368381
props: {
@@ -506,16 +519,22 @@
506519
type: Boolean,
507520
default: false
508521
},
509-
loadingOpacity:{
522+
loadingOpacity: {
510523
type: Number,
511524
default: 0.6
512525
},
513526
// 表体单元格样式回调
514527
columnCellClassName: Function,
515528
// footer单元格样式回调
516529
footerCellClassName: Function,
517-
// 行点击回调
518-
onRowClick: Function,
530+
// 行单击回调
531+
rowClick: Function,
532+
// 行双击回调
533+
rowDblclick: Function,
534+
// 表头单元格单击回调
535+
titleClick: Function,
536+
// 表头单元格双击回调
537+
titleDblclick: Function,
519538
// 鼠标进入行的回调
520539
rowMouseEnter: Function,
521540
// 鼠标离开行的回调
@@ -552,7 +571,7 @@
552571
553572
let result = this.internalWidth - this.leftViewWidth;
554573
555-
return this.hasFrozenColumn ? result -2 : result;
574+
return this.hasFrozenColumn ? result - 2 : result;
556575
},
557576
558577
// 左侧、右侧区域高度
@@ -761,7 +780,7 @@
761780
// 当没有设置高度时计算总高度 || 设置的高度大于所有列高度之和时
762781
if (!(this.height && this.height > 0) || this.height > totalColumnsHeight) {
763782
764-
if (!this.isVerticalResize){
783+
if (!this.isVerticalResize) {
765784
766785
this.internalHeight = totalColumnsHeight;
767786
}
@@ -856,6 +875,8 @@
856875
}
857876
858877
this.resize();
878+
879+
this.bodyScrollTop();
859880
},
860881
deep: true
861882
}

packages/v-table/src/checkbox-selection-mixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ export default {
8484
}
8585
}
8686

87-
this.selectAll && this.selectAll(this.getCheckedTableRow);
88-
8987
} else {
9088

9189
this.checkboxGroupModel = this.disabledChecked();
9290
}
9391

92+
this.selectAll && this.selectAll(this.getCheckedTableRow);
93+
9494
this.setIndeterminateState();
9595
},
9696

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ export default {
1414
body2.scrollTop = (body2.scrollTop - scrollHeight);
1515
},
1616

17+
// 表格内容滚动到顶部(常用与分页)
18+
bodyScrollTop(){
19+
20+
var view2 = this.$el.querySelector('.v-table-rightview');
21+
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
22+
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
23+
24+
if (body1) {
25+
body1.scrollTop = body2.scrollTop = 0;
26+
}
27+
},
28+
1729
body2Scroll(e){
1830

1931
var view2 = this.$el.querySelector('.v-table-rightview');

packages/v-table/src/table-row-mouse-events-mixin.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,38 @@ export default {
3232
this.rowMouseLeave && this.rowMouseLeave(rowIndex);
3333
},
3434

35+
/*
36+
* 表头单元格单击事件
37+
* 注意:如果为复杂表头,field 为数组
38+
* */
39+
titleCellClick(field,title){
40+
41+
this.titleClick && this.titleClick(title,field);
42+
},
3543

36-
//点击数据行时,回调点击事件
37-
onCellClick(rowIndex, rowData, column){
44+
/*
45+
* 表头单元格双击事件
46+
* 注意:如果为复杂表头,field 为数组
47+
* */
48+
titleCellDblClick(field,title){
3849

50+
this.titleDblclick && this.titleDblclick(title,field);
51+
},
52+
53+
// 行单击事件
54+
rowCellClick(rowIndex, rowData, column){
3955
if (this.rowClickColor && this.rowClickColor.length > 0) {
4056

4157
this.clickRowIndex = rowIndex;
4258
}
4359

44-
this.onRowClick && this.onRowClick(rowIndex, rowData, column);
60+
this.rowClick && this.rowClick(rowIndex, rowData, column);
61+
},
62+
63+
// 行双击事件
64+
rowCellDbClick(rowIndex, rowData, column){
65+
66+
this.rowDblclick && this.rowDblclick(rowIndex, rowData, column);
4567
},
4668

4769
/*

0 commit comments

Comments
 (0)