dtable-statistic 5.0.42-alpha.21 → 5.0.42-alpha.3
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/es/utils/export-table-utils.js +10 -43
- package/package.json +1 -1
|
@@ -111,16 +111,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
// count column
|
|
115
|
-
if (summaryColumn) {
|
|
116
|
-
const countColumn = {
|
|
117
|
-
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
118
|
-
name: summaryColumn === null || summaryColumn === void 0 ? void 0 : summaryColumn.name,
|
|
119
|
-
data: columnData
|
|
120
|
-
};
|
|
121
|
-
columns.push(countColumn);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
114
|
// total column
|
|
125
115
|
const totalColumn = {
|
|
126
116
|
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
@@ -145,9 +135,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
145
135
|
[groupbyColumn.name]: groupName,
|
|
146
136
|
[_reactIntlUniversal.default.get('Total')]: cellValue
|
|
147
137
|
};
|
|
148
|
-
if (summaryColumn) {
|
|
149
|
-
newRow[summaryColumn.name] = cellValue;
|
|
150
|
-
}
|
|
151
138
|
rows.push(newRow);
|
|
152
139
|
});
|
|
153
140
|
return {
|
|
@@ -155,13 +142,16 @@ const exportOneDimensionToTable = _ref => {
|
|
|
155
142
|
rows
|
|
156
143
|
};
|
|
157
144
|
}
|
|
158
|
-
|
|
145
|
+
console.log('pivot_columns', pivot_columns);
|
|
146
|
+
console.log('statisticTableColumns', statisticTableColumns);
|
|
159
147
|
// one dimension table with number columns
|
|
160
148
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
161
149
|
const {
|
|
162
150
|
key
|
|
163
151
|
} = item;
|
|
152
|
+
console.log('item', item);
|
|
164
153
|
const column = statisticTableColumns.find(column => column.key === key);
|
|
154
|
+
console.log('column', column);
|
|
165
155
|
if (column) {
|
|
166
156
|
const columnName = column.name;
|
|
167
157
|
let columnData;
|
|
@@ -204,7 +194,7 @@ const exportOneDimensionToTable = _ref => {
|
|
|
204
194
|
columns.push(newColumn);
|
|
205
195
|
}
|
|
206
196
|
});
|
|
207
|
-
|
|
197
|
+
console.log('pivot_rows', pivot_rows);
|
|
208
198
|
// generator rows
|
|
209
199
|
pivot_rows.forEach(item => {
|
|
210
200
|
const {
|
|
@@ -218,10 +208,11 @@ const exportOneDimensionToTable = _ref => {
|
|
|
218
208
|
};
|
|
219
209
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
220
210
|
const {
|
|
221
|
-
key
|
|
211
|
+
key,
|
|
212
|
+
method
|
|
222
213
|
} = item;
|
|
223
214
|
const column = columnMap[key];
|
|
224
|
-
const cellValueKey = key;
|
|
215
|
+
const cellValueKey = key + method;
|
|
225
216
|
const {
|
|
226
217
|
name,
|
|
227
218
|
type,
|
|
@@ -479,13 +470,10 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
479
470
|
updateTable,
|
|
480
471
|
statisticalResult
|
|
481
472
|
} = _ref5;
|
|
482
|
-
console.log('statisticalResult', statisticalResult);
|
|
483
|
-
console.log('updateTable', updateTable);
|
|
484
473
|
const {
|
|
485
474
|
pivotResult,
|
|
486
475
|
groupbyColumn,
|
|
487
|
-
statisticTableColumns
|
|
488
|
-
summaryColumn
|
|
476
|
+
statisticTableColumns
|
|
489
477
|
} = statisticalResult;
|
|
490
478
|
if (!groupbyColumn) return {};
|
|
491
479
|
const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
|
|
@@ -506,9 +494,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
506
494
|
// one dimension table no summary columns
|
|
507
495
|
if (pivot_columns.length < 2) {
|
|
508
496
|
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
509
|
-
if (summaryColumn) {
|
|
510
|
-
columnMap['sumary_column'] = (0, _dtableUtils.getTableColumnByName)(updateTable, summaryColumn.name);
|
|
511
|
-
}
|
|
512
497
|
|
|
513
498
|
// updated rows
|
|
514
499
|
pivot_rows.forEach(item => {
|
|
@@ -520,9 +505,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
520
505
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
521
506
|
const row = tableRows.find(row => row[nameColumn.key] === groupName);
|
|
522
507
|
const totalColumn = columnMap['total'];
|
|
523
|
-
const sumary_column = columnMap['sumary_column'];
|
|
524
|
-
console.log('totalColumn', totalColumn);
|
|
525
|
-
console.log('sumary_column', sumary_column);
|
|
526
508
|
if (row) {
|
|
527
509
|
// update old row
|
|
528
510
|
let updateRow = {};
|
|
@@ -532,11 +514,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
532
514
|
updateRow[totalColumn.key] = validTotalCellValue;
|
|
533
515
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
534
516
|
}
|
|
535
|
-
const validSummaryCellValue = getValidValueForColumn(sumary_column, total.total);
|
|
536
|
-
if (sumary_column && (0, _cellValue.isCellValueChanged)(row[sumary_column.key], validSummaryCellValue, sumary_column.type)) {
|
|
537
|
-
updateRow[sumary_column.key] = validSummaryCellValue;
|
|
538
|
-
oldRow[sumary_column.key] = row[sumary_column.key];
|
|
539
|
-
}
|
|
540
517
|
if (Object.keys(updateRow).length > 0) {
|
|
541
518
|
const rowId = row._id;
|
|
542
519
|
rowIds.push(rowId);
|
|
@@ -545,24 +522,14 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
545
522
|
}
|
|
546
523
|
} else {
|
|
547
524
|
// insert new row
|
|
548
|
-
console.log('insertrow');
|
|
549
525
|
let newRow = {};
|
|
550
526
|
newRow[nameColumn.key] = groupName;
|
|
551
527
|
if (totalColumn) {
|
|
552
528
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
553
529
|
}
|
|
554
|
-
if (sumary_column) {
|
|
555
|
-
newRow[sumary_column.key] = getValidValueForColumn(sumary_column, total.total);
|
|
556
|
-
}
|
|
557
530
|
newRows.push(newRow);
|
|
558
531
|
}
|
|
559
532
|
});
|
|
560
|
-
console.log(77, {
|
|
561
|
-
newRows,
|
|
562
|
-
updatedRows,
|
|
563
|
-
rowIds,
|
|
564
|
-
oldRows
|
|
565
|
-
});
|
|
566
533
|
return {
|
|
567
534
|
newRows,
|
|
568
535
|
updatedRows,
|
|
@@ -603,7 +570,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
603
570
|
method
|
|
604
571
|
} = item;
|
|
605
572
|
const column = columnMap[key];
|
|
606
|
-
const cellValueKey = key;
|
|
573
|
+
const cellValueKey = key + method;
|
|
607
574
|
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
608
575
|
if (column && (0, _cellValue.isCellValueChanged)(row[column.key], totalCellValue, column.type)) {
|
|
609
576
|
updateRow[column.key] = totalCellValue;
|