dtable-statistic 4.2.2 → 4.3.1
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/api/dtable-db-api.js +31 -37
- package/es/calculator/base-calculator.js +49 -99
- package/es/calculator/basic-chart-calculator.js +335 -559
- package/es/calculator/combination-calculator.js +231 -299
- package/es/calculator/compare-bar-calculator.js +184 -281
- package/es/calculator/completeness-calculator.js +203 -288
- package/es/calculator/copy-value.js +18 -18
- package/es/calculator/dashboard-calculator.js +68 -137
- package/es/calculator/heat-map-calculator.js +139 -220
- package/es/calculator/horizontal-bar-calculator.js +64 -93
- package/es/calculator/index.js +53 -69
- package/es/calculator/map-calculator.js +98 -174
- package/es/calculator/mirror-calculator.js +137 -216
- package/es/calculator/number-card-calculator.js +58 -126
- package/es/calculator/pivot-table-calculator.js +750 -792
- package/es/calculator/scatter-calculator.js +72 -140
- package/es/calculator/thread-manager.js +48 -67
- package/es/calculator/trend-calculator.js +107 -191
- package/es/calculator/workers/basic-chart-calculator-worker.js +194 -165
- package/es/calculator/workers/calculator.worker.js +22 -6
- package/es/calculator/workers/card-calculator-worker.js +16 -14
- package/es/calculator/workers/combination-calculator-worker.js +128 -135
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +80 -96
- package/es/calculator/workers/completeness-calculator-worker.js +56 -49
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -22
- package/es/calculator/workers/mirror-calculator-worker.js +52 -52
- package/es/calculator/workers/pivot-table-calculator-worker.js +247 -230
- package/es/calculator/workers/scatter-calculator-worker.js +34 -32
- package/es/calculator/workers/trend-calculator-worker.js +33 -29
- package/es/calculator/world-map-calculator.js +120 -197
- package/es/components/common-add-tool.js +7 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +67 -77
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +57 -67
- package/es/components/dialog/color-theme-dialog.js +34 -47
- package/es/components/dialog/delete-confirmation-dialog.js +7 -5
- package/es/components/dialog/enlarged-chart-dialog.js +68 -81
- package/es/components/dialog/new-table-dialog.js +62 -80
- package/es/components/dialog/new-view-dialog.js +50 -62
- package/es/components/dialog/rename-view-dialog.js +49 -58
- package/es/components/dialog/statistic-record-dialog/index.js +233 -231
- package/es/components/dialog/statistic-types-dialog/index.js +40 -49
- package/es/components/dialog/table-select-dialog.js +61 -70
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +129 -142
- package/es/components/dtable-popover.js +62 -81
- package/es/components/dtable-search-input.js +89 -99
- package/es/components/dtable-select.js +55 -74
- package/es/components/icon.js +5 -3
- package/es/components/loading.js +1 -1
- package/es/components/modal-portal.js +15 -32
- package/es/components/popover/color-rules/color-rule.js +137 -141
- package/es/components/popover/color-rules/index.js +58 -66
- package/es/components/popover/color-rules/rule-filters/filter.js +124 -124
- package/es/components/popover/color-rules/rule-filters/index.js +50 -58
- package/es/components/popover/color-rules/rule-filters/number-input.js +42 -57
- package/es/components/popover/color-rules-popover.js +117 -121
- package/es/components/popover/color-selector-popover.js +60 -70
- package/es/components/seatable-radio/index.js +2 -2
- package/es/components/select/option-group.js +139 -157
- package/es/components/select/option.js +26 -40
- package/es/components/select/select.js +97 -112
- package/es/components/toast/alert.js +65 -80
- package/es/components/toast/index.js +1 -1
- package/es/components/toast/toast.js +76 -103
- package/es/components/toast/toastManager.js +57 -93
- package/es/components/toast/toaster.js +58 -56
- package/es/constants/color-rules.js +8 -5
- package/es/constants/dtable-select-style.js +44 -48
- package/es/constants/event-types.js +4 -4
- package/es/constants/index.js +328 -242
- package/es/constants/map.js +2 -2
- package/es/constants/model.js +20 -20
- package/es/constants/regions.js +1 -1
- package/es/constants/zIndexes.js +1 -1
- package/es/custom-g2.js +11 -11
- package/es/dashboard.js +343 -333
- package/es/desktop-dashboard.js +217 -224
- package/es/index.js +45 -58
- package/es/locale/index.js +3 -3
- package/es/locale/lang/de.js +1 -1
- package/es/locale/lang/en.js +7 -7
- package/es/locale/lang/fr.js +1 -1
- package/es/locale/lang/zh_CN.js +1 -1
- package/es/mobile-dashboard.js +76 -89
- package/es/model/bar-group.js +34 -44
- package/es/model/bar.js +26 -36
- package/es/model/base-model.js +11 -12
- package/es/model/basic-number-card.js +10 -20
- package/es/model/collaborators.js +10 -11
- package/es/model/combination.js +32 -42
- package/es/model/compare-bar.js +30 -40
- package/es/model/completeness-group.js +19 -29
- package/es/model/completeness.js +14 -24
- package/es/model/custom-bar.js +14 -24
- package/es/model/dashboard.js +9 -19
- package/es/model/generic-model.js +187 -197
- package/es/model/heat-map.js +16 -26
- package/es/model/horizontal-bar-group.js +32 -42
- package/es/model/horizontal-bar.js +26 -36
- package/es/model/index.js +31 -3
- package/es/model/map.js +20 -30
- package/es/model/mirror.js +15 -25
- package/es/model/pie.js +21 -31
- package/es/model/ring.js +23 -33
- package/es/model/scatter.js +11 -21
- package/es/model/statistic-dashboard.js +7 -8
- package/es/model/table.js +19 -29
- package/es/model/trend.js +15 -25
- package/es/model/world-map.js +17 -27
- package/es/service/chart-service.js +69 -65
- package/es/service/dashboard-service.js +421 -419
- package/es/service/map-json.js +112 -132
- package/es/stat-editor/chart-name-editor.js +44 -58
- package/es/stat-editor/index.js +59 -70
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +93 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +246 -248
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +127 -126
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +5 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +78 -90
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +146 -150
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +88 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +100 -118
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +161 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +58 -66
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +58 -60
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +152 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +101 -105
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +81 -91
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +110 -122
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +101 -113
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +130 -120
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +200 -194
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +98 -110
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +106 -118
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +212 -223
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +109 -119
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +329 -319
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +82 -90
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +58 -65
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +126 -116
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +201 -182
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +79 -79
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +196 -175
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +35 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +180 -147
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +31 -40
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +56 -67
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +60 -69
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +165 -158
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +61 -74
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +199 -193
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +25 -38
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +79 -86
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +138 -120
- package/es/stat-editor/stat-settings/map/map-level.js +31 -43
- package/es/stat-editor/stat-settings/map/map-province-city.js +82 -83
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +48 -50
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +96 -96
- package/es/stat-editor/stat-settings/public-setting/calender.js +69 -75
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +5 -3
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +36 -41
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +37 -41
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +25 -38
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +40 -52
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +90 -93
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +23 -36
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +39 -44
- package/es/stat-list/chart-preview.js +85 -98
- package/es/stat-list/index.js +170 -178
- package/es/stat-view/area-chart.js +282 -274
- package/es/stat-view/bar-chart.js +300 -292
- package/es/stat-view/base-chart.js +58 -52
- package/es/stat-view/basic-number-card.js +115 -168
- package/es/stat-view/combination-chart.js +298 -334
- package/es/stat-view/compare-chart.js +256 -254
- package/es/stat-view/completeness-chart.js +194 -206
- package/es/stat-view/custom-bar.js +221 -223
- package/es/stat-view/dashboard-chart.js +122 -180
- package/es/stat-view/heat-map.js +268 -294
- package/es/stat-view/horizontal-bar-chart.js +291 -281
- package/es/stat-view/index.js +136 -152
- package/es/stat-view/line-chart.js +267 -265
- package/es/stat-view/map.js +246 -246
- package/es/stat-view/mirror.js +141 -152
- package/es/stat-view/pie-chart.js +143 -156
- package/es/stat-view/pivot-table/index.js +113 -118
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +104 -102
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +116 -118
- package/es/stat-view/pivot-table/pivot-table-display-name.js +96 -95
- package/es/stat-view/pivot-table/two-dimension-table.js +238 -229
- package/es/stat-view/ring-chart.js +189 -200
- package/es/stat-view/scatter-chart.js +162 -213
- package/es/stat-view/treemap-chart.js +136 -200
- package/es/stat-view/trend-chart.js +137 -183
- package/es/stat-view/world-map.js +233 -243
- package/es/tabs/index.js +164 -169
- package/es/tabs/tab.js +101 -116
- package/es/utils/basic-chart-utils.js +7 -9
- package/es/utils/cell-format.js +48 -51
- package/es/utils/cell-value.js +1 -1
- package/es/utils/collaborator.js +15 -14
- package/es/utils/color-utils.js +48 -37
- package/es/utils/column-utils.js +47 -33
- package/es/utils/column.js +1 -1
- package/es/utils/common-utils.js +111 -117
- package/es/utils/date-format.js +17 -17
- package/es/utils/export-table-utils.js +507 -396
- package/es/utils/index.js +6 -6
- package/es/utils/map.js +30 -34
- package/es/utils/model.js +3 -5
- package/es/utils/object.js +4 -4
- package/es/utils/pivot-table.js +20 -20
- package/es/utils/row-utils.js +41 -33
- package/es/utils/search.js +18 -20
- package/es/utils/sql-utils.js +132 -98
- package/es/utils/stat-utils.js +303 -320
- package/es/utils/trend-utils.js +57 -67
- package/package.json +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import dayjs from 'dayjs';
|
|
3
2
|
import intl from 'react-intl-universal';
|
|
4
3
|
import { getOption, getCollaborator, getNumberDisplayString, isNumber, CellType, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES, isDateColumn, TableUtils } from 'dtable-store';
|
|
@@ -7,70 +6,76 @@ import { getSelectColumnOptions, getDateColumnFormat } from './column';
|
|
|
7
6
|
import { getKnownCreatorByEmail } from './collaborator';
|
|
8
7
|
import { EMPTY_NAME, STATISTICS_COUNT_TYPE } from '../constants';
|
|
9
8
|
import { getPivotTableSummaryTotal } from './pivot-table';
|
|
10
|
-
|
|
9
|
+
const isEmptyName = title => {
|
|
11
10
|
return title === null || title === '';
|
|
12
11
|
};
|
|
13
|
-
|
|
12
|
+
const isSummaryDateColumn = summaryColumn => {
|
|
14
13
|
if (!summaryColumn) return false;
|
|
15
|
-
|
|
14
|
+
const {
|
|
15
|
+
type
|
|
16
|
+
} = summaryColumn;
|
|
16
17
|
return type !== CellType.LINK && isDateColumn(summaryColumn);
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
// eslint-disable-next-line
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type
|
|
23
|
-
data
|
|
24
|
-
|
|
21
|
+
const getTableValueDisplayName = (value, column) => {
|
|
22
|
+
let {
|
|
23
|
+
type,
|
|
24
|
+
data
|
|
25
|
+
} = column || {};
|
|
26
|
+
let {
|
|
27
|
+
collaborators
|
|
28
|
+
} = window.app.state;
|
|
25
29
|
switch (type) {
|
|
26
30
|
case CellType.SINGLE_SELECT:
|
|
27
31
|
case CellType.MULTIPLE_SELECT:
|
|
28
32
|
{
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
let options = getSelectColumnOptions(column);
|
|
34
|
+
let option = getOption(options, value) || {};
|
|
31
35
|
return option.name;
|
|
32
36
|
}
|
|
33
37
|
case CellType.COLLABORATOR:
|
|
34
38
|
{
|
|
35
|
-
|
|
39
|
+
let collaborator = getCollaborator(collaborators, value) || {};
|
|
36
40
|
return collaborator.name;
|
|
37
41
|
}
|
|
38
42
|
case CellType.CREATOR:
|
|
39
43
|
case CellType.LAST_MODIFIER:
|
|
40
44
|
{
|
|
41
|
-
|
|
42
|
-
return
|
|
45
|
+
let collaborator = getKnownCreatorByEmail(collaborators, value) || {};
|
|
46
|
+
return collaborator.name;
|
|
43
47
|
}
|
|
44
48
|
case CellType.NUMBER:
|
|
45
49
|
{
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
let valueNumber = parseFloat(value);
|
|
51
|
+
let displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
|
|
48
52
|
return displayValue;
|
|
49
53
|
}
|
|
50
54
|
case CellType.DATE:
|
|
51
55
|
{
|
|
52
|
-
|
|
56
|
+
let displayValue = value;
|
|
53
57
|
if (value && value.split('-').length === 3) {
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
let format = getDateColumnFormat(column);
|
|
59
|
+
let spaceIndex = format.indexOf(' ');
|
|
56
60
|
if (spaceIndex > -1) {
|
|
57
61
|
format = format.slice(0, spaceIndex);
|
|
58
62
|
}
|
|
59
|
-
|
|
63
|
+
displayValue = dayjs(value).format(format);
|
|
60
64
|
}
|
|
61
|
-
return
|
|
65
|
+
return displayValue;
|
|
62
66
|
}
|
|
63
67
|
case CellType.FORMULA:
|
|
64
68
|
case CellType.LINK_FORMULA:
|
|
65
69
|
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
result_type
|
|
70
|
+
let displayValue = value;
|
|
71
|
+
let {
|
|
72
|
+
result_type
|
|
73
|
+
} = data || {};
|
|
69
74
|
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
let valueNumber = parseFloat(value);
|
|
76
|
+
displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
|
|
72
77
|
}
|
|
73
|
-
return
|
|
78
|
+
return displayValue;
|
|
74
79
|
}
|
|
75
80
|
default:
|
|
76
81
|
{
|
|
@@ -78,10 +83,12 @@ var getTableValueDisplayName = function getTableValueDisplayName(value, column)
|
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
85
|
};
|
|
81
|
-
|
|
86
|
+
const getValidValueForColumn = (column, value) => {
|
|
82
87
|
if (!column) return '';
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
const {
|
|
89
|
+
type,
|
|
90
|
+
data
|
|
91
|
+
} = column;
|
|
85
92
|
if (FORMULA_COLUMN_TYPES.includes(type)) return '';
|
|
86
93
|
if (type === CellType.NUMBER) {
|
|
87
94
|
if (!value && value !== 0) return '';
|
|
@@ -91,25 +98,31 @@ var getValidValueForColumn = function getValidValueForColumn(column, value) {
|
|
|
91
98
|
if (type === CellType.DATE) {
|
|
92
99
|
if (!value) return '';
|
|
93
100
|
if (typeof value !== 'string') return '';
|
|
94
|
-
|
|
101
|
+
const validValueFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
|
|
95
102
|
return dayjs(value).format(validValueFormat);
|
|
96
103
|
}
|
|
97
104
|
if (type === CellType.TEXT) return value ? value : '';
|
|
98
105
|
return '';
|
|
99
106
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
const exportOneDimensionToTable = _ref => {
|
|
108
|
+
let {
|
|
109
|
+
statisticalResult
|
|
110
|
+
} = _ref;
|
|
111
|
+
const {
|
|
112
|
+
pivotResult,
|
|
113
|
+
groupbyColumn,
|
|
114
|
+
statisticTableColumns,
|
|
115
|
+
summaryColumn
|
|
116
|
+
} = statisticalResult;
|
|
117
|
+
const {
|
|
118
|
+
pivot_rows,
|
|
119
|
+
pivot_columns
|
|
120
|
+
} = pivotResult;
|
|
121
|
+
let columnMap = {};
|
|
122
|
+
let rows = [];
|
|
110
123
|
|
|
111
124
|
// generator columns
|
|
112
|
-
|
|
125
|
+
let columns = [{
|
|
113
126
|
// first column
|
|
114
127
|
key: '0000',
|
|
115
128
|
type: CellType.TEXT,
|
|
@@ -119,17 +132,18 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
|
|
|
119
132
|
|
|
120
133
|
// one dimension table no number columns
|
|
121
134
|
if (pivot_columns.length < 2) {
|
|
122
|
-
|
|
135
|
+
let columnData = {
|
|
123
136
|
format: 'number'
|
|
124
137
|
};
|
|
125
|
-
|
|
126
|
-
|
|
138
|
+
let _isDateSummaryColumn = false;
|
|
139
|
+
let isIncludeHour = false;
|
|
127
140
|
if (summaryColumn) {
|
|
128
141
|
if (isSummaryDateColumn(summaryColumn)) {
|
|
129
|
-
|
|
130
|
-
format
|
|
142
|
+
const {
|
|
143
|
+
format
|
|
144
|
+
} = summaryColumn.data || {};
|
|
131
145
|
columnData = {
|
|
132
|
-
format
|
|
146
|
+
format
|
|
133
147
|
};
|
|
134
148
|
_isDateSummaryColumn = true;
|
|
135
149
|
isIncludeHour = format && format.indexOf('HH:mm') > -1;
|
|
@@ -139,24 +153,25 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
|
|
|
139
153
|
such as the data attribute in the function column, which contains other content that is not
|
|
140
154
|
useful for creating a new column
|
|
141
155
|
*/
|
|
142
|
-
|
|
143
|
-
decimal
|
|
144
|
-
thousands
|
|
145
|
-
precision
|
|
146
|
-
enable_precision
|
|
147
|
-
|
|
156
|
+
const {
|
|
157
|
+
decimal,
|
|
158
|
+
thousands,
|
|
159
|
+
precision,
|
|
160
|
+
enable_precision,
|
|
161
|
+
format
|
|
162
|
+
} = summaryColumn.data || {};
|
|
148
163
|
columnData = {
|
|
149
|
-
decimal
|
|
150
|
-
thousands
|
|
151
|
-
precision
|
|
152
|
-
enable_precision
|
|
153
|
-
format
|
|
164
|
+
decimal,
|
|
165
|
+
thousands,
|
|
166
|
+
precision,
|
|
167
|
+
enable_precision,
|
|
168
|
+
format
|
|
154
169
|
};
|
|
155
170
|
}
|
|
156
171
|
}
|
|
157
172
|
|
|
158
173
|
// total column
|
|
159
|
-
|
|
174
|
+
const totalColumn = {
|
|
160
175
|
type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
|
|
161
176
|
name: intl.get('Total'),
|
|
162
177
|
data: columnData
|
|
@@ -164,41 +179,46 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
|
|
|
164
179
|
columns.push(totalColumn);
|
|
165
180
|
|
|
166
181
|
// generator rows
|
|
167
|
-
pivot_rows.forEach(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
original_name
|
|
171
|
-
total
|
|
172
|
-
|
|
173
|
-
|
|
182
|
+
pivot_rows.forEach(item => {
|
|
183
|
+
const {
|
|
184
|
+
name,
|
|
185
|
+
original_name,
|
|
186
|
+
total
|
|
187
|
+
} = item;
|
|
188
|
+
const groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
|
|
189
|
+
let cellValue = total.total;
|
|
174
190
|
if (_isDateSummaryColumn && cellValue) {
|
|
175
191
|
cellValue = isIncludeHour ? dayjs(cellValue).format('YYYY-MM-DD HH:mm') : dayjs(cellValue).format('YYYY-MM-DD');
|
|
176
192
|
}
|
|
177
|
-
|
|
193
|
+
const newRow = {
|
|
194
|
+
[groupbyColumn.name]: groupName,
|
|
195
|
+
[intl.get('Total')]: cellValue
|
|
196
|
+
};
|
|
178
197
|
rows.push(newRow);
|
|
179
198
|
});
|
|
180
199
|
return {
|
|
181
|
-
columns
|
|
182
|
-
rows
|
|
200
|
+
columns,
|
|
201
|
+
rows
|
|
183
202
|
};
|
|
184
203
|
}
|
|
185
204
|
|
|
186
205
|
// one dimension table with number columns
|
|
187
|
-
Array.isArray(pivot_columns) && pivot_columns.forEach(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
206
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
207
|
+
const {
|
|
208
|
+
key
|
|
209
|
+
} = item;
|
|
210
|
+
const column = statisticTableColumns.find(column => column.key === key);
|
|
192
211
|
if (column) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
212
|
+
const columnName = column.name;
|
|
213
|
+
let columnData;
|
|
214
|
+
let columnType = CellType.NUMBER;
|
|
196
215
|
if (isSummaryDateColumn(column)) {
|
|
197
216
|
columnType = CellType.DATE;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
217
|
+
const {
|
|
218
|
+
format
|
|
219
|
+
} = column.data || {};
|
|
220
|
+
columnData = {
|
|
221
|
+
format
|
|
202
222
|
};
|
|
203
223
|
} else {
|
|
204
224
|
/*
|
|
@@ -206,24 +226,25 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
|
|
|
206
226
|
such as the data attribute in the function column, which contains other content that is not
|
|
207
227
|
useful for creating a new column
|
|
208
228
|
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
229
|
+
const {
|
|
230
|
+
decimal,
|
|
231
|
+
thousands,
|
|
232
|
+
precision,
|
|
233
|
+
enable_precision,
|
|
234
|
+
format
|
|
235
|
+
} = column.data || {};
|
|
236
|
+
columnData = {
|
|
237
|
+
decimal,
|
|
238
|
+
thousands,
|
|
239
|
+
precision,
|
|
240
|
+
enable_precision,
|
|
241
|
+
format
|
|
221
242
|
};
|
|
222
243
|
}
|
|
223
|
-
|
|
244
|
+
const newColumn = {
|
|
224
245
|
type: columnType,
|
|
225
246
|
name: columnName,
|
|
226
|
-
data:
|
|
247
|
+
data: columnData
|
|
227
248
|
};
|
|
228
249
|
columnMap[key] = newColumn;
|
|
229
250
|
columns.push(newColumn);
|
|
@@ -231,23 +252,31 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
|
|
|
231
252
|
});
|
|
232
253
|
|
|
233
254
|
// generator rows
|
|
234
|
-
pivot_rows.forEach(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
255
|
+
pivot_rows.forEach(item => {
|
|
256
|
+
const {
|
|
257
|
+
name,
|
|
258
|
+
original_name,
|
|
259
|
+
total
|
|
260
|
+
} = item;
|
|
261
|
+
const groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
|
|
262
|
+
let newRow = {
|
|
263
|
+
[groupbyColumn.name]: groupName
|
|
264
|
+
};
|
|
265
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
266
|
+
const {
|
|
267
|
+
key,
|
|
268
|
+
method
|
|
269
|
+
} = item;
|
|
270
|
+
const column = columnMap[key];
|
|
271
|
+
const cellValueKey = key + method;
|
|
272
|
+
const {
|
|
273
|
+
name,
|
|
274
|
+
type,
|
|
275
|
+
data
|
|
276
|
+
} = column;
|
|
277
|
+
let cellValue = total[cellValueKey];
|
|
249
278
|
if (type === CellType.DATE && cellValue) {
|
|
250
|
-
|
|
279
|
+
const dateFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
|
|
251
280
|
cellValue = dayjs(cellValue).format(dateFormat);
|
|
252
281
|
}
|
|
253
282
|
newRow[name] = cellValue;
|
|
@@ -255,40 +284,47 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
|
|
|
255
284
|
rows.push(newRow);
|
|
256
285
|
});
|
|
257
286
|
return {
|
|
258
|
-
columns
|
|
259
|
-
rows
|
|
287
|
+
columns,
|
|
288
|
+
rows
|
|
260
289
|
};
|
|
261
290
|
};
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
291
|
+
const exportTwoDimensionToTable = _ref2 => {
|
|
292
|
+
let {
|
|
293
|
+
statisticalResult
|
|
294
|
+
} = _ref2;
|
|
295
|
+
const {
|
|
296
|
+
pivotResult,
|
|
297
|
+
groupbyColumn,
|
|
298
|
+
summaryColumn
|
|
299
|
+
} = statisticalResult;
|
|
300
|
+
const {
|
|
301
|
+
pivot_rows,
|
|
302
|
+
pivot_columns
|
|
303
|
+
} = pivotResult;
|
|
304
|
+
let columnMap = {};
|
|
305
|
+
let rows = [];
|
|
271
306
|
|
|
272
307
|
// generator columns
|
|
273
|
-
|
|
308
|
+
let columns = [{
|
|
274
309
|
// first column
|
|
275
310
|
key: '0000',
|
|
276
311
|
type: CellType.TEXT,
|
|
277
312
|
name: groupbyColumn.name,
|
|
278
313
|
data: null
|
|
279
314
|
}];
|
|
280
|
-
|
|
315
|
+
let columnData = {
|
|
281
316
|
format: 'number'
|
|
282
317
|
};
|
|
283
|
-
|
|
284
|
-
|
|
318
|
+
let _isDateSummaryColumn = false;
|
|
319
|
+
let isIncludeHour = false;
|
|
285
320
|
if (summaryColumn) {
|
|
286
321
|
if (isSummaryDateColumn(summaryColumn)) {
|
|
287
322
|
_isDateSummaryColumn = true;
|
|
288
|
-
|
|
289
|
-
format
|
|
323
|
+
const {
|
|
324
|
+
format
|
|
325
|
+
} = summaryColumn.data || {};
|
|
290
326
|
columnData = {
|
|
291
|
-
format
|
|
327
|
+
format
|
|
292
328
|
};
|
|
293
329
|
isIncludeHour = format && format.indexOf('HH:mm') > -1;
|
|
294
330
|
} else {
|
|
@@ -297,26 +333,29 @@ var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
|
|
|
297
333
|
such as the data attribute in the function column, which contains other content that is not
|
|
298
334
|
useful for creating a new column
|
|
299
335
|
*/
|
|
300
|
-
|
|
301
|
-
decimal
|
|
302
|
-
thousands
|
|
303
|
-
precision
|
|
304
|
-
enable_precision
|
|
305
|
-
|
|
336
|
+
const {
|
|
337
|
+
decimal,
|
|
338
|
+
thousands,
|
|
339
|
+
precision,
|
|
340
|
+
enable_precision,
|
|
341
|
+
format
|
|
342
|
+
} = summaryColumn.data || {};
|
|
306
343
|
columnData = {
|
|
307
|
-
decimal
|
|
308
|
-
thousands
|
|
309
|
-
precision
|
|
310
|
-
enable_precision
|
|
311
|
-
format
|
|
344
|
+
decimal,
|
|
345
|
+
thousands,
|
|
346
|
+
precision,
|
|
347
|
+
enable_precision,
|
|
348
|
+
format
|
|
312
349
|
};
|
|
313
350
|
}
|
|
314
351
|
}
|
|
315
|
-
Array.isArray(pivot_columns) && pivot_columns.forEach(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
352
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
353
|
+
const {
|
|
354
|
+
key,
|
|
355
|
+
original_key
|
|
356
|
+
} = item;
|
|
357
|
+
const columnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : key;
|
|
358
|
+
const newColumn = {
|
|
320
359
|
type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
|
|
321
360
|
name: columnName,
|
|
322
361
|
data: columnData
|
|
@@ -326,7 +365,7 @@ var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
|
|
|
326
365
|
});
|
|
327
366
|
|
|
328
367
|
// total column
|
|
329
|
-
|
|
368
|
+
const totalColumn = {
|
|
330
369
|
type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
|
|
331
370
|
name: intl.get('Total'),
|
|
332
371
|
data: columnData
|
|
@@ -334,23 +373,27 @@ var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
|
|
|
334
373
|
columns.push(totalColumn);
|
|
335
374
|
|
|
336
375
|
// generator rows
|
|
337
|
-
|
|
338
|
-
pivot_rows.forEach(
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
376
|
+
const dateFormat = isIncludeHour ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
|
|
377
|
+
pivot_rows.forEach(item => {
|
|
378
|
+
let {
|
|
379
|
+
name,
|
|
380
|
+
original_name,
|
|
381
|
+
cells,
|
|
382
|
+
total
|
|
383
|
+
} = item;
|
|
343
384
|
if (isEmptyName(original_name)) {
|
|
344
385
|
name = intl.get(EMPTY_NAME);
|
|
345
386
|
}
|
|
346
|
-
|
|
347
|
-
|
|
387
|
+
let newRow = {
|
|
388
|
+
[groupbyColumn.name]: name
|
|
389
|
+
};
|
|
390
|
+
let cellValue = total;
|
|
348
391
|
if (_isDateSummaryColumn && cellValue) {
|
|
349
392
|
cellValue = dayjs(cellValue).format(dateFormat);
|
|
350
393
|
}
|
|
351
394
|
newRow[intl.get('Total')] = cellValue;
|
|
352
|
-
Object.keys(cells).forEach(
|
|
353
|
-
|
|
395
|
+
Object.keys(cells).forEach(key => {
|
|
396
|
+
let cellValue = cells[key].total;
|
|
354
397
|
if (_isDateSummaryColumn) {
|
|
355
398
|
cellValue = cellValue ? dayjs(cellValue).format(dateFormat) : '';
|
|
356
399
|
}
|
|
@@ -359,56 +402,66 @@ var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
|
|
|
359
402
|
rows.push(newRow);
|
|
360
403
|
});
|
|
361
404
|
return {
|
|
362
|
-
columns
|
|
363
|
-
rows
|
|
405
|
+
columns,
|
|
406
|
+
rows
|
|
364
407
|
};
|
|
365
408
|
};
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
409
|
+
const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
410
|
+
let {
|
|
411
|
+
statisticalResult
|
|
412
|
+
} = _ref3;
|
|
413
|
+
const {
|
|
414
|
+
pivotResult,
|
|
415
|
+
groupbyColumn
|
|
416
|
+
} = statisticalResult;
|
|
417
|
+
const {
|
|
418
|
+
pivot_rows,
|
|
419
|
+
pivot_columns,
|
|
420
|
+
pivot_summary_multiple_columns,
|
|
421
|
+
formulaRows,
|
|
422
|
+
isSqlQuery
|
|
423
|
+
} = pivotResult;
|
|
424
|
+
const summaryColumns = pivot_summary_multiple_columns.filter(Boolean);
|
|
376
425
|
if (!groupbyColumn || summaryColumns.length === 0 || !Array.isArray(pivot_columns) || pivot_columns.length === 0 || !Array.isArray(pivot_rows) || pivot_rows.length === 0) return {};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
426
|
+
const groupbyColumnName = groupbyColumn.name;
|
|
427
|
+
const firstSummaryColumn = summaryColumns[0];
|
|
428
|
+
let columns = [{
|
|
380
429
|
// name column
|
|
381
430
|
key: '0000',
|
|
382
431
|
type: CellType.TEXT,
|
|
383
432
|
name: groupbyColumnName,
|
|
384
433
|
data: null
|
|
385
434
|
}];
|
|
386
|
-
|
|
387
|
-
pivot_columns.forEach(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
435
|
+
let tmpColumns = [];
|
|
436
|
+
pivot_columns.forEach(pivotColumn => {
|
|
437
|
+
const {
|
|
438
|
+
key: pivotColumnKey,
|
|
439
|
+
original_key
|
|
440
|
+
} = pivotColumn;
|
|
441
|
+
const pivotColumnColumnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : pivotColumnKey;
|
|
442
|
+
summaryColumns.forEach(summaryColumn => {
|
|
443
|
+
const {
|
|
444
|
+
key,
|
|
445
|
+
type,
|
|
446
|
+
sqlKey,
|
|
447
|
+
column_name,
|
|
448
|
+
data,
|
|
449
|
+
method
|
|
450
|
+
} = summaryColumn;
|
|
451
|
+
const newColumnName = "".concat(pivotColumnColumnName, "-").concat(column_name);
|
|
399
452
|
columns.push({
|
|
400
453
|
// just support number column
|
|
401
454
|
type: CellType.NUMBER,
|
|
402
455
|
name: newColumnName,
|
|
403
|
-
data
|
|
456
|
+
data
|
|
404
457
|
});
|
|
405
458
|
tmpColumns.push({
|
|
406
459
|
name: newColumnName,
|
|
407
|
-
pivotColumnKey
|
|
408
|
-
key
|
|
409
|
-
type
|
|
410
|
-
sqlKey
|
|
411
|
-
method
|
|
460
|
+
pivotColumnKey,
|
|
461
|
+
key,
|
|
462
|
+
type,
|
|
463
|
+
sqlKey,
|
|
464
|
+
method
|
|
412
465
|
});
|
|
413
466
|
});
|
|
414
467
|
});
|
|
@@ -417,29 +470,35 @@ var getTwoDimensionWithSummaryColumns = function getTwoDimensionWithSummaryColum
|
|
|
417
470
|
name: intl.get('Total'),
|
|
418
471
|
data: firstSummaryColumn.data
|
|
419
472
|
});
|
|
420
|
-
|
|
421
|
-
pivot_rows.forEach(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
473
|
+
let rows = [];
|
|
474
|
+
pivot_rows.forEach(pivotRow => {
|
|
475
|
+
let {
|
|
476
|
+
name,
|
|
477
|
+
original_name,
|
|
478
|
+
cells
|
|
479
|
+
} = pivotRow;
|
|
425
480
|
if (isEmptyName(original_name)) {
|
|
426
481
|
name = intl.get(EMPTY_NAME);
|
|
427
482
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
483
|
+
let newRow = {
|
|
484
|
+
[groupbyColumnName]: name
|
|
485
|
+
};
|
|
486
|
+
let total = 0;
|
|
487
|
+
tmpColumns.forEach(tmpColumn => {
|
|
488
|
+
const {
|
|
489
|
+
name,
|
|
490
|
+
pivotColumnKey,
|
|
491
|
+
key,
|
|
492
|
+
type,
|
|
493
|
+
sqlKey,
|
|
494
|
+
method
|
|
495
|
+
} = tmpColumn;
|
|
496
|
+
const cell = cells && cells[pivotColumnKey];
|
|
497
|
+
const cellRows = cell && cell.rows;
|
|
439
498
|
if (!Array.isArray(cellRows) || cellRows.length === 0) {
|
|
440
499
|
newRow[name] = 0;
|
|
441
500
|
} else {
|
|
442
|
-
|
|
501
|
+
const cellValue = getPivotTableSummaryTotal(type, key, sqlKey, STATISTICS_COUNT_TYPE.ADVANCED, method, cellRows, formulaRows, isSqlQuery);
|
|
443
502
|
newRow[name] = cellValue;
|
|
444
503
|
total += cellValue;
|
|
445
504
|
}
|
|
@@ -448,66 +507,76 @@ var getTwoDimensionWithSummaryColumns = function getTwoDimensionWithSummaryColum
|
|
|
448
507
|
rows.push(newRow);
|
|
449
508
|
});
|
|
450
509
|
return {
|
|
451
|
-
columns
|
|
452
|
-
rows
|
|
510
|
+
columns,
|
|
511
|
+
rows
|
|
453
512
|
};
|
|
454
513
|
};
|
|
455
|
-
|
|
456
|
-
|
|
514
|
+
const exportTwoDimensionWithSummaryColumnsToTable = _ref4 => {
|
|
515
|
+
let {
|
|
516
|
+
statisticalResult
|
|
517
|
+
} = _ref4;
|
|
457
518
|
return getTwoDimensionWithSummaryColumns({
|
|
458
|
-
statisticalResult
|
|
519
|
+
statisticalResult
|
|
459
520
|
});
|
|
460
521
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
522
|
+
const updatedOneDimensionToTable = _ref5 => {
|
|
523
|
+
let {
|
|
524
|
+
updateTable,
|
|
525
|
+
statisticalResult
|
|
526
|
+
} = _ref5;
|
|
527
|
+
const {
|
|
528
|
+
pivotResult,
|
|
529
|
+
groupbyColumn,
|
|
530
|
+
statisticTableColumns
|
|
531
|
+
} = statisticalResult;
|
|
467
532
|
if (!groupbyColumn) return {};
|
|
468
|
-
|
|
533
|
+
const nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
|
|
469
534
|
if (!nameColumn) return {};
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
535
|
+
const {
|
|
536
|
+
pivot_rows,
|
|
537
|
+
pivot_columns
|
|
538
|
+
} = pivotResult;
|
|
539
|
+
const {
|
|
540
|
+
rows: tableRows
|
|
541
|
+
} = updateTable;
|
|
542
|
+
let columnMap = {};
|
|
543
|
+
let newRows = [];
|
|
544
|
+
let updatedRows = {};
|
|
545
|
+
let oldRows = {};
|
|
546
|
+
let rowIds = [];
|
|
478
547
|
|
|
479
548
|
// one dimension table no summary columns
|
|
480
549
|
if (pivot_columns.length < 2) {
|
|
481
550
|
columnMap['total'] = TableUtils.getTableColumnByName(updateTable, intl.get('Total'));
|
|
482
551
|
|
|
483
552
|
// updated rows
|
|
484
|
-
pivot_rows.forEach(
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
553
|
+
pivot_rows.forEach(item => {
|
|
554
|
+
const {
|
|
555
|
+
name,
|
|
556
|
+
original_name,
|
|
557
|
+
total
|
|
558
|
+
} = item;
|
|
559
|
+
const groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
|
|
560
|
+
const row = tableRows.find(row => row[nameColumn.key] === groupName);
|
|
561
|
+
const totalColumn = columnMap['total'];
|
|
493
562
|
if (row) {
|
|
494
563
|
// update old row
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
564
|
+
let updateRow = {};
|
|
565
|
+
let oldRow = {};
|
|
566
|
+
const validTotalCellValue = getValidValueForColumn(totalColumn, total.total);
|
|
498
567
|
if (totalColumn && isCellValueChanged(row[totalColumn.key], validTotalCellValue, totalColumn.type)) {
|
|
499
568
|
updateRow[totalColumn.key] = validTotalCellValue;
|
|
500
569
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
501
570
|
}
|
|
502
571
|
if (Object.keys(updateRow).length > 0) {
|
|
503
|
-
|
|
572
|
+
const rowId = row._id;
|
|
504
573
|
rowIds.push(rowId);
|
|
505
574
|
updatedRows[rowId] = updateRow;
|
|
506
575
|
oldRows[rowId] = oldRow;
|
|
507
576
|
}
|
|
508
577
|
} else {
|
|
509
578
|
// insert new row
|
|
510
|
-
|
|
579
|
+
let newRow = {};
|
|
511
580
|
newRow[nameColumn.key] = groupName;
|
|
512
581
|
if (totalColumn) {
|
|
513
582
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
@@ -516,63 +585,71 @@ var updatedOneDimensionToTable = function updatedOneDimensionToTable(_ref13) {
|
|
|
516
585
|
}
|
|
517
586
|
});
|
|
518
587
|
return {
|
|
519
|
-
newRows
|
|
520
|
-
updatedRows
|
|
521
|
-
rowIds
|
|
522
|
-
oldRows
|
|
588
|
+
newRows,
|
|
589
|
+
updatedRows,
|
|
590
|
+
rowIds,
|
|
591
|
+
oldRows
|
|
523
592
|
};
|
|
524
593
|
}
|
|
525
594
|
|
|
526
595
|
// one dimension table with summary columns
|
|
527
|
-
Array.isArray(pivot_columns) && pivot_columns.forEach(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
596
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
597
|
+
const {
|
|
598
|
+
key
|
|
599
|
+
} = item;
|
|
600
|
+
const column = statisticTableColumns.find(column => column.key === key);
|
|
532
601
|
if (column) {
|
|
533
602
|
columnMap[key] = TableUtils.getTableColumnByName(updateTable, column.name);
|
|
534
603
|
}
|
|
535
604
|
});
|
|
536
605
|
|
|
537
606
|
// updated rows
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}
|
|
607
|
+
const {
|
|
608
|
+
key: nameColumnKey
|
|
609
|
+
} = nameColumn;
|
|
610
|
+
pivot_rows.forEach(item => {
|
|
611
|
+
const {
|
|
612
|
+
name,
|
|
613
|
+
original_name,
|
|
614
|
+
total
|
|
615
|
+
} = item;
|
|
616
|
+
const groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
|
|
617
|
+
const row = tableRows.find(row => row[nameColumnKey] === groupName);
|
|
547
618
|
if (row) {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
Array.isArray(pivot_columns) && pivot_columns.forEach(
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
619
|
+
let updateRow = {};
|
|
620
|
+
let oldRow = {};
|
|
621
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
622
|
+
const {
|
|
623
|
+
key,
|
|
624
|
+
method
|
|
625
|
+
} = item;
|
|
626
|
+
const column = columnMap[key];
|
|
627
|
+
const cellValueKey = key + method;
|
|
628
|
+
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
556
629
|
if (column && isCellValueChanged(row[column.key], totalCellValue, column.type)) {
|
|
557
630
|
updateRow[column.key] = totalCellValue;
|
|
558
631
|
oldRow[column.key] = row[column.key];
|
|
559
632
|
}
|
|
560
633
|
});
|
|
561
634
|
if (Object.keys(updateRow).length > 0) {
|
|
562
|
-
|
|
635
|
+
const rowId = row._id;
|
|
563
636
|
rowIds.push(rowId);
|
|
564
637
|
updatedRows[rowId] = updateRow;
|
|
565
638
|
oldRows[rowId] = oldRow;
|
|
566
639
|
}
|
|
567
640
|
} else {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
641
|
+
let newRow = {
|
|
642
|
+
[nameColumn.key]: groupName
|
|
643
|
+
};
|
|
644
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
645
|
+
const {
|
|
646
|
+
key,
|
|
647
|
+
method
|
|
648
|
+
} = item;
|
|
649
|
+
const cellValueKey = key + method;
|
|
650
|
+
const column = columnMap[key];
|
|
574
651
|
if (column) {
|
|
575
|
-
|
|
652
|
+
const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
|
|
576
653
|
newRow[column.key] = totalCellValue;
|
|
577
654
|
}
|
|
578
655
|
});
|
|
@@ -580,83 +657,97 @@ var updatedOneDimensionToTable = function updatedOneDimensionToTable(_ref13) {
|
|
|
580
657
|
}
|
|
581
658
|
});
|
|
582
659
|
return {
|
|
583
|
-
newRows
|
|
584
|
-
updatedRows
|
|
585
|
-
rowIds
|
|
586
|
-
oldRows
|
|
660
|
+
newRows,
|
|
661
|
+
updatedRows,
|
|
662
|
+
rowIds,
|
|
663
|
+
oldRows
|
|
587
664
|
};
|
|
588
665
|
};
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
666
|
+
const updateTwoDimensionToTable = _ref6 => {
|
|
667
|
+
let {
|
|
668
|
+
updateTable,
|
|
669
|
+
statisticalResult
|
|
670
|
+
} = _ref6;
|
|
671
|
+
const {
|
|
672
|
+
pivotResult,
|
|
673
|
+
groupbyColumn
|
|
674
|
+
} = statisticalResult;
|
|
675
|
+
const nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
|
|
595
676
|
if (!nameColumn) return {};
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
677
|
+
const {
|
|
678
|
+
pivot_rows,
|
|
679
|
+
pivot_columns
|
|
680
|
+
} = pivotResult;
|
|
681
|
+
const {
|
|
682
|
+
rows: tableRows
|
|
683
|
+
} = updateTable;
|
|
684
|
+
let columnMap = {};
|
|
685
|
+
let newRows = [];
|
|
686
|
+
let updatedRows = {};
|
|
687
|
+
let rowIds = [];
|
|
688
|
+
let oldRows = {};
|
|
604
689
|
|
|
605
690
|
// updated columns
|
|
606
|
-
|
|
607
|
-
Array.isArray(pivot_columns) && pivot_columns.forEach(
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
691
|
+
let updateColumns = [];
|
|
692
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
|
|
693
|
+
const {
|
|
694
|
+
key,
|
|
695
|
+
original_key
|
|
696
|
+
} = item;
|
|
697
|
+
const columnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : key;
|
|
698
|
+
const column = TableUtils.getTableColumnByName(updateTable, columnName);
|
|
612
699
|
columnMap[columnName] = column;
|
|
613
700
|
updateColumns.push(column);
|
|
614
701
|
});
|
|
615
|
-
|
|
702
|
+
const totalColumn = TableUtils.getTableColumnByName(updateTable, intl.get('Total'));
|
|
616
703
|
columnMap['total'] = totalColumn;
|
|
617
704
|
updateColumns.push(totalColumn);
|
|
618
705
|
|
|
619
706
|
// updated rows
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
707
|
+
for (let i = 0; i < pivot_rows.length; i++) {
|
|
708
|
+
const pivotRow = pivot_rows[i];
|
|
709
|
+
let {
|
|
710
|
+
name,
|
|
711
|
+
original_name,
|
|
712
|
+
cells,
|
|
713
|
+
total
|
|
714
|
+
} = pivotRow;
|
|
626
715
|
if (isEmptyName(original_name)) {
|
|
627
716
|
name = intl.get(EMPTY_NAME);
|
|
628
717
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
718
|
+
const {
|
|
719
|
+
key: nameColumnKey
|
|
720
|
+
} = nameColumn;
|
|
721
|
+
const row = tableRows.find(row => row[nameColumnKey] === name);
|
|
722
|
+
const totalColumn = columnMap['total'];
|
|
634
723
|
if (row) {
|
|
635
724
|
// update old row
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
725
|
+
const rowId = row._id;
|
|
726
|
+
let updatedRow = {};
|
|
727
|
+
let oldRow = {}; // op used
|
|
728
|
+
const validTotalCellValue = getValidValueForColumn(totalColumn, total);
|
|
640
729
|
if (totalColumn && isCellValueChanged(row[totalColumn.key], validTotalCellValue, totalColumn.type)) {
|
|
641
730
|
updatedRow[totalColumn.key] = validTotalCellValue;
|
|
642
731
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
643
732
|
}
|
|
644
|
-
|
|
733
|
+
const keys = Object.keys(cells);
|
|
645
734
|
if (keys.length === 0) {
|
|
646
|
-
updateColumns.forEach(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
735
|
+
updateColumns.forEach(column => {
|
|
736
|
+
const {
|
|
737
|
+
key,
|
|
738
|
+
type
|
|
739
|
+
} = column;
|
|
740
|
+
const newCellValue = key === totalColumn.key ? 0 : null;
|
|
650
741
|
if (isCellValueChanged(row[key], newCellValue, type)) {
|
|
651
742
|
updatedRow[key] = newCellValue;
|
|
652
743
|
oldRow[key] = row[key];
|
|
653
744
|
}
|
|
654
745
|
});
|
|
655
746
|
} else {
|
|
656
|
-
keys.forEach(
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
747
|
+
keys.forEach(key => {
|
|
748
|
+
const columnName = isEmptyName(key) ? intl.get(EMPTY_NAME) : key;
|
|
749
|
+
const column = columnMap[columnName];
|
|
750
|
+
let validCellValue = getValidValueForColumn(column, cells[key].total);
|
|
660
751
|
if (column && isCellValueChanged(row[column.key], validCellValue, column.type)) {
|
|
661
752
|
updatedRow[column.key] = validCellValue;
|
|
662
753
|
oldRow[column.key] = row[column.key];
|
|
@@ -670,14 +761,14 @@ var updateTwoDimensionToTable = function updateTwoDimensionToTable(_ref14) {
|
|
|
670
761
|
}
|
|
671
762
|
} else {
|
|
672
763
|
// insert new row
|
|
673
|
-
|
|
764
|
+
let newRow = {};
|
|
674
765
|
newRow[nameColumnKey] = name;
|
|
675
766
|
if (totalColumn) {
|
|
676
767
|
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, name);
|
|
677
768
|
}
|
|
678
|
-
Object.keys(cells).forEach(
|
|
679
|
-
|
|
680
|
-
|
|
769
|
+
Object.keys(cells).forEach(key => {
|
|
770
|
+
const columnName = isEmptyName(key) ? intl.get(EMPTY_NAME) : key;
|
|
771
|
+
const column = columnMap[columnName];
|
|
681
772
|
if (column) {
|
|
682
773
|
newRow[column.key] = getValidValueForColumn(column, cells[key].total);
|
|
683
774
|
}
|
|
@@ -686,66 +777,74 @@ var updateTwoDimensionToTable = function updateTwoDimensionToTable(_ref14) {
|
|
|
686
777
|
newRows.push(newRow);
|
|
687
778
|
}
|
|
688
779
|
}
|
|
689
|
-
};
|
|
690
|
-
for (var i = 0; i < pivot_rows.length; i++) {
|
|
691
|
-
_loop(i);
|
|
692
780
|
}
|
|
693
781
|
return {
|
|
694
|
-
newRows
|
|
695
|
-
updatedRows
|
|
696
|
-
oldRows
|
|
697
|
-
rowIds
|
|
782
|
+
newRows,
|
|
783
|
+
updatedRows,
|
|
784
|
+
oldRows,
|
|
785
|
+
rowIds
|
|
698
786
|
};
|
|
699
787
|
};
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
788
|
+
const updateTwoDimensionWithSummaryColumnsToTable = _ref7 => {
|
|
789
|
+
let {
|
|
790
|
+
updateTable,
|
|
791
|
+
statisticalResult
|
|
792
|
+
} = _ref7;
|
|
793
|
+
const {
|
|
794
|
+
groupbyColumn
|
|
795
|
+
} = statisticalResult;
|
|
796
|
+
const nameColumn = groupbyColumn && TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
|
|
705
797
|
if (!nameColumn) return {};
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
798
|
+
const {
|
|
799
|
+
columns: exportingColumns,
|
|
800
|
+
rows: exportingRows
|
|
801
|
+
} = getTwoDimensionWithSummaryColumns({
|
|
802
|
+
statisticalResult
|
|
803
|
+
});
|
|
711
804
|
if (!Array.isArray(exportingColumns) || exportingColumns.length === 0 || !Array.isArray(exportingRows) || exportingRows.length === 0) {
|
|
712
805
|
return {};
|
|
713
806
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
807
|
+
const {
|
|
808
|
+
rows: tableRows,
|
|
809
|
+
columns: tableColumns
|
|
810
|
+
} = updateTable;
|
|
811
|
+
const {
|
|
812
|
+
key: nameColumnKey
|
|
813
|
+
} = nameColumn;
|
|
814
|
+
const groupbyColumnName = groupbyColumn.name;
|
|
815
|
+
let newRows = [];
|
|
816
|
+
let updatedRows = {};
|
|
817
|
+
let rowIds = [];
|
|
818
|
+
let oldRows = {};
|
|
819
|
+
let nameCellValueExistRowMap = {};
|
|
820
|
+
tableRows.forEach(row => {
|
|
821
|
+
const nameCellValue = row[nameColumnKey];
|
|
725
822
|
if (!nameCellValueExistRowMap[nameCellValue]) {
|
|
726
823
|
nameCellValueExistRowMap[nameCellValue] = row;
|
|
727
824
|
}
|
|
728
825
|
});
|
|
729
|
-
exportingRows.forEach(
|
|
730
|
-
|
|
731
|
-
|
|
826
|
+
exportingRows.forEach(exportingRow => {
|
|
827
|
+
const nameCellValue = exportingRow[groupbyColumnName];
|
|
828
|
+
const existRow = nameCellValueExistRowMap[nameCellValue];
|
|
732
829
|
if (existRow) {
|
|
733
830
|
// update the row already exist
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
tableColumns.forEach(
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
831
|
+
let exportingRowData = {};
|
|
832
|
+
let existRowData = {};
|
|
833
|
+
tableColumns.forEach(tableColumn => {
|
|
834
|
+
const {
|
|
835
|
+
key: tableColumnKey,
|
|
836
|
+
type: tableColumnType,
|
|
837
|
+
name: tableColumnName
|
|
838
|
+
} = tableColumn;
|
|
839
|
+
const existCellValue = existRow[tableColumnKey];
|
|
840
|
+
const exportingCellValue = exportingRow[tableColumnName];
|
|
742
841
|
if (tableColumn && isCellValueChanged(existCellValue, exportingCellValue, tableColumnType)) {
|
|
743
842
|
exportingRowData[tableColumnKey] = exportingCellValue;
|
|
744
843
|
existRowData[tableColumnKey] = existCellValue;
|
|
745
844
|
}
|
|
746
845
|
});
|
|
747
846
|
if (Object.keys(exportingRowData).length > 0) {
|
|
748
|
-
|
|
847
|
+
let rowId = existRow._id;
|
|
749
848
|
rowIds.push(rowId);
|
|
750
849
|
updatedRows[rowId] = exportingRowData;
|
|
751
850
|
oldRows[rowId] = existRowData;
|
|
@@ -756,10 +855,10 @@ var updateTwoDimensionWithSummaryColumnsToTable = function updateTwoDimensionWit
|
|
|
756
855
|
}
|
|
757
856
|
});
|
|
758
857
|
return {
|
|
759
|
-
newRows
|
|
760
|
-
updatedRows
|
|
761
|
-
oldRows
|
|
762
|
-
rowIds
|
|
858
|
+
newRows,
|
|
859
|
+
updatedRows,
|
|
860
|
+
oldRows,
|
|
861
|
+
rowIds
|
|
763
862
|
};
|
|
764
863
|
};
|
|
765
864
|
|
|
@@ -794,57 +893,69 @@ var updateTwoDimensionWithSummaryColumnsToTable = function updateTwoDimensionWit
|
|
|
794
893
|
* ]
|
|
795
894
|
* }
|
|
796
895
|
*/
|
|
797
|
-
export
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
896
|
+
export const exportStatisticToTable = _ref8 => {
|
|
897
|
+
let {
|
|
898
|
+
statisticalResult
|
|
899
|
+
} = _ref8;
|
|
900
|
+
const {
|
|
901
|
+
pivotResult,
|
|
902
|
+
groupbyColumn,
|
|
903
|
+
columnGroupbyColumn
|
|
904
|
+
} = statisticalResult;
|
|
905
|
+
const {
|
|
906
|
+
pivot_columns,
|
|
907
|
+
pivot_summary_multiple_columns
|
|
908
|
+
} = pivotResult;
|
|
804
909
|
if (!groupbyColumn) return {};
|
|
805
910
|
|
|
806
911
|
// two dimension table
|
|
807
912
|
if (columnGroupbyColumn) {
|
|
808
913
|
if (Array.isArray(pivot_summary_multiple_columns) && pivot_summary_multiple_columns.length > 0) {
|
|
809
914
|
return exportTwoDimensionWithSummaryColumnsToTable({
|
|
810
|
-
statisticalResult
|
|
915
|
+
statisticalResult
|
|
811
916
|
});
|
|
812
917
|
}
|
|
813
918
|
return exportTwoDimensionToTable({
|
|
814
|
-
statisticalResult
|
|
919
|
+
statisticalResult
|
|
815
920
|
});
|
|
816
921
|
}
|
|
817
922
|
if (!Array.isArray(pivot_columns)) return {};
|
|
818
923
|
return exportOneDimensionToTable({
|
|
819
|
-
statisticalResult
|
|
924
|
+
statisticalResult
|
|
820
925
|
});
|
|
821
926
|
};
|
|
822
|
-
export
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
927
|
+
export const updateStatisticToTable = _ref9 => {
|
|
928
|
+
let {
|
|
929
|
+
updateTable,
|
|
930
|
+
statisticalResult
|
|
931
|
+
} = _ref9;
|
|
932
|
+
const {
|
|
933
|
+
groupbyColumn,
|
|
934
|
+
columnGroupbyColumn,
|
|
935
|
+
pivotResult
|
|
936
|
+
} = statisticalResult;
|
|
937
|
+
const {
|
|
938
|
+
pivot_summary_multiple_columns
|
|
939
|
+
} = pivotResult;
|
|
829
940
|
if (!groupbyColumn) return {};
|
|
830
941
|
|
|
831
942
|
// two dimension table
|
|
832
943
|
if (columnGroupbyColumn) {
|
|
833
944
|
if (Array.isArray(pivot_summary_multiple_columns) && pivot_summary_multiple_columns.length > 0) {
|
|
834
945
|
return updateTwoDimensionWithSummaryColumnsToTable({
|
|
835
|
-
updateTable
|
|
836
|
-
statisticalResult
|
|
946
|
+
updateTable,
|
|
947
|
+
statisticalResult
|
|
837
948
|
});
|
|
838
949
|
}
|
|
839
950
|
return updateTwoDimensionToTable({
|
|
840
|
-
updateTable
|
|
841
|
-
statisticalResult
|
|
951
|
+
updateTable,
|
|
952
|
+
statisticalResult
|
|
842
953
|
});
|
|
843
954
|
}
|
|
844
955
|
|
|
845
956
|
// one dimension table
|
|
846
957
|
return updatedOneDimensionToTable({
|
|
847
|
-
updateTable
|
|
848
|
-
statisticalResult
|
|
958
|
+
updateTable,
|
|
959
|
+
statisticalResult
|
|
849
960
|
});
|
|
850
961
|
};
|