ru.coon 2.8.25 → 2.8.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
+
# Version 2.8.27, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/cfbabb26922efaef2416052c0006bf73f27ec6cb)
|
|
2
|
+
* ## Fixes
|
|
3
|
+
* <span style='color:red'>fix CopyRowsFromGrid by HT-10923</span> ([f8c95a], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/f8c95aa079cf48471c05d210a3909a20bd3e644c))
|
|
4
|
+
|
|
5
|
+
* update: CHANGELOG.md ([a552cf], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/a552cf007c8061ee908bae2150eaf15d94767c2b))
|
|
6
|
+
|
|
7
|
+
# Version 2.8.26, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/e2d42324a8e9948d79584e4f9751f126405ef103)
|
|
8
|
+
* ## Features
|
|
9
|
+
* <span style='color:green'>feat: add style check before addCellStyle</span> ([ff4abf], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/ff4abf157a32ec98720caabafc2f65749b0c98bf))
|
|
10
|
+
|
|
11
|
+
* upd ([009237], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/009237a355c8aa9928fd919b90ff8e9f750db98e))
|
|
12
|
+
* relocate and rename method ([a2a61b], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/a2a61b2a6dcd4d4622becfc2f11602a97c9d49d8))
|
|
13
|
+
* update: CHANGELOG.md ([d4b2c7], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/d4b2c7e1effb2bd46eb587a3d5bf2d03cbc27053))
|
|
14
|
+
|
|
1
15
|
# Version 2.8.25, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0ead4798f8be665c09627567bb8ac2b473d6d429)
|
|
2
16
|
# Version 2.8.24, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/51b87374eb81c47d86d6fa33c8f25eaa9dce5d18)
|
|
17
|
+
* update: CHANGELOG.md ([82435f], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/82435f28e840a46cc9e30ec228a8778c22fc75c4))
|
|
18
|
+
|
|
19
|
+
# Version 2.8.24, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/c4c48ae9746e9698a71cee189e9d4193ee08b0ad)
|
|
20
|
+
* ## Fixes
|
|
21
|
+
* <span style='color:red'> refactoring CopyRowsFromGrid, add Coon.perf</span> ([347b0c], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/347b0c16446273fbe50dcd3a460d8454566355d1))
|
|
22
|
+
|
|
23
|
+
* upd ([148f60], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/148f60ace9a0813d409432b6871721c7f622d369))
|
|
24
|
+
* upd ([8e64dd], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/8e64dd9dcd8af8f4333d69c2bfcfdae7b94ec056))
|
|
3
25
|
* upd ([4091e1], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/4091e19d36ca3b790a53d1b5e0d79addd0146536))
|
|
4
26
|
* update: CHANGELOG.md ([6e87dc], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/6e87dc9719686cca7da70d876ea24da53b2dbe82))
|
|
5
27
|
|
|
@@ -12,6 +34,9 @@
|
|
|
12
34
|
|
|
13
35
|
* upd ([571495], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/571495ffbd6b23c76edd9eac741b87163fc59cdc))
|
|
14
36
|
* add loadFakeData to ReportPanel ([671b7f], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/671b7f27f3538291a56ba8c1b45016910b42e17d))
|
|
37
|
+
* upd ([5f960b], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/5f960b5e19d19540423a3d13bf288b5d4b2149bb))
|
|
38
|
+
* upd ([3f1cb7], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3f1cb7e4e680cfc6a30d92ae0731dcd370be9e4b))
|
|
39
|
+
* upd ([cab5b5], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/cab5b55a9360b8f6cfc5de6f36d31ad961862280))
|
|
15
40
|
* update: CHANGELOG.md ([c73ba4], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/c73ba4e040a66da70edbeb990b8e7d42a690cc1b))
|
|
16
41
|
|
|
17
42
|
# Version 2.8.22, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/abdcd052a504db9e3ef0d640c05c861dab6fc771)
|
|
@@ -25,6 +50,7 @@
|
|
|
25
50
|
* ## Fixes
|
|
26
51
|
* <span style='color:red'>fix builder issues</span> ([67abd4], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/67abd4785b47f62e1004e58ff8c27282d9e87664))
|
|
27
52
|
|
|
53
|
+
* upd ([3d3e6b], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3d3e6b7ea69c8114658f64859038187b16708f66))
|
|
28
54
|
* update: CHANGELOG.md ([866504], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/86650477e9606983c72620ed063150bb23fc3e4e))
|
|
29
55
|
|
|
30
56
|
# Version 2.8.21, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/dcc7c4b24a73690b18533027979c7ed0e3c88a78)
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "ru.coon"
|
|
5
5
|
},
|
|
6
6
|
"description": "",
|
|
7
|
-
"version": "2.8.
|
|
7
|
+
"version": "2.8.27",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+http://gitlab-dbr.sigma-it.local/dbr/ru.coon"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"extjs_iconpack": "1.3.27",
|
|
31
31
|
"json5": "2.2.3",
|
|
32
32
|
"object-hash": "^3.0.0",
|
|
33
|
-
"sigma-printjs": "^1.0.
|
|
33
|
+
"sigma-printjs": "^1.0.3",
|
|
34
34
|
"sql-formatter": "^13.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -302,7 +302,7 @@ Ext.define('Coon.report.component.ReportPanel', {
|
|
|
302
302
|
return undefined;
|
|
303
303
|
},
|
|
304
304
|
|
|
305
|
-
loadFakeData(len
|
|
305
|
+
loadFakeData(len) {
|
|
306
306
|
if (!this.isConfigured) {
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
@@ -326,6 +326,7 @@ Ext.define('Coon.report.component.ReportPanel', {
|
|
|
326
326
|
}, {id: Ext.id(false, 'fakeid-')});
|
|
327
327
|
const data = [...Array(len)].map(getRow);
|
|
328
328
|
this.grid.getStore().loadData(data);
|
|
329
|
+
return 'complete loadFakeData';
|
|
329
330
|
},
|
|
330
331
|
|
|
331
332
|
initComponent: function() {
|
|
@@ -405,12 +406,6 @@ Ext.define('Coon.report.component.ReportPanel', {
|
|
|
405
406
|
this.on('invalidateCache', this.filterHandler.bind(this, true));
|
|
406
407
|
},
|
|
407
408
|
|
|
408
|
-
onDestroy: function() {
|
|
409
|
-
if (this.eventDestroier) {
|
|
410
|
-
// Ext.destroy(this.eventDestroier)
|
|
411
|
-
}
|
|
412
|
-
},
|
|
413
|
-
|
|
414
409
|
onWindowResize: function(width, height) {
|
|
415
410
|
this.height = this.height || height - 105;
|
|
416
411
|
this.width = this.width || width - 270;
|
|
@@ -2,12 +2,15 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
2
2
|
extend: 'Coon.report.plugin.grid.ToolbarButtonPlugin',
|
|
3
3
|
alias: 'plugin.CopyRowsFromGrid',
|
|
4
4
|
uses: [],
|
|
5
|
-
requires: [
|
|
5
|
+
requires: [
|
|
6
|
+
'Coon.report.plugin.grid.exporters.xlsxExporter'
|
|
7
|
+
],
|
|
6
8
|
alternateClassName: [
|
|
7
9
|
'Sigma.common.grid.plugin.CopyRowsFromGrid',
|
|
8
10
|
'Sigma.common.plugin.grid.CopyRowsFromGrid'
|
|
9
11
|
],
|
|
10
12
|
defaultFloatPrecision: 2,
|
|
13
|
+
defaultFieldType: 'string',
|
|
11
14
|
configurePanelWizard: 'CopyRowsFromGridConfigPanel',
|
|
12
15
|
position: -1,
|
|
13
16
|
allowAddRowOnPaste: false,
|
|
@@ -87,9 +90,10 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
87
90
|
`;
|
|
88
91
|
},
|
|
89
92
|
|
|
90
|
-
init
|
|
93
|
+
init(component) {
|
|
91
94
|
this.injectForm();
|
|
92
95
|
this.callParent([component]);
|
|
96
|
+
this.reportPanel = this.getCmp().up('ReportPanel');
|
|
93
97
|
component.on('reconfigure', function(grid, store, columns) {
|
|
94
98
|
this.getCmp().store = store;
|
|
95
99
|
this.getCmp().columns = columns;
|
|
@@ -97,7 +101,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
97
101
|
Object.assign(this.tableHeaderStyle || {}, this.allBordersStyle);
|
|
98
102
|
},
|
|
99
103
|
|
|
100
|
-
createToolbarItem
|
|
104
|
+
createToolbarItem(config) {
|
|
101
105
|
let tbItem = this.callParent([config]);
|
|
102
106
|
if (this.showConfirmDialog) {
|
|
103
107
|
tbItem = new Ext.button.Split(Ext.apply({
|
|
@@ -125,7 +129,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
125
129
|
return tbItem;
|
|
126
130
|
},
|
|
127
131
|
|
|
128
|
-
handler
|
|
132
|
+
handler(button) {
|
|
129
133
|
this.recordsToExport = undefined;
|
|
130
134
|
if (button.itemId === 'getAllButton' || (button.itemId !== 'getSelectedButton' && this.exportAllRows)) {
|
|
131
135
|
this.recordsToExport = this.getAll();
|
|
@@ -147,7 +151,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
147
151
|
}
|
|
148
152
|
},
|
|
149
153
|
|
|
150
|
-
showConfirmFormatDialog
|
|
154
|
+
showConfirmFormatDialog(fn) {
|
|
151
155
|
const formatSelectField = Ext.create(Coon.common.field.combo.ConstantList, {
|
|
152
156
|
data: [
|
|
153
157
|
['xls', 'xls - старый формат'],
|
|
@@ -175,14 +179,14 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
175
179
|
buttons: [
|
|
176
180
|
{
|
|
177
181
|
text: this.buttonText,
|
|
178
|
-
handler
|
|
182
|
+
handler() {
|
|
179
183
|
fn(formatSelectField.getValue());
|
|
180
184
|
win.close();
|
|
181
185
|
},
|
|
182
186
|
},
|
|
183
187
|
{
|
|
184
188
|
text: 'Закрыть',
|
|
185
|
-
handler
|
|
189
|
+
handler() {
|
|
186
190
|
win.close();
|
|
187
191
|
},
|
|
188
192
|
}
|
|
@@ -191,14 +195,15 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
191
195
|
);
|
|
192
196
|
win.show();
|
|
193
197
|
},
|
|
194
|
-
|
|
198
|
+
|
|
199
|
+
rgbToHex(arr) {
|
|
195
200
|
return '#' + arr.map((x) => {
|
|
196
201
|
const hex = Number(x).toString(16);
|
|
197
202
|
return hex.length === 1 ? '0' + hex : hex;
|
|
198
203
|
}).join('');
|
|
199
204
|
},
|
|
200
205
|
|
|
201
|
-
mergeDeep
|
|
206
|
+
mergeDeep(target, ...sources) {
|
|
202
207
|
if (!sources.length) {
|
|
203
208
|
return target;
|
|
204
209
|
}
|
|
@@ -221,7 +226,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
221
226
|
},
|
|
222
227
|
|
|
223
228
|
getCurrentFilterParameters() {
|
|
224
|
-
return this.
|
|
229
|
+
return this.reportPanel.currentParamList || {};
|
|
225
230
|
},
|
|
226
231
|
|
|
227
232
|
applyTemplate(content = '', data = {}) {
|
|
@@ -234,7 +239,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
234
239
|
return tpl.apply(Object.assign(data, {parameters: this.getCurrentFilterParameters()}));
|
|
235
240
|
},
|
|
236
241
|
|
|
237
|
-
parseJsEditorObj
|
|
242
|
+
parseJsEditorObj(obj, workbook) {
|
|
238
243
|
if (typeof obj !== 'object' || !obj.blocks || !obj.blocks.length) {
|
|
239
244
|
return [];
|
|
240
245
|
}
|
|
@@ -296,161 +301,21 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
296
301
|
);
|
|
297
302
|
return result;
|
|
298
303
|
},
|
|
299
|
-
/**
|
|
300
|
-
* Формируем заголовок
|
|
301
|
-
* @returns {Object[] || []}
|
|
302
|
-
*/
|
|
303
|
-
collectHeaderJson: function(columnCount, workbook) {
|
|
304
|
-
const reportPanel = this.getCmp().up('ReportPanel');
|
|
305
|
-
const result = [];
|
|
306
|
-
// Работа с отображением выгрузок
|
|
307
|
-
if (this.addHeader === true) {
|
|
308
|
-
result.push({
|
|
309
|
-
value: reportPanel.title,
|
|
310
|
-
mergeAcross: columnCount || 1,
|
|
311
|
-
styleId: workbook.addCellStyle({
|
|
312
|
-
font: {
|
|
313
|
-
bold: true,
|
|
314
|
-
size: 17,
|
|
315
|
-
},
|
|
316
|
-
}),
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
return result;
|
|
320
|
-
},
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Собираем фильтры
|
|
324
|
-
* @returns {string}
|
|
325
|
-
*/
|
|
326
|
-
collectFiltersJson: function(columnCount, workbook) {
|
|
327
|
-
const reportPanel = this.getCmp().up('ReportPanel');
|
|
328
|
-
const result = [];
|
|
329
|
-
if (this.addFilters === true) {
|
|
330
|
-
result.push({
|
|
331
|
-
value: 'Используемые фильтры:',
|
|
332
|
-
mergeAcross: columnCount || 1,
|
|
333
|
-
styleId: workbook.addCellStyle({
|
|
334
|
-
font: {
|
|
335
|
-
bold: true,
|
|
336
|
-
size: 13,
|
|
337
|
-
color: '#a6a4a4',
|
|
338
|
-
},
|
|
339
|
-
}),
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
const customXtype = ['SimpleReportTag'];
|
|
343
|
-
const filterComponents = function(comp) {
|
|
344
|
-
return Ext.getClassName(comp) !== 'Ext.form.field.Display' &&
|
|
345
|
-
!Ext.isEmpty(comp.getValue()) &&
|
|
346
|
-
comp.xtype !== 'CustomValueCheckBox'; // todo: как-то узнать, почему нельзя этот компонент вывести в файл
|
|
347
|
-
};
|
|
348
|
-
const renderFilterConditions = function(filter) {
|
|
349
|
-
if (customXtype.includes(filter.xtype)) {
|
|
350
|
-
let tmp = '';
|
|
351
|
-
filter.valueCollection.items.forEach(function(it) {
|
|
352
|
-
tmp = tmp + it.getData()[filter.getDisplayField()];
|
|
353
|
-
});
|
|
354
|
-
result.push({
|
|
355
|
-
value: filter.fieldLabel + ': ' + tmp,
|
|
356
|
-
mergeAcross: columnCount || 1,
|
|
357
|
-
styleId: workbook.addCellStyle({
|
|
358
|
-
font: {
|
|
359
|
-
color: '#a6a4a4',
|
|
360
|
-
},
|
|
361
|
-
}),
|
|
362
|
-
});
|
|
363
|
-
} else if (!filter.initialConfig.hidden) {
|
|
364
|
-
const label = (Ext.getClassName(filter) === 'Ext.form.field.Checkbox') ?
|
|
365
|
-
filter.boxLabel || filter.fieldLabel :
|
|
366
|
-
filter.fieldLabel;
|
|
367
|
-
|
|
368
|
-
const rawValue = Ext.isBoolean(filter.getRawValue()) ? filter.getRawValue() ? 'Да' : 'Нет' :
|
|
369
|
-
filter.getRawValue();
|
|
370
|
-
result.push({
|
|
371
|
-
value: label + ': ' + rawValue,
|
|
372
|
-
mergeAcross: columnCount || 1,
|
|
373
|
-
styleId: workbook.addCellStyle({
|
|
374
|
-
font: {
|
|
375
|
-
bold: true,
|
|
376
|
-
},
|
|
377
|
-
}),
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
reportPanel.filterContainer.query('field')
|
|
382
|
-
.filter(filterComponents)
|
|
383
|
-
.forEach(renderFilterConditions);
|
|
384
|
-
}
|
|
385
|
-
return result;
|
|
386
|
-
},
|
|
387
|
-
collectGridDataAsObject: function(selections, workbook) {
|
|
388
|
-
const dataRows = [];
|
|
389
|
-
let headerRows = [];
|
|
390
|
-
let footerRows = [];
|
|
391
|
-
const grid = this.getCmp();
|
|
392
|
-
const columnModel = grid.getColumns();
|
|
393
|
-
const columnCount = grid.getColumns().length;
|
|
394
|
-
if (this.addHeader === true) {
|
|
395
|
-
headerRows = this.collectHeaderJson(columnCount, workbook);
|
|
396
|
-
}
|
|
397
|
-
if (this.addFilters === true) {
|
|
398
|
-
headerRows = headerRows.concat(
|
|
399
|
-
this.collectFiltersJson(columnCount, workbook)
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
if (this.headerXlsx) {
|
|
403
|
-
headerRows = headerRows.concat(this.parseJsEditorObj(this.headerXlsx, workbook));
|
|
404
|
-
}
|
|
405
|
-
const dataIndexToColumn = [];
|
|
406
|
-
const visibleColumns = [];
|
|
407
|
-
const columnIndexToDataIndex = [];
|
|
408
|
-
|
|
409
|
-
for (let c = 0; c < columnCount; c++) {
|
|
410
|
-
if (!columnModel[c].hidden) {
|
|
411
|
-
const dataIndex = columnModel[c].dataIndex;
|
|
412
|
-
if (!Ext.isEmpty(dataIndex)) {
|
|
413
|
-
visibleColumns.push(c);
|
|
414
|
-
columnIndexToDataIndex[c] = dataIndex;
|
|
415
|
-
dataIndexToColumn[dataIndex] = columnModel[c];
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
selections.forEach(function(record, i) {
|
|
420
|
-
dataRows.push(
|
|
421
|
-
this.collectColumns(
|
|
422
|
-
grid,
|
|
423
|
-
record,
|
|
424
|
-
visibleColumns,
|
|
425
|
-
columnIndexToDataIndex,
|
|
426
|
-
columnModel,
|
|
427
|
-
dataIndexToColumn,
|
|
428
|
-
i,
|
|
429
|
-
true,
|
|
430
|
-
workbook
|
|
431
|
-
)
|
|
432
|
-
);
|
|
433
|
-
}, this);
|
|
434
|
-
if (this.footerXlsx) {
|
|
435
|
-
footerRows = this.parseJsEditorObj(this.footerXlsx, workbook);
|
|
436
|
-
}
|
|
437
|
-
return {headerRows, dataRows, footerRows};
|
|
438
|
-
},
|
|
439
304
|
|
|
440
305
|
execute() {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
306
|
+
this.reportPanel && this.reportPanel.mask('Экспорт', 'x-mask-loading');
|
|
307
|
+
this.generateExport()
|
|
308
|
+
.then(
|
|
309
|
+
() => this.reportPanel && this.reportPanel.unmask()
|
|
310
|
+
).catch(console.error);
|
|
444
311
|
},
|
|
445
312
|
|
|
446
|
-
|
|
447
|
-
// const stop = Coon.perf.start('CPFG');
|
|
448
|
-
const reportPanel = this.getCmp().up('ReportPanel');
|
|
313
|
+
getFilename() {
|
|
449
314
|
const selected = this.getSelected()[0];
|
|
450
315
|
const name = this.getTemplatedFileName(this.reportFileName) ||
|
|
451
316
|
(selected && selected.data['CM_REPORT_CD']) ||
|
|
452
317
|
this.tryToGetTitle() ||
|
|
453
|
-
(reportPanel && reportPanel.reportId) ||
|
|
318
|
+
(this.reportPanel && this.reportPanel.reportId) ||
|
|
454
319
|
'defaultReportName';
|
|
455
320
|
const dateFormat = this.dateFormat || this.defaultDateFormat;
|
|
456
321
|
|
|
@@ -463,27 +328,57 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
463
328
|
filename += '_';
|
|
464
329
|
filename += Ext.Date.format(new Date(), dateFormat);
|
|
465
330
|
}
|
|
466
|
-
|
|
331
|
+
return this.normalizeFileName(filename);
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
generateXlsx(filename) {
|
|
335
|
+
const xlsxExporter = Ext.create('Coon.report.plugin.grid.exporters.xlsxExporter', {
|
|
336
|
+
plugin: this,
|
|
337
|
+
});
|
|
338
|
+
Coon.util.bindMethods([
|
|
339
|
+
'mergeDeep',
|
|
340
|
+
'getRenderedValue',
|
|
341
|
+
'getCellClass',
|
|
342
|
+
'getConfig',
|
|
343
|
+
'getCmp',
|
|
344
|
+
'getSelected',
|
|
345
|
+
'prepareData',
|
|
346
|
+
'getSummaryRows',
|
|
347
|
+
'getTableHeaderRows',
|
|
348
|
+
'getRowStyleXlsx',
|
|
349
|
+
'getRowStyle'
|
|
350
|
+
], this, xlsxExporter);
|
|
351
|
+
this.exporter = xlsxExporter.getExporter(filename);
|
|
352
|
+
return this.exporter.saveAs().then(function() {
|
|
353
|
+
this.exporter.destroy();
|
|
354
|
+
});
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
generateXls(filename) {
|
|
358
|
+
filename += '.xls';
|
|
359
|
+
const exporter = this.exporter = Ext.create('Ext.exporter.text.Html', {fileName: filename});
|
|
360
|
+
this.prepareData(exporter);
|
|
361
|
+
const blob = new Blob(this.collectGridDataAsArray(
|
|
362
|
+
this.getSelected(),
|
|
363
|
+
this.getTableHeaderRows(exporter, 'xls')
|
|
364
|
+
), {
|
|
365
|
+
type: 'text/xls;charset=UTF-8',
|
|
366
|
+
});
|
|
367
|
+
Coon.util.downloadFileFromBlob(blob, filename);
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
generateExport() {
|
|
371
|
+
// const stop = Coon.perf.start('CPFG');
|
|
372
|
+
const filename = this.getFilename();
|
|
467
373
|
|
|
468
374
|
if (this.format === 'xlsx') {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
});
|
|
375
|
+
return this.generateXlsx(filename);
|
|
376
|
+
// .then(() => {
|
|
377
|
+
// Coon.log.debug(Coon.perf.getLog(stop()));
|
|
378
|
+
// });
|
|
473
379
|
} else {
|
|
474
|
-
|
|
475
|
-
const exporter = this.exporter = Ext.create('Ext.exporter.text.Html', {fileName: filename});
|
|
476
|
-
this.prepareData(exporter);
|
|
477
|
-
const blob = new Blob(this.collectGridDataAsArray(
|
|
478
|
-
this.getSelected(),
|
|
479
|
-
this.getTableHeaderRows(exporter, 'xls')
|
|
480
|
-
), {
|
|
481
|
-
type: 'text/xls;charset=UTF-8',
|
|
482
|
-
});
|
|
483
|
-
Coon.util.downloadFileFromBlob(blob, filename);
|
|
380
|
+
return Promise.resolve(this.generateXls(filename));
|
|
484
381
|
}
|
|
485
|
-
reportPanel && reportPanel.unmask();
|
|
486
|
-
// console.log(Coon.perf.getLog(stop()));
|
|
487
382
|
},
|
|
488
383
|
|
|
489
384
|
/**
|
|
@@ -491,7 +386,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
491
386
|
* @param fileName имя файла
|
|
492
387
|
* @returns {*}
|
|
493
388
|
*/
|
|
494
|
-
getTemplatedFileName
|
|
389
|
+
getTemplatedFileName(fileName) {
|
|
495
390
|
if (!Ext.isString(fileName) || fileName.match(/{.*}/g) === null) {
|
|
496
391
|
return fileName;
|
|
497
392
|
}
|
|
@@ -505,7 +400,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
505
400
|
return fileName;
|
|
506
401
|
},
|
|
507
402
|
|
|
508
|
-
normalizeFileName
|
|
403
|
+
normalizeFileName(fileName) {
|
|
509
404
|
const forbiddenSymbolMap = {
|
|
510
405
|
underscore: '_',
|
|
511
406
|
space: ' ',
|
|
@@ -534,31 +429,6 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
534
429
|
return fileName;
|
|
535
430
|
},
|
|
536
431
|
|
|
537
|
-
initExporter: function(filename) {
|
|
538
|
-
const exporter = this.exporter = Ext.create('Ext.exporter.excel.Xlsx', {
|
|
539
|
-
fileName: filename + '.xlsx',
|
|
540
|
-
tableHeaderStyle: this.tableHeaderStyle,
|
|
541
|
-
});
|
|
542
|
-
exporter.excel = new Ext.exporter.file.ooxml.Excel({
|
|
543
|
-
properties: {
|
|
544
|
-
title: 'Лист 1',
|
|
545
|
-
},
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
exporter.worksheet = exporter.excel.addWorksheet({
|
|
549
|
-
name: 'Лист 1',
|
|
550
|
-
});
|
|
551
|
-
this.prepareData();
|
|
552
|
-
const {headerRows, dataRows, footerRows} =
|
|
553
|
-
this.collectGridDataAsObject(this.getSelected(), exporter.excel);
|
|
554
|
-
const tableHeaderRows = this.getTableHeaderRows(exporter);
|
|
555
|
-
const summaryRows = this.getSummaryRows(exporter.excel);
|
|
556
|
-
// this.assignStyle([...dataRows, ...summaryRows], this.allBordersStyle);
|
|
557
|
-
exporter.jsonData = [...headerRows, ...tableHeaderRows, ...dataRows, ...summaryRows, ...footerRows];
|
|
558
|
-
exporter.getContent = this.getContent.bind(exporter, this);
|
|
559
|
-
return exporter;
|
|
560
|
-
},
|
|
561
|
-
|
|
562
432
|
prepareData() {
|
|
563
433
|
let exporterPlugin = this.getCmp().plugins.find(
|
|
564
434
|
(p) => p.ptype === 'gridexporter'
|
|
@@ -570,27 +440,11 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
570
440
|
this.exporter.setData(exporterPlugin.prepareData({includeSummary: this.includeSummary}));
|
|
571
441
|
},
|
|
572
442
|
|
|
573
|
-
getContent: function() {
|
|
574
|
-
const me = this;
|
|
575
|
-
const config = this.getConfig();
|
|
576
|
-
me.tableHeaderStyleId = me.excel.addCellStyle(config.tableHeaderStyle);
|
|
577
|
-
me.worksheet.beginRowRendering();
|
|
578
|
-
if (this.jsonData) {
|
|
579
|
-
this.jsonData.forEach((row) => {
|
|
580
|
-
me.worksheet.addRow().addCell(row);
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
me.worksheet.endRowRendering();
|
|
584
|
-
me.columnStylesNormal = me.columnStylesNormalId = me.columnStylesFooter = null;
|
|
585
|
-
me.columnStylesFooterId = me.headerStyles = me.footerStyles = null;
|
|
586
|
-
|
|
587
|
-
return me.excel.render();
|
|
588
|
-
},
|
|
589
443
|
/**
|
|
590
444
|
* Возвращает агрегирующие строки из плагина GroupRowsPlugin.
|
|
591
445
|
* Чтобы экспортировать текст, например "Всего" в конфиге колонки должны быть указаны:
|
|
592
446
|
* ```
|
|
593
|
-
* summaryRenderer
|
|
447
|
+
* summaryRenderer(){return 'Всего'},
|
|
594
448
|
* exportSummaryRenderer: true
|
|
595
449
|
* ```
|
|
596
450
|
* @returns {Object[]}
|
|
@@ -659,11 +513,11 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
659
513
|
return row.cells;
|
|
660
514
|
});
|
|
661
515
|
},
|
|
662
|
-
getTitle
|
|
516
|
+
getTitle() {
|
|
663
517
|
return this.addHeader === true ? this.getCmp().up('ReportPanel').title : '';
|
|
664
518
|
},
|
|
665
519
|
|
|
666
|
-
getFilters
|
|
520
|
+
getFilters() {
|
|
667
521
|
const filters = [];
|
|
668
522
|
if (this.addFilters === true) {
|
|
669
523
|
const reportPanel = this.getCmp().up('ReportPanel');
|
|
@@ -695,7 +549,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
695
549
|
return filters;
|
|
696
550
|
},
|
|
697
551
|
|
|
698
|
-
getAdditionalParameters
|
|
552
|
+
getAdditionalParameters() {
|
|
699
553
|
const text = (this.header || '') + (this.footer || '');
|
|
700
554
|
if (Ext.isEmpty(text)) {
|
|
701
555
|
return;
|
|
@@ -716,7 +570,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
716
570
|
return additionalParameters;
|
|
717
571
|
},
|
|
718
572
|
|
|
719
|
-
insertAdditional
|
|
573
|
+
insertAdditional(additionalParameters) {
|
|
720
574
|
let header = this.header;
|
|
721
575
|
let footer = this.footer;
|
|
722
576
|
for (const key in additionalParameters) {
|
|
@@ -732,7 +586,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
732
586
|
this.execute();
|
|
733
587
|
},
|
|
734
588
|
|
|
735
|
-
customInit
|
|
589
|
+
customInit() {
|
|
736
590
|
this.buttonText = this.buttonText || 'Экспорт в Excel';
|
|
737
591
|
this.getCmp().CopyPlugin = this;
|
|
738
592
|
if (this.header) {
|
|
@@ -743,7 +597,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
743
597
|
}
|
|
744
598
|
},
|
|
745
599
|
|
|
746
|
-
addKeyMap
|
|
600
|
+
addKeyMap() {
|
|
747
601
|
if (this.disableCopying) {
|
|
748
602
|
return;
|
|
749
603
|
}
|
|
@@ -751,7 +605,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
751
605
|
{
|
|
752
606
|
key: Ext.event.Event.C,
|
|
753
607
|
ctrl: true,
|
|
754
|
-
handler
|
|
608
|
+
handler() {
|
|
755
609
|
this.copyToClipBoard(this.getSelected());
|
|
756
610
|
},
|
|
757
611
|
scope: this,
|
|
@@ -774,11 +628,11 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
774
628
|
}
|
|
775
629
|
},
|
|
776
630
|
|
|
777
|
-
getAll
|
|
631
|
+
getAll() {
|
|
778
632
|
return this.getCmp().getStore().getRange();
|
|
779
633
|
},
|
|
780
634
|
|
|
781
|
-
collectSelectedRecords
|
|
635
|
+
collectSelectedRecords() {
|
|
782
636
|
const selectionModel = this.getCmp().getSelectionModel();
|
|
783
637
|
const selectedRecords = [];
|
|
784
638
|
this.getCmp().getStore().each(function(record) {
|
|
@@ -794,7 +648,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
794
648
|
return selectedRecords;
|
|
795
649
|
},
|
|
796
650
|
|
|
797
|
-
getSelected
|
|
651
|
+
getSelected() {
|
|
798
652
|
if (this.recordsToExport) {
|
|
799
653
|
return this.recordsToExport;
|
|
800
654
|
}
|
|
@@ -803,7 +657,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
803
657
|
return records ? this.collectSelectedRecords() : this.getAll();
|
|
804
658
|
},
|
|
805
659
|
|
|
806
|
-
copyToClipBoard
|
|
660
|
+
copyToClipBoard(rows) {
|
|
807
661
|
let copiedData = null;
|
|
808
662
|
|
|
809
663
|
if (this.getCmp().getSelectionModel().type === 'cellmodel') {
|
|
@@ -828,7 +682,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
828
682
|
}
|
|
829
683
|
},
|
|
830
684
|
|
|
831
|
-
getStartPosition
|
|
685
|
+
getStartPosition() {
|
|
832
686
|
let startColumn = 0;
|
|
833
687
|
let startRow = 0;
|
|
834
688
|
const selectionModel = this.getCmp().getSelectionModel();
|
|
@@ -847,7 +701,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
847
701
|
return {row: startRow, column: startColumn};
|
|
848
702
|
},
|
|
849
703
|
|
|
850
|
-
pasteFromClipBoard
|
|
704
|
+
pasteFromClipBoard() {
|
|
851
705
|
if (!this.allowPaste) {
|
|
852
706
|
return;
|
|
853
707
|
}
|
|
@@ -856,7 +710,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
856
710
|
hiddenTextArea.focus();
|
|
857
711
|
},
|
|
858
712
|
|
|
859
|
-
updateGridData
|
|
713
|
+
updateGridData() {
|
|
860
714
|
if (!this.allowPaste) {
|
|
861
715
|
return;
|
|
862
716
|
}
|
|
@@ -934,7 +788,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
934
788
|
this.hiddentextarea.blur();
|
|
935
789
|
},
|
|
936
790
|
|
|
937
|
-
clearValue
|
|
791
|
+
clearValue(value, type, convert, record) {
|
|
938
792
|
let columnValue = value;
|
|
939
793
|
if (!Ext.isEmpty(type)) {
|
|
940
794
|
switch (type) {
|
|
@@ -965,7 +819,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
965
819
|
* @param tableHeaderRows
|
|
966
820
|
* @returns {*[]}
|
|
967
821
|
*/
|
|
968
|
-
collectGridDataAsArray
|
|
822
|
+
collectGridDataAsArray(selections, tableHeaderRows = []) {
|
|
969
823
|
const result = [];
|
|
970
824
|
const grid = this.getCmp();
|
|
971
825
|
const columnCount = grid.getColumns().length;
|
|
@@ -993,7 +847,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
993
847
|
result.push(this.applyTemplate(html, this.getDataForTemplate(html)));
|
|
994
848
|
}
|
|
995
849
|
// собираем заголовки
|
|
996
|
-
const dataIndexToColumn =
|
|
850
|
+
const dataIndexToColumn = {};
|
|
997
851
|
const visibleColumns = [];
|
|
998
852
|
const columnIndexToDataIndex = [];
|
|
999
853
|
const columnModel = grid.getColumns();
|
|
@@ -1038,12 +892,26 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1038
892
|
});
|
|
1039
893
|
}
|
|
1040
894
|
let chunk = '';
|
|
1041
|
-
|
|
895
|
+
const fieldTypes = this.getCmp().getStore().getModel().getFields().reduce((acc, field) => {
|
|
896
|
+
acc.set(field.name, field.type || this.defaultFieldType);
|
|
897
|
+
return acc;
|
|
898
|
+
}, new Map());
|
|
899
|
+
this.localData = {
|
|
900
|
+
fieldTypes,
|
|
901
|
+
grid,
|
|
902
|
+
visibleColumns,
|
|
903
|
+
columnIndexToDataIndex,
|
|
904
|
+
columnModel,
|
|
905
|
+
dataIndexToColumn,
|
|
906
|
+
};
|
|
907
|
+
selections.forEach(function(record, idx) {
|
|
1042
908
|
const row = [];
|
|
1043
|
-
row.push(
|
|
909
|
+
row.push(
|
|
910
|
+
this.collectColumns({record, idx})
|
|
911
|
+
);
|
|
1044
912
|
chunk += row.join('');
|
|
1045
913
|
// Через this.rowsInChunk строк сгружаем данные в массив
|
|
1046
|
-
if (
|
|
914
|
+
if (idx % this.rowsInChunk === 0 || idx === selections.length - 1) {
|
|
1047
915
|
result.push(chunk);
|
|
1048
916
|
chunk = '';
|
|
1049
917
|
}
|
|
@@ -1062,7 +930,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1062
930
|
* Формируем заголовок
|
|
1063
931
|
* @returns {string}
|
|
1064
932
|
*/
|
|
1065
|
-
collectHeader
|
|
933
|
+
collectHeader() {
|
|
1066
934
|
const reportPanel = this.getCmp().up('ReportPanel');
|
|
1067
935
|
let result = '';
|
|
1068
936
|
// Работа с отображением выгрузок
|
|
@@ -1077,7 +945,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1077
945
|
* Собираем фильтры
|
|
1078
946
|
* @returns {string}
|
|
1079
947
|
*/
|
|
1080
|
-
collectFilters
|
|
948
|
+
collectFilters() {
|
|
1081
949
|
const reportPanel = this.getCmp().up('ReportPanel');
|
|
1082
950
|
let name = '';
|
|
1083
951
|
const result = [];
|
|
@@ -1120,20 +988,9 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1120
988
|
* Собираем поля
|
|
1121
989
|
* @returns {string}
|
|
1122
990
|
*/
|
|
1123
|
-
collectColumns
|
|
1124
|
-
const
|
|
1125
|
-
const
|
|
1126
|
-
if (Array.isArray(record.fields)) {
|
|
1127
|
-
const field = record.fields.find(function(element, index, array) {
|
|
1128
|
-
if (element.name === idx) {
|
|
1129
|
-
return element;
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
return field ? field.type : defValue;
|
|
1133
|
-
} else {
|
|
1134
|
-
return defValue;
|
|
1135
|
-
}
|
|
1136
|
-
};
|
|
991
|
+
collectColumns({record, idx, xlsx}) {
|
|
992
|
+
const {grid, visibleColumns, columnIndexToDataIndex, columnModel, dataIndexToColumn, workbook} = this.localData;
|
|
993
|
+
const result = xlsx ? [] : ['<tr>'];
|
|
1137
994
|
visibleColumns.forEach(function(columnIndex) {
|
|
1138
995
|
const columnConfig = columnModel[columnIndex];
|
|
1139
996
|
if (columnConfig.ignoreExport) {
|
|
@@ -1143,7 +1000,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1143
1000
|
const dataIndex = columnIndexToDataIndex[columnIndex];
|
|
1144
1001
|
const renderer = columnConfig.renderer;
|
|
1145
1002
|
const exportRenderer = columnConfig.exportRenderer;
|
|
1146
|
-
const valueType = getValueType(dataIndex, 'string');
|
|
1003
|
+
const valueType = this.localData.fieldTypes.get(dataIndex);// getValueType(dataIndex, 'string');
|
|
1147
1004
|
|
|
1148
1005
|
|
|
1149
1006
|
const value = typeof (exportRenderer || renderer) === 'function' ?
|
|
@@ -1152,13 +1009,13 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1152
1009
|
record.get(dataIndex),
|
|
1153
1010
|
{column: columnConfig},
|
|
1154
1011
|
record,
|
|
1155
|
-
|
|
1012
|
+
idx,
|
|
1156
1013
|
columnIndex,
|
|
1157
1014
|
grid.getStore(),
|
|
1158
1015
|
grid.getView()
|
|
1159
1016
|
) :
|
|
1160
1017
|
record.data[dataIndex] || '';
|
|
1161
|
-
if (!
|
|
1018
|
+
if (!xlsx) {
|
|
1162
1019
|
const styles = this.getRowStyle(grid, record);
|
|
1163
1020
|
result.push(`
|
|
1164
1021
|
<td
|
|
@@ -1187,14 +1044,15 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1187
1044
|
result.push(JSON.parse(JSON.stringify(col)));
|
|
1188
1045
|
}
|
|
1189
1046
|
}, this);
|
|
1190
|
-
if (!
|
|
1047
|
+
if (!xlsx) {
|
|
1191
1048
|
result.push('</tr>');
|
|
1192
1049
|
return result.join('');
|
|
1193
1050
|
} else {
|
|
1194
1051
|
return result;
|
|
1195
1052
|
}
|
|
1196
1053
|
},
|
|
1197
|
-
|
|
1054
|
+
|
|
1055
|
+
getRowStyleXlsx(grid, record) {
|
|
1198
1056
|
let styles = {};
|
|
1199
1057
|
const rowElement = Ext.fly(grid.getView().getRow(grid.getStore().indexOf(record)));
|
|
1200
1058
|
if (rowElement) {
|
|
@@ -1211,7 +1069,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1211
1069
|
|
|
1212
1070
|
return {styles: styles};
|
|
1213
1071
|
},
|
|
1214
|
-
getRowStyle
|
|
1072
|
+
getRowStyle(grid, record) {
|
|
1215
1073
|
const rowElement = Ext.fly(grid.getView().getRow(grid.getStore().indexOf(record)));
|
|
1216
1074
|
|
|
1217
1075
|
let resultClasses = '';
|
|
@@ -1242,7 +1100,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1242
1100
|
return resultClasses;
|
|
1243
1101
|
},
|
|
1244
1102
|
|
|
1245
|
-
getHeaderStyle
|
|
1103
|
+
getHeaderStyle(value, type) {
|
|
1246
1104
|
let style = '';
|
|
1247
1105
|
if (!Ext.isEmpty(type)) {
|
|
1248
1106
|
switch (type) {
|
|
@@ -1254,7 +1112,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1254
1112
|
return style;
|
|
1255
1113
|
},
|
|
1256
1114
|
|
|
1257
|
-
getCellClass
|
|
1115
|
+
getCellClass(value, type) {
|
|
1258
1116
|
let style = '';
|
|
1259
1117
|
if (!Ext.isEmpty(type)) {
|
|
1260
1118
|
switch (type) {
|
|
@@ -1270,7 +1128,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1270
1128
|
}
|
|
1271
1129
|
return style;
|
|
1272
1130
|
},
|
|
1273
|
-
getRenderedValue
|
|
1131
|
+
getRenderedValue(v, type) {
|
|
1274
1132
|
let value = v;
|
|
1275
1133
|
if (v instanceof Date) {
|
|
1276
1134
|
value = Ext.util.Format.dateRenderer(this.dateFormat)(v);
|
|
@@ -1301,7 +1159,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1301
1159
|
return value;
|
|
1302
1160
|
},
|
|
1303
1161
|
|
|
1304
|
-
getHiddenTextArea
|
|
1162
|
+
getHiddenTextArea() {
|
|
1305
1163
|
if (!this.hiddentextarea) {
|
|
1306
1164
|
this.hiddentextarea = new Ext.Element(document.createElement('textarea'));
|
|
1307
1165
|
this.hiddentextarea.setStyle('position', 'absolute');
|
|
@@ -1315,7 +1173,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1315
1173
|
return this.hiddentextarea;
|
|
1316
1174
|
},
|
|
1317
1175
|
|
|
1318
|
-
tryToGetTitle
|
|
1176
|
+
tryToGetTitle() {
|
|
1319
1177
|
let title = this.getCmp().title || '';
|
|
1320
1178
|
if (Ext.isEmpty(title)) {
|
|
1321
1179
|
this.getCmp().bubble(function(panel) {
|
|
@@ -1329,7 +1187,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1329
1187
|
},
|
|
1330
1188
|
|
|
1331
1189
|
// Получение параметров шаблонов
|
|
1332
|
-
getDataForTemplate
|
|
1190
|
+
getDataForTemplate(text) {
|
|
1333
1191
|
if (Ext.isEmpty(text)) {
|
|
1334
1192
|
return {};
|
|
1335
1193
|
}
|
|
@@ -1374,7 +1232,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1374
1232
|
},
|
|
1375
1233
|
|
|
1376
1234
|
// Обработка шаблона
|
|
1377
|
-
processingTemplate
|
|
1235
|
+
processingTemplate(template) {
|
|
1378
1236
|
let result = '' + template;
|
|
1379
1237
|
this.getParametersForReplace().forEach(function(p) {
|
|
1380
1238
|
result = result.replace(new RegExp(p.re, 'g'), p.getHandler.call(this));
|
|
@@ -1388,12 +1246,12 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1388
1246
|
* re - регулярное выражения для поиска параметра
|
|
1389
1247
|
* getHandler - функция, возвращающая функцию замены
|
|
1390
1248
|
*/
|
|
1391
|
-
getParametersForReplace
|
|
1249
|
+
getParametersForReplace() {
|
|
1392
1250
|
if (Ext.isEmpty(this.parametersForReplace)) {
|
|
1393
1251
|
this.parametersForReplace = [
|
|
1394
1252
|
{
|
|
1395
1253
|
re: '\\{\\$\\w[\\w ,\\\\/.:-]*\\$\\}', // Даты в виде {$формат_даты$}
|
|
1396
|
-
getHandler
|
|
1254
|
+
getHandler() {
|
|
1397
1255
|
const date = new Date();
|
|
1398
1256
|
return function(m) {
|
|
1399
1257
|
return Ext.Date.format(date, m.substring(2, m.length - 2));
|
|
@@ -1402,7 +1260,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1402
1260
|
},
|
|
1403
1261
|
{
|
|
1404
1262
|
re: '\\{\\$\\w[\\w-]*(?!\\$)\\}', // Прочие параметры в виде {$имя_параметра}
|
|
1405
|
-
getHandler
|
|
1263
|
+
getHandler() {
|
|
1406
1264
|
const params = {
|
|
1407
1265
|
REPORT_TITLE: this.tryToGetTitle(),
|
|
1408
1266
|
};
|
|
@@ -1416,7 +1274,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1416
1274
|
return this.parametersForReplace;
|
|
1417
1275
|
},
|
|
1418
1276
|
|
|
1419
|
-
parseHTML
|
|
1277
|
+
parseHTML(htmlString) {
|
|
1420
1278
|
const div = document.createElement('div');
|
|
1421
1279
|
div.innerHTML = htmlString.split('body>')[1] && htmlString.split('body>')[1].slice(0, -2);
|
|
1422
1280
|
const result = [];
|
|
@@ -1430,13 +1288,12 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1430
1288
|
return result.join('\n');
|
|
1431
1289
|
},
|
|
1432
1290
|
|
|
1433
|
-
getPluginCustomPropsForFields
|
|
1291
|
+
getPluginCustomPropsForFields() {
|
|
1434
1292
|
return [{
|
|
1435
1293
|
name: 'exportRenderer',
|
|
1436
1294
|
description: 'Данное свойство позволяет обработать итоговые строки',
|
|
1437
1295
|
type: 'function',
|
|
1438
1296
|
fields: 'all',
|
|
1439
1297
|
}];
|
|
1440
|
-
}
|
|
1441
|
-
,
|
|
1298
|
+
},
|
|
1442
1299
|
});
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
Ext.define('Coon.report.plugin.grid.exporters.xlsxExporter', {
|
|
2
|
+
|
|
3
|
+
defaultFieldType: 'string',
|
|
4
|
+
|
|
5
|
+
constructor(cfg) {
|
|
6
|
+
Ext.apply(this, cfg);
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
getExporter(filename) {
|
|
10
|
+
// Coon.perf.clearAll();
|
|
11
|
+
// const stopMeasure = Coon.perf.start('getExporter', true);
|
|
12
|
+
const exporter = Ext.create('Ext.exporter.excel.Xlsx', {
|
|
13
|
+
fileName: filename + '.xlsx',
|
|
14
|
+
tableHeaderStyle: this.tableHeaderStyle,
|
|
15
|
+
});
|
|
16
|
+
this.plugin.exporter = exporter;
|
|
17
|
+
exporter.excel = new Ext.exporter.file.ooxml.Excel({
|
|
18
|
+
properties: {
|
|
19
|
+
title: 'Лист 1',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
exporter.worksheet = exporter.excel.addWorksheet({
|
|
24
|
+
name: 'Лист 1',
|
|
25
|
+
});
|
|
26
|
+
this.prepareData();
|
|
27
|
+
|
|
28
|
+
const {headerRows, dataRows, footerRows} =
|
|
29
|
+
this.collectGridDataAsObject(this.getSelected(), exporter.excel);
|
|
30
|
+
const tableHeaderRows = this.getTableHeaderRows(exporter);
|
|
31
|
+
const summaryRows = this.getSummaryRows(exporter.excel);
|
|
32
|
+
exporter.jsonData = [...headerRows, ...tableHeaderRows, ...dataRows, ...summaryRows, ...footerRows];
|
|
33
|
+
exporter.getContent = this.getContent.bind(exporter, this);
|
|
34
|
+
// Coon.log.debug(
|
|
35
|
+
// Coon.perf.getLog(stopMeasure())
|
|
36
|
+
// );
|
|
37
|
+
return exporter;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
getContent: function() {
|
|
41
|
+
const me = this;
|
|
42
|
+
const config = this.getConfig();
|
|
43
|
+
me.tableHeaderStyleId = me.excel.addCellStyle(config.tableHeaderStyle);
|
|
44
|
+
me.worksheet.beginRowRendering();
|
|
45
|
+
if (this.jsonData) {
|
|
46
|
+
this.jsonData.forEach((row) => {
|
|
47
|
+
me.worksheet.addRow().addCell(row);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
me.worksheet.endRowRendering();
|
|
51
|
+
me.columnStylesNormal = me.columnStylesNormalId = me.columnStylesFooter = null;
|
|
52
|
+
me.columnStylesFooterId = me.headerStyles = me.footerStyles = null;
|
|
53
|
+
|
|
54
|
+
return me.excel.render();
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
collectGridDataAsObject: function(selections, workbook) {
|
|
58
|
+
// const stopMeasure = Coon.perf.start('collectGridDataAsObject', true);
|
|
59
|
+
const dataRows = [];
|
|
60
|
+
let headerRows = [];
|
|
61
|
+
let footerRows = [];
|
|
62
|
+
const grid = this.getCmp();
|
|
63
|
+
const columnModel = grid.getColumns().reduce((acc, column) => {
|
|
64
|
+
if (!column.hidden) {
|
|
65
|
+
acc.push(column);
|
|
66
|
+
}
|
|
67
|
+
return acc;
|
|
68
|
+
}, []);
|
|
69
|
+
const columnCount = columnModel.length;
|
|
70
|
+
if (this.addHeader === true) {
|
|
71
|
+
headerRows = this.collectHeaderJson(columnCount, workbook);
|
|
72
|
+
}
|
|
73
|
+
if (this.addFilters === true) {
|
|
74
|
+
headerRows = headerRows.concat(
|
|
75
|
+
this.collectFiltersJson(columnCount, workbook)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (this.headerXlsx) {
|
|
79
|
+
headerRows = headerRows.concat(this.parseJsEditorObj(this.headerXlsx, workbook));
|
|
80
|
+
}
|
|
81
|
+
const dataIndexToColumn = {};
|
|
82
|
+
const visibleColumns = [];
|
|
83
|
+
const columnIndexToDataIndex = [];
|
|
84
|
+
|
|
85
|
+
for (let idx = 0; idx < columnCount; idx++) {
|
|
86
|
+
const el = columnModel[idx];
|
|
87
|
+
if (el.dataIndex) {
|
|
88
|
+
visibleColumns.push(idx);
|
|
89
|
+
columnIndexToDataIndex[idx] = el.dataIndex;
|
|
90
|
+
dataIndexToColumn[el.dataIndex] = columnModel[idx];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const fieldTypes = this.getCmp().getStore().getModel().getFields().reduce((acc, field) => {
|
|
94
|
+
acc.set(field.name, field.type || this.defaultFieldType);
|
|
95
|
+
return acc;
|
|
96
|
+
}, new Map());
|
|
97
|
+
|
|
98
|
+
this.localData = {
|
|
99
|
+
fieldTypes,
|
|
100
|
+
grid,
|
|
101
|
+
visibleColumns,
|
|
102
|
+
columnIndexToDataIndex,
|
|
103
|
+
columnModel,
|
|
104
|
+
dataIndexToColumn,
|
|
105
|
+
workbook,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
selections.forEach(function(record, idx) {
|
|
109
|
+
dataRows.push(
|
|
110
|
+
this.collectColumns({
|
|
111
|
+
record,
|
|
112
|
+
idx,
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
}, this);
|
|
116
|
+
if (this.footerXlsx) {
|
|
117
|
+
footerRows = this.parseJsEditorObj(this.footerXlsx, workbook);
|
|
118
|
+
}
|
|
119
|
+
// Coon.log.debug(
|
|
120
|
+
// Coon.perf.getLog(stopMeasure())
|
|
121
|
+
// );
|
|
122
|
+
// Coon.log.debug(
|
|
123
|
+
// Coon.perf.getLog('mergeDeep', 6)
|
|
124
|
+
// );
|
|
125
|
+
// Coon.log.debug(
|
|
126
|
+
// Coon.perf.getLog('collectColumns', 5)
|
|
127
|
+
// );
|
|
128
|
+
|
|
129
|
+
return {headerRows, dataRows, footerRows};
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Формируем заголовок
|
|
134
|
+
* @returns {Object[] || []}
|
|
135
|
+
*/
|
|
136
|
+
collectHeaderJson: function(columnCount, workbook) {
|
|
137
|
+
const reportPanel = this.getCmp().up('ReportPanel');
|
|
138
|
+
const result = [];
|
|
139
|
+
// Работа с отображением выгрузок
|
|
140
|
+
if (this.addHeader === true) {
|
|
141
|
+
result.push({
|
|
142
|
+
value: reportPanel.title,
|
|
143
|
+
mergeAcross: columnCount || 1,
|
|
144
|
+
styleId: workbook.addCellStyle({
|
|
145
|
+
font: {
|
|
146
|
+
bold: true,
|
|
147
|
+
size: 17,
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Собираем фильтры
|
|
157
|
+
* @returns {string}
|
|
158
|
+
*/
|
|
159
|
+
collectFiltersJson: function(columnCount, workbook) {
|
|
160
|
+
const reportPanel = this.getCmp().up('ReportPanel');
|
|
161
|
+
const result = [];
|
|
162
|
+
if (this.addFilters === true) {
|
|
163
|
+
result.push({
|
|
164
|
+
value: 'Используемые фильтры:',
|
|
165
|
+
mergeAcross: columnCount || 1,
|
|
166
|
+
styleId: workbook.addCellStyle({
|
|
167
|
+
font: {
|
|
168
|
+
bold: true,
|
|
169
|
+
size: 13,
|
|
170
|
+
color: '#a6a4a4',
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const customXtype = ['SimpleReportTag'];
|
|
176
|
+
const filterComponents = function(comp) {
|
|
177
|
+
return Ext.getClassName(comp) !== 'Ext.form.field.Display' &&
|
|
178
|
+
!Ext.isEmpty(comp.getValue()) &&
|
|
179
|
+
comp.xtype !== 'CustomValueCheckBox'; // todo: как-то узнать, почему нельзя этот компонент вывести в файл
|
|
180
|
+
};
|
|
181
|
+
const renderFilterConditions = function(filter) {
|
|
182
|
+
if (customXtype.includes(filter.xtype)) {
|
|
183
|
+
let tmp = '';
|
|
184
|
+
filter.valueCollection.items.forEach(function(it) {
|
|
185
|
+
tmp = tmp + it.getData()[filter.getDisplayField()];
|
|
186
|
+
});
|
|
187
|
+
result.push({
|
|
188
|
+
value: filter.fieldLabel + ': ' + tmp,
|
|
189
|
+
mergeAcross: columnCount || 1,
|
|
190
|
+
styleId: workbook.addCellStyle({
|
|
191
|
+
font: {
|
|
192
|
+
color: '#a6a4a4',
|
|
193
|
+
},
|
|
194
|
+
}),
|
|
195
|
+
});
|
|
196
|
+
} else if (!filter.initialConfig.hidden) {
|
|
197
|
+
const label = (Ext.getClassName(filter) === 'Ext.form.field.Checkbox') ?
|
|
198
|
+
filter.boxLabel || filter.fieldLabel :
|
|
199
|
+
filter.fieldLabel;
|
|
200
|
+
|
|
201
|
+
const rawValue = Ext.isBoolean(filter.getRawValue()) ? filter.getRawValue() ? 'Да' : 'Нет' :
|
|
202
|
+
filter.getRawValue();
|
|
203
|
+
result.push({
|
|
204
|
+
value: label + ': ' + rawValue,
|
|
205
|
+
mergeAcross: columnCount || 1,
|
|
206
|
+
styleId: workbook.addCellStyle({
|
|
207
|
+
font: {
|
|
208
|
+
bold: true,
|
|
209
|
+
},
|
|
210
|
+
}),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
reportPanel.filterContainer.query('field')
|
|
215
|
+
.filter(filterComponents)
|
|
216
|
+
.forEach(renderFilterConditions);
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Собираем поля
|
|
223
|
+
* @returns {string}
|
|
224
|
+
*/
|
|
225
|
+
collectColumns: function({record, idx}) {
|
|
226
|
+
// const stopMeasure = Coon.perf.startSerie('collectColumns');
|
|
227
|
+
const {grid, visibleColumns, columnIndexToDataIndex, columnModel, dataIndexToColumn, workbook} = this.localData;
|
|
228
|
+
const result = [];
|
|
229
|
+
visibleColumns.forEach(function(columnIndex) {
|
|
230
|
+
const columnConfig = columnModel[columnIndex];
|
|
231
|
+
if (columnConfig.ignoreExport) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const dataIndex = columnIndexToDataIndex[columnIndex];
|
|
236
|
+
const renderer = columnConfig.renderer;
|
|
237
|
+
const exportRenderer = columnConfig.exportRenderer;
|
|
238
|
+
const valueType = this.localData.fieldTypes.get(dataIndex);// getValueType(dataIndex, 'string');
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
const value = typeof (exportRenderer || renderer) === 'function' ?
|
|
242
|
+
(exportRenderer || renderer).call(
|
|
243
|
+
dataIndexToColumn[dataIndex],
|
|
244
|
+
record.get(dataIndex),
|
|
245
|
+
{column: columnConfig},
|
|
246
|
+
record,
|
|
247
|
+
idx,
|
|
248
|
+
columnIndex,
|
|
249
|
+
grid.getStore(),
|
|
250
|
+
grid.getView()
|
|
251
|
+
) :
|
|
252
|
+
record.data[dataIndex] || '';
|
|
253
|
+
// const stopMeasure1 = Coon.perf.startSerie('getRowStyleXlsx');
|
|
254
|
+
let styles = this.getRowStyleXlsx(grid, record, workbook);
|
|
255
|
+
// stopMeasure1();
|
|
256
|
+
const col = {value: this.getRenderedValue(value, valueType) || ''};
|
|
257
|
+
// const stopMeasure = Coon.perf.startSerie('mergeDeep');
|
|
258
|
+
styles = this.mergeDeep(styles, this.allBordersStyle);
|
|
259
|
+
// stopMeasure();
|
|
260
|
+
if (valueType === 'float') {
|
|
261
|
+
let precision = Number(columnConfig.precision);
|
|
262
|
+
if (!Number.isInteger(precision)) {
|
|
263
|
+
precision = Number(this.getConfig('floatPrecision') || this.defaultFloatPrecision);
|
|
264
|
+
}
|
|
265
|
+
styles = this.mergeDeep(styles, {format: precision !== 0 ? '0.'.padEnd(precision + 2, '0') : '0'});
|
|
266
|
+
if (col['value'].length) {
|
|
267
|
+
col['value'] = parseFloat(col['value'].replace(/\s/g, '').replace(',', '.'));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (this.isNotEmptyStyle(styles)) {
|
|
272
|
+
col['styleId'] = workbook.addCellStyle(styles);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
result.push(JSON.parse(JSON.stringify(col)));
|
|
276
|
+
}, this);
|
|
277
|
+
return result;
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
isNotEmptyStyle (styles) {
|
|
281
|
+
return Object.values(styles).find((el) => {
|
|
282
|
+
if (Ext.isObject(el) && Object.keys(el)[0]) {
|
|
283
|
+
return true;
|
|
284
|
+
} else if (!Ext.isObject(el) && el !== null && el !== undefined) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
},
|
|
289
|
+
});
|
package/src/version.js
CHANGED