cloud-web-corejs 1.0.54-dev.697 → 1.0.54-dev.698
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/package.json
CHANGED
|
@@ -44,56 +44,32 @@ function uniqueFileName(fileName, usedNames) {
|
|
|
44
44
|
return `${fileName}_${usedNames[fileName]}`;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const ARCHIVE_TYPE = {
|
|
48
48
|
FORM_SCRIPT: "formScript",
|
|
49
49
|
FORM_TEMPLATE: "formTemplate",
|
|
50
50
|
TABLE: "table",
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
const ARCHIVE_URL_MAP = [
|
|
54
|
+
{ match: "/form_develop/exportFormScript", type: ARCHIVE_TYPE.FORM_SCRIPT },
|
|
55
|
+
{ match: "/form_develop/exportFormTemplate", type: ARCHIVE_TYPE.FORM_TEMPLATE },
|
|
56
|
+
{ match: "/form_develop/exportSzTaMb", type: ARCHIVE_TYPE.TABLE },
|
|
57
|
+
];
|
|
58
|
+
|
|
53
59
|
export function getExportArchiveType(url) {
|
|
54
60
|
if (!url) return null;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
if (url.includes("/form_develop/exportFormTemplate")) {
|
|
59
|
-
return EXPORT_ARCHIVE_TYPES.FORM_TEMPLATE;
|
|
60
|
-
}
|
|
61
|
-
if (url.includes("/form_develop/exportSzTaMb")) {
|
|
62
|
-
return EXPORT_ARCHIVE_TYPES.TABLE;
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
61
|
+
const config = ARCHIVE_URL_MAP.find((item) => url.includes(item.match));
|
|
62
|
+
return config ? config.type : null;
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
function
|
|
65
|
+
function getFormScriptPrefix(item) {
|
|
68
66
|
const scriptCode = item.scriptCode || "script";
|
|
69
67
|
const formCode = item.formCode;
|
|
70
68
|
return formCode ? `S-${scriptCode}-${formCode}` : `S-${scriptCode}`;
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
function
|
|
74
|
-
const prefix = getFormScriptArchivePrefix(item);
|
|
75
|
-
const extraFiles = [];
|
|
76
|
-
|
|
77
|
-
if (!isNull(item.script)) {
|
|
78
|
-
const formatted = formatJsonContent(item.script);
|
|
79
|
-
item.script = formatted;
|
|
80
|
-
extraFiles.push({
|
|
81
|
-
fileName: `${prefix}-Item`,
|
|
82
|
-
content: formatted,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
mainContent: JSON.stringify(item, null, 2),
|
|
88
|
-
mainFileName: `${prefix}-Source`,
|
|
89
|
-
extraFiles,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function processFormTemplateArchiveItem(item) {
|
|
71
|
+
function appendFormTemplateExtraFiles(item, extraFiles, usedNames) {
|
|
94
72
|
const formCode = item.formCode || "form";
|
|
95
|
-
const extraFiles = [];
|
|
96
|
-
const usedNames = {};
|
|
97
73
|
|
|
98
74
|
if (!isNull(item.formViewContent)) {
|
|
99
75
|
const formatted = formatJsonContent(item.formViewContent);
|
|
@@ -104,8 +80,7 @@ function processFormTemplateArchiveItem(item) {
|
|
|
104
80
|
});
|
|
105
81
|
}
|
|
106
82
|
|
|
107
|
-
|
|
108
|
-
formScriptDTOs.forEach((scriptItem) => {
|
|
83
|
+
(item.formScriptDTOs || []).forEach((scriptItem) => {
|
|
109
84
|
if (!scriptItem || isNull(scriptItem.script)) return;
|
|
110
85
|
const scriptCode = scriptItem.scriptCode || "script";
|
|
111
86
|
const scriptFormCode = scriptItem.formCode || formCode;
|
|
@@ -119,6 +94,50 @@ function processFormTemplateArchiveItem(item) {
|
|
|
119
94
|
content: formatted,
|
|
120
95
|
});
|
|
121
96
|
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function formatExportFields(item, archiveType) {
|
|
100
|
+
if (archiveType === ARCHIVE_TYPE.FORM_SCRIPT && !isNull(item.script)) {
|
|
101
|
+
item.script = formatJsonContent(item.script);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (archiveType === ARCHIVE_TYPE.FORM_TEMPLATE) {
|
|
105
|
+
if (!isNull(item.formViewContent)) {
|
|
106
|
+
item.formViewContent = formatJsonContent(item.formViewContent);
|
|
107
|
+
}
|
|
108
|
+
(item.formScriptDTOs || []).forEach((scriptItem) => {
|
|
109
|
+
if (scriptItem && !isNull(scriptItem.script)) {
|
|
110
|
+
scriptItem.script = formatJsonContent(scriptItem.script);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function processFormScriptArchive(item) {
|
|
117
|
+
const prefix = getFormScriptPrefix(item);
|
|
118
|
+
formatExportFields(item, ARCHIVE_TYPE.FORM_SCRIPT);
|
|
119
|
+
const extraFiles = [];
|
|
120
|
+
|
|
121
|
+
if (!isNull(item.script)) {
|
|
122
|
+
extraFiles.push({
|
|
123
|
+
fileName: `${prefix}-Item`,
|
|
124
|
+
content: item.script,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
mainContent: JSON.stringify(item, null, 2),
|
|
130
|
+
mainFileName: `${prefix}-Source`,
|
|
131
|
+
extraFiles,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function processFormTemplateArchive(item) {
|
|
136
|
+
const formCode = item.formCode || "form";
|
|
137
|
+
const extraFiles = [];
|
|
138
|
+
const usedNames = {};
|
|
139
|
+
|
|
140
|
+
appendFormTemplateExtraFiles(item, extraFiles, usedNames);
|
|
122
141
|
|
|
123
142
|
return {
|
|
124
143
|
mainContent: JSON.stringify(item, null, 2),
|
|
@@ -127,11 +146,10 @@ function processFormTemplateArchiveItem(item) {
|
|
|
127
146
|
};
|
|
128
147
|
}
|
|
129
148
|
|
|
130
|
-
function
|
|
131
|
-
const taBm = item.taBm || "table";
|
|
149
|
+
function processTableArchive(item) {
|
|
132
150
|
return {
|
|
133
151
|
mainContent: JSON.stringify(item, null, 2),
|
|
134
|
-
mainFileName: `T-${taBm}`,
|
|
152
|
+
mainFileName: `T-${item.taBm || "table"}`,
|
|
135
153
|
extraFiles: [],
|
|
136
154
|
};
|
|
137
155
|
}
|
|
@@ -144,87 +162,29 @@ export function processArchiveExport(content, archiveType) {
|
|
|
144
162
|
|
|
145
163
|
const item = list[0];
|
|
146
164
|
switch (archiveType) {
|
|
147
|
-
case
|
|
148
|
-
return
|
|
149
|
-
case
|
|
150
|
-
return
|
|
151
|
-
case
|
|
152
|
-
return
|
|
165
|
+
case ARCHIVE_TYPE.FORM_SCRIPT:
|
|
166
|
+
return processFormScriptArchive(item);
|
|
167
|
+
case ARCHIVE_TYPE.FORM_TEMPLATE:
|
|
168
|
+
return processFormTemplateArchive(item);
|
|
169
|
+
case ARCHIVE_TYPE.TABLE:
|
|
170
|
+
return processTableArchive(item);
|
|
153
171
|
default:
|
|
154
172
|
return { mainContent: content, mainFileName: null, extraFiles: [] };
|
|
155
173
|
}
|
|
156
174
|
}
|
|
157
175
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (url.includes("/form_develop/exportFormScript")) {
|
|
164
|
-
return {
|
|
165
|
-
field: "script",
|
|
166
|
-
getExtraFileName(item) {
|
|
167
|
-
const prefix = getFormScriptArchivePrefix(item);
|
|
168
|
-
return `${prefix}-Item`;
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
if (url.includes("/form_develop/exportFormTemplate")) {
|
|
173
|
-
return {
|
|
174
|
-
field: "formViewContent",
|
|
175
|
-
getExtraFileName(item) {
|
|
176
|
-
return `F-${item.formCode || "form"}-Item`;
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export function processExportContent(content, extraConfig) {
|
|
184
|
-
if (!extraConfig) {
|
|
185
|
-
return { mainContent: content, extraFiles: [] };
|
|
176
|
+
/** 批量导出:仅格式化主 JSON 中的大字段,不额外拆文件 */
|
|
177
|
+
export function formatBatchExportContent(content, url) {
|
|
178
|
+
const archiveType = getExportArchiveType(url);
|
|
179
|
+
if (!archiveType || archiveType === ARCHIVE_TYPE.TABLE) {
|
|
180
|
+
return content;
|
|
186
181
|
}
|
|
187
182
|
|
|
188
|
-
const { field, getExtraFileName } = extraConfig;
|
|
189
183
|
const { list, isArray, invalid } = parseExportContent(content);
|
|
190
|
-
|
|
191
184
|
if (invalid || !list.length) {
|
|
192
|
-
return
|
|
185
|
+
return content;
|
|
193
186
|
}
|
|
194
187
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
list.forEach((item, index) => {
|
|
199
|
-
if (!item || isNull(item[field])) return;
|
|
200
|
-
|
|
201
|
-
const formatted = formatJsonContent(item[field]);
|
|
202
|
-
item[field] = formatted;
|
|
203
|
-
|
|
204
|
-
let fileName = getExtraFileName(item, index);
|
|
205
|
-
if (!fileName) return;
|
|
206
|
-
|
|
207
|
-
fileName = uniqueFileName(fileName, usedNames);
|
|
208
|
-
extraFiles.push({ fileName, content: formatted });
|
|
209
|
-
|
|
210
|
-
if (field === "formViewContent" && Array.isArray(item.formScriptDTOs)) {
|
|
211
|
-
item.formScriptDTOs.forEach((scriptItem) => {
|
|
212
|
-
if (!scriptItem || isNull(scriptItem.script)) return;
|
|
213
|
-
const scriptCode = scriptItem.scriptCode || "script";
|
|
214
|
-
const formCode = scriptItem.formCode || item.formCode || "form";
|
|
215
|
-
const scriptFormatted = formatJsonContent(scriptItem.script);
|
|
216
|
-
scriptItem.script = scriptFormatted;
|
|
217
|
-
extraFiles.push({
|
|
218
|
-
fileName: uniqueFileName(
|
|
219
|
-
`FS-${scriptCode}-${formCode}-Item`,
|
|
220
|
-
usedNames
|
|
221
|
-
),
|
|
222
|
-
content: scriptFormatted,
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
const mainContent = JSON.stringify(isArray ? list : list[0], null, 2);
|
|
229
|
-
return { mainContent, extraFiles };
|
|
188
|
+
list.forEach((item) => formatExportFields(item, archiveType));
|
|
189
|
+
return JSON.stringify(isArray ? list : list[0], null, 2);
|
|
230
190
|
}
|
|
@@ -3,12 +3,11 @@ import vue from "vue";
|
|
|
3
3
|
import excelImport from "./index.vue";
|
|
4
4
|
import exportDialog from "./exportDialog.vue";
|
|
5
5
|
import { getBdEnv } from "@base/api/user";
|
|
6
|
-
import { encrypt
|
|
6
|
+
import { encrypt } from "@base/utils/aes";
|
|
7
7
|
import {
|
|
8
|
+
formatBatchExportContent,
|
|
8
9
|
getExportArchiveType,
|
|
9
|
-
getExportExtraConfig,
|
|
10
10
|
processArchiveExport,
|
|
11
|
-
processExportContent,
|
|
12
11
|
} from "./exportUtil";
|
|
13
12
|
|
|
14
13
|
import { getToken } from "../../utils/auth";
|
|
@@ -61,7 +60,6 @@ moudule.install = function (Vue) {
|
|
|
61
60
|
Vue.prototype.$jsonImport = toDo;
|
|
62
61
|
|
|
63
62
|
Vue.prototype.$jsonExport = async function (options) {
|
|
64
|
-
let reqData = {};
|
|
65
63
|
let targetRef = options.targetRef;
|
|
66
64
|
let abcEnabled = options.abcEnabled !== false;
|
|
67
65
|
let editAuth = options.editAuth;
|
|
@@ -103,35 +101,24 @@ moudule.install = function (Vue) {
|
|
|
103
101
|
success: (res) => {
|
|
104
102
|
let content = res.objx;
|
|
105
103
|
if (content && content !== "[]") {
|
|
106
|
-
let fileName;
|
|
107
104
|
const archiveType = options.plaintext
|
|
108
105
|
&& getExportArchiveType(options.url);
|
|
109
106
|
|
|
110
107
|
if (archiveType) {
|
|
111
108
|
const processed = processArchiveExport(content, archiveType);
|
|
112
|
-
|
|
113
|
-
fileName = processed.mainFileName || options.fileName;
|
|
114
|
-
downloadTxt(fileName, content);
|
|
109
|
+
downloadTxt(processed.mainFileName, processed.mainContent);
|
|
115
110
|
downloadExtraFiles(processed.extraFiles);
|
|
116
111
|
} else {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
content = formatBatchExportContent(content, options.url);
|
|
113
|
+
let fileName = options.fileName;
|
|
114
|
+
if (!fileName) {
|
|
115
|
+
const timeStr = res.time
|
|
121
116
|
.replaceAll(":", "")
|
|
122
117
|
.replaceAll("-", "")
|
|
123
118
|
.replaceAll(" ", "");
|
|
124
|
-
fileName = options.title
|
|
125
|
-
}
|
|
126
|
-
const extraConfig = getExportExtraConfig(options.url, options);
|
|
127
|
-
if (extraConfig) {
|
|
128
|
-
const processed = processExportContent(content, extraConfig);
|
|
129
|
-
content = processed.mainContent;
|
|
130
|
-
downloadTxt(fileName, content);
|
|
131
|
-
downloadExtraFiles(processed.extraFiles);
|
|
132
|
-
} else {
|
|
133
|
-
downloadTxt(fileName, content);
|
|
119
|
+
fileName = `${options.title}(${timeStr})`;
|
|
134
120
|
}
|
|
121
|
+
downloadTxt(fileName, content);
|
|
135
122
|
}
|
|
136
123
|
} else {
|
|
137
124
|
this.$baseAlert(this.$t1("不存在需要导出的数据"));
|