ru.coon 2.8.24 → 2.8.25

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,9 +1,5 @@
1
- # Version 2.8.24, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/c4c48ae9746e9698a71cee189e9d4193ee08b0ad)
2
- * ## Fixes
3
- * <span style='color:red'> refactoring CopyRowsFromGrid, add Coon.perf</span> ([347b0c], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/347b0c16446273fbe50dcd3a460d8454566355d1))
4
-
5
- * upd ([148f60], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/148f60ace9a0813d409432b6871721c7f622d369))
6
- * upd ([8e64dd], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/8e64dd9dcd8af8f4333d69c2bfcfdae7b94ec056))
1
+ # Version 2.8.25, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0ead4798f8be665c09627567bb8ac2b473d6d429)
2
+ # Version 2.8.24, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/51b87374eb81c47d86d6fa33c8f25eaa9dce5d18)
7
3
  * upd ([4091e1], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/4091e19d36ca3b790a53d1b5e0d79addd0146536))
8
4
  * update: CHANGELOG.md ([6e87dc], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/6e87dc9719686cca7da70d876ea24da53b2dbe82))
9
5
 
@@ -16,9 +12,6 @@
16
12
 
17
13
  * upd ([571495], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/571495ffbd6b23c76edd9eac741b87163fc59cdc))
18
14
  * add loadFakeData to ReportPanel ([671b7f], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/671b7f27f3538291a56ba8c1b45016910b42e17d))
19
- * upd ([5f960b], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/5f960b5e19d19540423a3d13bf288b5d4b2149bb))
20
- * upd ([3f1cb7], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3f1cb7e4e680cfc6a30d92ae0731dcd370be9e4b))
21
- * upd ([cab5b5], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/cab5b55a9360b8f6cfc5de6f36d31ad961862280))
22
15
  * update: CHANGELOG.md ([c73ba4], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/c73ba4e040a66da70edbeb990b8e7d42a690cc1b))
23
16
 
24
17
  # Version 2.8.22, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/abdcd052a504db9e3ef0d640c05c861dab6fc771)
@@ -32,7 +25,6 @@
32
25
  * ## Fixes
33
26
  * <span style='color:red'>fix builder issues</span> ([67abd4], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/67abd4785b47f62e1004e58ff8c27282d9e87664))
34
27
 
35
- * upd ([3d3e6b], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3d3e6b7ea69c8114658f64859038187b16708f66))
36
28
  * update: CHANGELOG.md ([866504], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/86650477e9606983c72620ed063150bb23fc3e4e))
37
29
 
38
30
  # Version 2.8.21, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/dcc7c4b24a73690b18533027979c7ed0e3c88a78)
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as xEchartsJs from 'echarts';
2
- import xPrintJs from 'sigma-printjs';
2
+ import xPrintJs from 'sigma-printjs/dist/print';
3
3
  import xAceDiff from 'ace-diff';
4
4
  import hashFromObj from 'object-hash';
5
5
  import xAceEditor from 'ace-builds/src-noconflict/ace';
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "ru.coon"
5
5
  },
6
6
  "description": "",
7
- "version": "2.8.24",
7
+ "version": "2.8.25",
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.3",
33
+ "sigma-printjs": "^1.0.1",
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 = 1000) {
306
306
  if (!this.isConfigured) {
307
307
  return;
308
308
  }
@@ -405,6 +405,12 @@ Ext.define('Coon.report.component.ReportPanel', {
405
405
  this.on('invalidateCache', this.filterHandler.bind(this, true));
406
406
  },
407
407
 
408
+ onDestroy: function() {
409
+ if (this.eventDestroier) {
410
+ // Ext.destroy(this.eventDestroier)
411
+ }
412
+ },
413
+
408
414
  onWindowResize: function(width, height) {
409
415
  this.height = this.height || height - 105;
410
416
  this.width = this.width || width - 270;
@@ -2,15 +2,12 @@ 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: [
6
- 'Coon.report.plugin.grid.exporters.xlsxExporter'
7
- ],
5
+ requires: [],
8
6
  alternateClassName: [
9
7
  'Sigma.common.grid.plugin.CopyRowsFromGrid',
10
8
  'Sigma.common.plugin.grid.CopyRowsFromGrid'
11
9
  ],
12
10
  defaultFloatPrecision: 2,
13
- defaultFieldType: 'string',
14
11
  configurePanelWizard: 'CopyRowsFromGridConfigPanel',
15
12
  position: -1,
16
13
  allowAddRowOnPaste: false,
@@ -90,10 +87,9 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
90
87
  `;
91
88
  },
92
89
 
93
- init(component) {
90
+ init: function(component) {
94
91
  this.injectForm();
95
92
  this.callParent([component]);
96
- this.reportPanel = this.getCmp().up('ReportPanel');
97
93
  component.on('reconfigure', function(grid, store, columns) {
98
94
  this.getCmp().store = store;
99
95
  this.getCmp().columns = columns;
@@ -101,7 +97,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
101
97
  Object.assign(this.tableHeaderStyle || {}, this.allBordersStyle);
102
98
  },
103
99
 
104
- createToolbarItem(config) {
100
+ createToolbarItem: function(config) {
105
101
  let tbItem = this.callParent([config]);
106
102
  if (this.showConfirmDialog) {
107
103
  tbItem = new Ext.button.Split(Ext.apply({
@@ -129,7 +125,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
129
125
  return tbItem;
130
126
  },
131
127
 
132
- handler(button) {
128
+ handler: function(button) {
133
129
  this.recordsToExport = undefined;
134
130
  if (button.itemId === 'getAllButton' || (button.itemId !== 'getSelectedButton' && this.exportAllRows)) {
135
131
  this.recordsToExport = this.getAll();
@@ -151,7 +147,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
151
147
  }
152
148
  },
153
149
 
154
- showConfirmFormatDialog(fn) {
150
+ showConfirmFormatDialog: function(fn) {
155
151
  const formatSelectField = Ext.create(Coon.common.field.combo.ConstantList, {
156
152
  data: [
157
153
  ['xls', 'xls - старый формат'],
@@ -179,14 +175,14 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
179
175
  buttons: [
180
176
  {
181
177
  text: this.buttonText,
182
- handler() {
178
+ handler: function() {
183
179
  fn(formatSelectField.getValue());
184
180
  win.close();
185
181
  },
186
182
  },
187
183
  {
188
184
  text: 'Закрыть',
189
- handler() {
185
+ handler: function() {
190
186
  win.close();
191
187
  },
192
188
  }
@@ -195,15 +191,14 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
195
191
  );
196
192
  win.show();
197
193
  },
198
-
199
- rgbToHex(arr) {
194
+ rgbToHex: function(arr) {
200
195
  return '#' + arr.map((x) => {
201
196
  const hex = Number(x).toString(16);
202
197
  return hex.length === 1 ? '0' + hex : hex;
203
198
  }).join('');
204
199
  },
205
200
 
206
- mergeDeep(target, ...sources) {
201
+ mergeDeep: function(target, ...sources) {
207
202
  if (!sources.length) {
208
203
  return target;
209
204
  }
@@ -226,7 +221,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
226
221
  },
227
222
 
228
223
  getCurrentFilterParameters() {
229
- return this.reportPanel.currentParamList || {};
224
+ return this.getCmp().up('ReportPanel').currentParamList || {};
230
225
  },
231
226
 
232
227
  applyTemplate(content = '', data = {}) {
@@ -239,7 +234,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
239
234
  return tpl.apply(Object.assign(data, {parameters: this.getCurrentFilterParameters()}));
240
235
  },
241
236
 
242
- parseJsEditorObj(obj, workbook) {
237
+ parseJsEditorObj: function(obj, workbook) {
243
238
  if (typeof obj !== 'object' || !obj.blocks || !obj.blocks.length) {
244
239
  return [];
245
240
  }
@@ -301,21 +296,161 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
301
296
  );
302
297
  return result;
303
298
  },
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
+ },
304
321
 
305
- execute() {
306
- this.reportPanel && this.reportPanel.mask('Экспорт', 'x-mask-loading');
307
- this.generateExport()
308
- .then(
309
- () => this.reportPanel && this.reportPanel.unmask()
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)
310
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
+
440
+ execute() {
441
+ const reportPanel = this.getCmp().up('ReportPanel');
442
+ reportPanel && reportPanel.mask('Экспорт', 'x-mask-loading');
443
+ Ext.defer(this.generateExport, 1, this);
311
444
  },
312
445
 
313
- getFilename() {
446
+ generateExport: function() {
447
+ // const stop = Coon.perf.start('CPFG');
448
+ const reportPanel = this.getCmp().up('ReportPanel');
314
449
  const selected = this.getSelected()[0];
315
450
  const name = this.getTemplatedFileName(this.reportFileName) ||
316
451
  (selected && selected.data['CM_REPORT_CD']) ||
317
452
  this.tryToGetTitle() ||
318
- (this.reportPanel && this.reportPanel.reportId) ||
453
+ (reportPanel && reportPanel.reportId) ||
319
454
  'defaultReportName';
320
455
  const dateFormat = this.dateFormat || this.defaultDateFormat;
321
456
 
@@ -328,59 +463,27 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
328
463
  filename += '_';
329
464
  filename += Ext.Date.format(new Date(), dateFormat);
330
465
  }
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();
466
+ filename = this.normalizeFileName(filename);
373
467
 
374
468
  if (this.format === 'xlsx') {
375
- return this.generateXlsx(filename);
376
- // .then(() => {
377
- // Coon.log.debug(Coon.perf.getLog(stop()));
378
- // });
469
+ const exporter = this.initExporter(filename);
470
+ exporter.saveAs().then(function() {
471
+ exporter.destroy();
472
+ });
379
473
  } else {
380
- return Promise.resolve(() => {
381
- this.generateXls(filename);
474
+ filename += '.xls';
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',
382
482
  });
483
+ Coon.util.downloadFileFromBlob(blob, filename);
383
484
  }
485
+ reportPanel && reportPanel.unmask();
486
+ // console.log(Coon.perf.getLog(stop()));
384
487
  },
385
488
 
386
489
  /**
@@ -388,7 +491,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
388
491
  * @param fileName имя файла
389
492
  * @returns {*}
390
493
  */
391
- getTemplatedFileName(fileName) {
494
+ getTemplatedFileName: function(fileName) {
392
495
  if (!Ext.isString(fileName) || fileName.match(/{.*}/g) === null) {
393
496
  return fileName;
394
497
  }
@@ -402,7 +505,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
402
505
  return fileName;
403
506
  },
404
507
 
405
- normalizeFileName(fileName) {
508
+ normalizeFileName: function(fileName) {
406
509
  const forbiddenSymbolMap = {
407
510
  underscore: '_',
408
511
  space: ' ',
@@ -431,6 +534,31 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
431
534
  return fileName;
432
535
  },
433
536
 
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
+
434
562
  prepareData() {
435
563
  let exporterPlugin = this.getCmp().plugins.find(
436
564
  (p) => p.ptype === 'gridexporter'
@@ -442,11 +570,27 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
442
570
  this.exporter.setData(exporterPlugin.prepareData({includeSummary: this.includeSummary}));
443
571
  },
444
572
 
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
+ },
445
589
  /**
446
590
  * Возвращает агрегирующие строки из плагина GroupRowsPlugin.
447
591
  * Чтобы экспортировать текст, например "Всего" в конфиге колонки должны быть указаны:
448
592
  * ```
449
- * summaryRenderer(){return 'Всего'},
593
+ * summaryRenderer: function(){return 'Всего'},
450
594
  * exportSummaryRenderer: true
451
595
  * ```
452
596
  * @returns {Object[]}
@@ -515,11 +659,11 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
515
659
  return row.cells;
516
660
  });
517
661
  },
518
- getTitle() {
662
+ getTitle: function() {
519
663
  return this.addHeader === true ? this.getCmp().up('ReportPanel').title : '';
520
664
  },
521
665
 
522
- getFilters() {
666
+ getFilters: function() {
523
667
  const filters = [];
524
668
  if (this.addFilters === true) {
525
669
  const reportPanel = this.getCmp().up('ReportPanel');
@@ -551,7 +695,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
551
695
  return filters;
552
696
  },
553
697
 
554
- getAdditionalParameters() {
698
+ getAdditionalParameters: function() {
555
699
  const text = (this.header || '') + (this.footer || '');
556
700
  if (Ext.isEmpty(text)) {
557
701
  return;
@@ -572,7 +716,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
572
716
  return additionalParameters;
573
717
  },
574
718
 
575
- insertAdditional(additionalParameters) {
719
+ insertAdditional: function(additionalParameters) {
576
720
  let header = this.header;
577
721
  let footer = this.footer;
578
722
  for (const key in additionalParameters) {
@@ -588,7 +732,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
588
732
  this.execute();
589
733
  },
590
734
 
591
- customInit() {
735
+ customInit: function() {
592
736
  this.buttonText = this.buttonText || 'Экспорт в Excel';
593
737
  this.getCmp().CopyPlugin = this;
594
738
  if (this.header) {
@@ -599,7 +743,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
599
743
  }
600
744
  },
601
745
 
602
- addKeyMap() {
746
+ addKeyMap: function() {
603
747
  if (this.disableCopying) {
604
748
  return;
605
749
  }
@@ -607,7 +751,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
607
751
  {
608
752
  key: Ext.event.Event.C,
609
753
  ctrl: true,
610
- handler() {
754
+ handler: function() {
611
755
  this.copyToClipBoard(this.getSelected());
612
756
  },
613
757
  scope: this,
@@ -630,11 +774,11 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
630
774
  }
631
775
  },
632
776
 
633
- getAll() {
777
+ getAll: function() {
634
778
  return this.getCmp().getStore().getRange();
635
779
  },
636
780
 
637
- collectSelectedRecords() {
781
+ collectSelectedRecords: function() {
638
782
  const selectionModel = this.getCmp().getSelectionModel();
639
783
  const selectedRecords = [];
640
784
  this.getCmp().getStore().each(function(record) {
@@ -650,7 +794,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
650
794
  return selectedRecords;
651
795
  },
652
796
 
653
- getSelected() {
797
+ getSelected: function() {
654
798
  if (this.recordsToExport) {
655
799
  return this.recordsToExport;
656
800
  }
@@ -659,7 +803,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
659
803
  return records ? this.collectSelectedRecords() : this.getAll();
660
804
  },
661
805
 
662
- copyToClipBoard(rows) {
806
+ copyToClipBoard: function(rows) {
663
807
  let copiedData = null;
664
808
 
665
809
  if (this.getCmp().getSelectionModel().type === 'cellmodel') {
@@ -684,7 +828,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
684
828
  }
685
829
  },
686
830
 
687
- getStartPosition() {
831
+ getStartPosition: function() {
688
832
  let startColumn = 0;
689
833
  let startRow = 0;
690
834
  const selectionModel = this.getCmp().getSelectionModel();
@@ -703,7 +847,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
703
847
  return {row: startRow, column: startColumn};
704
848
  },
705
849
 
706
- pasteFromClipBoard() {
850
+ pasteFromClipBoard: function() {
707
851
  if (!this.allowPaste) {
708
852
  return;
709
853
  }
@@ -712,7 +856,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
712
856
  hiddenTextArea.focus();
713
857
  },
714
858
 
715
- updateGridData() {
859
+ updateGridData: function() {
716
860
  if (!this.allowPaste) {
717
861
  return;
718
862
  }
@@ -790,7 +934,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
790
934
  this.hiddentextarea.blur();
791
935
  },
792
936
 
793
- clearValue(value, type, convert, record) {
937
+ clearValue: function(value, type, convert, record) {
794
938
  let columnValue = value;
795
939
  if (!Ext.isEmpty(type)) {
796
940
  switch (type) {
@@ -821,7 +965,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
821
965
  * @param tableHeaderRows
822
966
  * @returns {*[]}
823
967
  */
824
- collectGridDataAsArray(selections, tableHeaderRows = []) {
968
+ collectGridDataAsArray: function(selections, tableHeaderRows = []) {
825
969
  const result = [];
826
970
  const grid = this.getCmp();
827
971
  const columnCount = grid.getColumns().length;
@@ -849,7 +993,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
849
993
  result.push(this.applyTemplate(html, this.getDataForTemplate(html)));
850
994
  }
851
995
  // собираем заголовки
852
- const dataIndexToColumn = {};
996
+ const dataIndexToColumn = [];
853
997
  const visibleColumns = [];
854
998
  const columnIndexToDataIndex = [];
855
999
  const columnModel = grid.getColumns();
@@ -894,21 +1038,12 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
894
1038
  });
895
1039
  }
896
1040
  let chunk = '';
897
- this.localData = {
898
- grid,
899
- visibleColumns,
900
- columnIndexToDataIndex,
901
- columnModel,
902
- dataIndexToColumn,
903
- };
904
- selections.forEach(function(record, idx) {
1041
+ selections.forEach(function(record, i) {
905
1042
  const row = [];
906
- row.push(
907
- this.collectColumns({record, idx})
908
- );
1043
+ row.push(this.collectColumns(grid, record, visibleColumns, columnIndexToDataIndex, columnModel, dataIndexToColumn, i));
909
1044
  chunk += row.join('');
910
1045
  // Через this.rowsInChunk строк сгружаем данные в массив
911
- if (idx % this.rowsInChunk === 0 || idx === selections.length - 1) {
1046
+ if (i % this.rowsInChunk === 0 || i === selections.length - 1) {
912
1047
  result.push(chunk);
913
1048
  chunk = '';
914
1049
  }
@@ -927,7 +1062,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
927
1062
  * Формируем заголовок
928
1063
  * @returns {string}
929
1064
  */
930
- collectHeader() {
1065
+ collectHeader: function() {
931
1066
  const reportPanel = this.getCmp().up('ReportPanel');
932
1067
  let result = '';
933
1068
  // Работа с отображением выгрузок
@@ -942,7 +1077,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
942
1077
  * Собираем фильтры
943
1078
  * @returns {string}
944
1079
  */
945
- collectFilters() {
1080
+ collectFilters: function() {
946
1081
  const reportPanel = this.getCmp().up('ReportPanel');
947
1082
  let name = '';
948
1083
  const result = [];
@@ -985,9 +1120,20 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
985
1120
  * Собираем поля
986
1121
  * @returns {string}
987
1122
  */
988
- collectColumns({record, idx, xlsx}) {
989
- const {grid, visibleColumns, columnIndexToDataIndex, columnModel, dataIndexToColumn, workbook} = this.localData;
990
- const result = xlsx ? [] : ['<tr>'];
1123
+ collectColumns: function(grid, record, visibleColumns, columnIndexToDataIndex, columnModel, dataIndexToColumn, i, object, workbook) {
1124
+ const result = object ? [] : ['<tr>'];
1125
+ const getValueType = function(idx, defValue) {
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
1137
  visibleColumns.forEach(function(columnIndex) {
992
1138
  const columnConfig = columnModel[columnIndex];
993
1139
  if (columnConfig.ignoreExport) {
@@ -997,7 +1143,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
997
1143
  const dataIndex = columnIndexToDataIndex[columnIndex];
998
1144
  const renderer = columnConfig.renderer;
999
1145
  const exportRenderer = columnConfig.exportRenderer;
1000
- const valueType = this.localData.fieldTypes.get(dataIndex);// getValueType(dataIndex, 'string');
1146
+ const valueType = getValueType(dataIndex, 'string');
1001
1147
 
1002
1148
 
1003
1149
  const value = typeof (exportRenderer || renderer) === 'function' ?
@@ -1006,13 +1152,13 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1006
1152
  record.get(dataIndex),
1007
1153
  {column: columnConfig},
1008
1154
  record,
1009
- idx,
1155
+ i,
1010
1156
  columnIndex,
1011
1157
  grid.getStore(),
1012
1158
  grid.getView()
1013
1159
  ) :
1014
1160
  record.data[dataIndex] || '';
1015
- if (!xlsx) {
1161
+ if (!object) {
1016
1162
  const styles = this.getRowStyle(grid, record);
1017
1163
  result.push(`
1018
1164
  <td
@@ -1041,15 +1187,14 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1041
1187
  result.push(JSON.parse(JSON.stringify(col)));
1042
1188
  }
1043
1189
  }, this);
1044
- if (!xlsx) {
1190
+ if (!object) {
1045
1191
  result.push('</tr>');
1046
1192
  return result.join('');
1047
1193
  } else {
1048
1194
  return result;
1049
1195
  }
1050
1196
  },
1051
-
1052
- getRowStyleXlsx(grid, record) {
1197
+ getRowStyleXlsx: function(grid, record, workbook) {
1053
1198
  let styles = {};
1054
1199
  const rowElement = Ext.fly(grid.getView().getRow(grid.getStore().indexOf(record)));
1055
1200
  if (rowElement) {
@@ -1066,7 +1211,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1066
1211
 
1067
1212
  return {styles: styles};
1068
1213
  },
1069
- getRowStyle(grid, record) {
1214
+ getRowStyle: function(grid, record) {
1070
1215
  const rowElement = Ext.fly(grid.getView().getRow(grid.getStore().indexOf(record)));
1071
1216
 
1072
1217
  let resultClasses = '';
@@ -1097,7 +1242,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1097
1242
  return resultClasses;
1098
1243
  },
1099
1244
 
1100
- getHeaderStyle(value, type) {
1245
+ getHeaderStyle: function(value, type) {
1101
1246
  let style = '';
1102
1247
  if (!Ext.isEmpty(type)) {
1103
1248
  switch (type) {
@@ -1109,7 +1254,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1109
1254
  return style;
1110
1255
  },
1111
1256
 
1112
- getCellClass(value, type) {
1257
+ getCellClass: function(value, type) {
1113
1258
  let style = '';
1114
1259
  if (!Ext.isEmpty(type)) {
1115
1260
  switch (type) {
@@ -1125,7 +1270,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1125
1270
  }
1126
1271
  return style;
1127
1272
  },
1128
- getRenderedValue(v, type) {
1273
+ getRenderedValue: function(v, type) {
1129
1274
  let value = v;
1130
1275
  if (v instanceof Date) {
1131
1276
  value = Ext.util.Format.dateRenderer(this.dateFormat)(v);
@@ -1156,7 +1301,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1156
1301
  return value;
1157
1302
  },
1158
1303
 
1159
- getHiddenTextArea() {
1304
+ getHiddenTextArea: function() {
1160
1305
  if (!this.hiddentextarea) {
1161
1306
  this.hiddentextarea = new Ext.Element(document.createElement('textarea'));
1162
1307
  this.hiddentextarea.setStyle('position', 'absolute');
@@ -1170,7 +1315,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1170
1315
  return this.hiddentextarea;
1171
1316
  },
1172
1317
 
1173
- tryToGetTitle() {
1318
+ tryToGetTitle: function() {
1174
1319
  let title = this.getCmp().title || '';
1175
1320
  if (Ext.isEmpty(title)) {
1176
1321
  this.getCmp().bubble(function(panel) {
@@ -1184,7 +1329,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1184
1329
  },
1185
1330
 
1186
1331
  // Получение параметров шаблонов
1187
- getDataForTemplate(text) {
1332
+ getDataForTemplate: function(text) {
1188
1333
  if (Ext.isEmpty(text)) {
1189
1334
  return {};
1190
1335
  }
@@ -1229,7 +1374,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1229
1374
  },
1230
1375
 
1231
1376
  // Обработка шаблона
1232
- processingTemplate(template) {
1377
+ processingTemplate: function(template) {
1233
1378
  let result = '' + template;
1234
1379
  this.getParametersForReplace().forEach(function(p) {
1235
1380
  result = result.replace(new RegExp(p.re, 'g'), p.getHandler.call(this));
@@ -1243,12 +1388,12 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1243
1388
  * re - регулярное выражения для поиска параметра
1244
1389
  * getHandler - функция, возвращающая функцию замены
1245
1390
  */
1246
- getParametersForReplace() {
1391
+ getParametersForReplace: function() {
1247
1392
  if (Ext.isEmpty(this.parametersForReplace)) {
1248
1393
  this.parametersForReplace = [
1249
1394
  {
1250
1395
  re: '\\{\\$\\w[\\w ,\\\\/.:-]*\\$\\}', // Даты в виде {$формат_даты$}
1251
- getHandler() {
1396
+ getHandler: function() {
1252
1397
  const date = new Date();
1253
1398
  return function(m) {
1254
1399
  return Ext.Date.format(date, m.substring(2, m.length - 2));
@@ -1257,7 +1402,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1257
1402
  },
1258
1403
  {
1259
1404
  re: '\\{\\$\\w[\\w-]*(?!\\$)\\}', // Прочие параметры в виде {$имя_параметра}
1260
- getHandler() {
1405
+ getHandler: function() {
1261
1406
  const params = {
1262
1407
  REPORT_TITLE: this.tryToGetTitle(),
1263
1408
  };
@@ -1271,7 +1416,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1271
1416
  return this.parametersForReplace;
1272
1417
  },
1273
1418
 
1274
- parseHTML(htmlString) {
1419
+ parseHTML: function(htmlString) {
1275
1420
  const div = document.createElement('div');
1276
1421
  div.innerHTML = htmlString.split('body>')[1] && htmlString.split('body>')[1].slice(0, -2);
1277
1422
  const result = [];
@@ -1285,12 +1430,13 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
1285
1430
  return result.join('\n');
1286
1431
  },
1287
1432
 
1288
- getPluginCustomPropsForFields() {
1433
+ getPluginCustomPropsForFields: function() {
1289
1434
  return [{
1290
1435
  name: 'exportRenderer',
1291
1436
  description: 'Данное свойство позволяет обработать итоговые строки',
1292
1437
  type: 'function',
1293
1438
  fields: 'all',
1294
1439
  }];
1295
- },
1440
+ }
1441
+ ,
1296
1442
  });
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '2.8.24',
3
+ number: '2.8.25',
4
4
  });
@@ -1,278 +0,0 @@
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
- col['styleId'] = workbook.addCellStyle(styles);
272
-
273
- result.push(JSON.parse(JSON.stringify(col)));
274
- }, this);
275
- return result;
276
- },
277
-
278
- });