@nocobase/plugin-flow-engine 2.1.0-beta.15 → 2.1.0-beta.16
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/dist/ai/ai-employees/nathan/index.d.ts +10 -0
- package/dist/ai/ai-employees/nathan/index.js +41 -0
- package/dist/ai/ai-employees/nathan/prompt.md +132 -0
- package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +69 -0
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.js +2 -2
- package/dist/ai/docs/runjs/context/block-model.md +35 -35
- package/dist/ai/docs/runjs/context/collection-field.md +53 -51
- package/dist/ai/docs/runjs/context/collection.md +39 -39
- package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
- package/dist/ai/docs/runjs/context/data-source.md +52 -44
- package/dist/ai/docs/runjs/context/element.md +44 -38
- package/dist/ai/docs/runjs/context/exit-all.md +37 -35
- package/dist/ai/docs/runjs/context/exit.md +38 -35
- package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
- package/dist/ai/docs/runjs/context/form.md +57 -57
- package/dist/ai/docs/runjs/context/get-model.md +22 -21
- package/dist/ai/docs/runjs/context/get-value.md +20 -19
- package/dist/ai/docs/runjs/context/get-var.md +61 -55
- package/dist/ai/docs/runjs/context/i18n.md +17 -14
- package/dist/ai/docs/runjs/context/import-async.md +333 -45
- package/dist/ai/docs/runjs/context/init-resource.md +20 -20
- package/dist/ai/docs/runjs/context/libs.md +31 -31
- package/dist/ai/docs/runjs/context/location.md +34 -31
- package/dist/ai/docs/runjs/context/logger.md +41 -40
- package/dist/ai/docs/runjs/context/make-resource.md +27 -26
- package/dist/ai/docs/runjs/context/message.md +42 -41
- package/dist/ai/docs/runjs/context/modal.md +44 -44
- package/dist/ai/docs/runjs/context/model.md +36 -33
- package/dist/ai/docs/runjs/context/notification.md +41 -40
- package/dist/ai/docs/runjs/context/off.md +14 -14
- package/dist/ai/docs/runjs/context/on.md +30 -29
- package/dist/ai/docs/runjs/context/open-view.md +40 -40
- package/dist/ai/docs/runjs/context/render.md +37 -32
- package/dist/ai/docs/runjs/context/request.md +46 -45
- package/dist/ai/docs/runjs/context/require-async.md +28 -25
- package/dist/ai/docs/runjs/context/resource.md +34 -34
- package/dist/ai/docs/runjs/context/route.md +36 -34
- package/dist/ai/docs/runjs/context/router.md +43 -31
- package/dist/ai/docs/runjs/context/set-value.md +18 -17
- package/dist/ai/docs/runjs/context/t.md +20 -17
- package/dist/ai/docs/runjs/context/view.md +49 -46
- package/dist/ai/docs/runjs/document.md +1 -0
- package/dist/ai/docs/runjs/import-modules.md +32 -32
- package/dist/ai/docs/runjs/index.md +13 -13
- package/dist/ai/docs/runjs/jsx.md +19 -19
- package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
- package/dist/ai/docs/runjs/render.md +15 -15
- package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
- package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
- package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
- package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
- package/dist/ai/docs/runjs/window.md +5 -5
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +11 -10
- package/dist/node_modules/ses/dist/ses.cjs +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/action-scope.d.ts +38 -0
- package/dist/server/flow-surfaces/action-scope.js +152 -0
- package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
- package/dist/server/flow-surfaces/apply/compiler.js +969 -0
- package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
- package/dist/server/flow-surfaces/apply/layout.js +175 -0
- package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
- package/dist/server/flow-surfaces/apply/matching.js +181 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
- package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
- package/dist/server/flow-surfaces/approval/blueprint.js +187 -0
- package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
- package/dist/server/flow-surfaces/approval/builder.js +384 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
- package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
- package/dist/server/flow-surfaces/approval/index.js +40 -0
- package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
- package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
- package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
- package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
- package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
- package/dist/server/flow-surfaces/association-title-field.js +158 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1007 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
- package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
- package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
- package/dist/server/flow-surfaces/blueprint/index.js +44 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.js +416 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
- package/dist/server/flow-surfaces/blueprint/public-types.d.ts +193 -0
- package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
- package/dist/server/flow-surfaces/builder.d.ts +211 -0
- package/dist/server/flow-surfaces/builder.js +1029 -0
- package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
- package/dist/server/flow-surfaces/catalog-smart.js +239 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
- package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
- package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
- package/dist/server/flow-surfaces/catalog.d.ts +78 -0
- package/dist/server/flow-surfaces/catalog.js +3496 -0
- package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
- package/dist/server/flow-surfaces/chart-config.js +1394 -0
- package/dist/server/flow-surfaces/compose-compiler.d.ts +108 -0
- package/dist/server/flow-surfaces/compose-compiler.js +167 -0
- package/dist/server/flow-surfaces/compose-runtime.d.ts +93 -0
- package/dist/server/flow-surfaces/compose-runtime.js +375 -0
- package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
- package/dist/server/flow-surfaces/configure-options.js +827 -0
- package/dist/server/flow-surfaces/constants.d.ts +351 -0
- package/dist/server/flow-surfaces/constants.js +104 -0
- package/dist/server/flow-surfaces/context.d.ts +72 -0
- package/dist/server/flow-surfaces/context.js +556 -0
- package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
- package/dist/server/flow-surfaces/contract-guard.js +402 -0
- package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
- package/dist/server/flow-surfaces/default-action-popup.js +322 -0
- package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
- package/dist/server/flow-surfaces/default-block-actions.js +185 -0
- package/dist/server/flow-surfaces/errors.d.ts +47 -0
- package/dist/server/flow-surfaces/errors.js +145 -0
- package/dist/server/flow-surfaces/executor.d.ts +23 -0
- package/dist/server/flow-surfaces/executor.js +132 -0
- package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
- package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
- package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
- package/dist/server/flow-surfaces/field-semantics.js +81 -0
- package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
- package/dist/server/flow-surfaces/filter-group.js +94 -0
- package/dist/server/flow-surfaces/index.d.ts +11 -0
- package/dist/server/flow-surfaces/index.js +243 -0
- package/dist/server/flow-surfaces/locator.d.ts +28 -0
- package/dist/server/flow-surfaces/locator.js +240 -0
- package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
- package/dist/server/flow-surfaces/node-use-sets.js +131 -0
- package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
- package/dist/server/flow-surfaces/payload-shape.js +61 -0
- package/dist/server/flow-surfaces/placement.d.ts +33 -0
- package/dist/server/flow-surfaces/placement.js +195 -0
- package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
- package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
- package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/compiler.js +376 -0
- package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
- package/dist/server/flow-surfaces/planning/context.js +139 -0
- package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
- package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
- package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
- package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
- package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
- package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
- package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/runtime.js +259 -0
- package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
- package/dist/server/flow-surfaces/planning/step-link.js +104 -0
- package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
- package/dist/server/flow-surfaces/planning/types.js +24 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +20 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +111 -0
- package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
- package/dist/server/flow-surfaces/reaction/errors.js +69 -0
- package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
- package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
- package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
- package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
- package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
- package/dist/server/flow-surfaces/reaction/meta.js +451 -0
- package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
- package/dist/server/flow-surfaces/reaction/registry.js +206 -0
- package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
- package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
- package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
- package/dist/server/flow-surfaces/reaction/types.js +24 -0
- package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
- package/dist/server/flow-surfaces/reaction/utils.js +67 -0
- package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
- package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
- package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
- package/dist/server/flow-surfaces/reference-guards.js +103 -0
- package/dist/server/flow-surfaces/route-sync.d.ts +47 -0
- package/dist/server/flow-surfaces/route-sync.js +392 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
- package/dist/server/flow-surfaces/service-helpers.js +377 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +108 -0
- package/dist/server/flow-surfaces/service-utils.js +811 -0
- package/dist/server/flow-surfaces/service.d.ts +773 -0
- package/dist/server/flow-surfaces/service.js +13008 -0
- package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
- package/dist/server/flow-surfaces/support-matrix.js +259 -0
- package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
- package/dist/server/flow-surfaces/surface-context.js +437 -0
- package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
- package/dist/server/flow-surfaces/template-compatibility.js +189 -0
- package/dist/server/flow-surfaces/template-display.d.ts +20 -0
- package/dist/server/flow-surfaces/template-display.js +289 -0
- package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
- package/dist/server/flow-surfaces/template-service-utils.js +281 -0
- package/dist/server/flow-surfaces/types.d.ts +288 -0
- package/dist/server/flow-surfaces/types.js +24 -0
- package/dist/server/plugin.js +2 -0
- package/dist/swagger/flow-surfaces.d.ts +5964 -0
- package/dist/swagger/flow-surfaces.examples.d.ts +1533 -0
- package/dist/swagger/flow-surfaces.examples.js +1758 -0
- package/dist/swagger/flow-surfaces.js +5315 -0
- package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
- package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
- package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
- package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
- package/dist/swagger/index.d.ts +5969 -0
- package/dist/swagger/index.js +50 -0
- package/package.json +2 -2
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
|
@@ -1,94 +1,96 @@
|
|
|
1
1
|
# ctx.exitAll()
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Terminates the current event flow and all subsequent event flows triggered in the same event dispatch. It is commonly used when all event flows under the current event need to be aborted immediately due to a global error or permission validation failure.
|
|
4
4
|
|
|
5
5
|
## Use Cases
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`ctx.exitAll()` is generally used in JS-executable contexts where it is necessary to **simultaneously abort the current event flow and subsequent event flows triggered by that event**:
|
|
8
8
|
|
|
9
9
|
| Scenario | Description |
|
|
10
|
-
|
|
11
|
-
| **Event
|
|
12
|
-
| **Linkage
|
|
13
|
-
| **Action
|
|
10
|
+
|------|------|
|
|
11
|
+
| **Event Flow** | Main event flow validation fails (e.g., insufficient permissions), requiring the termination of the main flow and any subsequent flows under the same event that have not yet executed. |
|
|
12
|
+
| **Linkage Rules** | When linkage validation fails, the current linkage and subsequent linkages triggered by the same event must be terminated. |
|
|
13
|
+
| **Action Events** | Pre-action validation fails (e.g., permission check before deletion), requiring the prevention of the main action and subsequent steps. |
|
|
14
14
|
|
|
15
|
-
> Difference from `ctx.exit()`: `ctx.exit()` only
|
|
15
|
+
> Difference from `ctx.exit()`: `ctx.exit()` only terminates the current event flow; `ctx.exitAll()` terminates the current event flow and any **unexecuted** subsequent event flows in the same event dispatch.
|
|
16
16
|
|
|
17
|
-
## Type
|
|
17
|
+
## Type Definition
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
20
|
exitAll(): never;
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Calling `ctx.exitAll()` throws an internal `FlowExitAllException`, which the
|
|
23
|
+
Calling `ctx.exitAll()` throws an internal `FlowExitAllException`, which is caught by the FlowEngine to stop the current event flow instance and subsequent event flows under the same event. Once called, the remaining statements in the current JS code will not be executed.
|
|
24
24
|
|
|
25
25
|
## Comparison with ctx.exit()
|
|
26
26
|
|
|
27
27
|
| Method | Scope |
|
|
28
|
-
|
|
29
|
-
| `ctx.exit()` |
|
|
30
|
-
| `ctx.exitAll()` |
|
|
28
|
+
|------|----------|
|
|
29
|
+
| `ctx.exit()` | Only terminates the current event flow; subsequent event flows are unaffected. |
|
|
30
|
+
| `ctx.exitAll()` | Terminates the current event flow and aborts subsequent event flows executed **sequentially** under the same event. |
|
|
31
31
|
|
|
32
|
-
## Execution
|
|
32
|
+
## Execution Mode
|
|
33
33
|
|
|
34
|
-
- **Sequential**: flows
|
|
35
|
-
- **Parallel**: flows
|
|
34
|
+
- **Sequential Execution**: Event flows under the same event are executed in order. After any event flow calls `ctx.exitAll()`, subsequent event flows will not execute.
|
|
35
|
+
- **Parallel Execution**: Event flows under the same event are executed in parallel. Calling `ctx.exitAll()` in one event flow will not interrupt other concurrent event flows (as they are independent).
|
|
36
36
|
|
|
37
37
|
## Examples
|
|
38
38
|
|
|
39
|
-
###
|
|
39
|
+
### Terminate all event flows when permission validation fails
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
|
+
// Abort the main event flow and subsequent event flows when permissions are insufficient
|
|
42
43
|
if (!hasPermission(ctx)) {
|
|
43
|
-
ctx.notification.error({ message: 'No permission' });
|
|
44
|
+
ctx.notification.error({ message: 'No operation permission' });
|
|
44
45
|
ctx.exitAll();
|
|
45
46
|
}
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
###
|
|
49
|
+
### Terminate when global pre-validation fails
|
|
49
50
|
|
|
50
51
|
```ts
|
|
52
|
+
// Example: If associated data is found to be non-deletable before deletion, prevent the main event flow and subsequent actions
|
|
51
53
|
const canDelete = await checkDeletable(ctx.model?.getValue?.());
|
|
52
54
|
if (!canDelete) {
|
|
53
|
-
ctx.message.error('Cannot delete:
|
|
55
|
+
ctx.message.error('Cannot delete: associated data exists');
|
|
54
56
|
ctx.exitAll();
|
|
55
57
|
}
|
|
56
58
|
```
|
|
57
59
|
|
|
58
|
-
###
|
|
60
|
+
### Choosing between ctx.exit() and ctx.exitAll()
|
|
59
61
|
|
|
60
62
|
```ts
|
|
61
|
-
// Only
|
|
63
|
+
// Only the current event flow needs to exit -> Use ctx.exit()
|
|
62
64
|
if (!params.valid) {
|
|
63
|
-
ctx.message.error('Invalid
|
|
64
|
-
ctx.exit();
|
|
65
|
+
ctx.message.error('Invalid parameters');
|
|
66
|
+
ctx.exit(); // Subsequent event flows are unaffected
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
//
|
|
69
|
+
// Need to terminate all subsequent event flows under the current event -> Use ctx.exitAll()
|
|
68
70
|
if (!ctx.model?.context?.getPermission?.()) {
|
|
69
|
-
ctx.notification.warning({ message: '
|
|
70
|
-
ctx.exitAll();
|
|
71
|
+
ctx.notification.warning({ message: 'Insufficient permissions' });
|
|
72
|
+
ctx.exitAll(); // Both the main event flow and subsequent event flows under the same event are terminated
|
|
71
73
|
}
|
|
72
74
|
```
|
|
73
75
|
|
|
74
|
-
###
|
|
76
|
+
### Prompt before terminating
|
|
75
77
|
|
|
76
78
|
```ts
|
|
77
79
|
if (!isValidInput(ctx.form?.getValues?.())) {
|
|
78
|
-
ctx.message.warning('Please
|
|
80
|
+
ctx.message.warning('Please correct the errors in the form first');
|
|
79
81
|
ctx.exitAll();
|
|
80
82
|
}
|
|
81
83
|
```
|
|
82
84
|
|
|
83
85
|
## Notes
|
|
84
86
|
|
|
85
|
-
- After `ctx.exitAll()`,
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
- In parallel mode, `ctx.exitAll()` only
|
|
87
|
+
- After calling `ctx.exitAll()`, subsequent code in the current JS will not execute. It is recommended to explain the reason to the user via `ctx.message`, `ctx.notification`, or a modal before calling it.
|
|
88
|
+
- Business code usually does not need to catch `FlowExitAllException`; let the FlowEngine handle it.
|
|
89
|
+
- If you only need to stop the current event flow without affecting subsequent ones, use `ctx.exit()`.
|
|
90
|
+
- In parallel mode, `ctx.exitAll()` only terminates the current event flow and does not interrupt other concurrent event flows.
|
|
89
91
|
|
|
90
92
|
## Related
|
|
91
93
|
|
|
92
|
-
- [ctx.exit()](./exit.md):
|
|
93
|
-
- [ctx.message](./message.md):
|
|
94
|
-
- [ctx.modal](./modal.md):
|
|
94
|
+
- [ctx.exit()](./exit.md): Terminates only the current event flow
|
|
95
|
+
- [ctx.message](./message.md): Message prompts
|
|
96
|
+
- [ctx.modal](./modal.md): Confirmation modal
|
|
@@ -1,86 +1,89 @@
|
|
|
1
1
|
# ctx.exit()
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Terminates the execution of the current event flow; subsequent steps will not run. It is commonly used when business conditions are not met, the user cancels, or an irrecoverable error occurs.
|
|
4
4
|
|
|
5
5
|
## Use Cases
|
|
6
6
|
|
|
7
|
-
`ctx.exit()` is used in contexts
|
|
7
|
+
`ctx.exit()` is generally used in the following contexts where JS can be executed:
|
|
8
8
|
|
|
9
9
|
| Scenario | Description |
|
|
10
|
-
|
|
11
|
-
| **Event
|
|
12
|
-
| **Linkage
|
|
13
|
-
| **Action
|
|
10
|
+
|------|------|
|
|
11
|
+
| **Event Flow** | In event flows triggered by form submissions, button clicks, etc., terminates subsequent steps when conditions are not met. |
|
|
12
|
+
| **Linkage Rules** | In field linkages, filter linkages, etc., terminates the current event flow when validation fails or execution needs to be skipped. |
|
|
13
|
+
| **Action Events** | In custom actions (e.g., delete confirmation, pre-save validation), exits when the user cancels or validation fails. |
|
|
14
14
|
|
|
15
|
-
> Difference from `ctx.exitAll()`: `ctx.exit()` only
|
|
15
|
+
> Difference from `ctx.exitAll()`: `ctx.exit()` only terminates the current event flow; other event flows under the same event are not affected. `ctx.exitAll()` terminates the current event flow as well as any subsequent event flows under the same event that have not yet been executed.
|
|
16
16
|
|
|
17
|
-
## Type
|
|
17
|
+
## Type Definition
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
20
|
exit(): never;
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Calling `ctx.exit()` throws an internal `FlowExitException`, which
|
|
23
|
+
Calling `ctx.exit()` throws an internal `FlowExitException`, which is caught by the FlowEngine to stop the current event flow execution. Once called, the remaining statements in the current JS code will not execute.
|
|
24
24
|
|
|
25
25
|
## Comparison with ctx.exitAll()
|
|
26
26
|
|
|
27
|
-
| Method | Scope |
|
|
28
|
-
|
|
29
|
-
| `ctx.exit()` |
|
|
30
|
-
| `ctx.exitAll()` |
|
|
27
|
+
| Method | Scope of Effect |
|
|
28
|
+
|------|----------|
|
|
29
|
+
| `ctx.exit()` | Terminates only the current event flow; subsequent event flows are unaffected. |
|
|
30
|
+
| `ctx.exitAll()` | Terminates the current event flow and aborts subsequent event flows under the same event that are set to **execute sequentially**. |
|
|
31
31
|
|
|
32
32
|
## Examples
|
|
33
33
|
|
|
34
|
-
### Exit on
|
|
34
|
+
### Exit on User Cancellation
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
|
+
// In a confirmation modal, terminate the event flow if the user clicks cancel
|
|
37
38
|
if (!confirmed) {
|
|
38
|
-
ctx.message.info('
|
|
39
|
+
ctx.message.info('Operation cancelled');
|
|
39
40
|
ctx.exit();
|
|
40
41
|
}
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
### Exit on
|
|
44
|
+
### Exit on Parameter Validation Failure
|
|
44
45
|
|
|
45
46
|
```ts
|
|
47
|
+
// Prompt and terminate when validation fails
|
|
46
48
|
if (!params.value || params.value.length < 3) {
|
|
47
|
-
ctx.message.error('Invalid
|
|
49
|
+
ctx.message.error('Invalid parameters, length must be at least 3');
|
|
48
50
|
ctx.exit();
|
|
49
51
|
}
|
|
50
52
|
```
|
|
51
53
|
|
|
52
|
-
### Exit
|
|
54
|
+
### Exit When Business Conditions Are Not Met
|
|
53
55
|
|
|
54
56
|
```ts
|
|
57
|
+
// Terminate if conditions are not met; subsequent steps will not execute
|
|
55
58
|
const record = ctx.model?.getValue?.();
|
|
56
59
|
if (!record || record.status !== 'draft') {
|
|
57
|
-
ctx.notification.warning({ message: 'Only
|
|
60
|
+
ctx.notification.warning({ message: 'Only drafts can be submitted' });
|
|
58
61
|
ctx.exit();
|
|
59
62
|
}
|
|
60
63
|
```
|
|
61
64
|
|
|
62
|
-
###
|
|
65
|
+
### Choosing Between ctx.exit() and ctx.exitAll()
|
|
63
66
|
|
|
64
67
|
```ts
|
|
65
|
-
// Only
|
|
68
|
+
// Only the current event flow needs to exit → Use ctx.exit()
|
|
66
69
|
if (!params.valid) {
|
|
67
|
-
ctx.message.error('Invalid
|
|
68
|
-
ctx.exit();
|
|
70
|
+
ctx.message.error('Invalid parameters');
|
|
71
|
+
ctx.exit(); // Other event flows are unaffected
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
//
|
|
74
|
+
// Need to terminate all subsequent event flows under the current event → Use ctx.exitAll()
|
|
72
75
|
if (!ctx.model?.context?.getPermission?.()) {
|
|
73
|
-
ctx.notification.warning({ message: '
|
|
74
|
-
ctx.exitAll();
|
|
76
|
+
ctx.notification.warning({ message: 'Insufficient permissions' });
|
|
77
|
+
ctx.exitAll(); // Both the current event flow and subsequent event flows under the same event are terminated
|
|
75
78
|
}
|
|
76
79
|
```
|
|
77
80
|
|
|
78
|
-
### Exit
|
|
81
|
+
### Exit Based on User Choice After Modal Confirmation
|
|
79
82
|
|
|
80
83
|
```ts
|
|
81
84
|
const ok = await ctx.modal?.confirm?.({
|
|
82
|
-
title: 'Confirm
|
|
83
|
-
content: '
|
|
85
|
+
title: 'Confirm Delete',
|
|
86
|
+
content: 'This action cannot be undone. Do you want to continue?',
|
|
84
87
|
});
|
|
85
88
|
if (!ok) {
|
|
86
89
|
ctx.message.info('Cancelled');
|
|
@@ -90,12 +93,12 @@ if (!ok) {
|
|
|
90
93
|
|
|
91
94
|
## Notes
|
|
92
95
|
|
|
93
|
-
- After `ctx.exit()`,
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
+
- After calling `ctx.exit()`, subsequent code in the current JS will not execute; it is recommended to explain the reason to the user via `ctx.message`, `ctx.notification`, or a modal before calling it.
|
|
97
|
+
- There is usually no need to catch `FlowExitException` in business code; let the FlowEngine handle it.
|
|
98
|
+
- If you need to terminate all subsequent event flows under the current event, use `ctx.exitAll()`.
|
|
96
99
|
|
|
97
100
|
## Related
|
|
98
101
|
|
|
99
|
-
- [ctx.exitAll()](./exit-all.md):
|
|
100
|
-
- [ctx.message](./message.md):
|
|
101
|
-
- [ctx.modal](./modal.md):
|
|
102
|
+
- [ctx.exitAll()](./exit-all.md): Terminates the current event flow and subsequent event flows under the same event.
|
|
103
|
+
- [ctx.message](./message.md): Message prompts.
|
|
104
|
+
- [ctx.modal](./modal.md): Confirmation modals.
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
# ctx.filterManager
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Filter Connection Manager is used to manage the filter associations between filter forms (FilterForm) and data blocks (tables, lists, charts, etc.). It is provided by `BlockGridModel` and is only available within its context (e.g., filter form blocks, data blocks).
|
|
4
4
|
|
|
5
5
|
## Use Cases
|
|
6
6
|
|
|
7
7
|
| Scenario | Description |
|
|
8
|
-
|
|
9
|
-
| **Filter
|
|
10
|
-
| **Data
|
|
11
|
-
| **Linkage /
|
|
12
|
-
| **Connection
|
|
8
|
+
|------|------|
|
|
9
|
+
| **Filter Form Block** | Manages connection configurations between filter items and target blocks; refreshes target data when filters change. |
|
|
10
|
+
| **Data Block (Table/List)** | Acts as a filter target, binding filter conditions via `bindToTarget`. |
|
|
11
|
+
| **Linkage Rules / Custom FilterModel** | Calls `refreshTargetsByFilter` within `doFilter` or `doReset` to trigger target refreshes. |
|
|
12
|
+
| **Connection Field Configuration** | Uses `getConnectFieldsConfig` and `saveConnectFieldsConfig` to maintain field mappings between filters and targets. |
|
|
13
13
|
|
|
14
|
-
> Note: `ctx.filterManager` is only available in RunJS contexts that have a `BlockGridModel` (e.g
|
|
14
|
+
> Note: `ctx.filterManager` is only available in RunJS contexts that have a `BlockGridModel` (e.g., within a page containing a filter form); it is `undefined` in regular JSBlocks or independent pages. It is recommended to use optional chaining before access.
|
|
15
15
|
|
|
16
|
-
## Type
|
|
16
|
+
## Type Definitions
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
filterManager: FilterManager;
|
|
20
20
|
|
|
21
21
|
type FilterConfig = {
|
|
22
|
-
filterId: string;
|
|
23
|
-
targetId: string;
|
|
24
|
-
filterPaths?: string[];
|
|
25
|
-
operator?: string;
|
|
22
|
+
filterId: string; // Filter model UID
|
|
23
|
+
targetId: string; // Target data block model UID
|
|
24
|
+
filterPaths?: string[]; // Field paths of the target block
|
|
25
|
+
operator?: string; // Filter operator
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
type ConnectFieldsConfig = {
|
|
@@ -33,24 +33,24 @@ type ConnectFieldsConfig = {
|
|
|
33
33
|
## Common Methods
|
|
34
34
|
|
|
35
35
|
| Method | Description |
|
|
36
|
-
|
|
37
|
-
| `getFilterConfigs()` |
|
|
38
|
-
| `getConnectFieldsConfig(filterId)` |
|
|
39
|
-
| `saveConnectFieldsConfig(filterId, config)` |
|
|
40
|
-
| `addFilterConfig(config)` |
|
|
41
|
-
| `removeFilterConfig({ filterId?, targetId?, persist? })` |
|
|
42
|
-
| `bindToTarget(targetId)` |
|
|
43
|
-
| `unbindFromTarget(targetId)` |
|
|
44
|
-
| `refreshTargetsByFilter(filterId
|
|
36
|
+
|------|------|
|
|
37
|
+
| `getFilterConfigs()` | Gets all current filter connection configurations. |
|
|
38
|
+
| `getConnectFieldsConfig(filterId)` | Gets the connection field configuration for a specific filter. |
|
|
39
|
+
| `saveConnectFieldsConfig(filterId, config)` | Saves the connection field configuration for a filter. |
|
|
40
|
+
| `addFilterConfig(config)` | Adds a filter configuration (filterId + targetId + filterPaths). |
|
|
41
|
+
| `removeFilterConfig({ filterId?, targetId?, persist? })` | Removes filter configurations by filterId, targetId, or both. |
|
|
42
|
+
| `bindToTarget(targetId)` | Binds the filter configuration to a target block, triggering its resource to apply the filter. |
|
|
43
|
+
| `unbindFromTarget(targetId)` | Unbinds the filter from the target block. |
|
|
44
|
+
| `refreshTargetsByFilter(filterId | filterId[])` | Refreshes associated target block data based on the filter(s). |
|
|
45
45
|
|
|
46
|
-
## Concepts
|
|
46
|
+
## Core Concepts
|
|
47
47
|
|
|
48
|
-
- **FilterModel**:
|
|
49
|
-
- **TargetModel**:
|
|
48
|
+
- **FilterModel**: A model providing filter conditions (e.g., FilterFormItemModel), which must implement `getFilterValue()` to return the current filter value.
|
|
49
|
+
- **TargetModel**: The data block being filtered; its `resource` must support `addFilterGroup`, `removeFilterGroup`, and `refresh`.
|
|
50
50
|
|
|
51
51
|
## Examples
|
|
52
52
|
|
|
53
|
-
### Add
|
|
53
|
+
### Add Filter Configuration
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
56
|
await ctx.filterManager?.addFilterConfig({
|
|
@@ -61,19 +61,23 @@ await ctx.filterManager?.addFilterConfig({
|
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
### Refresh
|
|
64
|
+
### Refresh Target Blocks
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
|
+
// In doFilter / doReset of a filter form
|
|
67
68
|
ctx.filterManager?.refreshTargetsByFilter(ctx.model.uid);
|
|
68
69
|
|
|
70
|
+
// Refresh targets associated with multiple filters
|
|
69
71
|
ctx.filterManager?.refreshTargetsByFilter(['filter-1', 'filter-2']);
|
|
70
72
|
```
|
|
71
73
|
|
|
72
|
-
### Connection
|
|
74
|
+
### Connection Field Configuration
|
|
73
75
|
|
|
74
76
|
```ts
|
|
77
|
+
// Get connection configuration
|
|
75
78
|
const config = ctx.filterManager?.getConnectFieldsConfig(ctx.model.uid);
|
|
76
79
|
|
|
80
|
+
// Save connection configuration
|
|
77
81
|
await ctx.filterManager?.saveConnectFieldsConfig(ctx.model.uid, {
|
|
78
82
|
targets: [
|
|
79
83
|
{ targetId: 'table-uid', filterPaths: ['status'] },
|
|
@@ -82,15 +86,17 @@ await ctx.filterManager?.saveConnectFieldsConfig(ctx.model.uid, {
|
|
|
82
86
|
});
|
|
83
87
|
```
|
|
84
88
|
|
|
85
|
-
### Remove
|
|
89
|
+
### Remove Configuration
|
|
86
90
|
|
|
87
91
|
```ts
|
|
92
|
+
// Delete all configurations for a specific filter
|
|
88
93
|
await ctx.filterManager?.removeFilterConfig({ filterId: 'filter-uid' });
|
|
89
94
|
|
|
95
|
+
// Delete all filter configurations for a specific target
|
|
90
96
|
await ctx.filterManager?.removeFilterConfig({ targetId: 'table-uid' });
|
|
91
97
|
```
|
|
92
98
|
|
|
93
99
|
## Related
|
|
94
100
|
|
|
95
|
-
- [ctx.resource](./resource.md): target block
|
|
96
|
-
- [ctx.model](./model.md): current model
|
|
101
|
+
- [ctx.resource](./resource.md): The target block's resource must support the filter interface.
|
|
102
|
+
- [ctx.model](./model.md): Used to get the current model's UID for filterId / targetId.
|
|
@@ -1,109 +1,109 @@
|
|
|
1
1
|
# ctx.form
|
|
2
2
|
|
|
3
|
-
The Ant Design Form instance
|
|
3
|
+
The Ant Design Form instance within the current block, used to read/write form fields, trigger validation, and submission. It is equivalent to `ctx.blockModel?.form` and can be used directly in form-related blocks (Form, Edit Form, Sub-form, etc.).
|
|
4
4
|
|
|
5
5
|
## Use Cases
|
|
6
6
|
|
|
7
7
|
| Scenario | Description |
|
|
8
|
-
|
|
9
|
-
| **JSField** | Read/write other fields
|
|
10
|
-
| **JSItem** | Read/write same
|
|
11
|
-
| **JSColumn** | Read row or
|
|
12
|
-
| **Form
|
|
8
|
+
|------|------|
|
|
9
|
+
| **JSField** | Read/write other form fields to implement linkage, or perform calculations and validation based on other field values. |
|
|
10
|
+
| **JSItem** | Read/write same-row or other fields within sub-table items to achieve in-table linkage. |
|
|
11
|
+
| **JSColumn** | Read the current row or association field values in a table column for rendering. |
|
|
12
|
+
| **Form Actions / Workflow** | Pre-submission validation, batch updating fields, resetting forms, etc. |
|
|
13
13
|
|
|
14
|
-
> Note: `ctx.form` is only available in RunJS contexts
|
|
14
|
+
> Note: `ctx.form` is only available in RunJS contexts related to form blocks (Form, Edit Form, Sub-form, etc.). It may not exist in non-form scenarios (such as independent JSBlocks or Table blocks). It is recommended to perform a null check before use: `ctx.form?.getFieldsValue()`.
|
|
15
15
|
|
|
16
|
-
## Type
|
|
16
|
+
## Type Definition
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
form: FormInstance<any>;
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
`FormInstance` is the Ant Design Form
|
|
22
|
+
`FormInstance` is the instance type of Ant Design Form. Common methods are as follows.
|
|
23
23
|
|
|
24
24
|
## Common Methods
|
|
25
25
|
|
|
26
|
-
###
|
|
26
|
+
### Reading Form Values
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
//
|
|
29
|
+
// Read values of currently registered fields (defaults to rendered fields only)
|
|
30
30
|
const values = ctx.form.getFieldsValue();
|
|
31
31
|
|
|
32
|
-
//
|
|
32
|
+
// Read values of all fields (including registered but unrendered fields, e.g., hidden or inside collapsed sections)
|
|
33
33
|
const allValues = ctx.form.getFieldsValue(true);
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// Read a single field
|
|
36
36
|
const email = ctx.form.getFieldValue('email');
|
|
37
37
|
|
|
38
|
-
//
|
|
38
|
+
// Read nested fields (e.g., in a sub-table)
|
|
39
39
|
const amount = ctx.form.getFieldValue(['orders', 0, 'amount']);
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
###
|
|
42
|
+
### Writing Form Values
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
|
-
// Batch update (
|
|
45
|
+
// Batch update (commonly used for linkage)
|
|
46
46
|
ctx.form.setFieldsValue({
|
|
47
47
|
status: 'active',
|
|
48
48
|
updatedAt: new Date(),
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
//
|
|
52
|
-
ctx.form.setFieldValue('remark', '
|
|
51
|
+
// Update a single field
|
|
52
|
+
ctx.form.setFieldValue('remark', 'Updated remark');
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
### Validation and
|
|
55
|
+
### Validation and Submission
|
|
56
56
|
|
|
57
57
|
```ts
|
|
58
|
-
// Trigger validation
|
|
58
|
+
// Trigger form validation
|
|
59
59
|
await ctx.form.validateFields();
|
|
60
60
|
|
|
61
|
-
// Trigger
|
|
61
|
+
// Trigger form submission
|
|
62
62
|
ctx.form.submit();
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
###
|
|
65
|
+
### Resetting
|
|
66
66
|
|
|
67
67
|
```ts
|
|
68
|
-
//
|
|
68
|
+
// Reset all fields
|
|
69
69
|
ctx.form.resetFields();
|
|
70
70
|
|
|
71
|
-
//
|
|
71
|
+
// Reset only specific fields
|
|
72
72
|
ctx.form.resetFields(['status', 'remark']);
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
##
|
|
75
|
+
## Relationship with Related Contexts
|
|
76
76
|
|
|
77
77
|
### ctx.getValue / ctx.setValue
|
|
78
78
|
|
|
79
|
-
| Scenario | Recommended |
|
|
80
|
-
|
|
81
|
-
| **
|
|
82
|
-
| **
|
|
79
|
+
| Scenario | Recommended Usage |
|
|
80
|
+
|------|----------|
|
|
81
|
+
| **Read/Write current field** | `ctx.getValue()` / `ctx.setValue(v)` |
|
|
82
|
+
| **Read/Write other fields** | `ctx.form.getFieldValue(name)` / `ctx.form.setFieldValue(name, v)` |
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
Within the current JS field, prioritize using `getValue`/`setValue` to read/write the field itself; use `ctx.form` when you need to access other fields.
|
|
85
85
|
|
|
86
86
|
### ctx.blockModel
|
|
87
87
|
|
|
88
|
-
|
|
|
89
|
-
|
|
90
|
-
| **Read/
|
|
91
|
-
| **
|
|
88
|
+
| Requirement | Recommended Usage |
|
|
89
|
+
|------|----------|
|
|
90
|
+
| **Read/Write form fields** | `ctx.form` (Equivalent to `ctx.blockModel?.form`, more convenient) |
|
|
91
|
+
| **Access parent block** | `ctx.blockModel` (Contains `collection`, `resource`, etc.) |
|
|
92
92
|
|
|
93
93
|
### ctx.getVar('ctx.formValues')
|
|
94
94
|
|
|
95
|
-
Form values
|
|
95
|
+
Form values must be obtained via `await ctx.getVar('ctx.formValues')` and are not directly exposed as `ctx.formValues`. In a form context, it is preferred to use `ctx.form.getFieldsValue()` to read the latest values in real-time.
|
|
96
96
|
|
|
97
97
|
## Notes
|
|
98
98
|
|
|
99
|
-
- `getFieldsValue()`
|
|
100
|
-
-
|
|
101
|
-
- `validateFields()` throws
|
|
102
|
-
- In
|
|
99
|
+
- `getFieldsValue()` returns only rendered fields by default. To include unrendered fields (e.g., in collapsed sections or hidden by conditional rules), pass `true`: `getFieldsValue(true)`.
|
|
100
|
+
- Paths for nested fields like sub-tables are arrays, e.g., `['orders', 0, 'amount']`. You can use `ctx.namePath` to get the current field's path and construct paths for other columns in the same row.
|
|
101
|
+
- `validateFields()` throws an error object containing `errorFields` and other information. If validation fails before submission, you can use `ctx.exit()` to terminate subsequent steps.
|
|
102
|
+
- In asynchronous scenarios like workflows or linkage rules, `ctx.form` might not be ready yet. It is recommended to use optional chaining or null checks.
|
|
103
103
|
|
|
104
104
|
## Examples
|
|
105
105
|
|
|
106
|
-
### Field
|
|
106
|
+
### Field Linkage: Display different content based on type
|
|
107
107
|
|
|
108
108
|
```ts
|
|
109
109
|
const type = ctx.form.getFieldValue('type');
|
|
@@ -114,7 +114,7 @@ if (type === 'vip') {
|
|
|
114
114
|
}
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
###
|
|
117
|
+
### Calculate current field based on other fields
|
|
118
118
|
|
|
119
119
|
```ts
|
|
120
120
|
const quantity = ctx.form.getFieldValue('quantity') ?? 0;
|
|
@@ -122,48 +122,48 @@ const price = ctx.form.getFieldValue('price') ?? 0;
|
|
|
122
122
|
ctx.setValue(quantity * price);
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
###
|
|
125
|
+
### Read/Write other columns in the same row within a sub-table
|
|
126
126
|
|
|
127
127
|
```ts
|
|
128
|
-
// ctx.namePath is current field
|
|
129
|
-
//
|
|
128
|
+
// ctx.namePath is the path of the current field in the form, e.g., ['orders', 0, 'amount']
|
|
129
|
+
// Read 'status' in the same row: ['orders', 0, 'status']
|
|
130
130
|
const rowIndex = ctx.namePath?.[1];
|
|
131
131
|
const status = ctx.form.getFieldValue(['orders', rowIndex, 'status']);
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
### Pre-
|
|
134
|
+
### Pre-submission Validation
|
|
135
135
|
|
|
136
136
|
```ts
|
|
137
137
|
try {
|
|
138
138
|
await ctx.form.validateFields();
|
|
139
|
-
//
|
|
139
|
+
// Validation passed, continue with submission logic
|
|
140
140
|
} catch (e) {
|
|
141
|
-
ctx.message.error('Please
|
|
141
|
+
ctx.message.error('Please check the form fields');
|
|
142
142
|
ctx.exit();
|
|
143
143
|
}
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
###
|
|
146
|
+
### Submit after Confirmation
|
|
147
147
|
|
|
148
148
|
```ts
|
|
149
149
|
const confirmed = await ctx.modal.confirm({
|
|
150
|
-
title: 'Confirm
|
|
151
|
-
content: '
|
|
152
|
-
okText: '
|
|
150
|
+
title: 'Confirm Submission',
|
|
151
|
+
content: 'You will not be able to modify this after submission. Continue?',
|
|
152
|
+
okText: 'Confirm',
|
|
153
153
|
cancelText: 'Cancel',
|
|
154
154
|
});
|
|
155
155
|
if (confirmed) {
|
|
156
156
|
await ctx.form.validateFields();
|
|
157
157
|
ctx.form.submit();
|
|
158
158
|
} else {
|
|
159
|
-
ctx.exit();
|
|
159
|
+
ctx.exit(); // Terminate if user cancels
|
|
160
160
|
}
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
## Related
|
|
164
164
|
|
|
165
|
-
- [ctx.getValue()](./get-value.md) / [ctx.setValue()](./set-value.md):
|
|
166
|
-
- [ctx.blockModel](./block-model.md):
|
|
167
|
-
- [ctx.modal](./modal.md):
|
|
168
|
-
- [ctx.exit()](./exit.md):
|
|
169
|
-
- `ctx.namePath`: current field
|
|
165
|
+
- [ctx.getValue()](./get-value.md) / [ctx.setValue()](./set-value.md): Read and write the current field value.
|
|
166
|
+
- [ctx.blockModel](./block-model.md): Parent block model; `ctx.form` is equivalent to `ctx.blockModel?.form`.
|
|
167
|
+
- [ctx.modal](./modal.md): Confirmation dialogs, often used with `ctx.form.validateFields()` and `ctx.form.submit()`.
|
|
168
|
+
- [ctx.exit()](./exit.md): Terminate the process upon validation failure or user cancellation.
|
|
169
|
+
- `ctx.namePath`: The path (array) of the current field in the form, used to construct names for `getFieldValue` / `setFieldValue` in nested fields.
|