dtable-statistic 5.0.45 → 5.0.47
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,26 @@ const exportOneDimensionToTable = _ref => {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// count column
|
|
114
|
+
if (pivot_columns.length === 0) {
|
|
115
|
+
const countColumn = {
|
|
116
|
+
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
117
|
+
name: _reactIntlUniversal.default.get('Amount'),
|
|
118
|
+
data: columnData
|
|
119
|
+
};
|
|
120
|
+
columns.push(countColumn);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// single field
|
|
124
|
+
if (summaryColumn) {
|
|
125
|
+
const singleColumn = {
|
|
126
|
+
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
127
|
+
name: summaryColumn === null || summaryColumn === void 0 ? void 0 : summaryColumn.name,
|
|
128
|
+
data: columnData
|
|
129
|
+
};
|
|
130
|
+
columns.push(singleColumn);
|
|
131
|
+
}
|
|
132
|
+
|
|
113
133
|
// total column
|
|
114
134
|
const totalColumn = {
|
|
115
135
|
type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
|
|
@@ -134,6 +154,14 @@ const exportOneDimensionToTable = _ref => {
|
|
|
134
154
|
[groupbyColumn.name]: groupName,
|
|
135
155
|
[_reactIntlUniversal.default.get('Total')]: cellValue
|
|
136
156
|
};
|
|
157
|
+
// single column
|
|
158
|
+
if (summaryColumn) {
|
|
159
|
+
newRow[summaryColumn.name] = cellValue;
|
|
160
|
+
}
|
|
161
|
+
// count column
|
|
162
|
+
if (pivot_columns.length === 0) {
|
|
163
|
+
newRow[_reactIntlUniversal.default.get('Amount')] = cellValue;
|
|
164
|
+
}
|
|
137
165
|
rows.push(newRow);
|
|
138
166
|
});
|
|
139
167
|
return {
|
|
@@ -191,6 +219,21 @@ const exportOneDimensionToTable = _ref => {
|
|
|
191
219
|
}
|
|
192
220
|
});
|
|
193
221
|
|
|
222
|
+
// total column
|
|
223
|
+
const totalColumn = {
|
|
224
|
+
type: _dtableUtils.CellType.NUMBER,
|
|
225
|
+
name: _reactIntlUniversal.default.get('Total'),
|
|
226
|
+
data: {
|
|
227
|
+
decimal: "dot",
|
|
228
|
+
enable_precision: false,
|
|
229
|
+
format: "yuan",
|
|
230
|
+
precision: 2,
|
|
231
|
+
thousands: "no"
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
columnMap['total'] = totalColumn;
|
|
235
|
+
columns.push(totalColumn);
|
|
236
|
+
|
|
194
237
|
// generator rows
|
|
195
238
|
pivot_rows.forEach(item => {
|
|
196
239
|
const {
|
|
@@ -198,17 +241,17 @@ const exportOneDimensionToTable = _ref => {
|
|
|
198
241
|
original_name,
|
|
199
242
|
total
|
|
200
243
|
} = item;
|
|
244
|
+
let rowTotal = 0;
|
|
201
245
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
202
246
|
let newRow = {
|
|
203
247
|
[groupbyColumn.name]: groupName
|
|
204
248
|
};
|
|
205
249
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
206
250
|
const {
|
|
207
|
-
key
|
|
208
|
-
method
|
|
251
|
+
key
|
|
209
252
|
} = item;
|
|
210
253
|
const column = columnMap[key];
|
|
211
|
-
const cellValueKey = key
|
|
254
|
+
const cellValueKey = key;
|
|
212
255
|
const {
|
|
213
256
|
name,
|
|
214
257
|
type,
|
|
@@ -220,7 +263,10 @@ const exportOneDimensionToTable = _ref => {
|
|
|
220
263
|
cellValue = (0, _dayjs.default)(cellValue).format(dateFormat);
|
|
221
264
|
}
|
|
222
265
|
newRow[name] = cellValue;
|
|
266
|
+
rowTotal = rowTotal + Number(cellValue);
|
|
223
267
|
});
|
|
268
|
+
// total row
|
|
269
|
+
newRow[_reactIntlUniversal.default.get('Total')] = rowTotal;
|
|
224
270
|
rows.push(newRow);
|
|
225
271
|
});
|
|
226
272
|
return {
|
|
@@ -467,7 +513,8 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
467
513
|
const {
|
|
468
514
|
pivotResult,
|
|
469
515
|
groupbyColumn,
|
|
470
|
-
statisticTableColumns
|
|
516
|
+
statisticTableColumns,
|
|
517
|
+
summaryColumn
|
|
471
518
|
} = statisticalResult;
|
|
472
519
|
if (!groupbyColumn) return {};
|
|
473
520
|
const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
|
|
@@ -488,6 +535,9 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
488
535
|
// one dimension table no summary columns
|
|
489
536
|
if (pivot_columns.length < 2) {
|
|
490
537
|
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
538
|
+
if (summaryColumn) {
|
|
539
|
+
columnMap['sumary_column'] = (0, _dtableUtils.getTableColumnByName)(updateTable, summaryColumn.name);
|
|
540
|
+
}
|
|
491
541
|
|
|
492
542
|
// updated rows
|
|
493
543
|
pivot_rows.forEach(item => {
|
|
@@ -499,6 +549,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
499
549
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
500
550
|
const row = tableRows.find(row => row[nameColumn.key] === groupName);
|
|
501
551
|
const totalColumn = columnMap['total'];
|
|
552
|
+
const sumary_column = columnMap['sumary_column'];
|
|
502
553
|
if (row) {
|
|
503
554
|
// update old row
|
|
504
555
|
let updateRow = {};
|
|
@@ -508,6 +559,11 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
508
559
|
updateRow[totalColumn.key] = validTotalCellValue;
|
|
509
560
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
510
561
|
}
|
|
562
|
+
const validSummaryCellValue = getValidValueForColumn(sumary_column, total.total);
|
|
563
|
+
if (sumary_column && (0, _cellValue.isCellValueChanged)(row[sumary_column.key], validSummaryCellValue, sumary_column.type)) {
|
|
564
|
+
updateRow[sumary_column.key] = validSummaryCellValue;
|
|
565
|
+
oldRow[sumary_column.key] = row[sumary_column.key];
|
|
566
|
+
}
|
|
511
567
|
if (Object.keys(updateRow).length > 0) {
|
|
512
568
|
const rowId = row._id;
|
|
513
569
|
rowIds.push(rowId);
|
|
@@ -521,6 +577,9 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
521
577
|
if (totalColumn) {
|
|
522
578
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
523
579
|
}
|
|
580
|
+
if (sumary_column) {
|
|
581
|
+
newRow[sumary_column.key] = getValidValueForColumn(sumary_column, total.total);
|
|
582
|
+
}
|
|
524
583
|
newRows.push(newRow);
|
|
525
584
|
}
|
|
526
585
|
});
|
|
@@ -542,6 +601,7 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
542
601
|
columnMap[key] = (0, _dtableUtils.getTableColumnByName)(updateTable, column.name);
|
|
543
602
|
}
|
|
544
603
|
});
|
|
604
|
+
columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
|
|
545
605
|
|
|
546
606
|
// updated rows
|
|
547
607
|
const {
|
|
@@ -555,22 +615,30 @@ const updatedOneDimensionToTable = _ref5 => {
|
|
|
555
615
|
} = item;
|
|
556
616
|
const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
557
617
|
const row = tableRows.find(row => row[nameColumnKey] === groupName);
|
|
618
|
+
let rowTotal = 0;
|
|
558
619
|
if (row) {
|
|
559
620
|
let updateRow = {};
|
|
560
621
|
let oldRow = {};
|
|
561
622
|
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
562
623
|
const {
|
|
563
|
-
key
|
|
564
|
-
method
|
|
624
|
+
key
|
|
565
625
|
} = item;
|
|
566
626
|
const column = columnMap[key];
|
|
567
|
-
const cellValueKey = key
|
|
627
|
+
const cellValueKey = key;
|
|
568
628
|
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
629
|
+
rowTotal = rowTotal + Number(totalCellValue);
|
|
569
630
|
if (column && (0, _cellValue.isCellValueChanged)(row[column.key], totalCellValue, column.type)) {
|
|
570
631
|
updateRow[column.key] = totalCellValue;
|
|
571
632
|
oldRow[column.key] = row[column.key];
|
|
572
633
|
}
|
|
573
634
|
});
|
|
635
|
+
|
|
636
|
+
// total column
|
|
637
|
+
const column = columnMap['total'];
|
|
638
|
+
if (column) {
|
|
639
|
+
updateRow[column.key] = rowTotal;
|
|
640
|
+
oldRow[column.key] = row[column.key];
|
|
641
|
+
}
|
|
574
642
|
if (Object.keys(updateRow).length > 0) {
|
|
575
643
|
const rowId = row._id;
|
|
576
644
|
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.47",
|
|
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.93"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"dtable-ui-component": "~5.0.*",
|