cloud-web-corejs 1.1.0-dev.10 → 1.1.0-dev.13

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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/components/VabUpload/view.vue +25 -25
  3. package/src/components/excelExport/exportColumnMemory.js +118 -0
  4. package/src/components/excelExport/exportFieldDialog.vue +50 -38
  5. package/src/components/excelExport/index.js +30 -13
  6. package/src/components/excelExport/mixins.js +390 -64
  7. package/src/components/excelImport/mixins.js +898 -850
  8. package/src/components/mobile/wf/addTaskUserdialog.vue +100 -100
  9. package/src/components/mobile/wf/content.vue +5 -5
  10. package/src/components/mobile/wf/deleteTaskUserDialog.vue +73 -73
  11. package/src/components/mobile/wf/selectUserDialog.vue +8 -12
  12. package/src/components/mobile/wf/setCandidateDialog.vue +69 -69
  13. package/src/components/mobile/wf/urgingDialog.vue +75 -75
  14. package/src/components/table/index.js +14 -1
  15. package/src/components/table/vxeFilter/mixin.js +28 -18
  16. package/src/components/xform/docs/2026-07 table/344/270/216excelExport/344/277/256/345/244/215/345/217/212/345/257/274/345/207/272/344/274/230/345/214/226.md" +64 -57
  17. package/src/components/xform/docs/2026-09 /346/235/241/344/273/266/345/257/274/345/207/272/345/244/247/346/225/260/346/215/256/351/207/217/345/264/251/346/272/203/346/216/222/346/237/245.md" +389 -0
  18. package/src/components/xform/form-designer/form-widget/container-widget/detail-h5-widget.vue +243 -243
  19. package/src/components/xform/form-designer/form-widget/container-widget/h5-card-pane-widget.vue +228 -228
  20. package/src/components/xform/form-designer/form-widget/container-widget/h5-card-widget.vue +165 -165
  21. package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin.js +61 -2
  22. package/src/components/xform/form-designer/form-widget/field-widget/select-export-item-button-widget.vue +3 -0
  23. package/src/components/xform/form-designer/form-widget/field-widget/singleUpload-widget.vue +145 -145
  24. package/src/components/xform/form-render/container-item/data-table-item.vue +350 -347
  25. package/src/components/xform/form-render/container-item/data-table-mixin.js +240 -37
  26. package/src/components/xform/form-render/container-item/detail-h5-item.vue +1 -1
  27. package/src/components/xform/form-render/container-item/list-h5-item.vue +1 -1
  28. package/src/components/xform/styles/h5.scss +483 -459
  29. package/src/components/xform/utils/dynamicSchemaUtil.js +385 -361
  30. package/src/layout/components/TagsView/index.vue +325 -323
  31. package/src/store/modules/tagsView.js +241 -217
  32. package/src/utils/importLimit.js +72 -0
  33. package/src/utils/pdfUtil.js +6 -1
  34. package/src/utils/request.js +17 -0
@@ -1,361 +1,385 @@
1
- /**
2
- * 后台动态定义(表头后台字段 / 数据表格动态列)共用协议。
3
- *
4
- * 单条定义顶层字段:
5
- * - 通用:keyName、type、label、optionItems、required 等字段级属性、options
6
- * - 表头:colspan
7
- * - 数据表格:width、formatS(展示列)、children(多级表头)、dropdownItems(dropdown 操作列)
8
- *
9
- * 请求体:{ formData, ...extra }
10
- * 响应体:objx 数组,或 { fields: [] } / { columns: [] }
11
- */
12
-
13
- /** 顶层字段白名单 */
14
- export const DYNAMIC_SCHEMA_CORE_KEYS = [
15
- "keyName",
16
- "type",
17
- "label",
18
- "optionItems",
19
- "options",
20
- ];
21
-
22
- /** 字段级属性:写顶层,不写 options(与表头 dynamicFieldMixin 一致) */
23
- export const DYNAMIC_SCHEMA_WIDGET_FLAG_KEYS = [
24
- "required",
25
- "readonly",
26
- "disabled",
27
- "hidden",
28
- "defaultValue",
29
- "placeholder",
30
- ];
31
-
32
- export const DYNAMIC_SCHEMA_TABLE_HEADER_KEYS = ["colspan"];
33
-
34
- export const DYNAMIC_SCHEMA_COLUMN_EXTRA_KEYS = [
35
- "width",
36
- "align",
37
- "sortable",
38
- "filterable",
39
- "show",
40
- "fixed",
41
- "formatS",
42
- "render",
43
- "utcTransformEnabled",
44
- "children",
45
- "dropdownItems",
46
- ];
47
-
48
- export const DYNAMIC_SCHEMA_OPTION_KEYS = {
49
- scriptCode: ["dynamicSchemaScriptCode", "dynamicColumnScriptCode"],
50
- scriptParam: ["dynamicSchemaScriptParam", "dynamicColumnScriptParam"],
51
- convert: ["dynamicSchemaConvert"],
52
- mode: ["dynamicSchemaMode", "dynamicColumnMode"],
53
- sourceType: ["dynamicSchemaSourceType", "dynamicColumnSourceType"],
54
- loadScript: ["dynamicSchemaLoadScript", "dynamicColumnLoadScript"],
55
- frontendScript: ["dynamicSchemaScript", "dynamicColumnsScript"],
56
- };
57
-
58
- export const widgetTypeToEditFormatMap = {
59
- input: "editInput",
60
- number: "editNumber",
61
- date: "editDate",
62
- select: "editSelect",
63
- vabsearch: "editSearch",
64
- baseAttachment: "editAttachment",
65
- status: "editStatus",
66
- text: "text",
67
- checkbox: "checkbox",
68
- radio: "radio",
69
- textarea: "textarea",
70
- "script-input": "editScriptInput",
71
- "a-text": "aText",
72
- "a-link": "aLink",
73
- button: "button",
74
- dropdown: "dropdown",
75
- };
76
-
77
- const ACTION_COLUMN_FORMATS = new Set(["aLink", "button", "dropdown"]);
78
-
79
- const NON_DATA_EXPORT_COLUMN_FORMATS = new Set([
80
- "dropdown",
81
- "button",
82
- "editDelete",
83
- "editButton",
84
- "editTreeButtonGroup",
85
- "addSiblingEditRow",
86
- "addChildTreeRow",
87
- "moveUpRow",
88
- "moveDownRow",
89
- "removeTreeRow",
90
- ]);
91
-
92
- const NON_DATA_EXPORT_WIDGET_TYPES = new Set([
93
- "button",
94
- "dropdown",
95
- "dropdown-item",
96
- "divider",
97
- "search_button",
98
- "save_button",
99
- "reset_button",
100
- "table-export-button",
101
- "select-export-button",
102
- "select-export-item-button",
103
- "add_button",
104
- "import-button",
105
- "import2-button",
106
- "print-button",
107
- "print-detail-button",
108
- "download-button",
109
- "save_submit_wf_button",
110
- "copy_button",
111
- "compare-change-button",
112
- "compare-button",
113
- "compare-close-button",
114
- "compare-del-button",
115
- ]);
116
-
117
- export function buildDropdownWidgetFromDef(def, index = 0) {
118
- const options = def?.options;
119
- const dropdownItems = def?.dropdownItems;
120
- if (!Array.isArray(dropdownItems) || !dropdownItems.length) return null;
121
-
122
- const ts = `${Date.now()}_${index}`;
123
- const widgetList = dropdownItems.map((entry, i) => ({
124
- type: "dropdown-item",
125
- id: `dropdownitem_${ts}_${i}`,
126
- options: {
127
- label: entry.label || "",
128
- onClick: entry.onClick || "",
129
- disabled: !!entry.disabled,
130
- hidden: !!entry.hidden,
131
- },
132
- }));
133
-
134
- return {
135
- type: "dropdown",
136
- id: `dropdown_${ts}`,
137
- options: {
138
- label: def.label || "操作",
139
- dropdownType: options?.dropdownType || "link",
140
- dropdownTrigger: options?.dropdownTrigger || "hover",
141
- dropdownFlag: 1,
142
- },
143
- widgetList,
144
- };
145
- }
146
-
147
- function isActionColumn(item, formatS) {
148
- return isActionColumnFormat(formatS, item?.type);
149
- }
150
-
151
- export function isActionColumnFormat(formatS, type) {
152
- if (ACTION_COLUMN_FORMATS.has(formatS)) return true;
153
- return ["a-link", "button", "dropdown"].includes(type);
154
- }
155
-
156
- export function isNonDataExportColumn(formatS, type, options) {
157
- if (NON_DATA_EXPORT_COLUMN_FORMATS.has(formatS)) return true;
158
- if (NON_DATA_EXPORT_WIDGET_TYPES.has(type)) return true;
159
- // a-link can either display a bound field or act as a row operation button.
160
- return (formatS === "aLink" || type === "a-link")
161
- && options?.isFormLabel !== true;
162
- }
163
-
164
- function isActionOrGroupColumn(item, formatS) {
165
- if (Array.isArray(item.children) && item.children.length) return true;
166
- return isActionColumn(item, formatS);
167
- }
168
-
169
- function buildWidgetOptions(item, formatS, label) {
170
- let widgetOptions =
171
- item.options && typeof item.options === "object"
172
- ? { ...item.options }
173
- : null;
174
-
175
- if (widgetOptions) {
176
- delete widgetOptions.dropdownItems;
177
- }
178
-
179
- DYNAMIC_SCHEMA_WIDGET_FLAG_KEYS.forEach((key) => {
180
- if (item[key] !== undefined) {
181
- widgetOptions = widgetOptions || {};
182
- widgetOptions[key] = item[key];
183
- }
184
- });
185
-
186
- if (label) {
187
- widgetOptions = widgetOptions || {};
188
- if (!widgetOptions.label) {
189
- widgetOptions.label = label;
190
- }
191
- }
192
-
193
- if (!isActionColumn(item, formatS)) {
194
- widgetOptions = widgetOptions || {};
195
- widgetOptions.labelHidden = true;
196
- }
197
-
198
- return widgetOptions;
199
- }
200
-
201
- export function getDynamicSchemaOption(options, key) {
202
- if (!options) return null;
203
- const keys = DYNAMIC_SCHEMA_OPTION_KEYS[key] || [];
204
- for (let i = 0; i < keys.length; i++) {
205
- const val = options[keys[i]];
206
- if (val !== undefined && val !== null && val !== "") {
207
- return val;
208
- }
209
- }
210
- return null;
211
- }
212
-
213
- export function resolveDynamicSchemaExtra(paramScript, handleCustomEvent) {
214
- if (!paramScript || !handleCustomEvent) return {};
215
- const result = handleCustomEvent(paramScript);
216
- return result && typeof result === "object" && !Array.isArray(result)
217
- ? result
218
- : {};
219
- }
220
-
221
- export function buildDynamicSchemaRequestData(
222
- formModel,
223
- paramScript,
224
- handleCustomEvent,
225
- wrapContext
226
- ) {
227
- const extra = resolveDynamicSchemaExtra(paramScript, handleCustomEvent);
228
- const payload = {
229
- formData: formModel || {},
230
- ...extra,
231
- };
232
- if (!wrapContext) {
233
- return payload;
234
- }
235
- const { formCode, formVersion, taBm, dataId } = wrapContext;
236
- return {
237
- formCode,
238
- formVersion,
239
- taBm,
240
- formData: payload.formData,
241
- dataId,
242
- data: {
243
- dataId,
244
- ...payload,
245
- },
246
- };
247
- }
248
-
249
- /** 从 objx 或转换脚本结果中提取定义数组 */
250
- export function extractDynamicSchemaItems(source) {
251
- if (!source) return [];
252
- if (Array.isArray(source)) return source;
253
- if (typeof source !== "object") return [];
254
- if (Array.isArray(source.fields)) return source.fields;
255
- if (Array.isArray(source.columns)) return source.columns;
256
- return [];
257
- }
258
-
259
- export function resolveDynamicSchemaResponse(res, convertScript, handleCustomEvent) {
260
- if (convertScript && handleCustomEvent) {
261
- const result = handleCustomEvent(convertScript, ["res"], [res]);
262
- return extractDynamicSchemaItems(result);
263
- }
264
- return extractDynamicSchemaItems(res && res.objx);
265
- }
266
-
267
- export function normalizeDynamicFieldKey(item) {
268
- if (!item || typeof item !== "object") return undefined;
269
- return item.keyName;
270
- }
271
-
272
- export function normalizeDynamicColumnItem(item, index) {
273
- if (!item || typeof item !== "object") {
274
- return null;
275
- }
276
-
277
- const keyName = normalizeDynamicFieldKey(item);
278
- const label = item.label;
279
- let formatS = item.formatS || null;
280
- if (!formatS && item.type) {
281
- formatS = widgetTypeToEditFormatMap[item.type] || item.type;
282
- }
283
-
284
- let editFormatS = null;
285
- if (formatS && String(formatS).startsWith("edit")) {
286
- editFormatS = formatS;
287
- }
288
-
289
- const widgetOptions = buildWidgetOptions(item, formatS, label);
290
-
291
- let widget = null;
292
- let widgetList = null;
293
- if (
294
- (item.type === "dropdown" || formatS === "dropdown") &&
295
- Array.isArray(item.dropdownItems) &&
296
- item.dropdownItems.length
297
- ) {
298
- widget = buildDropdownWidgetFromDef(item, index);
299
- if (widget && label) {
300
- widget.options.label = label;
301
- }
302
- if (widget?.widgetList?.length) {
303
- widgetList = widget.widgetList;
304
- }
305
- }
306
-
307
- if (!keyName && !isActionOrGroupColumn(item, formatS)) {
308
- return null;
309
- }
310
-
311
- const isAction = isActionColumn(item, formatS);
312
-
313
- const widgetFlags = {};
314
- DYNAMIC_SCHEMA_WIDGET_FLAG_KEYS.forEach((key) => {
315
- if (item[key] !== undefined) {
316
- widgetFlags[key] = item[key];
317
- } else if (widgetOptions?.[key] !== undefined) {
318
- widgetFlags[key] = widgetOptions[key];
319
- }
320
- });
321
-
322
- const children = Array.isArray(item.children)
323
- ? item.children
324
- .map((child, childIndex) =>
325
- normalizeDynamicColumnItem(child, index * 1000 + childIndex)
326
- )
327
- .filter(Boolean)
328
- : item.children;
329
-
330
- return {
331
- columnId: item.columnId || `${Date.now()}_${index}`,
332
- type: item.type,
333
- prop: keyName || undefined,
334
- label,
335
- width: item.width ?? 150,
336
- show: item.show !== false,
337
- sortable: isAction ? item.sortable === true : item.sortable !== false,
338
- filterable: isAction ? item.filterable === true : item.filterable !== false,
339
- ...(item.align ? { align: item.align } : {}),
340
- fixed: item.fixed,
341
- formatS,
342
- editFormatS: editFormatS || undefined,
343
- optionItems: item.optionItems,
344
- widget,
345
- widgetList,
346
- widgetOptions,
347
- children: children,
348
- render: item.render,
349
- utcTransformEnabled: item.utcTransformEnabled,
350
- ...widgetFlags,
351
- };
352
- }
353
-
354
- export function normalizeDynamicColumns(columns) {
355
- if (!Array.isArray(columns)) {
356
- return [];
357
- }
358
- return columns
359
- .map((item, index) => normalizeDynamicColumnItem(item, index))
360
- .filter(Boolean);
361
- }
1
+ /**
2
+ * 后台动态定义(表头后台字段 / 数据表格动态列)共用协议。
3
+ *
4
+ * 单条定义顶层字段:
5
+ * - 通用:keyName、type、label、optionItems、required 等字段级属性、options
6
+ * - 表头:colspan
7
+ * - 数据表格:width、formatS(展示列)、children(多级表头)、dropdownItems(dropdown 操作列)
8
+ *
9
+ * 请求体:{ formData, ...extra }
10
+ * 响应体:objx 数组,或 { fields: [] } / { columns: [] }
11
+ */
12
+
13
+ /** 顶层字段白名单 */
14
+ export const DYNAMIC_SCHEMA_CORE_KEYS = [
15
+ "keyName",
16
+ "type",
17
+ "label",
18
+ "optionItems",
19
+ "options",
20
+ ];
21
+
22
+ /** 字段级属性:写顶层,不写 options(与表头 dynamicFieldMixin 一致) */
23
+ export const DYNAMIC_SCHEMA_WIDGET_FLAG_KEYS = [
24
+ "required",
25
+ "readonly",
26
+ "disabled",
27
+ "hidden",
28
+ "defaultValue",
29
+ "placeholder",
30
+ ];
31
+
32
+ export const DYNAMIC_SCHEMA_TABLE_HEADER_KEYS = ["colspan"];
33
+
34
+ export const DYNAMIC_SCHEMA_COLUMN_EXTRA_KEYS = [
35
+ "width",
36
+ "align",
37
+ "sortable",
38
+ "filterable",
39
+ "show",
40
+ "fixed",
41
+ "formatS",
42
+ "render",
43
+ "utcTransformEnabled",
44
+ "children",
45
+ "dropdownItems",
46
+ ];
47
+
48
+ export const DYNAMIC_SCHEMA_OPTION_KEYS = {
49
+ scriptCode: ["dynamicSchemaScriptCode", "dynamicColumnScriptCode"],
50
+ scriptParam: ["dynamicSchemaScriptParam", "dynamicColumnScriptParam"],
51
+ convert: ["dynamicSchemaConvert"],
52
+ mode: ["dynamicSchemaMode", "dynamicColumnMode"],
53
+ sourceType: ["dynamicSchemaSourceType", "dynamicColumnSourceType"],
54
+ loadScript: ["dynamicSchemaLoadScript", "dynamicColumnLoadScript"],
55
+ frontendScript: ["dynamicSchemaScript", "dynamicColumnsScript"],
56
+ };
57
+
58
+ export const widgetTypeToEditFormatMap = {
59
+ input: "editInput",
60
+ number: "editNumber",
61
+ date: "editDate",
62
+ select: "editSelect",
63
+ vabsearch: "editSearch",
64
+ baseAttachment: "editAttachment",
65
+ status: "editStatus",
66
+ text: "text",
67
+ checkbox: "checkbox",
68
+ radio: "radio",
69
+ textarea: "textarea",
70
+ "script-input": "editScriptInput",
71
+ "a-text": "aText",
72
+ "a-link": "aLink",
73
+ button: "button",
74
+ dropdown: "dropdown",
75
+ };
76
+
77
+ const ACTION_COLUMN_FORMATS = new Set(["aLink", "button", "dropdown"]);
78
+
79
+ const NON_DATA_EXPORT_COLUMN_FORMATS = new Set([
80
+ "dropdown",
81
+ "button",
82
+ "editDelete",
83
+ "editButton",
84
+ "editTreeButtonGroup",
85
+ "addSiblingEditRow",
86
+ "addChildTreeRow",
87
+ "moveUpRow",
88
+ "moveDownRow",
89
+ "removeTreeRow",
90
+ ]);
91
+
92
+ const NON_DATA_EXPORT_WIDGET_TYPES = new Set([
93
+ "button",
94
+ "dropdown",
95
+ "dropdown-item",
96
+ "divider",
97
+ "search_button",
98
+ "save_button",
99
+ "reset_button",
100
+ "table-export-button",
101
+ "select-export-button",
102
+ "select-export-item-button",
103
+ "add_button",
104
+ "import-button",
105
+ "import2-button",
106
+ "print-button",
107
+ "print-detail-button",
108
+ "download-button",
109
+ "save_submit_wf_button",
110
+ "copy_button",
111
+ "compare-change-button",
112
+ "compare-button",
113
+ "compare-close-button",
114
+ "compare-del-button",
115
+ ]);
116
+
117
+ export function buildDropdownWidgetFromDef(def, index = 0) {
118
+ const options = def?.options;
119
+ const dropdownItems = def?.dropdownItems;
120
+ if (!Array.isArray(dropdownItems) || !dropdownItems.length) return null;
121
+
122
+ const ts = `${Date.now()}_${index}`;
123
+ const widgetList = dropdownItems.map((entry, i) => ({
124
+ type: "dropdown-item",
125
+ id: `dropdownitem_${ts}_${i}`,
126
+ options: {
127
+ label: entry.label || "",
128
+ onClick: entry.onClick || "",
129
+ disabled: !!entry.disabled,
130
+ hidden: !!entry.hidden,
131
+ },
132
+ }));
133
+
134
+ return {
135
+ type: "dropdown",
136
+ id: `dropdown_${ts}`,
137
+ options: {
138
+ label: def.label || "操作",
139
+ dropdownType: options?.dropdownType || "link",
140
+ dropdownTrigger: options?.dropdownTrigger || "hover",
141
+ dropdownFlag: 1,
142
+ },
143
+ widgetList,
144
+ };
145
+ }
146
+
147
+ function isActionColumn(item, formatS) {
148
+ return isActionColumnFormat(formatS, item?.type);
149
+ }
150
+
151
+ export function isActionColumnFormat(formatS, type) {
152
+ if (ACTION_COLUMN_FORMATS.has(formatS)) return true;
153
+ return ["a-link", "button", "dropdown"].includes(type);
154
+ }
155
+
156
+ export function isNonDataExportColumn(formatS, type, options) {
157
+ if (NON_DATA_EXPORT_COLUMN_FORMATS.has(formatS)) return true;
158
+ if (NON_DATA_EXPORT_WIDGET_TYPES.has(type)) return true;
159
+ // a-link can either display a bound field or act as a row operation button.
160
+ return (formatS === "aLink" || type === "a-link")
161
+ && options?.isFormLabel !== true;
162
+ }
163
+
164
+ /**
165
+ * 该列导出时是否只输出空值(列本身仍保留,表头与列位置不变)。
166
+ *
167
+ * 目前只有一种:**没有配「导出类型」的附件列**。附件的内容是文件,不配导出类型就意味着
168
+ * 这次导出既不写图片、也没有任何有意义的文本可写;而附件列没有 filterVal,走取值兜底会
169
+ * 落到 getCellValue 的 vNode 挂载,为了爬一段文件名文本给每个单元格挂一次附件组件 ——
170
+ * 既没价值又是导出耗时的大头。
171
+ *
172
+ * isNonDataExportColumn 的区别:那个是**整列剔除**(字段树里都看不到,用于操作列/
173
+ * 脱敏列);这个是**列在、格空**,不改变导出文件的列结构。
174
+ *
175
+ * 注意配了导出类型(Image/Image2)的附件列不在此列 —— 即使本次导出没开 showImageAtTable、
176
+ * 图片最终不会写进文件,也保持原有行为不变。
177
+ *
178
+ * @param {String} formatS 列的展示格式。
179
+ * @param {String} type 展示组件类型。
180
+ * @param {String} exportType 列上配置的导出类型。
181
+ * @returns {Boolean}
182
+ */
183
+ export function isBlankExportColumn(formatS, type, exportType) {
184
+ if (exportType) return false;
185
+ return formatS === "editAttachment" || type === "baseAttachment";
186
+ }
187
+
188
+ function isActionOrGroupColumn(item, formatS) {
189
+ if (Array.isArray(item.children) && item.children.length) return true;
190
+ return isActionColumn(item, formatS);
191
+ }
192
+
193
+ function buildWidgetOptions(item, formatS, label) {
194
+ let widgetOptions =
195
+ item.options && typeof item.options === "object"
196
+ ? { ...item.options }
197
+ : null;
198
+
199
+ if (widgetOptions) {
200
+ delete widgetOptions.dropdownItems;
201
+ }
202
+
203
+ DYNAMIC_SCHEMA_WIDGET_FLAG_KEYS.forEach((key) => {
204
+ if (item[key] !== undefined) {
205
+ widgetOptions = widgetOptions || {};
206
+ widgetOptions[key] = item[key];
207
+ }
208
+ });
209
+
210
+ if (label) {
211
+ widgetOptions = widgetOptions || {};
212
+ if (!widgetOptions.label) {
213
+ widgetOptions.label = label;
214
+ }
215
+ }
216
+
217
+ if (!isActionColumn(item, formatS)) {
218
+ widgetOptions = widgetOptions || {};
219
+ widgetOptions.labelHidden = true;
220
+ }
221
+
222
+ return widgetOptions;
223
+ }
224
+
225
+ export function getDynamicSchemaOption(options, key) {
226
+ if (!options) return null;
227
+ const keys = DYNAMIC_SCHEMA_OPTION_KEYS[key] || [];
228
+ for (let i = 0; i < keys.length; i++) {
229
+ const val = options[keys[i]];
230
+ if (val !== undefined && val !== null && val !== "") {
231
+ return val;
232
+ }
233
+ }
234
+ return null;
235
+ }
236
+
237
+ export function resolveDynamicSchemaExtra(paramScript, handleCustomEvent) {
238
+ if (!paramScript || !handleCustomEvent) return {};
239
+ const result = handleCustomEvent(paramScript);
240
+ return result && typeof result === "object" && !Array.isArray(result)
241
+ ? result
242
+ : {};
243
+ }
244
+
245
+ export function buildDynamicSchemaRequestData(
246
+ formModel,
247
+ paramScript,
248
+ handleCustomEvent,
249
+ wrapContext
250
+ ) {
251
+ const extra = resolveDynamicSchemaExtra(paramScript, handleCustomEvent);
252
+ const payload = {
253
+ formData: formModel || {},
254
+ ...extra,
255
+ };
256
+ if (!wrapContext) {
257
+ return payload;
258
+ }
259
+ const { formCode, formVersion, taBm, dataId } = wrapContext;
260
+ return {
261
+ formCode,
262
+ formVersion,
263
+ taBm,
264
+ formData: payload.formData,
265
+ dataId,
266
+ data: {
267
+ dataId,
268
+ ...payload,
269
+ },
270
+ };
271
+ }
272
+
273
+ /** objx 或转换脚本结果中提取定义数组 */
274
+ export function extractDynamicSchemaItems(source) {
275
+ if (!source) return [];
276
+ if (Array.isArray(source)) return source;
277
+ if (typeof source !== "object") return [];
278
+ if (Array.isArray(source.fields)) return source.fields;
279
+ if (Array.isArray(source.columns)) return source.columns;
280
+ return [];
281
+ }
282
+
283
+ export function resolveDynamicSchemaResponse(res, convertScript, handleCustomEvent) {
284
+ if (convertScript && handleCustomEvent) {
285
+ const result = handleCustomEvent(convertScript, ["res"], [res]);
286
+ return extractDynamicSchemaItems(result);
287
+ }
288
+ return extractDynamicSchemaItems(res && res.objx);
289
+ }
290
+
291
+ export function normalizeDynamicFieldKey(item) {
292
+ if (!item || typeof item !== "object") return undefined;
293
+ return item.keyName;
294
+ }
295
+
296
+ export function normalizeDynamicColumnItem(item, index) {
297
+ if (!item || typeof item !== "object") {
298
+ return null;
299
+ }
300
+
301
+ const keyName = normalizeDynamicFieldKey(item);
302
+ const label = item.label;
303
+ let formatS = item.formatS || null;
304
+ if (!formatS && item.type) {
305
+ formatS = widgetTypeToEditFormatMap[item.type] || item.type;
306
+ }
307
+
308
+ let editFormatS = null;
309
+ if (formatS && String(formatS).startsWith("edit")) {
310
+ editFormatS = formatS;
311
+ }
312
+
313
+ const widgetOptions = buildWidgetOptions(item, formatS, label);
314
+
315
+ let widget = null;
316
+ let widgetList = null;
317
+ if (
318
+ (item.type === "dropdown" || formatS === "dropdown") &&
319
+ Array.isArray(item.dropdownItems) &&
320
+ item.dropdownItems.length
321
+ ) {
322
+ widget = buildDropdownWidgetFromDef(item, index);
323
+ if (widget && label) {
324
+ widget.options.label = label;
325
+ }
326
+ if (widget?.widgetList?.length) {
327
+ widgetList = widget.widgetList;
328
+ }
329
+ }
330
+
331
+ if (!keyName && !isActionOrGroupColumn(item, formatS)) {
332
+ return null;
333
+ }
334
+
335
+ const isAction = isActionColumn(item, formatS);
336
+
337
+ const widgetFlags = {};
338
+ DYNAMIC_SCHEMA_WIDGET_FLAG_KEYS.forEach((key) => {
339
+ if (item[key] !== undefined) {
340
+ widgetFlags[key] = item[key];
341
+ } else if (widgetOptions?.[key] !== undefined) {
342
+ widgetFlags[key] = widgetOptions[key];
343
+ }
344
+ });
345
+
346
+ const children = Array.isArray(item.children)
347
+ ? item.children
348
+ .map((child, childIndex) =>
349
+ normalizeDynamicColumnItem(child, index * 1000 + childIndex)
350
+ )
351
+ .filter(Boolean)
352
+ : item.children;
353
+
354
+ return {
355
+ columnId: item.columnId || `${Date.now()}_${index}`,
356
+ type: item.type,
357
+ prop: keyName || undefined,
358
+ label,
359
+ width: item.width ?? 150,
360
+ show: item.show !== false,
361
+ sortable: isAction ? item.sortable === true : item.sortable !== false,
362
+ filterable: isAction ? item.filterable === true : item.filterable !== false,
363
+ ...(item.align ? { align: item.align } : {}),
364
+ fixed: item.fixed,
365
+ formatS,
366
+ editFormatS: editFormatS || undefined,
367
+ optionItems: item.optionItems,
368
+ widget,
369
+ widgetList,
370
+ widgetOptions,
371
+ children: children,
372
+ render: item.render,
373
+ utcTransformEnabled: item.utcTransformEnabled,
374
+ ...widgetFlags,
375
+ };
376
+ }
377
+
378
+ export function normalizeDynamicColumns(columns) {
379
+ if (!Array.isArray(columns)) {
380
+ return [];
381
+ }
382
+ return columns
383
+ .map((item, index) => normalizeDynamicColumnItem(item, index))
384
+ .filter(Boolean);
385
+ }