dtable-statistic 5.0.43-alpha.1 → 5.0.43
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.
|
@@ -48,7 +48,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
48
48
|
let {
|
|
49
49
|
statisticalResult
|
|
50
50
|
} = _ref;
|
|
51
|
-
console.log('exportOneDimensionToTable', statisticalResult);
|
|
52
51
|
const {
|
|
53
52
|
pivotResult,
|
|
54
53
|
groupbyColumn,
|
|
@@ -73,13 +72,11 @@ const exportOneDimensionToTable = _ref => {
|
|
|
73
72
|
|
|
74
73
|
// one dimension table no number columns
|
|
75
74
|
if (pivot_columns.length < 2) {
|
|
76
|
-
console.log('-2');
|
|
77
75
|
let columnData = {
|
|
78
76
|
format: 'number'
|
|
79
77
|
};
|
|
80
78
|
let _isDateSummaryColumn = false;
|
|
81
79
|
let isIncludeHour = false;
|
|
82
|
-
console.log('summaryColumn', summaryColumn);
|
|
83
80
|
if (summaryColumn) {
|
|
84
81
|
if (isSummaryDateColumn(summaryColumn)) {
|
|
85
82
|
const {
|
|
@@ -113,16 +110,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
|
|
116
|
-
// count column
|
|
117
|
-
if (summaryColumn) {
|
|
118
|
-
const countColumn = {
|
|
119
|
-
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
120
|
-
name: summaryColumn === null || summaryColumn === void 0 ? void 0 : summaryColumn.name,
|
|
121
|
-
data: columnData
|
|
122
|
-
};
|
|
123
|
-
columns.push(countColumn);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
113
|
// total column
|
|
127
114
|
const totalColumn = {
|
|
128
115
|
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
@@ -147,9 +134,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
147
134
|
[groupbyColumn.name]: groupName,
|
|
148
135
|
[_reactIntlUniversal.default.get('Total')]: cellValue
|
|
149
136
|
};
|
|
150
|
-
if (summaryColumn) {
|
|
151
|
-
newRow[summaryColumn.name] = cellValue;
|
|
152
|
-
}
|
|
153
137
|
rows.push(newRow);
|
|
154
138
|
});
|
|
155
139
|
return {
|
|
@@ -207,21 +191,6 @@ const exportOneDimensionToTable = _ref => {
|
|
|
207
191
|
}
|
|
208
192
|
});
|
|
209
193
|
|
|
210
|
-
// total column
|
|
211
|
-
const totalColumn = {
|
|
212
|
-
type: _dtableUtils.CellType.NUMBER,
|
|
213
|
-
name: _reactIntlUniversal.default.get('Total'),
|
|
214
|
-
data: {
|
|
215
|
-
decimal: "dot",
|
|
216
|
-
enable_precision: false,
|
|
217
|
-
format: "yuan",
|
|
218
|
-
precision: 2,
|
|
219
|
-
thousands: "no"
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
columnMap['total'] = totalColumn;
|
|
223
|
-
columns.push(totalColumn);
|
|
224
|
-
|
|
225
194
|
// generator rows
|
|
226
195
|
pivot_rows.forEach(item => {
|
|
227
196
|
const {
|
|
@@ -229,17 +198,17 @@ const exportOneDimensionToTable = _ref => {
|
|
|
229
198
|
original_name,
|
|
230
199
|
total
|
|
231
200
|
} = item;
|
|
232
|
-
let rowTotal = 0;
|
|
233
201
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
234
202
|
let newRow = {
|
|
235
203
|
[groupbyColumn.name]: groupName
|
|
236
204
|
};
|
|
237
205
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
238
206
|
const {
|
|
239
|
-
key
|
|
207
|
+
key,
|
|
208
|
+
method
|
|
240
209
|
} = item;
|
|
241
210
|
const column = columnMap[key];
|
|
242
|
-
const cellValueKey = key;
|
|
211
|
+
const cellValueKey = key + method;
|
|
243
212
|
const {
|
|
244
213
|
name,
|
|
245
214
|
type,
|
|
@@ -251,10 +220,7 @@ const exportOneDimensionToTable = _ref => {
|
|
|
251
220
|
cellValue = (0, _dayjs.default)(cellValue).format(dateFormat);
|
|
252
221
|
}
|
|
253
222
|
newRow[name] = cellValue;
|
|
254
|
-
rowTotal = rowTotal + Number(cellValue);
|
|
255
223
|
});
|
|
256
|
-
// total row
|
|
257
|
-
newRow[_reactIntlUniversal.default.get('Total')] = rowTotal;
|
|
258
224
|
rows.push(newRow);
|
|
259
225
|
});
|
|
260
226
|
return {
|
|
@@ -501,8 +467,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
501
467
|
const {
|
|
502
468
|
pivotResult,
|
|
503
469
|
groupbyColumn,
|
|
504
|
-
statisticTableColumns
|
|
505
|
-
summaryColumn
|
|
470
|
+
statisticTableColumns
|
|
506
471
|
} = statisticalResult;
|
|
507
472
|
if (!groupbyColumn) return {};
|
|
508
473
|
const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
|
|
@@ -523,9 +488,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
523
488
|
// one dimension table no summary columns
|
|
524
489
|
if (pivot_columns.length < 2) {
|
|
525
490
|
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
526
|
-
if (summaryColumn) {
|
|
527
|
-
columnMap['sumary_column'] = (0, _dtableUtils.getTableColumnByName)(updateTable, summaryColumn.name);
|
|
528
|
-
}
|
|
529
491
|
|
|
530
492
|
// updated rows
|
|
531
493
|
pivot_rows.forEach(item => {
|
|
@@ -537,7 +499,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
537
499
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
538
500
|
const row = tableRows.find(row => row[nameColumn.key] === groupName);
|
|
539
501
|
const totalColumn = columnMap['total'];
|
|
540
|
-
const sumary_column = columnMap['sumary_column'];
|
|
541
502
|
if (row) {
|
|
542
503
|
// update old row
|
|
543
504
|
let updateRow = {};
|
|
@@ -547,11 +508,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
547
508
|
updateRow[totalColumn.key] = validTotalCellValue;
|
|
548
509
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
549
510
|
}
|
|
550
|
-
const validSummaryCellValue = getValidValueForColumn(sumary_column, total.total);
|
|
551
|
-
if (sumary_column && (0, _cellValue.isCellValueChanged)(row[sumary_column.key], validSummaryCellValue, sumary_column.type)) {
|
|
552
|
-
updateRow[sumary_column.key] = validSummaryCellValue;
|
|
553
|
-
oldRow[sumary_column.key] = row[sumary_column.key];
|
|
554
|
-
}
|
|
555
511
|
if (Object.keys(updateRow).length > 0) {
|
|
556
512
|
const rowId = row._id;
|
|
557
513
|
rowIds.push(rowId);
|
|
@@ -565,9 +521,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
565
521
|
if (totalColumn) {
|
|
566
522
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
567
523
|
}
|
|
568
|
-
if (sumary_column) {
|
|
569
|
-
newRow[sumary_column.key] = getValidValueForColumn(sumary_column, total.total);
|
|
570
|
-
}
|
|
571
524
|
newRows.push(newRow);
|
|
572
525
|
}
|
|
573
526
|
});
|
|
@@ -589,7 +542,6 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
589
542
|
columnMap[key] = (0, _dtableUtils.getTableColumnByName)(updateTable, column.name);
|
|
590
543
|
}
|
|
591
544
|
});
|
|
592
|
-
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
593
545
|
|
|
594
546
|
// updated rows
|
|
595
547
|
const {
|
|
@@ -603,30 +555,22 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
603
555
|
} = item;
|
|
604
556
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
605
557
|
const row = tableRows.find(row => row[nameColumnKey] === groupName);
|
|
606
|
-
let rowTotal = 0;
|
|
607
558
|
if (row) {
|
|
608
559
|
let updateRow = {};
|
|
609
560
|
let oldRow = {};
|
|
610
561
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
611
562
|
const {
|
|
612
|
-
key
|
|
563
|
+
key,
|
|
564
|
+
method
|
|
613
565
|
} = item;
|
|
614
566
|
const column = columnMap[key];
|
|
615
|
-
const cellValueKey = key;
|
|
567
|
+
const cellValueKey = key + method;
|
|
616
568
|
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
617
|
-
rowTotal = rowTotal + Number(totalCellValue);
|
|
618
569
|
if (column && (0, _cellValue.isCellValueChanged)(row[column.key], totalCellValue, column.type)) {
|
|
619
570
|
updateRow[column.key] = totalCellValue;
|
|
620
571
|
oldRow[column.key] = row[column.key];
|
|
621
572
|
}
|
|
622
573
|
});
|
|
623
|
-
|
|
624
|
-
// total column
|
|
625
|
-
const column = columnMap['total'];
|
|
626
|
-
if (column) {
|
|
627
|
-
updateRow[column.key] = rowTotal;
|
|
628
|
-
oldRow[column.key] = row[column.key];
|
|
629
|
-
}
|
|
630
574
|
if (Object.keys(updateRow).length > 0) {
|
|
631
575
|
const rowId = row._id;
|
|
632
576
|
rowIds.push(rowId);
|