dtable-statistic 5.0.42-alpha.2 → 5.0.42-alpha.20
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,12 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
468
479
|
updateTable,
|
|
469
480
|
statisticalResult
|
|
470
481
|
} = _ref5;
|
|
482
|
+
console.log('statisticalResult', statisticalResult);
|
|
471
483
|
const {
|
|
472
484
|
pivotResult,
|
|
473
485
|
groupbyColumn,
|
|
474
|
-
statisticTableColumns
|
|
486
|
+
statisticTableColumns,
|
|
487
|
+
summaryColumn
|
|
475
488
|
} = statisticalResult;
|
|
476
489
|
if (!groupbyColumn) return {};
|
|
477
490
|
const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
|
|
@@ -492,6 +505,9 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
492
505
|
// one dimension table no summary columns
|
|
493
506
|
if (pivot_columns.length < 2) {
|
|
494
507
|
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
508
|
+
if (summaryColumn) {
|
|
509
|
+
columnMap['sumary_column'] = (0, _dtableUtils.getTableColumnByName)(updateTable, summaryColumn.name);
|
|
510
|
+
}
|
|
495
511
|
|
|
496
512
|
// updated rows
|
|
497
513
|
pivot_rows.forEach(item => {
|
|
@@ -503,6 +519,9 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
503
519
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
504
520
|
const row = tableRows.find(row => row[nameColumn.key] === groupName);
|
|
505
521
|
const totalColumn = columnMap['total'];
|
|
522
|
+
const sumary_column = columnMap['sumary_column'];
|
|
523
|
+
console.log('totalColumn', totalColumn);
|
|
524
|
+
console.log('sumary_column', sumary_column);
|
|
506
525
|
if (row) {
|
|
507
526
|
// update old row
|
|
508
527
|
let updateRow = {};
|
|
@@ -512,6 +531,11 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
512
531
|
updateRow[totalColumn.key] = validTotalCellValue;
|
|
513
532
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
514
533
|
}
|
|
534
|
+
const validSummaryCellValue = getValidValueForColumn(sumary_column, total.total);
|
|
535
|
+
if (sumary_column && (0, _cellValue.isCellValueChanged)(row[sumary_column.key], validSummaryCellValue, sumary_column.type)) {
|
|
536
|
+
updateRow[sumary_column.key] = validSummaryCellValue;
|
|
537
|
+
oldRow[sumary_column.key] = row[sumary_column.key];
|
|
538
|
+
}
|
|
515
539
|
if (Object.keys(updateRow).length > 0) {
|
|
516
540
|
const rowId = row._id;
|
|
517
541
|
rowIds.push(rowId);
|
|
@@ -520,14 +544,24 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
520
544
|
}
|
|
521
545
|
} else {
|
|
522
546
|
// insert new row
|
|
547
|
+
console.log('insertrow');
|
|
523
548
|
let newRow = {};
|
|
524
549
|
newRow[nameColumn.key] = groupName;
|
|
525
550
|
if (totalColumn) {
|
|
526
551
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
527
552
|
}
|
|
553
|
+
if (sumary_column) {
|
|
554
|
+
newRow[sumary_column.key] = getValidValueForColumn(sumary_column, total.total);
|
|
555
|
+
}
|
|
528
556
|
newRows.push(newRow);
|
|
529
557
|
}
|
|
530
558
|
});
|
|
559
|
+
console.log(77, {
|
|
560
|
+
newRows,
|
|
561
|
+
updatedRows,
|
|
562
|
+
rowIds,
|
|
563
|
+
oldRows
|
|
564
|
+
});
|
|
531
565
|
return {
|
|
532
566
|
newRows,
|
|
533
567
|
updatedRows,
|
|
@@ -568,7 +602,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
568
602
|
method
|
|
569
603
|
} = item;
|
|
570
604
|
const column = columnMap[key];
|
|
571
|
-
const cellValueKey = key
|
|
605
|
+
const cellValueKey = key;
|
|
572
606
|
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
573
607
|
if (column && (0, _cellValue.isCellValueChanged)(row[column.key], totalCellValue, column.type)) {
|
|
574
608
|
updateRow[column.key] = totalCellValue;
|