Skip to content

Commit 43cfd36

Browse files
author
黄书伟
committed
fixed bug
1 parent d4c13cd commit 43cfd36

File tree

8 files changed

+93
-72
lines changed

8 files changed

+93
-72
lines changed

libs/themes-base/index.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,6 @@
826826
background-color: #fff;
827827
height:100%;
828828
width:100%;
829-
opacity: 0.6;
830829
}
831830

832831

libs/themes-base/v-table.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@
218218
background-color: #fff;
219219
height:100%;
220220
width:100%;
221-
opacity: 0.6;
222221
}
223222

224223

libs/v-table/src/loading.vue

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<div style="width:100%;height: 100%;">
3-
<div class="v-table-loading"></div>
4-
3+
<div class="v-table-loading" :style="{'opacity':loadingOpacity}"></div>
54
<div class="v-table-loading-content" v-html="loadingContent"></div>
65
</div>
76

@@ -14,28 +13,35 @@
1413
1514
loadingContent: [String],
1615
17-
width: [Number, String],
16+
loadingOpacity: [Number],
17+
18+
titleRows: [Array],
1819
19-
height: [Number, String]
20+
titleRowHeight: [Number],
2021
22+
columns:[Array]
2123
},
2224
2325
methods: {
2426
2527
setPosition(){
2628
27-
var loadingEle = this.$el,
28-
loadingContentEle = this.$el.querySelector('.v-table-loading-content');
29+
let loadingEle = this.$el,
30+
loadingContentEle = this.$el.querySelector('.v-table-loading-content'),
31+
titleHeight = 0;
2932
30-
loadingContentEle.style.top = (loadingEle.clientHeight / 2 - loadingContentEle.clientHeight / 2) + 'px';
33+
if (this.columns && this.columns.length > 0){
3134
32-
}
35+
titleHeight = (this.titleRows && this.titleRows.length > 0) ? this.titleRows.length * this.titleRowHeight : this.titleRowHeight;
36+
}
3337
38+
loadingContentEle.style.top = ((loadingEle.clientHeight + titleHeight) / 2 - loadingContentEle.clientHeight / 2) + 'px';
39+
}
3440
},
3541
3642
mounted(){
3743
38-
this.$nextTick(x=>{
44+
this.$nextTick(x => {
3945
this.setPosition();
4046
})
4147
}
Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
Object.defineProperty(exports, "__esModule", {
4-
value: true
4+
value: true
55
});
66

77
var _utils = require('../../src/utils/utils.js');
@@ -11,58 +11,65 @@ var _utils2 = _interopRequireDefault(_utils);
1111
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1212

1313
exports.default = {
14-
methods: {
15-
body1Mousewheel: function body1Mousewheel(e) {
16-
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
17-
18-
var e1 = e.originalEvent || window.event || e;
19-
var scrollHeight = e1.wheelDelta || e1.detail * -1;
20-
body2.scrollTop = body2.scrollTop - scrollHeight;
21-
},
22-
body2Scroll: function body2Scroll(e) {
23-
24-
var view2 = this.$el.querySelector('.v-table-rightview');
25-
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
26-
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
27-
28-
if (body1) {
29-
body1.scrollTop = body2.scrollTop;
30-
}
14+
methods: {
15+
body1Mousewheel: function body1Mousewheel(e) {
16+
17+
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
18+
19+
var e1 = e.originalEvent || window.event || e;
20+
var scrollHeight = e1.wheelDelta || e1.detail * -1;
21+
body2.scrollTop = body2.scrollTop - scrollHeight;
22+
},
23+
body2Scroll: function body2Scroll(e) {
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');
3128

32-
view2.querySelector('.v-table-header').scrollLeft = body2.scrollLeft;
33-
},
34-
rightViewFooterScroll: function rightViewFooterScroll() {
29+
if (body1) {
30+
body1.scrollTop = body2.scrollTop;
31+
}
3532

36-
var view2 = this.$el.querySelector('.v-table-rightview');
33+
view2.querySelector('.v-table-header').scrollLeft = body2.scrollLeft;
34+
},
35+
rightViewFooterScroll: function rightViewFooterScroll() {
3736

38-
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
37+
var view2 = this.$el.querySelector('.v-table-rightview');
3938

40-
view2.querySelector('.v-table-header').scrollLeft = rightViewFooter.scrollLeft;
41-
view2.querySelector('.v-table-body').scrollLeft = rightViewFooter.scrollLeft;
42-
},
43-
scrollControl: function scrollControl() {
44-
var _this = this;
39+
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
4540

46-
this.$nextTick(function (x) {
41+
view2.querySelector('.v-table-header').scrollLeft = rightViewFooter.scrollLeft;
42+
view2.querySelector('.v-table-body').scrollLeft = rightViewFooter.scrollLeft;
43+
},
44+
scrollControl: function scrollControl() {
45+
var _this = this;
4746

48-
var body1 = _this.$el.querySelector('.v-table-leftview .v-table-body');
49-
var body2 = _this.$el.querySelector('.v-table-rightview .v-table-body');
50-
var rightViewFooter = _this.$el.querySelector('.v-table-rightview .v-table-footer');
47+
if (this.hasBindScrollEvent) {
48+
return false;
49+
}
5150

52-
_utils2.default.bind(body1, 'mousewheel', _this.body1Mousewheel);
53-
_utils2.default.bind(body2, 'scroll', _this.body2Scroll);
54-
_utils2.default.bind(rightViewFooter, 'scroll', _this.rightViewFooterScroll);
55-
});
56-
}
57-
},
51+
this.hasBindScrollEvent = true;
5852

59-
beforeDestroy: function beforeDestroy() {
60-
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
61-
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
62-
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
53+
setTimeout(function (x) {
6354

64-
_utils2.default.unbind(body1, 'mousewheel', this.body1Mousewheel);
65-
_utils2.default.unbind(body2, 'scroll', this.body2Scroll);
66-
_utils2.default.unbind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
67-
}
55+
var body1 = _this.$el.querySelector('.v-table-leftview .v-table-body');
56+
var body2 = _this.$el.querySelector('.v-table-rightview .v-table-body');
57+
var rightViewFooter = _this.$el.querySelector('.v-table-rightview .v-table-footer');
58+
59+
_utils2.default.bind(body1, 'mousewheel', _this.body1Mousewheel);
60+
_utils2.default.bind(body2, 'scroll', _this.body2Scroll);
61+
_utils2.default.bind(rightViewFooter, 'scroll', _this.rightViewFooterScroll);
62+
});
63+
}
64+
},
65+
66+
beforeDestroy: function beforeDestroy() {
67+
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
68+
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
69+
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
70+
71+
_utils2.default.unbind(body1, 'mousewheel', this.body1Mousewheel);
72+
_utils2.default.unbind(body2, 'scroll', this.body2Scroll);
73+
_utils2.default.unbind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
74+
}
6875
};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ exports.default = {
116116
bottom = window.document.documentElement.clientHeight - currentHeight - viewOffset.top - 2;
117117

118118
if (self.isVerticalResize && currentHeight > 0) {
119-
bottom -= self.VerticalResizeOffset;
120-
if (bottom < 0 && currentHeight > minHeight || bottom > 0 && currentHeight < maxHeight) {
119+
bottom -= self.verticalResizeOffset;
120+
if (currentHeight > minHeight || currentHeight < maxHeight) {
121121
var currentHeight = currentHeight + bottom;
122122
currentHeight = currentHeight > maxHeight ? maxHeight : currentHeight;
123123
currentHeight = currentHeight < minHeight ? minHeight : currentHeight;

libs/v-table/src/table.vue

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,20 @@
296296

297297
<table-empty v-if="isTableEmpty"
298298
:width="internalWidth"
299-
:totalColumnsWidth="totalColumnsWidth"
300-
:contentHeight="errorContentHeight"
301-
:titleHeight="getTotalColumnsHeight()"
302-
:errorContent="errorContent"
303-
:isLoading="isLoading"
299+
:total-columns-width="totalColumnsWidth"
300+
:content-height="errorContentHeight"
301+
:title-height="getTotalColumnsHeight()"
302+
:error-content="errorContent"
303+
:is-loading="isLoading"
304304
></table-empty>
305305

306306
<loading
307307
v-if="isLoading"
308-
:loadingContent="loadingContent"
308+
:loading-content="loadingContent"
309+
:title-rows="internalTitleRows"
310+
:title-row-height="titleRowHeight"
311+
:columns="internalColumns"
312+
:loading-opacity="loadingOpacity"
309313
></loading>
310314

311315
<!--列拖动时的线条-->
@@ -392,7 +396,7 @@
392396
},
393397
394398
// 垂直自适应偏移量
395-
VerticalResizeOffset: {
399+
verticalResizeOffset: {
396400
type: Number,
397401
default: 0
398402
},
@@ -498,6 +502,10 @@
498502
type: Boolean,
499503
default: false
500504
},
505+
loadingOpacity:{
506+
type: Number,
507+
default: 0.6
508+
},
501509
// 表体单元格样式回调
502510
columnCellClassName: Function,
503511
// footer单元格样式回调
@@ -798,7 +806,6 @@
798806
if (Array.isArray(this.tableData) && this.tableData.length > 0) {
799807
800808
this.scrollControl();
801-
this.hasBindScrollEvent = true;
802809
}
803810
804811
this.singelSortInit();
@@ -835,13 +842,16 @@
835842
836843
this.tableEmpty();
837844
845+
if (this.isTableEmpty){
846+
847+
this.hasBindScrollEvent = false;
848+
}
849+
838850
if (Array.isArray(newVal) && newVal.length > 0) {
839851
840852
this.initView();
841853
842-
if (!this.hasBindScrollEvent) {
843-
this.scrollControl();
844-
}
854+
this.scrollControl();
845855
}
846856
847857
this.resize();

0 commit comments

Comments
 (0)