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