ru.coon 2.8.25 → 2.8.26
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,21 @@
|
|
|
1
|
+
# Version 2.8.26, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/e2d42324a8e9948d79584e4f9751f126405ef103)
|
|
2
|
+
* ## Features
|
|
3
|
+
* <span style='color:green'>feat: add style check before addCellStyle</span> ([ff4abf], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/ff4abf157a32ec98720caabafc2f65749b0c98bf))
|
|
4
|
+
|
|
5
|
+
* upd ([009237], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/009237a355c8aa9928fd919b90ff8e9f750db98e))
|
|
6
|
+
* relocate and rename method ([a2a61b], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/a2a61b2a6dcd4d4622becfc2f11602a97c9d49d8))
|
|
7
|
+
* update: CHANGELOG.md ([d4b2c7], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/d4b2c7e1effb2bd46eb587a3d5bf2d03cbc27053))
|
|
8
|
+
|
|
1
9
|
# Version 2.8.25, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0ead4798f8be665c09627567bb8ac2b473d6d429)
|
|
2
10
|
# Version 2.8.24, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/51b87374eb81c47d86d6fa33c8f25eaa9dce5d18)
|
|
11
|
+
* update: CHANGELOG.md ([82435f], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/82435f28e840a46cc9e30ec228a8778c22fc75c4))
|
|
12
|
+
|
|
13
|
+
# Version 2.8.24, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/c4c48ae9746e9698a71cee189e9d4193ee08b0ad)
|
|
14
|
+
* ## Fixes
|
|
15
|
+
* <span style='color:red'> refactoring CopyRowsFromGrid, add Coon.perf</span> ([347b0c], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/347b0c16446273fbe50dcd3a460d8454566355d1))
|
|
16
|
+
|
|
17
|
+
* upd ([148f60], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/148f60ace9a0813d409432b6871721c7f622d369))
|
|
18
|
+
* upd ([8e64dd], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/8e64dd9dcd8af8f4333d69c2bfcfdae7b94ec056))
|
|
3
19
|
* upd ([4091e1], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/4091e19d36ca3b790a53d1b5e0d79addd0146536))
|
|
4
20
|
* update: CHANGELOG.md ([6e87dc], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/6e87dc9719686cca7da70d876ea24da53b2dbe82))
|
|
5
21
|
|
|
@@ -12,6 +28,9 @@
|
|
|
12
28
|
|
|
13
29
|
* upd ([571495], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/571495ffbd6b23c76edd9eac741b87163fc59cdc))
|
|
14
30
|
* add loadFakeData to ReportPanel ([671b7f], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/671b7f27f3538291a56ba8c1b45016910b42e17d))
|
|
31
|
+
* upd ([5f960b], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/5f960b5e19d19540423a3d13bf288b5d4b2149bb))
|
|
32
|
+
* upd ([3f1cb7], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3f1cb7e4e680cfc6a30d92ae0731dcd370be9e4b))
|
|
33
|
+
* upd ([cab5b5], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/cab5b55a9360b8f6cfc5de6f36d31ad961862280))
|
|
15
34
|
* update: CHANGELOG.md ([c73ba4], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/c73ba4e040a66da70edbeb990b8e7d42a690cc1b))
|
|
16
35
|
|
|
17
36
|
# Version 2.8.22, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/abdcd052a504db9e3ef0d640c05c861dab6fc771)
|
|
@@ -25,6 +44,7 @@
|
|
|
25
44
|
* ## Fixes
|
|
26
45
|
* <span style='color:red'>fix builder issues</span> ([67abd4], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/67abd4785b47f62e1004e58ff8c27282d9e87664))
|
|
27
46
|
|
|
47
|
+
* upd ([3d3e6b], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3d3e6b7ea69c8114658f64859038187b16708f66))
|
|
28
48
|
* update: CHANGELOG.md ([866504], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/86650477e9606983c72620ed063150bb23fc3e4e))
|
|
29
49
|
|
|
30
50
|
# 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.26",
|
|
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
|
+
);
|
|
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,59 @@ 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
|
-
|
|
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',
|
|
380
|
+
return Promise.resolve(() => {
|
|
381
|
+
this.generateXls(filename);
|
|
482
382
|
});
|
|
483
|
-
Coon.util.downloadFileFromBlob(blob, filename);
|
|
484
383
|
}
|
|
485
|
-
reportPanel && reportPanel.unmask();
|
|
486
|
-
// console.log(Coon.perf.getLog(stop()));
|
|
487
384
|
},
|
|
488
385
|
|
|
489
386
|
/**
|
|
@@ -491,7 +388,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
491
388
|
* @param fileName имя файла
|
|
492
389
|
* @returns {*}
|
|
493
390
|
*/
|
|
494
|
-
getTemplatedFileName
|
|
391
|
+
getTemplatedFileName(fileName) {
|
|
495
392
|
if (!Ext.isString(fileName) || fileName.match(/{.*}/g) === null) {
|
|
496
393
|
return fileName;
|
|
497
394
|
}
|
|
@@ -505,7 +402,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
505
402
|
return fileName;
|
|
506
403
|
},
|
|
507
404
|
|
|
508
|
-
normalizeFileName
|
|
405
|
+
normalizeFileName(fileName) {
|
|
509
406
|
const forbiddenSymbolMap = {
|
|
510
407
|
underscore: '_',
|
|
511
408
|
space: ' ',
|
|
@@ -534,31 +431,6 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
534
431
|
return fileName;
|
|
535
432
|
},
|
|
536
433
|
|
|
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
434
|
prepareData() {
|
|
563
435
|
let exporterPlugin = this.getCmp().plugins.find(
|
|
564
436
|
(p) => p.ptype === 'gridexporter'
|
|
@@ -570,27 +442,11 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
570
442
|
this.exporter.setData(exporterPlugin.prepareData({includeSummary: this.includeSummary}));
|
|
571
443
|
},
|
|
572
444
|
|
|
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
445
|
/**
|
|
590
446
|
* Возвращает агрегирующие строки из плагина GroupRowsPlugin.
|
|
591
447
|
* Чтобы экспортировать текст, например "Всего" в конфиге колонки должны быть указаны:
|
|
592
448
|
* ```
|
|
593
|
-
* summaryRenderer
|
|
449
|
+
* summaryRenderer(){return 'Всего'},
|
|
594
450
|
* exportSummaryRenderer: true
|
|
595
451
|
* ```
|
|
596
452
|
* @returns {Object[]}
|
|
@@ -659,11 +515,11 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
659
515
|
return row.cells;
|
|
660
516
|
});
|
|
661
517
|
},
|
|
662
|
-
getTitle
|
|
518
|
+
getTitle() {
|
|
663
519
|
return this.addHeader === true ? this.getCmp().up('ReportPanel').title : '';
|
|
664
520
|
},
|
|
665
521
|
|
|
666
|
-
getFilters
|
|
522
|
+
getFilters() {
|
|
667
523
|
const filters = [];
|
|
668
524
|
if (this.addFilters === true) {
|
|
669
525
|
const reportPanel = this.getCmp().up('ReportPanel');
|
|
@@ -695,7 +551,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
695
551
|
return filters;
|
|
696
552
|
},
|
|
697
553
|
|
|
698
|
-
getAdditionalParameters
|
|
554
|
+
getAdditionalParameters() {
|
|
699
555
|
const text = (this.header || '') + (this.footer || '');
|
|
700
556
|
if (Ext.isEmpty(text)) {
|
|
701
557
|
return;
|
|
@@ -716,7 +572,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
716
572
|
return additionalParameters;
|
|
717
573
|
},
|
|
718
574
|
|
|
719
|
-
insertAdditional
|
|
575
|
+
insertAdditional(additionalParameters) {
|
|
720
576
|
let header = this.header;
|
|
721
577
|
let footer = this.footer;
|
|
722
578
|
for (const key in additionalParameters) {
|
|
@@ -732,7 +588,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
732
588
|
this.execute();
|
|
733
589
|
},
|
|
734
590
|
|
|
735
|
-
customInit
|
|
591
|
+
customInit() {
|
|
736
592
|
this.buttonText = this.buttonText || 'Экспорт в Excel';
|
|
737
593
|
this.getCmp().CopyPlugin = this;
|
|
738
594
|
if (this.header) {
|
|
@@ -743,7 +599,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
743
599
|
}
|
|
744
600
|
},
|
|
745
601
|
|
|
746
|
-
addKeyMap
|
|
602
|
+
addKeyMap() {
|
|
747
603
|
if (this.disableCopying) {
|
|
748
604
|
return;
|
|
749
605
|
}
|
|
@@ -751,7 +607,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
751
607
|
{
|
|
752
608
|
key: Ext.event.Event.C,
|
|
753
609
|
ctrl: true,
|
|
754
|
-
handler
|
|
610
|
+
handler() {
|
|
755
611
|
this.copyToClipBoard(this.getSelected());
|
|
756
612
|
},
|
|
757
613
|
scope: this,
|
|
@@ -774,11 +630,11 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
774
630
|
}
|
|
775
631
|
},
|
|
776
632
|
|
|
777
|
-
getAll
|
|
633
|
+
getAll() {
|
|
778
634
|
return this.getCmp().getStore().getRange();
|
|
779
635
|
},
|
|
780
636
|
|
|
781
|
-
collectSelectedRecords
|
|
637
|
+
collectSelectedRecords() {
|
|
782
638
|
const selectionModel = this.getCmp().getSelectionModel();
|
|
783
639
|
const selectedRecords = [];
|
|
784
640
|
this.getCmp().getStore().each(function(record) {
|
|
@@ -794,7 +650,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
794
650
|
return selectedRecords;
|
|
795
651
|
},
|
|
796
652
|
|
|
797
|
-
getSelected
|
|
653
|
+
getSelected() {
|
|
798
654
|
if (this.recordsToExport) {
|
|
799
655
|
return this.recordsToExport;
|
|
800
656
|
}
|
|
@@ -803,7 +659,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
803
659
|
return records ? this.collectSelectedRecords() : this.getAll();
|
|
804
660
|
},
|
|
805
661
|
|
|
806
|
-
copyToClipBoard
|
|
662
|
+
copyToClipBoard(rows) {
|
|
807
663
|
let copiedData = null;
|
|
808
664
|
|
|
809
665
|
if (this.getCmp().getSelectionModel().type === 'cellmodel') {
|
|
@@ -828,7 +684,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
828
684
|
}
|
|
829
685
|
},
|
|
830
686
|
|
|
831
|
-
getStartPosition
|
|
687
|
+
getStartPosition() {
|
|
832
688
|
let startColumn = 0;
|
|
833
689
|
let startRow = 0;
|
|
834
690
|
const selectionModel = this.getCmp().getSelectionModel();
|
|
@@ -847,7 +703,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
847
703
|
return {row: startRow, column: startColumn};
|
|
848
704
|
},
|
|
849
705
|
|
|
850
|
-
pasteFromClipBoard
|
|
706
|
+
pasteFromClipBoard() {
|
|
851
707
|
if (!this.allowPaste) {
|
|
852
708
|
return;
|
|
853
709
|
}
|
|
@@ -856,7 +712,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
856
712
|
hiddenTextArea.focus();
|
|
857
713
|
},
|
|
858
714
|
|
|
859
|
-
updateGridData
|
|
715
|
+
updateGridData() {
|
|
860
716
|
if (!this.allowPaste) {
|
|
861
717
|
return;
|
|
862
718
|
}
|
|
@@ -934,7 +790,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
934
790
|
this.hiddentextarea.blur();
|
|
935
791
|
},
|
|
936
792
|
|
|
937
|
-
clearValue
|
|
793
|
+
clearValue(value, type, convert, record) {
|
|
938
794
|
let columnValue = value;
|
|
939
795
|
if (!Ext.isEmpty(type)) {
|
|
940
796
|
switch (type) {
|
|
@@ -965,7 +821,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
965
821
|
* @param tableHeaderRows
|
|
966
822
|
* @returns {*[]}
|
|
967
823
|
*/
|
|
968
|
-
collectGridDataAsArray
|
|
824
|
+
collectGridDataAsArray(selections, tableHeaderRows = []) {
|
|
969
825
|
const result = [];
|
|
970
826
|
const grid = this.getCmp();
|
|
971
827
|
const columnCount = grid.getColumns().length;
|
|
@@ -993,7 +849,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
993
849
|
result.push(this.applyTemplate(html, this.getDataForTemplate(html)));
|
|
994
850
|
}
|
|
995
851
|
// собираем заголовки
|
|
996
|
-
const dataIndexToColumn =
|
|
852
|
+
const dataIndexToColumn = {};
|
|
997
853
|
const visibleColumns = [];
|
|
998
854
|
const columnIndexToDataIndex = [];
|
|
999
855
|
const columnModel = grid.getColumns();
|
|
@@ -1038,12 +894,21 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1038
894
|
});
|
|
1039
895
|
}
|
|
1040
896
|
let chunk = '';
|
|
1041
|
-
|
|
897
|
+
this.localData = {
|
|
898
|
+
grid,
|
|
899
|
+
visibleColumns,
|
|
900
|
+
columnIndexToDataIndex,
|
|
901
|
+
columnModel,
|
|
902
|
+
dataIndexToColumn,
|
|
903
|
+
};
|
|
904
|
+
selections.forEach(function(record, idx) {
|
|
1042
905
|
const row = [];
|
|
1043
|
-
row.push(
|
|
906
|
+
row.push(
|
|
907
|
+
this.collectColumns({record, idx})
|
|
908
|
+
);
|
|
1044
909
|
chunk += row.join('');
|
|
1045
910
|
// Через this.rowsInChunk строк сгружаем данные в массив
|
|
1046
|
-
if (
|
|
911
|
+
if (idx % this.rowsInChunk === 0 || idx === selections.length - 1) {
|
|
1047
912
|
result.push(chunk);
|
|
1048
913
|
chunk = '';
|
|
1049
914
|
}
|
|
@@ -1062,7 +927,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1062
927
|
* Формируем заголовок
|
|
1063
928
|
* @returns {string}
|
|
1064
929
|
*/
|
|
1065
|
-
collectHeader
|
|
930
|
+
collectHeader() {
|
|
1066
931
|
const reportPanel = this.getCmp().up('ReportPanel');
|
|
1067
932
|
let result = '';
|
|
1068
933
|
// Работа с отображением выгрузок
|
|
@@ -1077,7 +942,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1077
942
|
* Собираем фильтры
|
|
1078
943
|
* @returns {string}
|
|
1079
944
|
*/
|
|
1080
|
-
collectFilters
|
|
945
|
+
collectFilters() {
|
|
1081
946
|
const reportPanel = this.getCmp().up('ReportPanel');
|
|
1082
947
|
let name = '';
|
|
1083
948
|
const result = [];
|
|
@@ -1120,20 +985,9 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1120
985
|
* Собираем поля
|
|
1121
986
|
* @returns {string}
|
|
1122
987
|
*/
|
|
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
|
-
};
|
|
988
|
+
collectColumns({record, idx, xlsx}) {
|
|
989
|
+
const {grid, visibleColumns, columnIndexToDataIndex, columnModel, dataIndexToColumn, workbook} = this.localData;
|
|
990
|
+
const result = xlsx ? [] : ['<tr>'];
|
|
1137
991
|
visibleColumns.forEach(function(columnIndex) {
|
|
1138
992
|
const columnConfig = columnModel[columnIndex];
|
|
1139
993
|
if (columnConfig.ignoreExport) {
|
|
@@ -1143,7 +997,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1143
997
|
const dataIndex = columnIndexToDataIndex[columnIndex];
|
|
1144
998
|
const renderer = columnConfig.renderer;
|
|
1145
999
|
const exportRenderer = columnConfig.exportRenderer;
|
|
1146
|
-
const valueType = getValueType(dataIndex, 'string');
|
|
1000
|
+
const valueType = this.localData.fieldTypes.get(dataIndex);// getValueType(dataIndex, 'string');
|
|
1147
1001
|
|
|
1148
1002
|
|
|
1149
1003
|
const value = typeof (exportRenderer || renderer) === 'function' ?
|
|
@@ -1152,13 +1006,13 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1152
1006
|
record.get(dataIndex),
|
|
1153
1007
|
{column: columnConfig},
|
|
1154
1008
|
record,
|
|
1155
|
-
|
|
1009
|
+
idx,
|
|
1156
1010
|
columnIndex,
|
|
1157
1011
|
grid.getStore(),
|
|
1158
1012
|
grid.getView()
|
|
1159
1013
|
) :
|
|
1160
1014
|
record.data[dataIndex] || '';
|
|
1161
|
-
if (!
|
|
1015
|
+
if (!xlsx) {
|
|
1162
1016
|
const styles = this.getRowStyle(grid, record);
|
|
1163
1017
|
result.push(`
|
|
1164
1018
|
<td
|
|
@@ -1187,14 +1041,15 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1187
1041
|
result.push(JSON.parse(JSON.stringify(col)));
|
|
1188
1042
|
}
|
|
1189
1043
|
}, this);
|
|
1190
|
-
if (!
|
|
1044
|
+
if (!xlsx) {
|
|
1191
1045
|
result.push('</tr>');
|
|
1192
1046
|
return result.join('');
|
|
1193
1047
|
} else {
|
|
1194
1048
|
return result;
|
|
1195
1049
|
}
|
|
1196
1050
|
},
|
|
1197
|
-
|
|
1051
|
+
|
|
1052
|
+
getRowStyleXlsx(grid, record) {
|
|
1198
1053
|
let styles = {};
|
|
1199
1054
|
const rowElement = Ext.fly(grid.getView().getRow(grid.getStore().indexOf(record)));
|
|
1200
1055
|
if (rowElement) {
|
|
@@ -1211,7 +1066,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1211
1066
|
|
|
1212
1067
|
return {styles: styles};
|
|
1213
1068
|
},
|
|
1214
|
-
getRowStyle
|
|
1069
|
+
getRowStyle(grid, record) {
|
|
1215
1070
|
const rowElement = Ext.fly(grid.getView().getRow(grid.getStore().indexOf(record)));
|
|
1216
1071
|
|
|
1217
1072
|
let resultClasses = '';
|
|
@@ -1242,7 +1097,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1242
1097
|
return resultClasses;
|
|
1243
1098
|
},
|
|
1244
1099
|
|
|
1245
|
-
getHeaderStyle
|
|
1100
|
+
getHeaderStyle(value, type) {
|
|
1246
1101
|
let style = '';
|
|
1247
1102
|
if (!Ext.isEmpty(type)) {
|
|
1248
1103
|
switch (type) {
|
|
@@ -1254,7 +1109,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1254
1109
|
return style;
|
|
1255
1110
|
},
|
|
1256
1111
|
|
|
1257
|
-
getCellClass
|
|
1112
|
+
getCellClass(value, type) {
|
|
1258
1113
|
let style = '';
|
|
1259
1114
|
if (!Ext.isEmpty(type)) {
|
|
1260
1115
|
switch (type) {
|
|
@@ -1270,7 +1125,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1270
1125
|
}
|
|
1271
1126
|
return style;
|
|
1272
1127
|
},
|
|
1273
|
-
getRenderedValue
|
|
1128
|
+
getRenderedValue(v, type) {
|
|
1274
1129
|
let value = v;
|
|
1275
1130
|
if (v instanceof Date) {
|
|
1276
1131
|
value = Ext.util.Format.dateRenderer(this.dateFormat)(v);
|
|
@@ -1301,7 +1156,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1301
1156
|
return value;
|
|
1302
1157
|
},
|
|
1303
1158
|
|
|
1304
|
-
getHiddenTextArea
|
|
1159
|
+
getHiddenTextArea() {
|
|
1305
1160
|
if (!this.hiddentextarea) {
|
|
1306
1161
|
this.hiddentextarea = new Ext.Element(document.createElement('textarea'));
|
|
1307
1162
|
this.hiddentextarea.setStyle('position', 'absolute');
|
|
@@ -1315,7 +1170,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1315
1170
|
return this.hiddentextarea;
|
|
1316
1171
|
},
|
|
1317
1172
|
|
|
1318
|
-
tryToGetTitle
|
|
1173
|
+
tryToGetTitle() {
|
|
1319
1174
|
let title = this.getCmp().title || '';
|
|
1320
1175
|
if (Ext.isEmpty(title)) {
|
|
1321
1176
|
this.getCmp().bubble(function(panel) {
|
|
@@ -1329,7 +1184,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1329
1184
|
},
|
|
1330
1185
|
|
|
1331
1186
|
// Получение параметров шаблонов
|
|
1332
|
-
getDataForTemplate
|
|
1187
|
+
getDataForTemplate(text) {
|
|
1333
1188
|
if (Ext.isEmpty(text)) {
|
|
1334
1189
|
return {};
|
|
1335
1190
|
}
|
|
@@ -1374,7 +1229,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1374
1229
|
},
|
|
1375
1230
|
|
|
1376
1231
|
// Обработка шаблона
|
|
1377
|
-
processingTemplate
|
|
1232
|
+
processingTemplate(template) {
|
|
1378
1233
|
let result = '' + template;
|
|
1379
1234
|
this.getParametersForReplace().forEach(function(p) {
|
|
1380
1235
|
result = result.replace(new RegExp(p.re, 'g'), p.getHandler.call(this));
|
|
@@ -1388,12 +1243,12 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1388
1243
|
* re - регулярное выражения для поиска параметра
|
|
1389
1244
|
* getHandler - функция, возвращающая функцию замены
|
|
1390
1245
|
*/
|
|
1391
|
-
getParametersForReplace
|
|
1246
|
+
getParametersForReplace() {
|
|
1392
1247
|
if (Ext.isEmpty(this.parametersForReplace)) {
|
|
1393
1248
|
this.parametersForReplace = [
|
|
1394
1249
|
{
|
|
1395
1250
|
re: '\\{\\$\\w[\\w ,\\\\/.:-]*\\$\\}', // Даты в виде {$формат_даты$}
|
|
1396
|
-
getHandler
|
|
1251
|
+
getHandler() {
|
|
1397
1252
|
const date = new Date();
|
|
1398
1253
|
return function(m) {
|
|
1399
1254
|
return Ext.Date.format(date, m.substring(2, m.length - 2));
|
|
@@ -1402,7 +1257,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1402
1257
|
},
|
|
1403
1258
|
{
|
|
1404
1259
|
re: '\\{\\$\\w[\\w-]*(?!\\$)\\}', // Прочие параметры в виде {$имя_параметра}
|
|
1405
|
-
getHandler
|
|
1260
|
+
getHandler() {
|
|
1406
1261
|
const params = {
|
|
1407
1262
|
REPORT_TITLE: this.tryToGetTitle(),
|
|
1408
1263
|
};
|
|
@@ -1416,7 +1271,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1416
1271
|
return this.parametersForReplace;
|
|
1417
1272
|
},
|
|
1418
1273
|
|
|
1419
|
-
parseHTML
|
|
1274
|
+
parseHTML(htmlString) {
|
|
1420
1275
|
const div = document.createElement('div');
|
|
1421
1276
|
div.innerHTML = htmlString.split('body>')[1] && htmlString.split('body>')[1].slice(0, -2);
|
|
1422
1277
|
const result = [];
|
|
@@ -1430,13 +1285,12 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
|
|
|
1430
1285
|
return result.join('\n');
|
|
1431
1286
|
},
|
|
1432
1287
|
|
|
1433
|
-
getPluginCustomPropsForFields
|
|
1288
|
+
getPluginCustomPropsForFields() {
|
|
1434
1289
|
return [{
|
|
1435
1290
|
name: 'exportRenderer',
|
|
1436
1291
|
description: 'Данное свойство позволяет обработать итоговые строки',
|
|
1437
1292
|
type: 'function',
|
|
1438
1293
|
fields: 'all',
|
|
1439
1294
|
}];
|
|
1440
|
-
}
|
|
1441
|
-
,
|
|
1295
|
+
},
|
|
1442
1296
|
});
|
|
@@ -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