dtable-statistic 5.1.19 → 5.1.20
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.
|
@@ -224,11 +224,11 @@ const exportOneDimensionToTable = _ref => {
|
|
|
224
224
|
type: _dtableUtils.CellType.NUMBER,
|
|
225
225
|
name: _reactIntlUniversal.default.get('Total'),
|
|
226
226
|
data: {
|
|
227
|
-
decimal:
|
|
227
|
+
decimal: 'dot',
|
|
228
228
|
enable_precision: false,
|
|
229
|
-
format:
|
|
229
|
+
format: 'yuan',
|
|
230
230
|
precision: 2,
|
|
231
|
-
thousands:
|
|
231
|
+
thousands: 'no'
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
234
|
columnMap['total'] = totalColumn;
|
|
@@ -24,13 +24,21 @@ async function calcViewRowsWithWorker(view, table, value, username, userId, user
|
|
|
24
24
|
if (!_resultCacheManager.cachedBase) {
|
|
25
25
|
(0, _resultCacheManager.initCachedBase)(value);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const tableRows = table.rows;
|
|
28
|
+
const idRowMap = table.id_row_map;
|
|
29
|
+
const clonedTable = (0, _lodashEs.cloneDeepWith)(table, (value, key) => {
|
|
30
|
+
if (key === 'rows' || key === 'id_row_map') {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
28
34
|
// Symbol can't passed to workers
|
|
29
35
|
clonedTable.columns = clonedTable.columns.map(c => {
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
c.editor = null;
|
|
37
|
+
c.formatter = null;
|
|
32
38
|
return c;
|
|
33
39
|
});
|
|
40
|
+
clonedTable.rows = tableRows;
|
|
41
|
+
clonedTable.id_row_map = idRowMap;
|
|
34
42
|
const workerId = uuid();
|
|
35
43
|
let worker;
|
|
36
44
|
try {
|
|
@@ -38,7 +46,12 @@ async function calcViewRowsWithWorker(view, table, value, username, userId, user
|
|
|
38
46
|
} catch (e) {
|
|
39
47
|
return [];
|
|
40
48
|
}
|
|
41
|
-
const
|
|
49
|
+
const getWorker = () => new Promise((resolve, reject) => {
|
|
50
|
+
requestAnimationFrame(() => {
|
|
51
|
+
resolve(Comlink.wrap(worker));
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
const calcWorker = await getWorker();
|
|
42
55
|
const rows = await calcWorker.getViewRows(view, clonedTable, _resultCacheManager.cachedBase, username, userId, userDepartmentIdsMap);
|
|
43
56
|
if (rows && Object.keys(rows).length) {
|
|
44
57
|
_resultCacheManager.viewRowsCacheManager.set(key, rows);
|
|
@@ -55,17 +68,25 @@ async function calcFormulaResultsWithWorker(table, rows, value, formulaColumns,
|
|
|
55
68
|
if (!_resultCacheManager.cachedBase) {
|
|
56
69
|
(0, _resultCacheManager.initCachedBase)(value);
|
|
57
70
|
}
|
|
58
|
-
const
|
|
71
|
+
const tableRows = table.rows;
|
|
72
|
+
const idRowMap = table.id_row_map;
|
|
73
|
+
const clonedTable = (0, _lodashEs.cloneDeepWith)(table, (value, key) => {
|
|
74
|
+
if (key === 'rows' || key === 'id_row_map') {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
59
78
|
// Symbol can't passed to workers
|
|
60
79
|
clonedTable.columns = clonedTable.columns.map(c => {
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
c.editor = null;
|
|
81
|
+
c.formatter = null;
|
|
63
82
|
return c;
|
|
64
83
|
});
|
|
84
|
+
clonedTable.rows = tableRows;
|
|
85
|
+
clonedTable.id_row_map = idRowMap;
|
|
65
86
|
let clonedFormulaColumns = (0, _lodashEs.cloneDeep)(formulaColumns);
|
|
66
87
|
clonedFormulaColumns = clonedFormulaColumns.map(c => {
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
c.editor = null;
|
|
89
|
+
c.formatter = null;
|
|
69
90
|
return c;
|
|
70
91
|
});
|
|
71
92
|
const workerId = uuid();
|
|
@@ -75,7 +96,12 @@ async function calcFormulaResultsWithWorker(table, rows, value, formulaColumns,
|
|
|
75
96
|
} catch (e) {
|
|
76
97
|
return [];
|
|
77
98
|
}
|
|
78
|
-
const
|
|
99
|
+
const getWorker = () => new Promise((resolve, reject) => {
|
|
100
|
+
requestAnimationFrame(() => {
|
|
101
|
+
resolve(Comlink.wrap(worker));
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
const calcWorker = await getWorker();
|
|
79
105
|
const results = await calcWorker.getTableFormulaResults(clonedTable, rows, _resultCacheManager.cachedBase, clonedFormulaColumns, username, userId, userDepartmentIdsMap);
|
|
80
106
|
if (results && Object.keys(results).length) {
|
|
81
107
|
_resultCacheManager.formulaResultsCacheManager.set(key, results);
|
|
@@ -27,24 +27,27 @@ const viewRowsCacheManager = exports.viewRowsCacheManager = new ResultCacheManag
|
|
|
27
27
|
const formulaResultsCacheManager = exports.formulaResultsCacheManager = new ResultCacheManager();
|
|
28
28
|
let cachedBase = exports.cachedBase = null;
|
|
29
29
|
function initCachedBase(value) {
|
|
30
|
-
// don't clone rows cause they are really big
|
|
31
30
|
const tableIdRowMap = {};
|
|
32
31
|
value.tables.forEach(t => {
|
|
33
|
-
tableIdRowMap[t._id] =
|
|
34
|
-
|
|
32
|
+
tableIdRowMap[t._id] = {
|
|
33
|
+
rows: t === null || t === void 0 ? void 0 : t.rows,
|
|
34
|
+
id_row_map: t === null || t === void 0 ? void 0 : t.id_row_map
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
// don't clone rows cause they are really big
|
|
38
|
+
const clonedBase = (0, _lodashEs.cloneDeepWith)(value, (v, k) => {
|
|
39
|
+
if (k === 'rows' || k === 'id_row_map') {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
35
42
|
});
|
|
36
|
-
const clonedBase = (0, _lodashEs.cloneDeep)(value);
|
|
37
43
|
clonedBase.tables.forEach(t => {
|
|
38
|
-
// delete symbols
|
|
39
44
|
t.columns = t.columns.map(c => {
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
c.editor = null;
|
|
46
|
+
c.formatter = null;
|
|
42
47
|
return c;
|
|
43
48
|
});
|
|
44
|
-
t.rows = tableIdRowMap[t._id];
|
|
45
|
-
|
|
46
|
-
value.tables.forEach(t => {
|
|
47
|
-
t.rows = tableIdRowMap[t._id];
|
|
49
|
+
t.rows = tableIdRowMap[t._id].rows;
|
|
50
|
+
t.id_row_map = tableIdRowMap[t._id].id_row_map;
|
|
48
51
|
});
|
|
49
52
|
exports.cachedBase = cachedBase = clonedBase;
|
|
50
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-statistic",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.20",
|
|
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": "^1.1.
|
|
21
|
+
"sea-chart": "^1.1.25"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"dtable-ui-component": "~5.1.*",
|