@gingkoo/base-server 0.0.4-alpha.10 → 0.0.4-alpha.11
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.
|
@@ -99,11 +99,12 @@ router.post('/excel-export/:moduleId', async function (req, res) {
|
|
|
99
99
|
|
|
100
100
|
let { moduleId } = req.params;
|
|
101
101
|
let options = {
|
|
102
|
+
MODULE_ID: moduleId,
|
|
102
103
|
...req.query,
|
|
103
104
|
...req.body,
|
|
104
105
|
};
|
|
105
106
|
|
|
106
|
-
let [err, result] = await importExportService.downloadFile(userid,
|
|
107
|
+
let [err, result] = await importExportService.downloadFile(userid, options);
|
|
107
108
|
if (err) {
|
|
108
109
|
return res.sendErr(err?.message || '导出失败');
|
|
109
110
|
}
|
|
@@ -3,6 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const dayjs = require('dayjs');
|
|
5
5
|
const { format: timeFormat } = require('date-fns');
|
|
6
|
+
const config = require('../../../config');
|
|
6
7
|
const { creatTask } = require('../../services/task');
|
|
7
8
|
const { sse, bgTaskEnum } = require('../../sse');
|
|
8
9
|
const tasks = require('../../task');
|
|
@@ -69,7 +70,7 @@ module.exports = {
|
|
|
69
70
|
TASK_NAME,
|
|
70
71
|
MODULE_ID: 'import',
|
|
71
72
|
TASK_SERVICE: FWD,
|
|
72
|
-
TASK_ID:
|
|
73
|
+
TASK_ID: taskId,
|
|
73
74
|
taskProgressStatus: bgTaskEnum.taskProgressStatus.dataLoading,
|
|
74
75
|
STATUS: 'Pending',
|
|
75
76
|
DATA_CRT_DATE: curDate,
|
|
@@ -93,14 +94,13 @@ module.exports = {
|
|
|
93
94
|
/**
|
|
94
95
|
* 下载文件
|
|
95
96
|
* @param {string} USER_ID 当前登录用户
|
|
96
|
-
* @param {string} moduleId 模块id
|
|
97
97
|
* @param {object} options 参数
|
|
98
98
|
*/
|
|
99
|
-
async downloadFile(USER_ID,
|
|
100
|
-
let { FWD, ...rest } = options;
|
|
99
|
+
async downloadFile(USER_ID, options) {
|
|
100
|
+
let { FWD, MODULE_ID, ...rest } = options;
|
|
101
101
|
|
|
102
102
|
let curTime = dayjs().format('YYYYMMDDHHmmss');
|
|
103
|
-
let FILE_NAME =
|
|
103
|
+
let FILE_NAME = MODULE_ID + '_' + curTime + '.xlsx';
|
|
104
104
|
let storageDir = path.join(config['app']['home'], 'storage');
|
|
105
105
|
let dir = path.join(global.orgid.toLowerCase(), 'users', USER_ID);
|
|
106
106
|
let FILE_DIR = path.join(storageDir, dir);
|
|
@@ -119,7 +119,7 @@ module.exports = {
|
|
|
119
119
|
FILE_DIR: dir, // 这里为什么不拼上 storageDir,这里不拼,那下载不也得拼吗?
|
|
120
120
|
TASK_TYPE: 'excelExport',
|
|
121
121
|
TASK_NAME,
|
|
122
|
-
MODULE_ID
|
|
122
|
+
MODULE_ID,
|
|
123
123
|
TASK_SERVICE: FWD,
|
|
124
124
|
DATA_CRT_DATE: curDate,
|
|
125
125
|
DATA_CRT_TIME: curTime1,
|
|
@@ -140,7 +140,7 @@ module.exports = {
|
|
|
140
140
|
FILE_DIR: dir, // 这里为什么不拼上 storageDir,这里不拼,那下载不也得拼吗?
|
|
141
141
|
TASK_TYPE: 'excelExport',
|
|
142
142
|
TASK_NAME,
|
|
143
|
-
MODULE_ID
|
|
143
|
+
MODULE_ID,
|
|
144
144
|
TASK_SERVICE: FWD,
|
|
145
145
|
TASK_ID: result.TASK,
|
|
146
146
|
taskProgressStatus: bgTaskEnum.taskProgressStatus.exportOutData,
|
|
@@ -35,7 +35,9 @@ const handleDynamicParams = (layout, data) => {
|
|
|
35
35
|
return obj;
|
|
36
36
|
} else if (typeof layout === 'string') {
|
|
37
37
|
// 字符串
|
|
38
|
-
return /\$\{.+\}/.test(layout)
|
|
38
|
+
return /\$\{.+\}/.test(layout)
|
|
39
|
+
? tokenize(handleSpecialChars(layout), data)
|
|
40
|
+
: handleSpecialChars(layout);
|
|
39
41
|
} else {
|
|
40
42
|
// 数字 boolean null undefined 等等 都不处理
|
|
41
43
|
return layout;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gingkoo/base-server",
|
|
3
|
-
"version": "0.0.4-alpha.
|
|
3
|
+
"version": "0.0.4-alpha.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"date-fns": "^2.29.3",
|
|
31
31
|
"dayjs": "^1.11.6",
|
|
32
32
|
"express": "^4.19.1",
|
|
33
|
+
"exceljs": "^4.3.0",
|
|
33
34
|
"express-xml-bodyparser": "^0.3.0",
|
|
34
35
|
"getavataaars": "^1.0.0",
|
|
35
36
|
"http-proxy-middleware": "^2.0.1",
|