body-cell-merge-mixin.js
7.56 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
data: function data() {
return {
skipRenderCells: []
};
},
methods: {
cellMergeInit: function cellMergeInit(rowIndex, field, rowData, isFrozenColumns) {
if (this.skipRenderCells.indexOf(rowIndex + '-' + field) !== -1) {
return false;
}
var setting = this.cellMerge && this.cellMerge(rowIndex, rowData, field);
if (setting && (setting.colSpan && setting.colSpan > 1 || setting.rowSpan && setting.rowSpan > 1)) {
this.setSkipRenderCells(setting.colSpan, setting.rowSpan, rowIndex, field, isFrozenColumns);
}
return true;
},
setSkipRenderCells: function setSkipRenderCells(colSpan, rowSpan, rowIndex, field, isFrozenColumns) {
var columnsFields = isFrozenColumns ? this.getFrozenColumnsFields : this.getNoFrozenColumnsFields,
skipCell = '',
startPosX = void 0,
endPosX = void 0,
startPosY = void 0,
endPosY = void 0;
endPosX = startPosX = columnsFields.indexOf(field);
if (colSpan && colSpan > 1) {
endPosX = startPosX + colSpan - 1;
}
endPosY = startPosY = rowIndex;
if (rowSpan && rowSpan > 1) {
endPosY = rowIndex + rowSpan - 1;
}
for (var posX = startPosX; posX <= endPosX; posX++) {
for (var posY = startPosY; posY <= endPosY; posY++) {
if (posX == startPosX && posY == startPosY) {
continue;
}
skipCell = posY + '-' + columnsFields[posX];
if (this.skipRenderCells.indexOf(skipCell) === -1) {
this.skipRenderCells.push(skipCell);
}
}
}
},
setColRowSpan: function setColRowSpan(rowIndex, field, rowData) {
var result = {
colSpan: '',
rowSpan: ''
},
setting = this.cellMerge && this.cellMerge(rowIndex, rowData, field);
if (setting) {
result = {
colSpan: setting.colSpan ? setting.colSpan : '',
rowSpan: setting.rowSpan ? setting.rowSpan : ''
};
}
return result;
},
isCellMergeRender: function isCellMergeRender(rowIndex, field, rowData) {
var setting = this.cellMerge && this.cellMerge(rowIndex, rowData, field);
if (setting && (setting.colSpan && setting.colSpan > 0 || setting.rowSpan && setting.rowSpan > 0)) {
return true;
}
return false;
},
getRowHeightByRowSpan: function getRowHeightByRowSpan(rowIndex, field, rowData) {
var setting = this.cellMerge && this.cellMerge(rowIndex, rowData, field);
if (setting && setting.rowSpan && setting.rowSpan > 1) {
return this.rowHeight * setting.rowSpan;
}
return this.rowHeight;
},
getRowWidthByColSpan: function getRowWidthByColSpan(rowIndex, field, rowData) {
var endPosX = void 0,
startPosX = void 0,
columnsFields = this.getColumnsFields,
setting = this.cellMerge && this.cellMerge(rowIndex, rowData, field),
colSpan = setting.colSpan,
totalWidth = 0;
if (setting && colSpan && colSpan >= 1) {
startPosX = columnsFields.indexOf(field);
endPosX = startPosX + colSpan - 1;
for (var i = startPosX; i <= endPosX; i++) {
this.internalColumns.forEach(function (x) {
if (columnsFields[i] === x.field) {
totalWidth += x.width;
}
});
}
}
return totalWidth;
},
cellMergeContentType: function cellMergeContentType(rowIndex, field, rowData) {
var result = {
isComponent: false,
isContent: false
};
var setting = this.cellMerge && this.cellMerge(rowIndex, rowData, field);
if (setting) {
if (setting.componentName && typeof setting.componentName === 'string' && setting.componentName.length > 0) {
result.isComponent = true;
} else if (setting.content && setting.content.length > 0) {
result.isContent = true;
}
}
return result;
}
}
};