dtable-statistic 5.3.33 → 5.3.35
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.
- package/es/utils/export-table-utils.js +25 -33
- package/package.json +4 -4
|
@@ -10,7 +10,6 @@ var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal")
|
|
|
10
10
|
var _dtableUtils = require("dtable-utils");
|
|
11
11
|
var _cellValue = require("./cell-value");
|
|
12
12
|
var _constants = require("../constants");
|
|
13
|
-
var _pivotTable = require("./pivot-table");
|
|
14
13
|
const isEmptyName = title => {
|
|
15
14
|
return title === null || title === '';
|
|
16
15
|
};
|
|
@@ -403,14 +402,11 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
|
403
402
|
const {
|
|
404
403
|
pivot_rows,
|
|
405
404
|
pivot_columns,
|
|
406
|
-
|
|
407
|
-
formulaRows,
|
|
408
|
-
isSqlQuery
|
|
405
|
+
summary_columns
|
|
409
406
|
} = pivotResult;
|
|
410
|
-
|
|
411
|
-
if (!groupbyColumn || summaryColumns.length === 0 || !Array.isArray(pivot_columns) || pivot_columns.length === 0 || !Array.isArray(pivot_rows) || pivot_rows.length === 0) return {};
|
|
407
|
+
if (!groupbyColumn || summary_columns.length === 0 || !Array.isArray(pivot_columns) || pivot_columns.length === 0 || !Array.isArray(pivot_rows) || pivot_rows.length === 0) return {};
|
|
412
408
|
const groupbyColumnName = groupbyColumn.name;
|
|
413
|
-
const firstSummaryColumn =
|
|
409
|
+
const firstSummaryColumn = summary_columns[0];
|
|
414
410
|
let columns = [{
|
|
415
411
|
// name column
|
|
416
412
|
key: '0000',
|
|
@@ -425,16 +421,12 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
|
425
421
|
original_key
|
|
426
422
|
} = pivotColumn;
|
|
427
423
|
const pivotColumnColumnName = isEmptyName(original_key) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : pivotColumnKey;
|
|
428
|
-
|
|
424
|
+
summary_columns.forEach(summaryColumn => {
|
|
429
425
|
const {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
sqlKey,
|
|
433
|
-
column_name,
|
|
434
|
-
data,
|
|
435
|
-
method
|
|
426
|
+
name,
|
|
427
|
+
data
|
|
436
428
|
} = summaryColumn;
|
|
437
|
-
const newColumnName = `${
|
|
429
|
+
const newColumnName = `${name}(${pivotColumnColumnName})`;
|
|
438
430
|
columns.push({
|
|
439
431
|
// just support number column
|
|
440
432
|
type: _dtableUtils.CellType.NUMBER,
|
|
@@ -443,11 +435,8 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
|
443
435
|
});
|
|
444
436
|
tmpColumns.push({
|
|
445
437
|
name: newColumnName,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
type,
|
|
449
|
-
sqlKey,
|
|
450
|
-
method
|
|
438
|
+
summaryName: name,
|
|
439
|
+
pivotColumnKey
|
|
451
440
|
});
|
|
452
441
|
});
|
|
453
442
|
});
|
|
@@ -472,22 +461,25 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
|
472
461
|
let total = 0;
|
|
473
462
|
tmpColumns.forEach(tmpColumn => {
|
|
474
463
|
const {
|
|
475
|
-
name,
|
|
476
464
|
pivotColumnKey,
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
sqlKey,
|
|
480
|
-
method
|
|
465
|
+
name: columnName,
|
|
466
|
+
summaryName
|
|
481
467
|
} = tmpColumn;
|
|
482
468
|
const cell = cells && cells[pivotColumnKey];
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
469
|
+
if (!cell) return;
|
|
470
|
+
const cellTotal = cell && cell.total;
|
|
471
|
+
|
|
472
|
+
// cellTotal: [[summaryName, value, summaryColumnKey], ...]
|
|
473
|
+
let value = '';
|
|
474
|
+
if (Array.isArray(cellTotal)) {
|
|
475
|
+
const pair = cellTotal.find(item => Array.isArray(item) && item[0] === summaryName);
|
|
476
|
+
value = pair ? pair[1] : '';
|
|
486
477
|
} else {
|
|
487
|
-
|
|
488
|
-
newRow[name] = cellValue;
|
|
489
|
-
total += cellValue;
|
|
478
|
+
value = '';
|
|
490
479
|
}
|
|
480
|
+
newRow[columnName] = value;
|
|
481
|
+
const num = Number(value);
|
|
482
|
+
if (!isNaN(num)) total += num;
|
|
491
483
|
});
|
|
492
484
|
newRow[_reactIntlUniversal.default.get('Total')] = total;
|
|
493
485
|
rows.push(newRow);
|
|
@@ -921,13 +913,13 @@ const exportStatisticToTable = _ref8 => {
|
|
|
921
913
|
} = statisticalResult;
|
|
922
914
|
const {
|
|
923
915
|
pivot_columns,
|
|
924
|
-
|
|
916
|
+
summary_columns
|
|
925
917
|
} = pivotResult;
|
|
926
918
|
if (!groupbyColumn) return {};
|
|
927
919
|
|
|
928
920
|
// two dimension table
|
|
929
921
|
if (columnGroupbyColumn) {
|
|
930
|
-
if (Array.isArray(
|
|
922
|
+
if (Array.isArray(summary_columns) && summary_columns.length > 0) {
|
|
931
923
|
return exportTwoDimensionWithSummaryColumnsToTable({
|
|
932
924
|
statisticalResult
|
|
933
925
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-statistic",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.35",
|
|
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": "9.2.3",
|
|
21
|
-
"sea-chart": "^1.1.
|
|
21
|
+
"sea-chart": "^1.1.106"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"dtable-ui-component": "~6.0.*",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
53
53
|
"dotenv": "^10.0.0",
|
|
54
54
|
"dotenv-expand": "^5.1.0",
|
|
55
|
-
"dtable-store": "6.0.
|
|
56
|
-
"dtable-ui-component": "^6.0.
|
|
55
|
+
"dtable-store": "6.0.11",
|
|
56
|
+
"dtable-ui-component": "^6.0.98",
|
|
57
57
|
"dtable-utils": "^5.0.23",
|
|
58
58
|
"eslint": "^8.3.0",
|
|
59
59
|
"eslint-config-react-app": "^7.0.1",
|