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