cloud-web-corejs 1.0.54-dev.705 → 1.0.54-dev.706

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.54-dev.705",
4
+ "version": "1.0.54-dev.706",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -1,25 +1,3 @@
1
- function isNull(val) {
2
- return val == null || val === "" || val === undefined;
3
- }
4
-
5
- export function formatJsonContent(content) {
6
- if (isNull(content)) return "";
7
- if (typeof content === "object") {
8
- try {
9
- return JSON.stringify(content, null, 2);
10
- } catch (e) {
11
- return String(content);
12
- }
13
- }
14
- const text = String(content).trim();
15
- if (!text) return "";
16
- try {
17
- return JSON.stringify(JSON.parse(text), null, 2);
18
- } catch (e) {
19
- return text;
20
- }
21
- }
22
-
23
1
  function parseExportContent(content) {
24
2
  if (!content) {
25
3
  return { list: [], isArray: true };
@@ -62,129 +40,59 @@ export function getExportArchiveType(url) {
62
40
  return config ? config.type : null;
63
41
  }
64
42
 
65
- function getFormScriptPrefix(item) {
66
- const scriptCode = item.scriptCode || "script";
67
- const formCode = item.formCode;
68
- return formCode ? `S-${scriptCode}-${formCode}` : `S-${scriptCode}`;
43
+ function getFormScriptFileName(scriptCode, formCode) {
44
+ const code = scriptCode || "script";
45
+ return formCode ? `S&${code}&${formCode}` : `S&${code}`;
69
46
  }
70
47
 
71
- function appendFormTemplateExtraFiles(item, extraFiles, usedNames) {
48
+ function buildFormTemplateScriptExtras(item) {
72
49
  const formCode = item.formCode || "form";
50
+ const usedNames = {};
73
51
 
74
- if (!isNull(item.formViewContent)) {
75
- const formatted = formatJsonContent(item.formViewContent);
76
- item.formViewContent = formatted;
77
- extraFiles.push({
78
- fileName: uniqueFileName(`F-${formCode}-Item`, usedNames),
79
- content: formatted,
80
- });
81
- }
82
-
83
- (item.formScriptDTOs || []).forEach((scriptItem) => {
84
- if (!scriptItem || isNull(scriptItem.script)) return;
85
- const scriptCode = scriptItem.scriptCode || "script";
86
- const scriptFormCode = scriptItem.formCode || formCode;
87
- const formatted = formatJsonContent(scriptItem.script);
88
- scriptItem.script = formatted;
89
- extraFiles.push({
52
+ return (item.formScriptDTOs || []).reduce((files, scriptItem) => {
53
+ if (!scriptItem) return files;
54
+ files.push({
90
55
  fileName: uniqueFileName(
91
- `FS-${scriptCode}-${scriptFormCode}-Item`,
56
+ getFormScriptFileName(scriptItem.scriptCode, scriptItem.formCode || formCode),
92
57
  usedNames
93
58
  ),
94
- content: formatted,
95
- });
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,
59
+ content: JSON.stringify(scriptItem, null, 2),
125
60
  });
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);
141
-
142
- return {
143
- mainContent: JSON.stringify(item, null, 2),
144
- mainFileName: `F-${formCode}-Source`,
145
- extraFiles,
146
- };
147
- }
148
-
149
- function processTableArchive(item) {
150
- return {
151
- mainContent: JSON.stringify(item, null, 2),
152
- mainFileName: `T-${item.taBm || "table"}`,
153
- extraFiles: [],
154
- };
61
+ return files;
62
+ }, []);
155
63
  }
156
64
 
157
- export function processArchiveExport(content, archiveType) {
158
- const { list, invalid } = parseExportContent(content);
159
- if (invalid || !list.length) {
160
- return { mainContent: content, mainFileName: null, extraFiles: [] };
161
- }
65
+ function buildArchiveResult(item, archiveType) {
66
+ const mainContent = JSON.stringify(item, null, 2);
162
67
 
163
- const item = list[0];
164
68
  switch (archiveType) {
165
69
  case ARCHIVE_TYPE.FORM_SCRIPT:
166
- return processFormScriptArchive(item);
70
+ return {
71
+ mainContent,
72
+ mainFileName: getFormScriptFileName(item.scriptCode, item.formCode),
73
+ extraFiles: [],
74
+ };
167
75
  case ARCHIVE_TYPE.FORM_TEMPLATE:
168
- return processFormTemplateArchive(item);
76
+ return {
77
+ mainContent,
78
+ mainFileName: `F&${item.formCode || "form"}`,
79
+ extraFiles: buildFormTemplateScriptExtras(item),
80
+ };
169
81
  case ARCHIVE_TYPE.TABLE:
170
- return processTableArchive(item);
82
+ return {
83
+ mainContent,
84
+ mainFileName: `T&${item.taBm || "table"}`,
85
+ extraFiles: [],
86
+ };
171
87
  default:
172
- return { mainContent: content, mainFileName: null, extraFiles: [] };
88
+ return { mainContent, mainFileName: null, extraFiles: [] };
173
89
  }
174
90
  }
175
91
 
176
- /** 批量导出:仅格式化主 JSON 中的大字段,不额外拆文件 */
177
- export function formatBatchExportContent(content, url) {
178
- const archiveType = getExportArchiveType(url);
179
- if (!archiveType || archiveType === ARCHIVE_TYPE.TABLE) {
180
- return content;
181
- }
182
-
183
- const { list, isArray, invalid } = parseExportContent(content);
92
+ export function processArchiveExport(content, archiveType) {
93
+ const { list, invalid } = parseExportContent(content);
184
94
  if (invalid || !list.length) {
185
- return content;
95
+ return { mainContent: content, mainFileName: null, extraFiles: [] };
186
96
  }
187
-
188
- list.forEach((item) => formatExportFields(item, archiveType));
189
- return JSON.stringify(isArray ? list : list[0], null, 2);
97
+ return buildArchiveResult(list[0], archiveType);
190
98
  }
@@ -5,7 +5,6 @@ import exportDialog from "./exportDialog.vue";
5
5
  import { getBdEnv } from "@base/api/user";
6
6
  import { encrypt } from "@base/utils/aes";
7
7
  import {
8
- formatBatchExportContent,
9
8
  getExportArchiveType,
10
9
  processArchiveExport,
11
10
  } from "./exportUtil";
@@ -107,9 +106,12 @@ moudule.install = function (Vue) {
107
106
  if (archiveType) {
108
107
  const processed = processArchiveExport(content, archiveType);
109
108
  downloadTxt(processed.mainFileName, processed.mainContent);
110
- downloadExtraFiles(processed.extraFiles);
109
+ (processed.extraFiles || []).forEach((file, index) => {
110
+ setTimeout(() => {
111
+ downloadTxt(file.fileName, file.content);
112
+ }, (index + 1) * 300);
113
+ });
111
114
  } else {
112
- content = formatBatchExportContent(content, options.url);
113
115
  let fileName = options.fileName;
114
116
  if (!fileName) {
115
117
  const timeStr = res.time
@@ -157,15 +159,6 @@ moudule.install = function (Vue) {
157
159
  };
158
160
  };
159
161
 
160
- function downloadExtraFiles(extraFiles) {
161
- if (!extraFiles || !extraFiles.length) return;
162
- extraFiles.forEach((file, index) => {
163
- setTimeout(() => {
164
- downloadTxt(file.fileName, file.content);
165
- }, (index + 1) * 300);
166
- });
167
- }
168
-
169
162
  function downloadTxt(fileName, content) {
170
163
  // 创建Blob对象
171
164
  const blob = new Blob([content], { type: "text/plain;charset=utf-8" });