dtable-statistic 5.0.42-alpha.22 → 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 +13 -36
- package/package.json +1 -1
|
@@ -48,6 +48,7 @@ const exportOneDimensionToTable = _ref => {
|
|
|
48
48
|
let {
|
|
49
49
|
statisticalResult
|
|
50
50
|
} = _ref;
|
|
51
|
+
console.log('exportOneDimensionToTable');
|
|
51
52
|
const {
|
|
52
53
|
pivotResult,
|
|
53
54
|
groupbyColumn,
|
|
@@ -110,16 +111,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
// count column
|
|
114
|
-
if (summaryColumn) {
|
|
115
|
-
const countColumn = {
|
|
116
|
-
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
117
|
-
name: summaryColumn === null || summaryColumn === void 0 ? void 0 : summaryColumn.name,
|
|
118
|
-
data: columnData
|
|
119
|
-
};
|
|
120
|
-
columns.push(countColumn);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
114
|
// total column
|
|
124
115
|
const totalColumn = {
|
|
125
116
|
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
@@ -144,9 +135,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
144
135
|
[groupbyColumn.name]: groupName,
|
|
145
136
|
[_reactIntlUniversal.default.get('Total')]: cellValue
|
|
146
137
|
};
|
|
147
|
-
if (summaryColumn) {
|
|
148
|
-
newRow[summaryColumn.name] = cellValue;
|
|
149
|
-
}
|
|
150
138
|
rows.push(newRow);
|
|
151
139
|
});
|
|
152
140
|
return {
|
|
@@ -154,13 +142,16 @@ const exportOneDimensionToTable = _ref => {
|
|
|
154
142
|
rows
|
|
155
143
|
};
|
|
156
144
|
}
|
|
157
|
-
|
|
145
|
+
console.log('pivot_columns', pivot_columns);
|
|
146
|
+
console.log('statisticTableColumns', statisticTableColumns);
|
|
158
147
|
// one dimension table with number columns
|
|
159
148
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
160
149
|
const {
|
|
161
150
|
key
|
|
162
151
|
} = item;
|
|
152
|
+
console.log('item', item);
|
|
163
153
|
const column = statisticTableColumns.find(column => column.key === key);
|
|
154
|
+
console.log('column', column);
|
|
164
155
|
if (column) {
|
|
165
156
|
const columnName = column.name;
|
|
166
157
|
let columnData;
|
|
@@ -203,7 +194,7 @@ const exportOneDimensionToTable = _ref => {
|
|
|
203
194
|
columns.push(newColumn);
|
|
204
195
|
}
|
|
205
196
|
});
|
|
206
|
-
|
|
197
|
+
console.log('pivot_rows', pivot_rows);
|
|
207
198
|
// generator rows
|
|
208
199
|
pivot_rows.forEach(item => {
|
|
209
200
|
const {
|
|
@@ -217,10 +208,11 @@ const exportOneDimensionToTable = _ref => {
|
|
|
217
208
|
};
|
|
218
209
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
219
210
|
const {
|
|
220
|
-
key
|
|
211
|
+
key,
|
|
212
|
+
method
|
|
221
213
|
} = item;
|
|
222
214
|
const column = columnMap[key];
|
|
223
|
-
const cellValueKey = key;
|
|
215
|
+
const cellValueKey = key + method;
|
|
224
216
|
const {
|
|
225
217
|
name,
|
|
226
218
|
type,
|
|
@@ -235,10 +227,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
235
227
|
});
|
|
236
228
|
rows.push(newRow);
|
|
237
229
|
});
|
|
238
|
-
console.log(11, {
|
|
239
|
-
columns,
|
|
240
|
-
rows
|
|
241
|
-
});
|
|
242
230
|
return {
|
|
243
231
|
columns,
|
|
244
232
|
rows
|
|
@@ -248,6 +236,7 @@ const exportTwoDimensionToTable = _ref2 => {
|
|
|
248
236
|
let {
|
|
249
237
|
statisticalResult
|
|
250
238
|
} = _ref2;
|
|
239
|
+
console.log('exportTwoDimensionToTable');
|
|
251
240
|
const {
|
|
252
241
|
pivotResult,
|
|
253
242
|
groupbyColumn,
|
|
@@ -471,6 +460,7 @@ const exportTwoDimensionWithSummaryColumnsToTable = _ref4 => {
|
|
|
471
460
|
let {
|
|
472
461
|
statisticalResult
|
|
473
462
|
} = _ref4;
|
|
463
|
+
console.log('exportTwoDimensionWithSummaryColumnsToTable');
|
|
474
464
|
return getTwoDimensionWithSummaryColumns({
|
|
475
465
|
statisticalResult
|
|
476
466
|
});
|
|
@@ -483,8 +473,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
483
473
|
const {
|
|
484
474
|
pivotResult,
|
|
485
475
|
groupbyColumn,
|
|
486
|
-
statisticTableColumns
|
|
487
|
-
summaryColumn
|
|
476
|
+
statisticTableColumns
|
|
488
477
|
} = statisticalResult;
|
|
489
478
|
if (!groupbyColumn) return {};
|
|
490
479
|
const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
|
|
@@ -505,9 +494,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
505
494
|
// one dimension table no summary columns
|
|
506
495
|
if (pivot_columns.length < 2) {
|
|
507
496
|
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
508
|
-
if (summaryColumn) {
|
|
509
|
-
columnMap['sumary_column'] = (0, _dtableUtils.getTableColumnByName)(updateTable, summaryColumn.name);
|
|
510
|
-
}
|
|
511
497
|
|
|
512
498
|
// updated rows
|
|
513
499
|
pivot_rows.forEach(item => {
|
|
@@ -519,7 +505,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
519
505
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
520
506
|
const row = tableRows.find(row => row[nameColumn.key] === groupName);
|
|
521
507
|
const totalColumn = columnMap['total'];
|
|
522
|
-
const sumary_column = columnMap['sumary_column'];
|
|
523
508
|
if (row) {
|
|
524
509
|
// update old row
|
|
525
510
|
let updateRow = {};
|
|
@@ -529,11 +514,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
529
514
|
updateRow[totalColumn.key] = validTotalCellValue;
|
|
530
515
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
531
516
|
}
|
|
532
|
-
const validSummaryCellValue = getValidValueForColumn(sumary_column, total.total);
|
|
533
|
-
if (sumary_column && (0, _cellValue.isCellValueChanged)(row[sumary_column.key], validSummaryCellValue, sumary_column.type)) {
|
|
534
|
-
updateRow[sumary_column.key] = validSummaryCellValue;
|
|
535
|
-
oldRow[sumary_column.key] = row[sumary_column.key];
|
|
536
|
-
}
|
|
537
517
|
if (Object.keys(updateRow).length > 0) {
|
|
538
518
|
const rowId = row._id;
|
|
539
519
|
rowIds.push(rowId);
|
|
@@ -547,9 +527,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
547
527
|
if (totalColumn) {
|
|
548
528
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
549
529
|
}
|
|
550
|
-
if (sumary_column) {
|
|
551
|
-
newRow[sumary_column.key] = getValidValueForColumn(sumary_column, total.total);
|
|
552
|
-
}
|
|
553
530
|
newRows.push(newRow);
|
|
554
531
|
}
|
|
555
532
|
});
|
|
@@ -593,7 +570,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
593
570
|
method
|
|
594
571
|
} = item;
|
|
595
572
|
const column = columnMap[key];
|
|
596
|
-
const cellValueKey = key;
|
|
573
|
+
const cellValueKey = key + method;
|
|
597
574
|
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
598
575
|
if (column && (0, _cellValue.isCellValueChanged)(row[column.key], totalCellValue, column.type)) {
|
|
599
576
|
updateRow[column.key] = totalCellValue;
|