dtable-statistic 5.0.42 → 5.0.43-alpha.0
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.
|
@@ -110,6 +110,16 @@ const exportOneDimensionToTable = _ref => {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
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
|
+
|
|
113
123
|
// total column
|
|
114
124
|
const totalColumn = {
|
|
115
125
|
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
@@ -134,6 +144,9 @@ const exportOneDimensionToTable = _ref => {
|
|
|
134
144
|
[groupbyColumn.name]: groupName,
|
|
135
145
|
[_reactIntlUniversal.default.get('Total')]: cellValue
|
|
136
146
|
};
|
|
147
|
+
if (summaryColumn) {
|
|
148
|
+
newRow[summaryColumn.name] = cellValue;
|
|
149
|
+
}
|
|
137
150
|
rows.push(newRow);
|
|
138
151
|
});
|
|
139
152
|
return {
|
|
@@ -191,6 +204,21 @@ const exportOneDimensionToTable = _ref => {
|
|
|
191
204
|
}
|
|
192
205
|
});
|
|
193
206
|
|
|
207
|
+
// total column
|
|
208
|
+
const totalColumn = {
|
|
209
|
+
type: _dtableUtils.CellType.NUMBER,
|
|
210
|
+
name: _reactIntlUniversal.default.get('Total'),
|
|
211
|
+
data: {
|
|
212
|
+
decimal: "dot",
|
|
213
|
+
enable_precision: false,
|
|
214
|
+
format: "yuan",
|
|
215
|
+
precision: 2,
|
|
216
|
+
thousands: "no"
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
columnMap['total'] = totalColumn;
|
|
220
|
+
columns.push(totalColumn);
|
|
221
|
+
|
|
194
222
|
// generator rows
|
|
195
223
|
pivot_rows.forEach(item => {
|
|
196
224
|
const {
|
|
@@ -198,17 +226,17 @@ const exportOneDimensionToTable = _ref => {
|
|
|
198
226
|
original_name,
|
|
199
227
|
total
|
|
200
228
|
} = item;
|
|
229
|
+
let rowTotal = 0;
|
|
201
230
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
202
231
|
let newRow = {
|
|
203
232
|
[groupbyColumn.name]: groupName
|
|
204
233
|
};
|
|
205
234
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
206
235
|
const {
|
|
207
|
-
key
|
|
208
|
-
method
|
|
236
|
+
key
|
|
209
237
|
} = item;
|
|
210
238
|
const column = columnMap[key];
|
|
211
|
-
const cellValueKey = key
|
|
239
|
+
const cellValueKey = key;
|
|
212
240
|
const {
|
|
213
241
|
name,
|
|
214
242
|
type,
|
|
@@ -220,7 +248,10 @@ const exportOneDimensionToTable = _ref => {
|
|
|
220
248
|
cellValue = (0, _dayjs.default)(cellValue).format(dateFormat);
|
|
221
249
|
}
|
|
222
250
|
newRow[name] = cellValue;
|
|
251
|
+
rowTotal = rowTotal + Number(cellValue);
|
|
223
252
|
});
|
|
253
|
+
// total row
|
|
254
|
+
newRow[_reactIntlUniversal.default.get('Total')] = rowTotal;
|
|
224
255
|
rows.push(newRow);
|
|
225
256
|
});
|
|
226
257
|
return {
|
|
@@ -467,7 +498,8 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
467
498
|
const {
|
|
468
499
|
pivotResult,
|
|
469
500
|
groupbyColumn,
|
|
470
|
-
statisticTableColumns
|
|
501
|
+
statisticTableColumns,
|
|
502
|
+
summaryColumn
|
|
471
503
|
} = statisticalResult;
|
|
472
504
|
if (!groupbyColumn) return {};
|
|
473
505
|
const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
|
|
@@ -488,6 +520,9 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
488
520
|
// one dimension table no summary columns
|
|
489
521
|
if (pivot_columns.length < 2) {
|
|
490
522
|
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
523
|
+
if (summaryColumn) {
|
|
524
|
+
columnMap['sumary_column'] = (0, _dtableUtils.getTableColumnByName)(updateTable, summaryColumn.name);
|
|
525
|
+
}
|
|
491
526
|
|
|
492
527
|
// updated rows
|
|
493
528
|
pivot_rows.forEach(item => {
|
|
@@ -499,6 +534,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
499
534
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
500
535
|
const row = tableRows.find(row => row[nameColumn.key] === groupName);
|
|
501
536
|
const totalColumn = columnMap['total'];
|
|
537
|
+
const sumary_column = columnMap['sumary_column'];
|
|
502
538
|
if (row) {
|
|
503
539
|
// update old row
|
|
504
540
|
let updateRow = {};
|
|
@@ -508,6 +544,11 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
508
544
|
updateRow[totalColumn.key] = validTotalCellValue;
|
|
509
545
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
510
546
|
}
|
|
547
|
+
const validSummaryCellValue = getValidValueForColumn(sumary_column, total.total);
|
|
548
|
+
if (sumary_column && (0, _cellValue.isCellValueChanged)(row[sumary_column.key], validSummaryCellValue, sumary_column.type)) {
|
|
549
|
+
updateRow[sumary_column.key] = validSummaryCellValue;
|
|
550
|
+
oldRow[sumary_column.key] = row[sumary_column.key];
|
|
551
|
+
}
|
|
511
552
|
if (Object.keys(updateRow).length > 0) {
|
|
512
553
|
const rowId = row._id;
|
|
513
554
|
rowIds.push(rowId);
|
|
@@ -521,6 +562,9 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
521
562
|
if (totalColumn) {
|
|
522
563
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
523
564
|
}
|
|
565
|
+
if (sumary_column) {
|
|
566
|
+
newRow[sumary_column.key] = getValidValueForColumn(sumary_column, total.total);
|
|
567
|
+
}
|
|
524
568
|
newRows.push(newRow);
|
|
525
569
|
}
|
|
526
570
|
});
|
|
@@ -542,6 +586,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
542
586
|
columnMap[key] = (0, _dtableUtils.getTableColumnByName)(updateTable, column.name);
|
|
543
587
|
}
|
|
544
588
|
});
|
|
589
|
+
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
545
590
|
|
|
546
591
|
// updated rows
|
|
547
592
|
const {
|
|
@@ -555,22 +600,30 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
555
600
|
} = item;
|
|
556
601
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
557
602
|
const row = tableRows.find(row => row[nameColumnKey] === groupName);
|
|
603
|
+
let rowTotal = 0;
|
|
558
604
|
if (row) {
|
|
559
605
|
let updateRow = {};
|
|
560
606
|
let oldRow = {};
|
|
561
607
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
562
608
|
const {
|
|
563
|
-
key
|
|
564
|
-
method
|
|
609
|
+
key
|
|
565
610
|
} = item;
|
|
566
611
|
const column = columnMap[key];
|
|
567
|
-
const cellValueKey = key
|
|
612
|
+
const cellValueKey = key;
|
|
568
613
|
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
614
|
+
rowTotal = rowTotal + Number(totalCellValue);
|
|
569
615
|
if (column && (0, _cellValue.isCellValueChanged)(row[column.key], totalCellValue, column.type)) {
|
|
570
616
|
updateRow[column.key] = totalCellValue;
|
|
571
617
|
oldRow[column.key] = row[column.key];
|
|
572
618
|
}
|
|
573
619
|
});
|
|
620
|
+
|
|
621
|
+
// total column
|
|
622
|
+
const column = columnMap['total'];
|
|
623
|
+
if (column) {
|
|
624
|
+
updateRow[column.key] = rowTotal;
|
|
625
|
+
oldRow[column.key] = row[column.key];
|
|
626
|
+
}
|
|
574
627
|
if (Object.keys(updateRow).length > 0) {
|
|
575
628
|
const rowId = row._id;
|
|
576
629
|
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.0",
|
|
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.*",
|