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