dtable-statistic 5.0.42-alpha.9 → 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.
@@ -48,7 +48,6 @@ const exportOneDimensionToTable = _ref => {
48
48
  let {
49
49
  statisticalResult
50
50
  } = _ref;
51
- console.log('exportOneDimensionToTable');
52
51
  const {
53
52
  pivotResult,
54
53
  groupbyColumn,
@@ -113,7 +112,6 @@ const exportOneDimensionToTable = _ref => {
113
112
 
114
113
  // count column
115
114
  if (summaryColumn) {
116
- console.log('columnData', columnData);
117
115
  const countColumn = {
118
116
  type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
119
117
  name: summaryColumn === null || summaryColumn === void 0 ? void 0 : summaryColumn.name,
@@ -146,27 +144,23 @@ const exportOneDimensionToTable = _ref => {
146
144
  [groupbyColumn.name]: groupName,
147
145
  [_reactIntlUniversal.default.get('Total')]: cellValue
148
146
  };
147
+ if (summaryColumn) {
148
+ newRow[summaryColumn.name] = cellValue;
149
+ }
149
150
  rows.push(newRow);
150
151
  });
151
- console.log(11, {
152
- columns,
153
- rows
154
- });
155
152
  return {
156
153
  columns,
157
154
  rows
158
155
  };
159
156
  }
160
- console.log('pivot_columns', pivot_columns);
161
- console.log('statisticTableColumns', statisticTableColumns);
157
+
162
158
  // one dimension table with number columns
163
159
  Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
164
160
  const {
165
161
  key
166
162
  } = item;
167
- console.log('item', item);
168
163
  const column = statisticTableColumns.find(column => column.key === key);
169
- console.log('column', column);
170
164
  if (column) {
171
165
  const columnName = column.name;
172
166
  let columnData;
@@ -209,7 +203,22 @@ const exportOneDimensionToTable = _ref => {
209
203
  columns.push(newColumn);
210
204
  }
211
205
  });
212
- console.log('pivot_rows', pivot_rows);
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
+
213
222
  // generator rows
214
223
  pivot_rows.forEach(item => {
215
224
  const {
@@ -217,6 +226,7 @@ const exportOneDimensionToTable = _ref => {
217
226
  original_name,
218
227
  total
219
228
  } = item;
229
+ let rowTotal = 0;
220
230
  const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
221
231
  let newRow = {
222
232
  [groupbyColumn.name]: groupName
@@ -238,11 +248,12 @@ const exportOneDimensionToTable = _ref => {
238
248
  cellValue = (0, _dayjs.default)(cellValue).format(dateFormat);
239
249
  }
240
250
  newRow[name] = cellValue;
251
+ rowTotal = rowTotal + Number(cellValue);
241
252
  });
242
- console.log('newRow', newRow);
253
+ // total row
254
+ newRow[_reactIntlUniversal.default.get('Total')] = rowTotal;
243
255
  rows.push(newRow);
244
256
  });
245
- console.log('rows', rows);
246
257
  return {
247
258
  columns,
248
259
  rows
@@ -252,7 +263,6 @@ const exportTwoDimensionToTable = _ref2 => {
252
263
  let {
253
264
  statisticalResult
254
265
  } = _ref2;
255
- console.log('exportTwoDimensionToTable');
256
266
  const {
257
267
  pivotResult,
258
268
  groupbyColumn,
@@ -476,7 +486,6 @@ const exportTwoDimensionWithSummaryColumnsToTable = _ref4 => {
476
486
  let {
477
487
  statisticalResult
478
488
  } = _ref4;
479
- console.log('exportTwoDimensionWithSummaryColumnsToTable');
480
489
  return getTwoDimensionWithSummaryColumns({
481
490
  statisticalResult
482
491
  });
@@ -489,7 +498,8 @@ const updatedOneDimensionToTable = _ref5 => {
489
498
  const {
490
499
  pivotResult,
491
500
  groupbyColumn,
492
- statisticTableColumns
501
+ statisticTableColumns,
502
+ summaryColumn
493
503
  } = statisticalResult;
494
504
  if (!groupbyColumn) return {};
495
505
  const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
@@ -510,6 +520,9 @@ const updatedOneDimensionToTable = _ref5 => {
510
520
  // one dimension table no summary columns
511
521
  if (pivot_columns.length < 2) {
512
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
+ }
513
526
 
514
527
  // updated rows
515
528
  pivot_rows.forEach(item => {
@@ -521,6 +534,7 @@ const updatedOneDimensionToTable = _ref5 => {
521
534
  const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
522
535
  const row = tableRows.find(row => row[nameColumn.key] === groupName);
523
536
  const totalColumn = columnMap['total'];
537
+ const sumary_column = columnMap['sumary_column'];
524
538
  if (row) {
525
539
  // update old row
526
540
  let updateRow = {};
@@ -530,6 +544,11 @@ const updatedOneDimensionToTable = _ref5 => {
530
544
  updateRow[totalColumn.key] = validTotalCellValue;
531
545
  oldRow[totalColumn.key] = row[totalColumn.key];
532
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
+ }
533
552
  if (Object.keys(updateRow).length > 0) {
534
553
  const rowId = row._id;
535
554
  rowIds.push(rowId);
@@ -543,6 +562,9 @@ const updatedOneDimensionToTable = _ref5 => {
543
562
  if (totalColumn) {
544
563
  newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
545
564
  }
565
+ if (sumary_column) {
566
+ newRow[sumary_column.key] = getValidValueForColumn(sumary_column, total.total);
567
+ }
546
568
  newRows.push(newRow);
547
569
  }
548
570
  });
@@ -564,6 +586,7 @@ const updatedOneDimensionToTable = _ref5 => {
564
586
  columnMap[key] = (0, _dtableUtils.getTableColumnByName)(updateTable, column.name);
565
587
  }
566
588
  });
589
+ columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
567
590
 
568
591
  // updated rows
569
592
  const {
@@ -577,22 +600,30 @@ const updatedOneDimensionToTable = _ref5 => {
577
600
  } = item;
578
601
  const groupName = isEmptyName(original_name) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
579
602
  const row = tableRows.find(row => row[nameColumnKey] === groupName);
603
+ let rowTotal = 0;
580
604
  if (row) {
581
605
  let updateRow = {};
582
606
  let oldRow = {};
583
607
  Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
584
608
  const {
585
- key,
586
- method
609
+ key
587
610
  } = item;
588
611
  const column = columnMap[key];
589
612
  const cellValueKey = key;
590
613
  const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
614
+ rowTotal = rowTotal + Number(totalCellValue);
591
615
  if (column && (0, _cellValue.isCellValueChanged)(row[column.key], totalCellValue, column.type)) {
592
616
  updateRow[column.key] = totalCellValue;
593
617
  oldRow[column.key] = row[column.key];
594
618
  }
595
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
+ }
596
627
  if (Object.keys(updateRow).length > 0) {
597
628
  const rowId = row._id;
598
629
  rowIds.push(rowId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "5.0.42-alpha.9",
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.88"
21
+ "sea-chart": "~0.0.89"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "dtable-ui-component": "~5.0.*",