@fecp/designer 5.5.100 → 5.5.102

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 (75) hide show
  1. package/es/designer/package.json.mjs +1 -1
  2. package/es/designer/src/packages/dialog/useDialogDialog.mjs +1 -1
  3. package/es/designer/src/packages/dialogGlobal/useDialogGlobalDialog.mjs +1 -1
  4. package/es/designer/src/packages/form/property/widgets.vue.mjs +2 -2
  5. package/es/designer.css +436 -125
  6. package/es/packages/mobile/index.mjs +4 -0
  7. package/es/packages/mobile/src/components/all.mjs +4 -0
  8. package/es/packages/mobile/src/components/custom/appDetail/AppDetail.vue.mjs +69 -9
  9. package/es/packages/mobile/src/components/custom/approvalBar/ApprovalBar.vue.mjs +191 -0
  10. package/es/packages/mobile/src/components/custom/approvalBar/index.mjs +10 -0
  11. package/es/packages/mobile/src/components/custom/approvalList/ApprovalList.vue.mjs +391 -0
  12. package/es/packages/mobile/src/components/custom/approvalList/index.mjs +10 -0
  13. package/es/packages/mobile/src/components/dataDisplay/cardList/CardList.vue.mjs +2 -18
  14. package/es/packages/mobile/src/components/dataDisplay/table/Table.vue.mjs +43 -11
  15. package/es/packages/mobile/src/components/form/field/Field.vue.mjs +38 -26
  16. package/es/packages/mobile/src/components/form/fieldArea/FieldArea.vue.mjs +4 -2
  17. package/es/packages/mobile/src/components/form/fieldCalendarPicker/FieldCalendarPicker.vue.mjs +1 -1
  18. package/es/packages/mobile/src/components/form/fieldCascaderPicker/fieldCascaderPicker.vue.mjs +1 -1
  19. package/es/packages/mobile/src/components/form/fieldDatePicker/FieldDatePicker.vue.mjs +1 -1
  20. package/es/packages/mobile/src/components/form/fieldDateTimePicker/FieldDateTimePicker.vue.mjs +1 -1
  21. package/es/packages/mobile/src/components/form/fieldIndustry/FieldIndustry.vue.mjs +38 -27
  22. package/es/packages/mobile/src/components/form/fieldPicker/FieldPicker.vue.mjs +58 -41
  23. package/es/packages/mobile/src/components/form/fieldTimePicker/FieldTimePicker.vue.mjs +1 -1
  24. package/es/packages/mobile/src/components/navigation/tabs/Tabs.vue.mjs +34 -5
  25. package/es/packages/mobile/src/composables/usePageEvents.mjs +80 -0
  26. package/es/packages/mobile/src/index.vue.mjs +11 -21
  27. package/es/packages/mobile/src/page.vue.mjs +152 -12
  28. package/es/packages/mobile/src/utils/common.mjs +15 -0
  29. package/es/packages/mobile/src/utils/datasource.mjs +12 -1
  30. package/es/packages/mobile/src/utils/eventFlow/actionHandlers.mjs +852 -0
  31. package/es/packages/mobile/src/utils/eventFlow/eventFlowHandler.mjs +94 -0
  32. package/es/packages/mobile/src/utils/eventFlowParser.mjs +396 -0
  33. package/es/packages/mobile/src/utils/formatterUtil.mjs +1 -0
  34. package/es/packages/mobile/src/utils/parseFilterConfig.mjs +98 -0
  35. package/es/packages/vue/src/components/forms/form/Form.vue.mjs +1 -1
  36. package/es/packages/vue/src/components/forms/subTable/SubTable.vue.mjs +8 -7
  37. package/es/packages/vue/src/components/table/Table.vue.mjs +11 -1
  38. package/lib/designer/package.json.js +1 -1
  39. package/lib/designer/src/packages/dialog/useDialogDialog.js +1 -1
  40. package/lib/designer/src/packages/dialogGlobal/useDialogGlobalDialog.js +1 -1
  41. package/lib/designer/src/packages/form/property/widgets.vue.js +2 -2
  42. package/lib/designer.css +436 -125
  43. package/lib/packages/mobile/index.js +6 -2
  44. package/lib/packages/mobile/src/components/all.js +4 -0
  45. package/lib/packages/mobile/src/components/custom/appDetail/AppDetail.vue.js +68 -8
  46. package/lib/packages/mobile/src/components/custom/approvalBar/ApprovalBar.vue.js +191 -0
  47. package/lib/packages/mobile/src/components/custom/approvalBar/index.js +10 -0
  48. package/lib/packages/mobile/src/components/custom/approvalList/ApprovalList.vue.js +391 -0
  49. package/lib/packages/mobile/src/components/custom/approvalList/index.js +10 -0
  50. package/lib/packages/mobile/src/components/dataDisplay/cardList/CardList.vue.js +2 -18
  51. package/lib/packages/mobile/src/components/dataDisplay/table/Table.vue.js +43 -11
  52. package/lib/packages/mobile/src/components/form/field/Field.vue.js +37 -25
  53. package/lib/packages/mobile/src/components/form/fieldArea/FieldArea.vue.js +4 -2
  54. package/lib/packages/mobile/src/components/form/fieldCalendarPicker/FieldCalendarPicker.vue.js +1 -1
  55. package/lib/packages/mobile/src/components/form/fieldCascaderPicker/fieldCascaderPicker.vue.js +1 -1
  56. package/lib/packages/mobile/src/components/form/fieldDatePicker/FieldDatePicker.vue.js +1 -1
  57. package/lib/packages/mobile/src/components/form/fieldDateTimePicker/FieldDateTimePicker.vue.js +1 -1
  58. package/lib/packages/mobile/src/components/form/fieldIndustry/FieldIndustry.vue.js +37 -26
  59. package/lib/packages/mobile/src/components/form/fieldPicker/FieldPicker.vue.js +57 -40
  60. package/lib/packages/mobile/src/components/form/fieldTimePicker/FieldTimePicker.vue.js +1 -1
  61. package/lib/packages/mobile/src/components/navigation/tabs/Tabs.vue.js +33 -4
  62. package/lib/packages/mobile/src/composables/usePageEvents.js +80 -0
  63. package/lib/packages/mobile/src/index.vue.js +11 -21
  64. package/lib/packages/mobile/src/page.vue.js +151 -11
  65. package/lib/packages/mobile/src/utils/common.js +15 -0
  66. package/lib/packages/mobile/src/utils/datasource.js +14 -3
  67. package/lib/packages/mobile/src/utils/eventFlow/actionHandlers.js +852 -0
  68. package/lib/packages/mobile/src/utils/eventFlow/eventFlowHandler.js +94 -0
  69. package/lib/packages/mobile/src/utils/eventFlowParser.js +396 -0
  70. package/lib/packages/mobile/src/utils/formatterUtil.js +1 -0
  71. package/lib/packages/mobile/src/utils/parseFilterConfig.js +98 -0
  72. package/lib/packages/vue/src/components/forms/form/Form.vue.js +1 -1
  73. package/lib/packages/vue/src/components/forms/subTable/SubTable.vue.js +7 -6
  74. package/lib/packages/vue/src/components/table/Table.vue.js +11 -1
  75. package/package.json +1 -1
@@ -0,0 +1,852 @@
1
+ import { createDataSource } from "../datasource.mjs";
2
+ import { parseRouteParams, parseSingleParamValue } from "../parseRouteParams.mjs";
3
+ import { removeEmptyValues } from "../common.mjs";
4
+ import "../../../../../node_modules/element-plus/es/index.mjs";
5
+ /* empty css */
6
+ /* empty css */
7
+ /* empty css */
8
+ /* empty css */
9
+ /* empty css */
10
+ import { ElMessageBox } from "../../../../../node_modules/element-plus/es/components/message-box/index.mjs";
11
+ import { ElMessage } from "../../../../../node_modules/element-plus/es/components/message/index.mjs";
12
+ async function handlePageJump(node, data, fields, context) {
13
+ var _a, _b, _c;
14
+ const dialogDoms = document.querySelectorAll(".el-modal-dialog");
15
+ if ((dialogDoms == null ? void 0 : dialogDoms.length) > 0) {
16
+ for (let i = 0; i < dialogDoms.length; i++) {
17
+ if (!dialogDoms[i].style.display) {
18
+ return {
19
+ success: true,
20
+ message: "页面存在弹层,跳过页面跳转"
21
+ };
22
+ }
23
+ }
24
+ }
25
+ const basic = node.basic || {};
26
+ const transitionType = basic.transitionType || "page";
27
+ const formComponent = (_a = context.components) == null ? void 0 : _a.form;
28
+ const getFormDataMethod = (_c = (_b = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _b.exposed) == null ? void 0 : _c.getFormData;
29
+ if (getFormDataMethod && typeof getFormDataMethod === "function") {
30
+ data = getFormDataMethod();
31
+ }
32
+ const params = parseRouteParams(basic.routeParams, data, fields);
33
+ if (transitionType === "external") {
34
+ const url = basic.routePath;
35
+ if (!url) {
36
+ return {
37
+ success: false,
38
+ message: "外部链接地址不能为空",
39
+ shouldShowError: true
40
+ };
41
+ }
42
+ let fullUrl = url;
43
+ if (Object.keys(params).length > 0) {
44
+ const queryString = new URLSearchParams(params).toString();
45
+ fullUrl = url + (url.includes("?") ? "&" : "?") + queryString;
46
+ }
47
+ if (basic.openNewPage) {
48
+ window.open(fullUrl, "_blank");
49
+ } else {
50
+ window.location.href = fullUrl;
51
+ }
52
+ return {
53
+ success: true,
54
+ message: basic.openNewPage ? "已在新标签页打开链接" : "已在当前页面打开链接",
55
+ url: fullUrl,
56
+ openNewPage: basic.openNewPage
57
+ };
58
+ }
59
+ if (basic.routePath) {
60
+ const router = context.ctx.$router;
61
+ if (router) {
62
+ const route = { path: basic.routePath };
63
+ if (Object.keys(params).length > 0) {
64
+ route.query = params;
65
+ }
66
+ if (basic.openNewPage === true) {
67
+ const url = router.resolve(route).href;
68
+ window.open(url, "_blank");
69
+ } else {
70
+ if (basic.canNotGoBack) {
71
+ await router.replace(route);
72
+ } else {
73
+ await router.push(route);
74
+ }
75
+ }
76
+ }
77
+ }
78
+ return {
79
+ success: true,
80
+ message: basic.openNewPage === true ? "已在新标签页打开" : "跳转成功",
81
+ routePath: basic.routePath,
82
+ routeParams: params,
83
+ transitionType,
84
+ openNewPage: basic.openNewPage
85
+ };
86
+ }
87
+ async function handlePageGoBack(node, data, fields, context) {
88
+ var _a;
89
+ const basic = node.basic || {};
90
+ const config = {
91
+ backLevel: basic.backLevel || 1,
92
+ showConfirm: basic.showConfirm || false,
93
+ confirmTitle: basic.confirmTitle || "确认回退",
94
+ confirmMessage: basic.confirmMessage || "确定要返回上一页吗?",
95
+ noHistoryAction: basic.noHistoryAction || "none"
96
+ };
97
+ if (config.showConfirm) {
98
+ try {
99
+ await ElMessageBox.confirm(config.confirmMessage, config.confirmTitle, {
100
+ confirmButtonText: "确定",
101
+ cancelButtonText: "取消",
102
+ type: "warning",
103
+ draggable: true,
104
+ showClose: false
105
+ });
106
+ } catch (error) {
107
+ return {
108
+ success: false,
109
+ message: "用户已取消回退操作",
110
+ confirmed: false,
111
+ shouldShowError: false
112
+ };
113
+ }
114
+ }
115
+ const router = (_a = context.ctx) == null ? void 0 : _a.$router;
116
+ if (!router) {
117
+ return {
118
+ success: false,
119
+ message: "路由实例未找到,无法执行回退操作",
120
+ shouldShowError: true
121
+ };
122
+ }
123
+ try {
124
+ const goBackSteps = -Math.abs(config.backLevel);
125
+ router.go(goBackSteps);
126
+ return {
127
+ success: true,
128
+ message: `已成功回退 ${config.backLevel} 级`,
129
+ backLevel: config.backLevel,
130
+ showConfirm: config.showConfirm
131
+ };
132
+ } catch (error) {
133
+ console.error("[EventFlow] 页面回退失败:", error);
134
+ return {
135
+ success: false,
136
+ message: error.message || "页面回退失败",
137
+ shouldShowError: true
138
+ };
139
+ }
140
+ }
141
+ async function handleApiCall(node, data, fields, context, params) {
142
+ var _a;
143
+ console.log("[EventFlow] 执行API调用:", node.basic);
144
+ const basic = node.basic || {};
145
+ const metadata = context.metadata || {};
146
+ const isApproval = ((_a = metadata == null ? void 0 : metadata.item) == null ? void 0 : _a.isApproval) || false;
147
+ if (!basic.dataSourceId) {
148
+ return {
149
+ success: false,
150
+ message: "数据源配置不完整,缺少 dataSourceId"
151
+ };
152
+ }
153
+ const dataSources = context.localConfig.dataSources || [];
154
+ const dataSourceConfig = dataSources.find((ds) => ds.id === basic.dataSourceId);
155
+ if (!dataSourceConfig) {
156
+ return {
157
+ success: false,
158
+ message: `未找到数据源: ${basic.dataSourceId}`
159
+ };
160
+ }
161
+ const dataSourceManager = createDataSource({
162
+ http: context.ctx.$http,
163
+ params,
164
+ dataSources,
165
+ currentDataSourceId: basic.dataSourceId,
166
+ showSuccessMessage: basic.showSuccessMessage,
167
+ data,
168
+ fields,
169
+ notShowMessage: isApproval
170
+ });
171
+ try {
172
+ const result = await dataSourceManager.fetch();
173
+ return {
174
+ success: true,
175
+ message: "API调用成功",
176
+ data: result,
177
+ shouldShowError: false
178
+ };
179
+ } catch (error) {
180
+ console.error("[EventFlow] API调用失败:", error);
181
+ return {
182
+ success: false,
183
+ message: error.message || "API调用失败",
184
+ error,
185
+ shouldShowError: false
186
+ // API 调用失败需要提示错误
187
+ };
188
+ } finally {
189
+ dataSourceManager.destroy();
190
+ }
191
+ }
192
+ async function handleConfirm(node, data, fields, context) {
193
+ const basic = node.basic || {};
194
+ const config = {
195
+ messageType: basic.messageType || "warning",
196
+ title: basic.title || "确认操作",
197
+ message: basic.message || "确定要执行此操作吗?",
198
+ confirmText: basic.confirmText || "确定",
199
+ cancelText: basic.cancelText || "取消",
200
+ showCancel: basic.showCancel !== false,
201
+ confirmAction: basic.confirmAction || "continue",
202
+ cancelAction: basic.cancelAction || "stop"
203
+ };
204
+ try {
205
+ await ElMessageBox.confirm(config.message, config.title, {
206
+ confirmButtonText: config.confirmText,
207
+ cancelButtonText: config.cancelText,
208
+ type: config.messageType,
209
+ showCancelButton: config.showCancel,
210
+ draggable: true,
211
+ showClose: false
212
+ });
213
+ if (config.confirmAction === "stop") {
214
+ return {
215
+ success: false,
216
+ message: "用户确认后停止执行",
217
+ confirmed: true,
218
+ shouldShowError: false
219
+ };
220
+ }
221
+ return {
222
+ success: true,
223
+ message: "用户已确认",
224
+ confirmed: true,
225
+ shouldShowError: false
226
+ };
227
+ } catch (error) {
228
+ return {
229
+ success: false,
230
+ message: "用户已取消",
231
+ confirmed: false,
232
+ shouldShowError: false
233
+ // 用户取消不提示错误
234
+ };
235
+ }
236
+ }
237
+ async function handleMessage(node, data, fields, context) {
238
+ var _a;
239
+ const metadata = context.metadata || {};
240
+ const isApproval = ((_a = metadata == null ? void 0 : metadata.item) == null ? void 0 : _a.isApproval) || false;
241
+ if (isApproval) {
242
+ return {
243
+ success: true,
244
+ message: "审批按钮的消息不显示"
245
+ };
246
+ }
247
+ if (node.basic) {
248
+ const messageType = node.basic.messageType || "info";
249
+ const message = node.basic.message || "操作成功";
250
+ switch (messageType) {
251
+ case "success":
252
+ ElMessage.success(message);
253
+ break;
254
+ case "warning":
255
+ ElMessage.warning(message);
256
+ break;
257
+ case "error":
258
+ ElMessage.error(message);
259
+ break;
260
+ case "info":
261
+ default:
262
+ ElMessage.info(message);
263
+ break;
264
+ }
265
+ }
266
+ return {
267
+ success: true,
268
+ message: "消息已显示"
269
+ };
270
+ }
271
+ async function handleTableRefresh(node, data, fields, context) {
272
+ var _a, _b, _c;
273
+ console.log("[EventFlow] 执行表格刷新:", node.basic);
274
+ const basic = node.basic || {};
275
+ const refreshOptions = {
276
+ resetSort: basic.resetSort !== false,
277
+ // 默认 true
278
+ resetFilter: basic.resetFilter !== false,
279
+ // 默认 true
280
+ resetPagination: basic.resetPagination !== false
281
+ // 默认 true
282
+ };
283
+ console.log("[EventFlow] 刷新选项:", refreshOptions);
284
+ const tableComponent = (_a = context.components) == null ? void 0 : _a.table;
285
+ const refreshMethod = (_c = (_b = tableComponent == null ? void 0 : tableComponent.$) == null ? void 0 : _b.exposed) == null ? void 0 : _c.refresh;
286
+ if (typeof refreshMethod === "function") {
287
+ await refreshMethod(refreshOptions);
288
+ return {
289
+ success: true,
290
+ message: "表格已刷新"
291
+ };
292
+ } else {
293
+ console.error("[EventFlow] 未找到表格组件的 refresh 方法");
294
+ return {
295
+ success: false,
296
+ message: "表格组件未正确配置或 refresh 方法未暴露",
297
+ shouldShowError: true
298
+ };
299
+ }
300
+ }
301
+ async function handleTableChildRefresh(node, data, fields, context) {
302
+ var _a, _b, _c, _d;
303
+ console.log("[EventFlow] 执行子表格刷新:", node.basic);
304
+ const basic = node.basic || {};
305
+ const formComponent = (_a = context.components) == null ? void 0 : _a.form;
306
+ const getFormItemRefMethod = (_c = (_b = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _b.exposed) == null ? void 0 : _c.getFormItemRef;
307
+ if (typeof getFormItemRefMethod === "function") {
308
+ const subTableRef = getFormItemRefMethod(
309
+ String(basic.selectSubTableFieldId)
310
+ );
311
+ context.components.table = {
312
+ $: {
313
+ exposed: {
314
+ refresh: (_d = subTableRef == null ? void 0 : subTableRef.subTableRef) == null ? void 0 : _d.refresh
315
+ }
316
+ }
317
+ };
318
+ return await handleTableRefresh(node, data, fields, context);
319
+ } else {
320
+ console.error("[EventFlow] 未找到表单组件的 getFormItemRef 方法");
321
+ return {
322
+ success: false,
323
+ message: "表单组件未正确配置或 getFormItemRef 方法未暴露",
324
+ shouldShowError: true
325
+ };
326
+ }
327
+ }
328
+ async function handleTableChildSelection(node, data, fields, context) {
329
+ var _a, _b, _c, _d, _e, _f, _g, _h;
330
+ console.log("[EventFlow] 执行子表格选择赋值:", node.basic);
331
+ const basic = node.basic || {};
332
+ const formComponent = (_a = context.components) == null ? void 0 : _a.form;
333
+ const getFormDataMethod = (_c = (_b = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _b.exposed) == null ? void 0 : _c.getFormData;
334
+ const setFormDataMethod = (_e = (_d = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _d.exposed) == null ? void 0 : _e.setFormData;
335
+ const getFormItemRefMethod = (_g = (_f = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _f.exposed) == null ? void 0 : _g.getFormItemRef;
336
+ if (typeof getFormItemRefMethod === "function") {
337
+ const subTableRef = getFormItemRefMethod(
338
+ String(basic.selectSubTableFieldId)
339
+ );
340
+ const getSelectionMethod = (_h = subTableRef == null ? void 0 : subTableRef.subTableRef) == null ? void 0 : _h.getSelection;
341
+ if (typeof getSelectionMethod === "function") {
342
+ const rows = await getSelectionMethod();
343
+ const fieldMapping = basic.subTableSelectionFieldMapping;
344
+ if (fieldMapping && Array.isArray(fieldMapping)) {
345
+ let formData = getFormDataMethod();
346
+ fieldMapping.forEach((mapping) => {
347
+ const { field, value } = mapping;
348
+ const targetField = fields.find((item) => item.id == field);
349
+ if (!targetField) {
350
+ return {
351
+ success: false,
352
+ message: `未找到字段: ${field}`
353
+ };
354
+ }
355
+ const values = rows.map((row) => row[value]);
356
+ formData[targetField.fieldName] = values.join(",");
357
+ });
358
+ if (typeof setFormDataMethod === "function") {
359
+ setFormDataMethod(formData);
360
+ return {
361
+ success: true,
362
+ message: "赋值成功"
363
+ };
364
+ } else {
365
+ console.error("未找到表单组件的 setFormData 方法");
366
+ return {
367
+ success: false,
368
+ message: "表单组件未正确配置或 setFormData 方法未暴露",
369
+ shouldShowError: true
370
+ };
371
+ }
372
+ }
373
+ } else {
374
+ console.error("[EventFlow] 未找到子列表组件的 getSelection 方法");
375
+ return {
376
+ success: false,
377
+ message: "子列表组件未正确配置或 getSelection 方法未暴露",
378
+ shouldShowError: true
379
+ };
380
+ }
381
+ } else {
382
+ console.error("[EventFlow] 未找到表单组件的 getFormItemRef 方法");
383
+ return {
384
+ success: false,
385
+ message: "表单组件未正确配置或 getFormItemRef 方法未暴露",
386
+ shouldShowError: true
387
+ };
388
+ }
389
+ }
390
+ async function handleTableRowDelete(node, data, fields, context) {
391
+ var _a, _b, _c;
392
+ console.log("[EventFlow] 执行表格行删除:", node.basic);
393
+ const basic = node.basic || {};
394
+ if (basic.showConfirmDeleteMessage) {
395
+ try {
396
+ await ElMessageBox.confirm(
397
+ "此操作将永久删除该记录, 是否继续",
398
+ "确认操作",
399
+ {
400
+ // confirmButtonText: "确定",
401
+ // cancelButtonText: "取消",
402
+ type: "warning",
403
+ draggable: true,
404
+ showClose: false
405
+ }
406
+ );
407
+ } catch (error) {
408
+ return {
409
+ success: false,
410
+ message: "用户已取消",
411
+ confirmed: false,
412
+ shouldShowError: false
413
+ // 用户取消不提示错误
414
+ };
415
+ }
416
+ }
417
+ const result = await handleApiCall(node, data, fields, context);
418
+ if (!result.success) {
419
+ return result;
420
+ }
421
+ if (basic.resetTableAfterDelete) {
422
+ const tableComponent = (_a = context.components) == null ? void 0 : _a.table;
423
+ const refreshMethod = (_c = (_b = tableComponent == null ? void 0 : tableComponent.$) == null ? void 0 : _b.exposed) == null ? void 0 : _c.refresh;
424
+ if (typeof refreshMethod === "function") {
425
+ const refreshOptions = {
426
+ resetSort: false,
427
+ resetFilter: false,
428
+ resetPagination: false
429
+ };
430
+ await refreshMethod(refreshOptions);
431
+ return {
432
+ success: true,
433
+ message: "表格已刷新"
434
+ };
435
+ } else {
436
+ console.error("[EventFlow] 未找到表格组件的 refresh 方法");
437
+ return {
438
+ success: false,
439
+ message: "表格组件未正确配置或 refresh 方法未暴露",
440
+ shouldShowError: true
441
+ };
442
+ }
443
+ }
444
+ return {
445
+ success: true,
446
+ message: "列表数据已删除"
447
+ };
448
+ }
449
+ async function handleCustomAction(node, data, fields, context) {
450
+ console.log("[EventFlow] 执行自定义动作:", node.basic);
451
+ return {
452
+ success: true,
453
+ message: "自定义动作已执行"
454
+ };
455
+ }
456
+ async function handleFormSetValue(node, data, fields, context) {
457
+ var _a, _b, _c, _d;
458
+ const basic = node.basic || {};
459
+ if (!(basic == null ? void 0 : basic.dataSourceId)) {
460
+ console.error("form-setValue: 缺少 dataSourceId 配置");
461
+ return;
462
+ }
463
+ const metadata = context.metadata || {};
464
+ const initSearchData = (metadata == null ? void 0 : metadata.initSearchData) || {};
465
+ const result = await handleApiCall(
466
+ node,
467
+ data,
468
+ fields,
469
+ context,
470
+ initSearchData
471
+ );
472
+ if (!result.success) {
473
+ return result;
474
+ }
475
+ let formData = result.data;
476
+ if (basic.fieldMapping && Array.isArray(basic.fieldMapping)) {
477
+ basic.fieldMapping.forEach((mapping) => {
478
+ const { field, value } = mapping;
479
+ const targetField = fields.find((item) => item.id == field);
480
+ if (!targetField) {
481
+ return {
482
+ success: false,
483
+ message: `未找到字段: ${field}`
484
+ };
485
+ }
486
+ formData[targetField.fieldName] = formData[value];
487
+ delete formData[value];
488
+ });
489
+ }
490
+ formData = removeEmptyValues(formData);
491
+ formData == null ? true : delete formData.pageNo;
492
+ formData == null ? true : delete formData.pageSize;
493
+ const formComponent = ((_a = context.components) == null ? void 0 : _a.form) || ((_b = context.components) == null ? void 0 : _b.table);
494
+ const setFormDataMethod = (_d = (_c = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _c.exposed) == null ? void 0 : _d.setFormData;
495
+ if (typeof setFormDataMethod === "function") {
496
+ setFormDataMethod(formData);
497
+ return {
498
+ success: true,
499
+ message: "表单已赋值"
500
+ };
501
+ } else {
502
+ console.error("未找到表单组件的 setFormData 方法");
503
+ return {
504
+ success: false,
505
+ message: "表单组件未正确配置或 setFormData 方法未暴露",
506
+ shouldShowError: true
507
+ };
508
+ }
509
+ }
510
+ async function handleFormSubmit(node, data, fields, context) {
511
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
512
+ const basic = node.basic || {};
513
+ if (!(basic == null ? void 0 : basic.dataSourceId)) {
514
+ console.error("form-setValue: 缺少 dataSourceId 配置");
515
+ return;
516
+ }
517
+ const formComponent = (_a = context.components) == null ? void 0 : _a.form;
518
+ const validateMethod = (_c = (_b = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _b.exposed) == null ? void 0 : _c.validate;
519
+ const getFormDataMethod = (_e = (_d = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _d.exposed) == null ? void 0 : _e.getFormData;
520
+ if (basic == null ? void 0 : basic.formValidate) {
521
+ try {
522
+ if (typeof validateMethod === "function") {
523
+ await validateMethod();
524
+ } else {
525
+ console.error("未找到表单组件的 validate 方法");
526
+ return {
527
+ success: false,
528
+ message: "表单组件未正确配置或 validate 方法未暴露",
529
+ shouldShowError: true
530
+ };
531
+ }
532
+ } catch (error) {
533
+ return {
534
+ success: false,
535
+ message: "表单验证失败!",
536
+ shouldShowError: false
537
+ };
538
+ }
539
+ }
540
+ if (basic == null ? void 0 : basic.docValidate) {
541
+ const docValidateMethod = (_g = (_f = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _f.exposed) == null ? void 0 : _g.docValidate;
542
+ try {
543
+ if (typeof docValidateMethod === "function") {
544
+ await docValidateMethod();
545
+ } else {
546
+ console.error("未找到表单组件的 docValidate 方法");
547
+ return {
548
+ success: false,
549
+ message: "表单组件未正确配置或 docValidate 方法未暴露",
550
+ shouldShowError: true
551
+ };
552
+ }
553
+ } catch (error) {
554
+ return {
555
+ success: false,
556
+ message: "要件校验失败!",
557
+ shouldShowError: false
558
+ };
559
+ }
560
+ }
561
+ if (typeof getFormDataMethod === "function") {
562
+ try {
563
+ let formData = getFormDataMethod();
564
+ if (basic.fieldMapping && Array.isArray(basic.fieldMapping)) {
565
+ basic.fieldMapping.forEach((mapping) => {
566
+ const { field, value } = mapping;
567
+ const targetField = fields.find((item) => item.id == field);
568
+ if (!targetField) {
569
+ return {
570
+ success: false,
571
+ message: `未找到字段: ${field}`
572
+ };
573
+ }
574
+ formData[value] = formData[targetField.fieldName];
575
+ delete formData[targetField.fieldName];
576
+ });
577
+ }
578
+ const result = await handleApiCall(node, data, fields, context, formData);
579
+ if (!result.success) {
580
+ return result;
581
+ }
582
+ if (basic.returnToForm) {
583
+ formData = removeEmptyValues(result.data || {});
584
+ delete formData.pageNo;
585
+ delete formData.pageSize;
586
+ const formComponent2 = (_h = context.components) == null ? void 0 : _h.form;
587
+ const setFormDataMethod = (_j = (_i = formComponent2 == null ? void 0 : formComponent2.$) == null ? void 0 : _i.exposed) == null ? void 0 : _j.setFormData;
588
+ if (typeof setFormDataMethod === "function") {
589
+ setFormDataMethod(formData);
590
+ } else {
591
+ console.error("未找到表单组件的 setFormData 方法");
592
+ return {
593
+ success: false,
594
+ message: "表单组件未正确配置或 setFormData 方法未暴露",
595
+ shouldShowError: true
596
+ };
597
+ }
598
+ }
599
+ return {
600
+ success: true,
601
+ message: "表单提交成功"
602
+ };
603
+ } catch (error) {
604
+ return {
605
+ success: false,
606
+ message: "表单验证失败!",
607
+ shouldShowError: false
608
+ };
609
+ }
610
+ } else {
611
+ console.error("未找到表单组件的 getFormData 方法");
612
+ return {
613
+ success: false,
614
+ message: "表单组件未正确配置或 getFormData 方法未暴露",
615
+ shouldShowError: true
616
+ };
617
+ }
618
+ }
619
+ async function handleDialog(node, data, fields, context) {
620
+ const basic = node.basic || {};
621
+ if (!(basic == null ? void 0 : basic.dialogId)) {
622
+ console.error("ui-dialog: 缺少 dialogId 配置");
623
+ return;
624
+ }
625
+ let dialog = null;
626
+ if (basic.dialogSource == "global") {
627
+ const data2 = await api.getTemplateDialogById(
628
+ context.ctx.$http,
629
+ basic.dialogId
630
+ );
631
+ dialog = JSON.parse(data2.config);
632
+ dialog.id = data2.id;
633
+ dialog.name = data2.name;
634
+ dialog.selectionMode = basic.selectionMode;
635
+ dialog.displayFormat = basic.displayFormat;
636
+ dialog.displayFormatText = basic.displayFormatText;
637
+ dialog.fieldMapping = basic.fieldMapping;
638
+ dialog.callbackEventConfig = basic.callbackEventConfig;
639
+ } else if (basic.dialogSource == "custom") {
640
+ const dialogList = context.localConfig.dialogs || [];
641
+ dialog = dialogList.find((item) => item.id == (basic == null ? void 0 : basic.dialogId));
642
+ dialog.subFormMode = basic.subFormMode;
643
+ }
644
+ if (!dialog) {
645
+ console.error("ui-dialog: 未找到匹配的弹层配置," + (basic == null ? void 0 : basic.dialogId));
646
+ return;
647
+ }
648
+ try {
649
+ await openDialog(
650
+ basic.displayFieldName,
651
+ dialog,
652
+ context.instance,
653
+ context.ctx,
654
+ fields,
655
+ data
656
+ );
657
+ return {
658
+ success: true,
659
+ message: "用户已确认",
660
+ shouldShowError: false
661
+ };
662
+ } catch (error) {
663
+ return {
664
+ success: false,
665
+ message: "用户已取消",
666
+ confirmed: false,
667
+ shouldShowError: false
668
+ // 用户取消不提示错误
669
+ };
670
+ }
671
+ }
672
+ async function handleRiskSchDialog(node, data, fields, context) {
673
+ var _a, _b, _c, _d, _e, _f;
674
+ const basic = node.basic || {};
675
+ if (!(basic == null ? void 0 : basic.schNo)) {
676
+ console.error("风险拦截校验: 缺少 schNo 配置");
677
+ return;
678
+ }
679
+ if (!(basic == null ? void 0 : basic.busNo)) {
680
+ console.error("风险拦截校验: 缺少 busNo 配置");
681
+ return;
682
+ }
683
+ if (basic == null ? void 0 : basic.formValidate) {
684
+ const formComponent = (_a = context.components) == null ? void 0 : _a.form;
685
+ const validateMethod = (_c = (_b = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _b.exposed) == null ? void 0 : _c.validate;
686
+ if (typeof validateMethod === "function") {
687
+ await validateMethod();
688
+ }
689
+ }
690
+ if (basic == null ? void 0 : basic.docValidate) {
691
+ const formComponent = (_d = context.components) == null ? void 0 : _d.form;
692
+ const docValidateMethod = (_f = (_e = formComponent == null ? void 0 : formComponent.$) == null ? void 0 : _e.exposed) == null ? void 0 : _f.docValidate;
693
+ if (typeof docValidateMethod === "function") {
694
+ await docValidateMethod();
695
+ }
696
+ }
697
+ const schNo = basic.schNo;
698
+ const paramList = parseRouteParams(basic == null ? void 0 : basic.params, data, fields);
699
+ const busNo = parseSingleParamValue(basic.busNo, data, fields);
700
+ try {
701
+ await openRiskSch(
702
+ { schNo, busNo, paramList },
703
+ context.instance,
704
+ context.ctx
705
+ );
706
+ return {
707
+ success: true,
708
+ message: "用户已确认",
709
+ shouldShowError: false
710
+ };
711
+ } catch (error) {
712
+ return {
713
+ success: false,
714
+ message: "用户已取消",
715
+ confirmed: false,
716
+ shouldShowError: false
717
+ // 用户取消不提示错误
718
+ };
719
+ }
720
+ }
721
+ async function handleUpload(node, data, fields, context) {
722
+ const basic = node.basic || {};
723
+ console.log("[EventFlow] 执行文件上传动作:", basic);
724
+ const dataSourceId = basic.dataSourceId || "";
725
+ const acceptType = basic.acceptType || [];
726
+ const maxSize = basic.maxSize || 0;
727
+ const multipleUpload = basic.multipleUpload || false;
728
+ if (!dataSourceId) {
729
+ return {
730
+ success: false,
731
+ message: "文件上传动作缺少必要的数据源配置(dataSourceId)",
732
+ shouldShowError: true
733
+ };
734
+ }
735
+ const acceptArr = [];
736
+ if (acceptType.includes("image")) {
737
+ acceptArr.push("image/*");
738
+ }
739
+ if (acceptType.includes("video")) {
740
+ acceptArr.push("video/*");
741
+ }
742
+ if (acceptType.includes("audio")) {
743
+ acceptArr.push("audio/*");
744
+ }
745
+ if (acceptType.includes("text")) {
746
+ acceptArr.push("text/plain");
747
+ }
748
+ if (acceptType.includes("doc")) {
749
+ acceptArr.push(".doc");
750
+ acceptArr.push(".docx");
751
+ }
752
+ if (acceptType.includes("xls")) {
753
+ acceptArr.push(".xls");
754
+ acceptArr.push(".xlsx");
755
+ }
756
+ if (acceptType.includes("ppt")) {
757
+ acceptArr.push(".ppt");
758
+ acceptArr.push(".pptx");
759
+ }
760
+ if (acceptType.includes("pdf")) {
761
+ acceptArr.push("application/pdf");
762
+ }
763
+ if (acceptType.includes("zip")) {
764
+ acceptArr.push("application/zip");
765
+ acceptArr.push("application/x-rar-compressed");
766
+ }
767
+ let accept = "";
768
+ if (acceptArr.length < 13) {
769
+ accept = acceptArr.join(",");
770
+ }
771
+ const files = await new Promise((resolve, reject) => {
772
+ const input = document.createElement("input");
773
+ input.type = "file";
774
+ input.multiple = multipleUpload;
775
+ input.accept = accept;
776
+ input.click();
777
+ input.onchange = () => {
778
+ let files2 = Array.from(input.files || []);
779
+ if (files2.length === 0) return resolve([]);
780
+ if (maxSize > 0) {
781
+ const maxByte = maxSize * 1024 * 1024;
782
+ const invalidFiles = files2.some((f) => f.size > maxByte);
783
+ if (invalidFiles) {
784
+ reject(new Error(`文件不能超过 ${maxSize}MB`));
785
+ return;
786
+ }
787
+ }
788
+ resolve(files2);
789
+ };
790
+ });
791
+ if (!files || files.length === 0) {
792
+ return { success: false, message: "未选择文件" };
793
+ }
794
+ try {
795
+ const params = multipleUpload ? { files } : { file: files[0] };
796
+ const result = await handleApiCall(node, data, fields, context, params);
797
+ if (!result.success) {
798
+ return result;
799
+ }
800
+ return {
801
+ success: true,
802
+ message: `文件上传成功'}`,
803
+ data: {
804
+ dataSourceId,
805
+ acceptType,
806
+ maxSize,
807
+ multipleUpload,
808
+ acceptType
809
+ }
810
+ };
811
+ } catch (error) {
812
+ return {
813
+ success: false,
814
+ message: "上传失败",
815
+ shouldShowError: false
816
+ };
817
+ }
818
+ }
819
+ const defaultActionHandlers = {
820
+ "page-jump": handlePageJump,
821
+ "page-go-back": handlePageGoBack,
822
+ "request-send": handleApiCall,
823
+ "ui-confirm": handleConfirm,
824
+ "ui-message": handleMessage,
825
+ "table-refresh": handleTableRefresh,
826
+ "table-row-delete": handleTableRowDelete,
827
+ "table-child-refresh": handleTableChildRefresh,
828
+ "table-child-selection": handleTableChildSelection,
829
+ "form-setValue": handleFormSetValue,
830
+ "form-submit": handleFormSubmit,
831
+ custom: handleCustomAction,
832
+ "ui-dialog": handleDialog,
833
+ "ui-upload": handleUpload,
834
+ riskSchDialog: handleRiskSchDialog
835
+ };
836
+ export {
837
+ defaultActionHandlers as default,
838
+ defaultActionHandlers,
839
+ handleApiCall,
840
+ handleConfirm,
841
+ handleCustomAction,
842
+ handleDialog,
843
+ handleMessage,
844
+ handlePageGoBack,
845
+ handlePageJump,
846
+ handleRiskSchDialog,
847
+ handleTableChildRefresh,
848
+ handleTableChildSelection,
849
+ handleTableRefresh,
850
+ handleTableRowDelete,
851
+ handleUpload
852
+ };