dtable-statistic 5.0.42-alpha.22 → 5.0.42-alpha.4
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 +14 -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,7 @@ const exportOneDimensionToTable = _ref => {
|
|
|
235
227
|
});
|
|
236
228
|
rows.push(newRow);
|
|
237
229
|
});
|
|
238
|
-
console.log(
|
|
239
|
-
columns,
|
|
240
|
-
rows
|
|
241
|
-
});
|
|
230
|
+
console.log('columns-rows', columns, rows);
|
|
242
231
|
return {
|
|
243
232
|
columns,
|
|
244
233
|
rows
|
|
@@ -248,6 +237,7 @@ const exportTwoDimensionToTable = _ref2 => {
|
|
|
248
237
|
let {
|
|
249
238
|
statisticalResult
|
|
250
239
|
} = _ref2;
|
|
240
|
+
console.log('exportTwoDimensionToTable');
|
|
251
241
|
const {
|
|
252
242
|
pivotResult,
|
|
253
243
|
groupbyColumn,
|
|
@@ -471,6 +461,7 @@ const exportTwoDimensionWithSummaryColumnsToTable = _ref4 => {
|
|
|
471
461
|
let {
|
|
472
462
|
statisticalResult
|
|
473
463
|
} = _ref4;
|
|
464
|
+
console.log('exportTwoDimensionWithSummaryColumnsToTable');
|
|
474
465
|
return getTwoDimensionWithSummaryColumns({
|
|
475
466
|
statisticalResult
|
|
476
467
|
});
|
|
@@ -483,8 +474,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
483
474
|
const {
|
|
484
475
|
pivotResult,
|
|
485
476
|
groupbyColumn,
|
|
486
|
-
statisticTableColumns
|
|
487
|
-
summaryColumn
|
|
477
|
+
statisticTableColumns
|
|
488
478
|
} = statisticalResult;
|
|
489
479
|
if (!groupbyColumn) return {};
|
|
490
480
|
const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
|
|
@@ -505,9 +495,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
505
495
|
// one dimension table no summary columns
|
|
506
496
|
if (pivot_columns.length < 2) {
|
|
507
497
|
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
498
|
|
|
512
499
|
// updated rows
|
|
513
500
|
pivot_rows.forEach(item => {
|
|
@@ -519,7 +506,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
519
506
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
520
507
|
const row = tableRows.find(row => row[nameColumn.key] === groupName);
|
|
521
508
|
const totalColumn = columnMap['total'];
|
|
522
|
-
const sumary_column = columnMap['sumary_column'];
|
|
523
509
|
if (row) {
|
|
524
510
|
// update old row
|
|
525
511
|
let updateRow = {};
|
|
@@ -529,11 +515,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
529
515
|
updateRow[totalColumn.key] = validTotalCellValue;
|
|
530
516
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
531
517
|
}
|
|
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
518
|
if (Object.keys(updateRow).length > 0) {
|
|
538
519
|
const rowId = row._id;
|
|
539
520
|
rowIds.push(rowId);
|
|
@@ -547,9 +528,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
547
528
|
if (totalColumn) {
|
|
548
529
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
549
530
|
}
|
|
550
|
-
if (sumary_column) {
|
|
551
|
-
newRow[sumary_column.key] = getValidValueForColumn(sumary_column, total.total);
|
|
552
|
-
}
|
|
553
531
|
newRows.push(newRow);
|
|
554
532
|
}
|
|
555
533
|
});
|
|
@@ -593,7 +571,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
593
571
|
method
|
|
594
572
|
} = item;
|
|
595
573
|
const column = columnMap[key];
|
|
596
|
-
const cellValueKey = key;
|
|
574
|
+
const cellValueKey = key + method;
|
|
597
575
|
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
598
576
|
if (column && (0, _cellValue.isCellValueChanged)(row[column.key], totalCellValue, column.type)) {
|
|
599
577
|
updateRow[column.key] = totalCellValue;
|