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