Skip to content

Commit 4ad881c

Browse files
author
黄书伟
committed
add to libs
1 parent 635243b commit 4ad881c

File tree

7 files changed

+327
-36
lines changed

7 files changed

+327
-36
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.default = {
7+
8+
computed: {
9+
vTableFooter: function vTableFooter() {
10+
11+
return {
12+
13+
'v-table-rightview-special-border': this.hasFrozenColumn
14+
};
15+
},
16+
vTableBodyInner: function vTableBodyInner() {
17+
18+
return {
19+
'v-table-body-inner-pb': !this.hasTableFooter
20+
};
21+
},
22+
vTableBodyCell: function vTableBodyCell() {
23+
24+
return {
25+
'vertical-border': this.showVerticalBorder,
26+
'horizontal-border': this.showHorizontalBorder
27+
};
28+
}
29+
}
30+
};

libs/v-table/src/frozen-columns-mixin.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
"use strict";
1+
'use strict';
22

33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6+
7+
var _utils = require('../../src/utils/utils.js');
8+
9+
var _utils2 = _interopRequireDefault(_utils);
10+
11+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12+
613
exports.default = {
714
computed: {
815
frozenCols: function frozenCols() {
@@ -66,5 +73,26 @@ exports.default = {
6673
}
6774
return noFrozenTitleCols;
6875
}
76+
},
77+
78+
methods: {
79+
setInternalHeightByFrozen: function setInternalHeightByFrozen(totalColumnsHeight) {
80+
var _this = this;
81+
82+
if (this.$el && this.hasFrozenColumn) {
83+
84+
this.$nextTick(function (x) {
85+
86+
if (_this.hasBodyHorizontalScrollBar()) {
87+
88+
totalColumnsHeight += _utils2.default.getScrollbarWidth();
89+
}
90+
_this.internalHeight = totalColumnsHeight;
91+
});
92+
} else {
93+
94+
this.internalHeight = totalColumnsHeight;
95+
}
96+
}
6997
}
7098
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.default = {
7+
8+
methods: {
9+
controlScrollBar: function controlScrollBar() {
10+
11+
if (this.hasTableFooter) {
12+
13+
var body = this.$el.querySelector('.v-table-rightview .v-table-body');
14+
body.style.overflowX = 'hidden';
15+
}
16+
},
17+
hasBodyHorizontalScrollBar: function hasBodyHorizontalScrollBar() {
18+
19+
return this.rightViewWidth < this.totalNoFrozenColumnsWidth;
20+
}
21+
}
22+
23+
};

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,38 @@ exports.default = {
3131

3232
view2.querySelector('.v-table-header').scrollLeft = body2.scrollLeft;
3333
},
34+
rightViewFooterScroll: function rightViewFooterScroll() {
35+
36+
var view2 = this.$el.querySelector('.v-table-rightview');
37+
38+
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
39+
40+
view2.querySelector('.v-table-header').scrollLeft = rightViewFooter.scrollLeft;
41+
view2.querySelector('.v-table-body').scrollLeft = rightViewFooter.scrollLeft;
42+
},
3443
scrollControl: function scrollControl() {
3544
var _this = this;
3645

3746
this.$nextTick(function (x) {
3847

3948
var body1 = _this.$el.querySelector('.v-table-leftview .v-table-body');
4049
var body2 = _this.$el.querySelector('.v-table-rightview .v-table-body');
50+
var rightViewFooter = _this.$el.querySelector('.v-table-rightview .v-table-footer');
4151

4252
_utils2.default.bind(body1, 'mousewheel', _this.body1Mousewheel);
4353
_utils2.default.bind(body2, 'scroll', _this.body2Scroll);
54+
_utils2.default.bind(rightViewFooter, 'scroll', _this.rightViewFooterScroll);
4455
});
4556
}
4657
},
4758

4859
beforeDestroy: function beforeDestroy() {
4960
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
5061
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
62+
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
5163

5264
_utils2.default.unbind(body1, 'mousewheel', this.body1Mousewheel);
5365
_utils2.default.unbind(body2, 'scroll', this.body2Scroll);
66+
_utils2.default.bind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
5467
}
5568
};
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _deepClone = require('../../src/utils/deepClone.js');
8+
9+
var _deepClone2 = _interopRequireDefault(_deepClone);
10+
11+
var _utils = require('../../src/utils/utils.js');
12+
13+
var _utils2 = _interopRequireDefault(_utils);
14+
15+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16+
17+
exports.default = {
18+
19+
computed: {
20+
frozenFooterCols: function frozenFooterCols() {
21+
22+
var result = [];
23+
24+
if (this.initInternalFooter.length > 0) {
25+
26+
this.initInternalFooter.forEach(function (columns) {
27+
28+
result.push(columns.filter(function (col) {
29+
return col.isFrozen;
30+
}));
31+
});
32+
}
33+
34+
return result;
35+
},
36+
noFrozenFooterCols: function noFrozenFooterCols() {
37+
var result = [];
38+
39+
if (this.initInternalFooter.length > 0) {
40+
41+
this.initInternalFooter.forEach(function (columns) {
42+
43+
result.push(columns.filter(function (col) {
44+
return !col.isFrozen;
45+
}));
46+
});
47+
}
48+
49+
return result;
50+
},
51+
getFooterTotalRowHeight: function getFooterTotalRowHeight() {
52+
53+
if (Array.isArray(this.footer) && this.footer.length > 0) {
54+
55+
return this.footer.length * this.footerRowHeight;
56+
}
57+
return 0;
58+
},
59+
getFooterContainerHeight: function getFooterContainerHeight() {
60+
61+
var result = 0;
62+
if (this.getFooterTotalRowHeight > 0) {
63+
64+
result = this.getFooterTotalRowHeight;
65+
66+
if (this.hasBodyHorizontalScrollBar()) {
67+
68+
result += _utils2.default.getScrollbarWidth();
69+
}
70+
}
71+
72+
return result;
73+
},
74+
hasTableFooter: function hasTableFooter() {
75+
76+
return Array.isArray(this.footer) && this.footer.length;
77+
},
78+
initInternalFooter: function initInternalFooter() {
79+
80+
if (!(Array.isArray(this.footer) && this.footer.length > 0)) {
81+
82+
return [];
83+
}
84+
85+
var result = [],
86+
resultRow = [],
87+
cloneInternalColumns;
88+
89+
cloneInternalColumns = (0, _deepClone2.default)(this.internalColumns);
90+
91+
cloneInternalColumns.sort(function (a, b) {
92+
93+
if (a.isFrozen) {
94+
95+
return -1;
96+
} else if (b.isFrozen) {
97+
98+
return 1;
99+
}
100+
return 0;
101+
});
102+
103+
this.footer.forEach(function (items, rows) {
104+
105+
resultRow = [];
106+
107+
items.forEach(function (value, index) {
108+
109+
resultRow.push({
110+
content: value,
111+
width: cloneInternalColumns[index].width,
112+
align: cloneInternalColumns[index].columnAlign,
113+
isFrozen: cloneInternalColumns[index].isFrozen ? true : false
114+
});
115+
});
116+
117+
result.push(resultRow);
118+
});
119+
return result;
120+
}
121+
},
122+
123+
methods: {
124+
setFooterCellClassName: function setFooterCellClassName(isLeftView, rowIndex, colIndex, value) {
125+
126+
var _colIndex = colIndex;
127+
128+
if (!isLeftView && this.hasFrozenColumn) {
129+
130+
_colIndex += this.frozenCols.length;
131+
}
132+
133+
return this.footerCellClassName && this.footerCellClassName(rowIndex, _colIndex, value);
134+
}
135+
}
136+
137+
};

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,31 @@ exports.default = {
8484

8585
var differ = currentWidth - 2 - this.totalColumnsWidth,
8686
initResizeWidths = this.initTotalColumnsWidth,
87-
rightViewBody = this.$el.querySelector('.v-table-rightview .v-table-body');
87+
rightViewBody = this.$el.querySelector('.v-table-rightview .v-table-body'),
88+
rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
8889

8990
if (currentWidth <= initResizeWidths && !this.isTableEmpty) {
9091

91-
rightViewBody.style.overflowX = 'scroll';
92+
if (this.hasTableFooter) {
93+
94+
rightViewFooter.style.overflowX = 'scroll';
95+
} else {
96+
97+
rightViewBody.style.overflowX = 'scroll';
98+
}
9299
} else {
93100
if (this.getTotalColumnsHeight() > this.internalHeight) {
94101

95102
differ -= _utils2.default.getScrollbarWidth() + 1;
96103
}
97104

98-
rightViewBody.style.overflowX = 'hidden';
105+
if (this.hasTableFooter) {
106+
107+
rightViewFooter.style.overflowX = 'hidden';
108+
} else {
109+
110+
rightViewBody.style.overflowX = 'hidden';
111+
}
99112
}
100113

101114
if (currentWidth >= initResizeWidths || differ > 0) {

0 commit comments

Comments
 (0)