weaver-e10-builder 1.0.8-beta → 1.0.9-beta
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/commands/actionflow.d.ts +7 -0
- package/dist/commands/actionflow.d.ts.map +1 -0
- package/dist/commands/actionflow.js +105 -0
- package/dist/commands/actionflow.js.map +1 -0
- package/dist/commands/auth.js +1 -1
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/form-list.d.ts.map +1 -1
- package/dist/commands/form-list.js +18 -9
- package/dist/commands/form-list.js.map +1 -1
- package/dist/commands/form-native.d.ts +0 -14
- package/dist/commands/form-native.d.ts.map +1 -1
- package/dist/commands/form-native.js +398 -72
- package/dist/commands/form-native.js.map +1 -1
- package/dist/commands/form.d.ts.map +1 -1
- package/dist/commands/form.js +5 -2
- package/dist/commands/form.js.map +1 -1
- package/dist/commands/wf-form.d.ts.map +1 -1
- package/dist/commands/wf-form.js +49 -1
- package/dist/commands/wf-form.js.map +1 -1
- package/dist/commands/workflow-action.d.ts +11 -0
- package/dist/commands/workflow-action.d.ts.map +1 -1
- package/dist/commands/workflow-action.js +13 -1592
- package/dist/commands/workflow-action.js.map +1 -1
- package/dist/commands/workflow-create-workflow.d.ts.map +1 -1
- package/dist/commands/workflow-create-workflow.js +36 -5
- package/dist/commands/workflow-create-workflow.js.map +1 -1
- package/dist/core/client.d.ts +2 -0
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +2 -0
- package/dist/core/client.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/services/actionflow/build_workflow_draft.d.ts +20 -0
- package/dist/services/actionflow/build_workflow_draft.d.ts.map +1 -0
- package/dist/services/actionflow/build_workflow_draft.js +222 -0
- package/dist/services/actionflow/build_workflow_draft.js.map +1 -0
- package/dist/services/actionflow/calendar_mapper.d.ts +3 -0
- package/dist/services/actionflow/calendar_mapper.d.ts.map +1 -0
- package/dist/services/actionflow/calendar_mapper.js +152 -0
- package/dist/services/actionflow/calendar_mapper.js.map +1 -0
- package/dist/services/actionflow/component_registry.d.ts +13 -0
- package/dist/services/actionflow/component_registry.d.ts.map +1 -0
- package/dist/services/actionflow/component_registry.js +213 -0
- package/dist/services/actionflow/component_registry.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_add.d.ts +3 -0
- package/dist/services/actionflow/components/action_eb_add.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_add.js +127 -0
- package/dist/services/actionflow/components/action_eb_add.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_add_compiler.d.ts +4 -0
- package/dist/services/actionflow/components/action_eb_add_compiler.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_add_compiler.js +13 -0
- package/dist/services/actionflow/components/action_eb_add_compiler.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_delete.d.ts +3 -0
- package/dist/services/actionflow/components/action_eb_delete.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_delete.js +69 -0
- package/dist/services/actionflow/components/action_eb_delete.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_delete_compiler.d.ts +4 -0
- package/dist/services/actionflow/components/action_eb_delete_compiler.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_delete_compiler.js +7 -0
- package/dist/services/actionflow/components/action_eb_delete_compiler.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_recover.d.ts +3 -0
- package/dist/services/actionflow/components/action_eb_recover.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_recover.js +28 -0
- package/dist/services/actionflow/components/action_eb_recover.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_recover_compiler.d.ts +3 -0
- package/dist/services/actionflow/components/action_eb_recover_compiler.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_recover_compiler.js +16 -0
- package/dist/services/actionflow/components/action_eb_recover_compiler.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_save_version.d.ts +3 -0
- package/dist/services/actionflow/components/action_eb_save_version.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_save_version.js +30 -0
- package/dist/services/actionflow/components/action_eb_save_version.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_save_version_compiler.d.ts +3 -0
- package/dist/services/actionflow/components/action_eb_save_version_compiler.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_save_version_compiler.js +15 -0
- package/dist/services/actionflow/components/action_eb_save_version_compiler.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_update.d.ts +3 -0
- package/dist/services/actionflow/components/action_eb_update.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_update.js +154 -0
- package/dist/services/actionflow/components/action_eb_update.js.map +1 -0
- package/dist/services/actionflow/components/action_eb_update_compiler.d.ts +16 -0
- package/dist/services/actionflow/components/action_eb_update_compiler.d.ts.map +1 -0
- package/dist/services/actionflow/components/action_eb_update_compiler.js +94 -0
- package/dist/services/actionflow/components/action_eb_update_compiler.js.map +1 -0
- package/dist/services/actionflow/components/approve_create.d.ts +3 -0
- package/dist/services/actionflow/components/approve_create.d.ts.map +1 -0
- package/dist/services/actionflow/components/approve_create.js +44 -0
- package/dist/services/actionflow/components/approve_create.js.map +1 -0
- package/dist/services/actionflow/components/approve_trigger.d.ts +5 -0
- package/dist/services/actionflow/components/approve_trigger.d.ts.map +1 -0
- package/dist/services/actionflow/components/approve_trigger.js +184 -0
- package/dist/services/actionflow/components/approve_trigger.js.map +1 -0
- package/dist/services/actionflow/components/approve_trigger_compiler.d.ts +4 -0
- package/dist/services/actionflow/components/approve_trigger_compiler.d.ts.map +1 -0
- package/dist/services/actionflow/components/approve_trigger_compiler.js +20 -0
- package/dist/services/actionflow/components/approve_trigger_compiler.js.map +1 -0
- package/dist/services/actionflow/components/condition.d.ts +3 -0
- package/dist/services/actionflow/components/condition.d.ts.map +1 -0
- package/dist/services/actionflow/components/condition.js +23 -0
- package/dist/services/actionflow/components/condition.js.map +1 -0
- package/dist/services/actionflow/components/date_trigger.d.ts +5 -0
- package/dist/services/actionflow/components/date_trigger.d.ts.map +1 -0
- package/dist/services/actionflow/components/date_trigger.js +129 -0
- package/dist/services/actionflow/components/date_trigger.js.map +1 -0
- package/dist/services/actionflow/components/document_actions.d.ts +28 -0
- package/dist/services/actionflow/components/document_actions.d.ts.map +1 -0
- package/dist/services/actionflow/components/document_actions.js +266 -0
- package/dist/services/actionflow/components/document_actions.js.map +1 -0
- package/dist/services/actionflow/components/eb_get_data_by_id.d.ts +5 -0
- package/dist/services/actionflow/components/eb_get_data_by_id.d.ts.map +1 -0
- package/dist/services/actionflow/components/eb_get_data_by_id.js +44 -0
- package/dist/services/actionflow/components/eb_get_data_by_id.js.map +1 -0
- package/dist/services/actionflow/components/enquiry_form.d.ts +5 -0
- package/dist/services/actionflow/components/enquiry_form.d.ts.map +1 -0
- package/dist/services/actionflow/components/enquiry_form.js +100 -0
- package/dist/services/actionflow/components/enquiry_form.js.map +1 -0
- package/dist/services/actionflow/components/event_form_data.d.ts +3 -0
- package/dist/services/actionflow/components/event_form_data.d.ts.map +1 -0
- package/dist/services/actionflow/components/event_form_data.js +29 -0
- package/dist/services/actionflow/components/event_form_data.js.map +1 -0
- package/dist/services/actionflow/components/hrm_actions.d.ts +7 -0
- package/dist/services/actionflow/components/hrm_actions.d.ts.map +1 -0
- package/dist/services/actionflow/components/hrm_actions.js +138 -0
- package/dist/services/actionflow/components/hrm_actions.js.map +1 -0
- package/dist/services/actionflow/components/index.d.ts +32 -0
- package/dist/services/actionflow/components/index.d.ts.map +1 -0
- package/dist/services/actionflow/components/index.js +132 -0
- package/dist/services/actionflow/components/index.js.map +1 -0
- package/dist/services/actionflow/components/logic_flow_set.d.ts +10 -0
- package/dist/services/actionflow/components/logic_flow_set.d.ts.map +1 -0
- package/dist/services/actionflow/components/logic_flow_set.js +79 -0
- package/dist/services/actionflow/components/logic_flow_set.js.map +1 -0
- package/dist/services/actionflow/components/meeting_create.d.ts +5 -0
- package/dist/services/actionflow/components/meeting_create.d.ts.map +1 -0
- package/dist/services/actionflow/components/meeting_create.js +37 -0
- package/dist/services/actionflow/components/meeting_create.js.map +1 -0
- package/dist/services/actionflow/components/multiple_execution.d.ts +5 -0
- package/dist/services/actionflow/components/multiple_execution.d.ts.map +1 -0
- package/dist/services/actionflow/components/multiple_execution.js +136 -0
- package/dist/services/actionflow/components/multiple_execution.js.map +1 -0
- package/dist/services/actionflow/components/output.d.ts +9 -0
- package/dist/services/actionflow/components/output.d.ts.map +1 -0
- package/dist/services/actionflow/components/output.js +81 -0
- package/dist/services/actionflow/components/output.js.map +1 -0
- package/dist/services/actionflow/components/schedule_create.d.ts +5 -0
- package/dist/services/actionflow/components/schedule_create.d.ts.map +1 -0
- package/dist/services/actionflow/components/schedule_create.js +42 -0
- package/dist/services/actionflow/components/schedule_create.js.map +1 -0
- package/dist/services/actionflow/components/send_message.d.ts +7 -0
- package/dist/services/actionflow/components/send_message.d.ts.map +1 -0
- package/dist/services/actionflow/components/send_message.js +200 -0
- package/dist/services/actionflow/components/send_message.js.map +1 -0
- package/dist/services/actionflow/components/simple_scheduler.d.ts +5 -0
- package/dist/services/actionflow/components/simple_scheduler.d.ts.map +1 -0
- package/dist/services/actionflow/components/simple_scheduler.js +22 -0
- package/dist/services/actionflow/components/simple_scheduler.js.map +1 -0
- package/dist/services/actionflow/components/time_batch_trigger.d.ts +5 -0
- package/dist/services/actionflow/components/time_batch_trigger.d.ts.map +1 -0
- package/dist/services/actionflow/components/time_batch_trigger.js +92 -0
- package/dist/services/actionflow/components/time_batch_trigger.js.map +1 -0
- package/dist/services/actionflow/components/workflow_actions.d.ts +26 -0
- package/dist/services/actionflow/components/workflow_actions.d.ts.map +1 -0
- package/dist/services/actionflow/components/workflow_actions.js +403 -0
- package/dist/services/actionflow/components/workflow_actions.js.map +1 -0
- package/dist/services/actionflow/context_data_builder.d.ts +9 -0
- package/dist/services/actionflow/context_data_builder.d.ts.map +1 -0
- package/dist/services/actionflow/context_data_builder.js +31 -0
- package/dist/services/actionflow/context_data_builder.js.map +1 -0
- package/dist/services/actionflow/context_preflight.d.ts +6 -0
- package/dist/services/actionflow/context_preflight.d.ts.map +1 -0
- package/dist/services/actionflow/context_preflight.js +122 -0
- package/dist/services/actionflow/context_preflight.js.map +1 -0
- package/dist/services/actionflow/context_provider.d.ts +18 -0
- package/dist/services/actionflow/context_provider.d.ts.map +1 -0
- package/dist/services/actionflow/context_provider.js +102 -0
- package/dist/services/actionflow/context_provider.js.map +1 -0
- package/dist/services/actionflow/context_source.d.ts +7 -0
- package/dist/services/actionflow/context_source.d.ts.map +1 -0
- package/dist/services/actionflow/context_source.js +10 -0
- package/dist/services/actionflow/context_source.js.map +1 -0
- package/dist/services/actionflow/design_client.d.ts +48 -0
- package/dist/services/actionflow/design_client.d.ts.map +1 -0
- package/dist/services/actionflow/design_client.js +170 -0
- package/dist/services/actionflow/design_client.js.map +1 -0
- package/dist/services/actionflow/document_source.d.ts +5 -0
- package/dist/services/actionflow/document_source.d.ts.map +1 -0
- package/dist/services/actionflow/document_source.js +5 -0
- package/dist/services/actionflow/document_source.js.map +1 -0
- package/dist/services/actionflow/enrich_approve_trigger.d.ts +12 -0
- package/dist/services/actionflow/enrich_approve_trigger.d.ts.map +1 -0
- package/dist/services/actionflow/enrich_approve_trigger.js +107 -0
- package/dist/services/actionflow/enrich_approve_trigger.js.map +1 -0
- package/dist/services/actionflow/filter_rules.d.ts +14 -0
- package/dist/services/actionflow/filter_rules.d.ts.map +1 -0
- package/dist/services/actionflow/filter_rules.js +259 -0
- package/dist/services/actionflow/filter_rules.js.map +1 -0
- package/dist/services/actionflow/form_source.d.ts +17 -0
- package/dist/services/actionflow/form_source.d.ts.map +1 -0
- package/dist/services/actionflow/form_source.js +42 -0
- package/dist/services/actionflow/form_source.js.map +1 -0
- package/dist/services/actionflow/formula_service.d.ts +51 -0
- package/dist/services/actionflow/formula_service.d.ts.map +1 -0
- package/dist/services/actionflow/formula_service.js +999 -0
- package/dist/services/actionflow/formula_service.js.map +1 -0
- package/dist/services/actionflow/generation_service.d.ts +28 -0
- package/dist/services/actionflow/generation_service.d.ts.map +1 -0
- package/dist/services/actionflow/generation_service.js +283 -0
- package/dist/services/actionflow/generation_service.js.map +1 -0
- package/dist/services/actionflow/hrm_source.d.ts +4 -0
- package/dist/services/actionflow/hrm_source.d.ts.map +1 -0
- package/dist/services/actionflow/hrm_source.js +8 -0
- package/dist/services/actionflow/hrm_source.js.map +1 -0
- package/dist/services/actionflow/id_generator.d.ts +13 -0
- package/dist/services/actionflow/id_generator.d.ts.map +1 -0
- package/dist/services/actionflow/id_generator.js +33 -0
- package/dist/services/actionflow/id_generator.js.map +1 -0
- package/dist/services/actionflow/person_source.d.ts +7 -0
- package/dist/services/actionflow/person_source.d.ts.map +1 -0
- package/dist/services/actionflow/person_source.js +34 -0
- package/dist/services/actionflow/person_source.js.map +1 -0
- package/dist/services/actionflow/preflight_service.d.ts +42 -0
- package/dist/services/actionflow/preflight_service.d.ts.map +1 -0
- package/dist/services/actionflow/preflight_service.js +1247 -0
- package/dist/services/actionflow/preflight_service.js.map +1 -0
- package/dist/services/actionflow/query_field_defaults.d.ts +3 -0
- package/dist/services/actionflow/query_field_defaults.d.ts.map +1 -0
- package/dist/services/actionflow/query_field_defaults.js +46 -0
- package/dist/services/actionflow/query_field_defaults.js.map +1 -0
- package/dist/services/actionflow/readback_verifier.d.ts +11 -0
- package/dist/services/actionflow/readback_verifier.d.ts.map +1 -0
- package/dist/services/actionflow/readback_verifier.js +252 -0
- package/dist/services/actionflow/readback_verifier.js.map +1 -0
- package/dist/services/actionflow/request.d.ts +13 -0
- package/dist/services/actionflow/request.d.ts.map +1 -0
- package/dist/services/actionflow/request.js +15 -0
- package/dist/services/actionflow/request.js.map +1 -0
- package/dist/services/actionflow/runtime_metadata.d.ts +27 -0
- package/dist/services/actionflow/runtime_metadata.d.ts.map +1 -0
- package/dist/services/actionflow/runtime_metadata.js +142 -0
- package/dist/services/actionflow/runtime_metadata.js.map +1 -0
- package/dist/services/actionflow/save_workflow_draft.d.ts +34 -0
- package/dist/services/actionflow/save_workflow_draft.d.ts.map +1 -0
- package/dist/services/actionflow/save_workflow_draft.js +449 -0
- package/dist/services/actionflow/save_workflow_draft.js.map +1 -0
- package/dist/services/actionflow/system_params.d.ts +5 -0
- package/dist/services/actionflow/system_params.d.ts.map +1 -0
- package/dist/services/actionflow/system_params.js +55 -0
- package/dist/services/actionflow/system_params.js.map +1 -0
- package/dist/services/actionflow/trigger_common.d.ts +6 -0
- package/dist/services/actionflow/trigger_common.d.ts.map +1 -0
- package/dist/services/actionflow/trigger_common.js +41 -0
- package/dist/services/actionflow/trigger_common.js.map +1 -0
- package/dist/services/actionflow/workflow_compiler.d.ts +27 -0
- package/dist/services/actionflow/workflow_compiler.d.ts.map +1 -0
- package/dist/services/actionflow/workflow_compiler.js +1804 -0
- package/dist/services/actionflow/workflow_compiler.js.map +1 -0
- package/dist/services/actionflow/workflow_source.d.ts +14 -0
- package/dist/services/actionflow/workflow_source.d.ts.map +1 -0
- package/dist/services/actionflow/workflow_source.js +86 -0
- package/dist/services/actionflow/workflow_source.js.map +1 -0
- package/package.json +1 -1
|
@@ -2,1525 +2,19 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { AuthSession } from '../core/auth.js';
|
|
4
4
|
import { ApiClient } from '../core/client.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* workflow action — 动作流管理命令。
|
|
7
|
+
*
|
|
8
|
+
* 动作流「生成」走 `e10-cli actionflow generate`(语义 plan → 编译 → preflight → 暂存 → 回读,
|
|
9
|
+
* 在 design 的 event 节点里绑流程节点,不走 pathdef/addaction)。本组只保留动作流的生命周期
|
|
10
|
+
* 与节点绑定管理:列/清节点绑定、禁用、删除、批量删除。
|
|
11
|
+
*
|
|
12
|
+
* - list-node / clear-node:读 / 清流程节点上绑定的动作(pathdef/addaction 的 getAddActionDataList /
|
|
13
|
+
* deleteAddAction,含 type0 常量赋值与 type2 动作流)。
|
|
14
|
+
* - disable / delete / batch-delete:ESB 应用层禁用与回收(forbiddenAppById / batchAddRecycle)。
|
|
15
|
+
*/
|
|
8
16
|
export function registerWorkflowActionCommands(wf, program) {
|
|
9
|
-
|
|
10
|
-
const actionCmd = wf.command('action').description('动作流管理(跨表单数据操作)');
|
|
11
|
-
/**
|
|
12
|
-
* Generate a temporary ID for new ESB design nodes.
|
|
13
|
-
* Uses positive timestamp + random to simulate Snowflake-like IDs.
|
|
14
|
-
*/
|
|
15
|
-
function tempId() {
|
|
16
|
-
return String(Date.now() * 1000 + Math.floor(Math.random() * 10000));
|
|
17
|
-
}
|
|
18
|
-
/** Minimal itemAndLayout template for ApproveTrigger */
|
|
19
|
-
const EVENT_LAYOUT = { "items": { "module": { "readOnly": true, "itemType": "SELECT", "data": [{ "id": "workflow", "content": "流程", "browserModule": "workflow/pathdef", "type": "workflowPathBrowser", "defaultSelected": true, "browserModule4approve": "workflow", "type4approve": "wfcRequest" }], "required": false, "defaultValue": "workflow" }, "workflowPath": { "itemType": "BROWSER", "readOnly": true, "browserBean": { "type": "workflowPathBrowser", "module": "workflow/pathdef", "browserAssociativeProps": { "displayInput": true } }, "requestHeaderParams": { "ebBusinessId": "10000000000000000" }, "required": true, "commonParams": { "checkDetachable": true, "permissionCode": 3, "status": 1 } }, "triggerType": { "itemType": "RADIO", "fieldName": "触发类型", "readOnly": true, "canReversedChoose": false, "data": [{ "id": "singleApprove", "content": "单流程" }, { "id": "multiApprove", "content": "多流程" }] }, "singleApproveConfig": { "itemType": "CUSTOM" }, "approveList": { "itemType": "CUSTOM" }, "approveListFormOpen": { "itemType": "SWITCH", "fieldName": "启用公共表单设置", "canReversedChoose": false }, "approveListFormModule": { "itemType": "RADIO", "fieldName": "表单类型", "canReversedChoose": false, "data": [{ "id": "workflow", "content": "流程表单" }, { "id": "ebuilder", "content": "EB表单" }] }, "approveListFormWF": { "itemType": "BROWSER", "required": true, "browserBean": { "type": "formBrowser", "module": "workflow/core", "browserAssociativeProps": { "displayInput": true, "placeholder": "选择流程表单" }, "commonParams": { "browserMultiple": false, "formState": "enable", "authFilter": true, "formType": "company", "isDelete": "0", "detachable": true, "type": "and" } } }, "approveListFormEB": { "itemType": "BROWSER", "required": true, "browserBean": { "type": "ebuilderForm", "module": "ebuilder/form", "browserAssociativeProps": { "displayInput": true, "placeholder": "选择EB表单" }, "commonParams": { "isTree": true, "from": "flow" } } } }, "layout": [[{ "id": "workflowPath", "label": "选择工作流", "items": ["module", "workflowPath"], "wrapClassName": "weapp-esb-setting-efdesigner-card-approve-trigger-workflowpath", "labelSpan": 6, "hide": false }], [{ "id": "approveListFormOpen", "label": "启用公共表单设置", "items": ["approveListFormOpen"], "labelSpan": 6, "hide": true, "helpTipProps": { "placement": "top" } }], [{ "id": "approveListFormModule", "label": "表单类型", "items": ["approveListFormModule"], "labelSpan": 6, "hide": true, "helpTipProps": { "placement": "top" } }], [{ "id": "approveListFormWF", "label": "选择流程表单", "items": ["approveListFormWF"], "labelSpan": 6, "hide": true, "helpTip": "选择流程表单后,将只能选择该表单的工作流,触发设置中非当前表单的工作流将被清空", "helpTipProps": { "placement": "top" } }], [{ "id": "approveListFormEB", "label": "选择EB表单", "items": ["approveListFormEB"], "labelSpan": 6, "hide": true, "helpTip": "选择EB表单后,将只能选择该表单的工作流,触发设置中非当前表单的工作流将被清空", "helpTipProps": { "placement": "top" } }], [{ "id": "approveList", "label": "", "items": ["approveList"], "labelSpan": 0, "hide": true }], [{ "id": "singleApproveConfig", "label": "触发时机", "items": ["singleApproveConfig"], "labelSpan": 6, "hide": false }]] };
|
|
20
|
-
/** Build itemAndLayout template for ActionEbAdd scoped to a target app */
|
|
21
|
-
function buildActionLayout(appId) {
|
|
22
|
-
return { "items": { "ebActionId": { "itemType": "DESCRIPTION", "value": "-1", "className": "weapp-esb-setting-description" }, "targetForm": { "itemType": "CUSTOM", "required": true }, "appType": { "itemType": "CUSTOM", "browserBean": { "type": "app", "module": "ebuilder/app", "dataParams": { "publishStatus": "ALL" }, "completeParams": { "publishStatus": "ALL" }, "requestHeaderParams": { "ebBusinessId": "10000000000000000" }, "browserDialogProps": { "title": "选择应用", "className": "weapp-esb-setting-browser-wrapper" }, "browserAssociativeProps": { "displayInput": true } }, "placeholder": "选择应用" }, "tableType": { "itemType": "BROWSER", "browserBean": { "type": "ebuilderForm", "module": "ebuilder/form", "dataParams": { "appId": appId }, "completeParams": { "appId": appId }, "requestHeaderParams": { "ebBusinessId": appId }, "browserDialogProps": { "title": "选择表单", "className": "weapp-esb-setting-browser-wrapper" }, "browserAssociativeProps": { "displayInput": true } }, "placeholder": "选择表单" }, "person": { "itemType": "CUSTOM", "required": true }, "opType": { "itemType": "SELECT", "data": [{ "id": "insert", "content": "新增单条数据" }, { "id": "batchInsert", "content": "批量新增(一对多)" }], "defaultValue": "insert", "value": "insert", "required": true }, "basisValueFormula": { "itemType": "CUSTOM" }, "classification": { "itemType": "CUSTOM", "required": true }, "classificationExpire": { "itemType": "CUSTOM" }, "setting": { "itemType": "CUSTOM", "required": true }, "syncType": { "itemType": "CUSTOM", "data": [{ "id": "0", "content": "异步执行" }, { "id": "1", "content": "并行执行" }], "defaultValue": "0", "required": true }, "workflowFields": { "itemType": "CUSTOM" } }, "layout": [[{ "id": "targetForm", "label": "数据目标表单", "wrapClassName": "weapp-esb-setting-efdesigner-com-new-field-item-required", "items": ["targetForm"], "labelSpan": 6, "hide": false }], [{ "id": "appType", "label": "新增数据表单所属应用", "wrapClassName": "weapp-esb-setting-efdesigner-com-new-field-item-required", "items": ["appType"], "labelSpan": 6, "hide": true }], [{ "id": "tableType", "label": "需新增数据的表单", "items": ["tableType"], "labelSpan": 6, "hide": true }], [{ "id": "person", "label": "数据创建者", "items": ["person"], "labelSpan": 6, "hide": false }], [{ "id": "opType", "label": "新增方式", "wrapClassName": "weapp-esb-setting-efdesigner-com-new-field-item-required", "colClassName": "weapp-esb-setting-efdesigner-com-actionEbAdd-opType", "items": ["opType"], "labelSpan": 6, "hide": false }], [{ "id": "basisValueFormula", "label": "依据明细/列表", "items": ["basisValueFormula"], "labelSpan": 6, "hide": false }], [{ "id": "classification", "label": "密级", "items": ["classification"], "labelSpan": 6, "hide": true }], [{ "id": "classificationExpire", "label": "保密期限", "items": ["classificationExpire"], "labelSpan": 6, "hide": true, "colClassName": "weapp-esb-setting-efdesigner-com-actionEbAdd-classificationExpire" }], [{ "id": "setting", "label": "数据目标表字段内容", "items": ["setting"], "labelSpan": 6, "hide": false }], [{ "id": "syncType", "label": "权限重构同步处理", "items": ["syncType"], "labelSpan": 6, "hide": false }], [{ "id": "workflowFields", "label": "回写数据ID对应字段", "items": ["workflowFields"], "labelSpan": 6, "hide": true }]] };
|
|
23
|
-
}
|
|
24
|
-
/** Minimal itemAndLayout template for ActionEbUpdate */
|
|
25
|
-
const UPDATE_LAYOUT = { "items": { "targetForm": { "itemType": "CUSTOM", "required": true }, "ebActionId": { "itemType": "DESCRIPTION", "value": "-1", "className": "weapp-esb-setting-description" }, "appType": { "itemType": "CUSTOM", "browserBean": { "type": "app", "module": "ebuilder/app", "dataParams": { "publishStatus": "ALL" }, "completeParams": { "publishStatus": "ALL" }, "requestHeaderParams": { "ebBusinessId": "10000000000000000" }, "browserDialogProps": { "title": "选择应用", "className": "weapp-esb-setting-browser-wrapper" }, "browserAssociativeProps": { "displayInput": true } }, "placeholder": "选择应用" }, "tableType": { "itemType": "BROWSER", "browserBean": { "type": "ebuilderForm", "module": "ebuilder/form", "dataParams": {}, "completeParams": {}, "requestHeaderParams": {}, "browserDialogProps": { "title": "选择表单", "className": "weapp-esb-setting-browser-wrapper" }, "browserAssociativeProps": { "displayInput": true } }, "placeholder": "选择表单" }, "person": { "itemType": "CUSTOM", "required": true }, "setting": { "itemType": "CUSTOM", "required": true }, "opType": { "itemType": "CUSTOM", "data": [{ "id": "id", "content": "按数据ID更新" }, { "id": "updateData", "content": "按条件更新" }, { "id": "fieldUpdate", "content": "按字段匹配更新" }], "defaultValue": "id", "value": "id", "required": true, "maxLength": 30, "readOnly": false }, "basisValueFormula": { "itemType": "CUSTOM" }, "classification": { "itemType": "CUSTOM", "required": true }, "classificationExpire": { "itemType": "CUSTOM" }, "filterInput": { "itemType": "CUSTOM", "required": true }, "dataSource": { "itemType": "CUSTOM", "required": false }, "needAdd": { "itemType": "SWITCH", "value": false }, "nodataFlag": { "itemType": "CUSTOM", "value": false }, "nullOpflag": { "itemType": "CUSTOM", "value": false }, "syncType": { "itemType": "CUSTOM", "required": true }, "updateId": { "itemType": "CUSTOM", "required": false }, "updateFieldCondition": { "itemType": "CUSTOM", "required": true }, "updatePolicy": { "itemType": "CUSTOM", "data": [{ "id": "ALL", "content": "更新全部数据" }, { "id": "FIRST", "content": "更新第一行数据" }, { "id": "LAST", "content": "更新最后一行数据" }, { "id": "ZERO", "content": "仅更新单独对应数据" }, { "id": "EXCEPTION", "content": "仅全部数据单独对应时更新" }], "defaultValue": "ALL", "value": "ALL", "multiple": false, "required": true, "maxLength": 30, "readOnly": false }, "workflowFields": { "itemType": "CUSTOM" } }, "layout": [[{ "id": "targetForm", "label": "更新目标表单", "wrapClassName": "weapp-esb-setting-efdesigner-com-new-field-item-required", "items": ["targetForm"], "labelSpan": 6, "hide": false }], [{ "id": "appType", "label": "更新表单所属应用", "wrapClassName": "weapp-esb-setting-efdesigner-com-new-field-item-required", "items": ["appType"], "labelSpan": 6, "hide": true }], [{ "id": "tableType", "label": "需更新数据的表单", "items": ["tableType"], "labelSpan": 6, "hide": true }], [{ "id": "opType", "label": "更新方式", "items": ["opType"], "wrapClassName": "weapp-esb-setting-efdesigner-com-new-field-item-required", "labelSpan": 6, "hide": false }], [{ "id": "basisValueFormula", "label": "依据值", "items": ["basisValueFormula"], "labelSpan": 6, "hide": false }], [{ "id": "updateFieldCondition", "label": "条件字段设置", "items": ["updateFieldCondition"], "labelSpan": 6, "hide": false }], [{ "id": "updatePolicy", "label": "更新策略", "items": ["updatePolicy"], "labelSpan": 6, "hide": true }], [{ "id": "updateId", "label": "数据ID", "items": ["updateId"], "labelSpan": 6, "hide": false }], [{ "id": "filterInput", "label": "更新条件", "items": ["filterInput"], "labelSpan": 6, "hide": true }], [{ "id": "setting", "label": "数据目标表字段内容", "items": ["setting"], "labelSpan": 6, "hide": false }], [{ "id": "person", "label": "数据更新人", "items": ["person"], "labelSpan": 6, "hide": false }], [{ "id": "needAdd", "label": "条件不满足时按设置新增数据", "items": ["needAdd"], "labelSpan": 6, "hide": false }], [{ "id": "classification", "label": "密级", "items": ["classification"], "labelSpan": 6, "hide": true }], [{ "id": "classificationExpire", "label": "保密期限", "items": ["classificationExpire"], "labelSpan": 6, "hide": true }], [{ "id": "syncType", "label": "权限重构同步处理", "items": ["syncType"], "labelSpan": 6, "hide": false }], [{ "id": "nodataFlag", "label": "无数据时执行", "items": ["nodataFlag"], "labelSpan": 6, "hide": false }], [{ "id": "nullOpflag", "label": "传空值时执行", "items": ["nullOpflag"], "labelSpan": 6, "hide": false }], [{ "id": "workflowFields", "label": "回写数据ID对应字段", "items": ["workflowFields"], "labelSpan": 6, "hide": false }]] };
|
|
26
|
-
/** Minimal itemAndLayout template for ActionEbDelete */
|
|
27
|
-
const DELETE_LAYOUT = { "items": { "ebActionId": { "itemType": "DESCRIPTION", "value": "-1", "className": "weapp-esb-setting-description" }, "targetForm": { "itemType": "CUSTOM", "required": true }, "appType": { "itemType": "BROWSER", "browserBean": { "type": "app", "module": "ebuilder/app", "dataParams": { "publishStatus": "ALL" }, "completeParams": { "publishStatus": "ALL" }, "requestHeaderParams": { "ebBusinessId": "10000000000000000" }, "browserDialogProps": { "title": "选择应用", "className": "weapp-esb-setting-browser-wrapper" }, "browserAssociativeProps": { "displayInput": true } }, "placeholder": "选择应用" }, "tableType": { "itemType": "BROWSER", "browserBean": { "type": "ebuilderForm", "module": "ebuilder/form", "dataParams": { "includeVform": "1" }, "completeParams": { "includeVform": "1" }, "requestHeaderParams": {}, "browserDialogProps": { "title": "选择表单", "className": "weapp-esb-setting-browser-wrapper" }, "browserAssociativeProps": { "displayInput": true } }, "placeholder": "选择表单" }, "person": { "itemType": "CUSTOM", "required": true }, "filterInput": { "itemType": "CUSTOM", "required": true }, "dataSource": { "itemType": "CUSTOM", "required": false }, "nullOpflag": { "itemType": "CUSTOM", "value": false } }, "layout": [[{ "id": "targetForm", "label": "删除数据所在表单", "wrapClassName": "weapp-esb-setting-efdesigner-com-new-field-item-required", "items": ["targetForm"], "labelSpan": 6, "hide": false }], [{ "id": "appType", "label": "选择应用", "items": ["appType"], "labelSpan": 6, "hide": true }], [{ "id": "tableType", "label": "选择表单", "items": ["tableType"], "labelSpan": 6, "hide": true }], [{ "id": "person", "label": "删除者", "items": ["person"], "labelSpan": 6, "hide": false }], [{ "id": "filterInput", "label": "删除条件", "items": ["filterInput"], "labelSpan": 6, "hide": false }], [{ "id": "nullOpflag", "label": "传空值时执行", "items": ["nullOpflag"], "labelSpan": 6, "hide": false }]] };
|
|
28
|
-
/** Minimal itemAndLayout template for Output */
|
|
29
|
-
const OUTPUT_LAYOUT = { "items": { "outputStatus": { "placeholder": "状态", "itemType": "RADIO", "defaultValue": "1", "value": "1", "data": [{ "id": "1", "content": "成功" }, { "id": "0", "content": "失败" }], "required": true, "maxLength": 30, "readOnly": false, "canReversedChoose": false }, "reminder": { "itemType": "SELECT", "data": [{ "id": "0", "content": "无" }, { "id": "1", "content": "提醒" }, { "id": "2", "content": "确认" }, { "id": "3", "content": "警告" }], "required": true, "className": "weapp-esb-setting-efdesigner-output-reminder" }, "pageAction": { "itemType": "CUSTOM" }, "jumpUrl": { "itemType": "CUSTOM", "required": true }, "nextAction": { "itemType": "SWITCH" }, "triggerFlag": { "itemType": "CUSTOM" }, "formSetting": { "itemType": "CUSTOM" }, "fixedData": { "itemType": "CUSTOM" }, "customOutputData": { "itemType": "CUSTOM" }, "reminderMsgFormula": { "itemType": "CUSTOM", "required": true }, "reminderContent": { "itemType": "CUSTOM", "required": true, "className": "weapp-esb-setting-page-act-reminderContent" }, "customParamSetting": { "itemType": "CUSTOM" }, "conditionEnable": { "itemType": "SWITCH" }, "conditionInfo": { "itemType": "CUSTOM", "required": true }, "fieldLinkCustomParamSetting": { "itemType": "CUSTOM" } }, "layout": [[{ "id": "formSetting", "label": "内容赋值", "items": ["formSetting"], "labelSpan": 6, "hide": true }], [{ "id": "fixedData", "label": "参数设置", "items": ["fixedData"], "labelSpan": 6, "hide": true }], [{ "id": "customOutputData", "label": "自定义输出内容", "items": ["customOutputData"], "labelSpan": 6, "hide": true }], [{ "id": "customParamSetting", "label": "输出参数设置", "items": ["customParamSetting"], "labelSpan": 6, "hide": true }], [{ "id": "conditionEnable", "label": "启用赋值前提", "items": ["conditionEnable"], "labelSpan": 6, "hide": true }], [{ "id": "conditionInfo", "label": "前提条件设置", "items": ["conditionInfo"], "labelSpan": 6, "hide": true }], [{ "id": "fieldLinkCustomParamSetting", "label": "联动字段设置", "items": ["fieldLinkCustomParamSetting"], "labelSpan": 6, "hide": true }], [{ "id": "outputStatus", "label": "执行结果", "items": ["outputStatus"], "labelSpan": 6, "hide": false }], [{ "id": "triggerFlag", "label": "需要触发页面交互", "items": ["triggerFlag"], "labelSpan": 6, "hide": false }], [{ "id": "pageAction", "label": "触发页面动作", "items": ["pageAction"], "labelSpan": 6, "hide": false }], [{ "id": "jumpUrl", "label": "跳转地址", "items": ["jumpUrl"], "labelSpan": 6, "hide": false }], [{ "id": "reminder", "label": "触发操作反馈类型", "items": ["reminder"], "labelSpan": 6, "hide": false }], [{ "id": "reminderMsgFormula", "label": "提醒内容", "items": ["reminderMsgFormula"], "labelSpan": 6, "hide": false }], [{ "id": "reminderContent", "label": "提醒内容", "items": ["reminderContent"], "labelSpan": 6, "hide": false }], [{ "id": "nextAction", "label": "阻止触发模块后续操作", "items": ["nextAction"], "labelSpan": 6, "hide": false }]] };
|
|
30
|
-
/** Build a synthetic designerResult block matching the platform UI shape */
|
|
31
|
-
function makeDesignerResult() {
|
|
32
|
-
return {
|
|
33
|
-
designResultEnum: "GET_SUCCESS",
|
|
34
|
-
msg: "获取成功",
|
|
35
|
-
label: 268960,
|
|
36
|
-
success: true,
|
|
37
|
-
placeholders: [],
|
|
38
|
-
fromComponent: false,
|
|
39
|
-
contactDefault: false,
|
|
40
|
-
path: "",
|
|
41
|
-
outErrorCode: { errorLineNum: 0, show: false },
|
|
42
|
-
costTime: 0,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Build a formula tree node for a "fixed value" (like {userid}).
|
|
47
|
-
* type=8 is a formula container, type=9 is a literal leaf.
|
|
48
|
-
*/
|
|
49
|
-
function makeFixedValueFormula(appId, value) {
|
|
50
|
-
const childId = tempId();
|
|
51
|
-
const topId = tempId();
|
|
52
|
-
const topBizId = tempId();
|
|
53
|
-
const childBizId = tempId();
|
|
54
|
-
const positionId = tempId();
|
|
55
|
-
return {
|
|
56
|
-
formulaType: "string",
|
|
57
|
-
name: "",
|
|
58
|
-
businessId: topBizId,
|
|
59
|
-
id: topId,
|
|
60
|
-
type: "8",
|
|
61
|
-
applicationId: appId,
|
|
62
|
-
value: `textarea#${positionId}#`,
|
|
63
|
-
childs: [{
|
|
64
|
-
formulaType: "string",
|
|
65
|
-
name: value,
|
|
66
|
-
businessId: childBizId,
|
|
67
|
-
id: childId,
|
|
68
|
-
position: positionId,
|
|
69
|
-
type: "9",
|
|
70
|
-
value,
|
|
71
|
-
childs: [],
|
|
72
|
-
config: { paramType: "string", formulaVersion: "V1" },
|
|
73
|
-
parentId: topId,
|
|
74
|
-
}],
|
|
75
|
-
config: { paramType: "string", switchType: "assign", formulaVersion: "V1" },
|
|
76
|
-
parentId: "0",
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Type info for a field-mapping assign node, derived from the target field's componentKey.
|
|
81
|
-
* The browser's ActionEbUpdate plain assign uses type "3" (direct source field reference)
|
|
82
|
-
* with paramType/formulaType/componentKey matching the field type — NOT esbAssignSelf(type 10)
|
|
83
|
-
* with hardcoded string/Text (which breaks Date and other non-Text fields).
|
|
84
|
-
*/
|
|
85
|
-
function typeInfoFor(ck) {
|
|
86
|
-
if (['DateComponent', 'DatePicker', 'DateTimePicker', 'Date'].includes(ck)) {
|
|
87
|
-
return { paramType: 'datetime', formulaType: 'datetime', fieldTypeAssign: 'datetime', paramTypeString: 'DATETIME', fieldTypeValue: 'DateComponent', componentKey: 'DateComponent' };
|
|
88
|
-
}
|
|
89
|
-
if (['Money'].includes(ck)) {
|
|
90
|
-
return { paramType: 'double', formulaType: 'double', fieldTypeAssign: 'number', paramTypeString: 'DOUBLE', fieldTypeValue: 'Money', componentKey: 'Money' };
|
|
91
|
-
}
|
|
92
|
-
if (['NumberComponent', 'Number', 'Float', 'Integer'].includes(ck)) {
|
|
93
|
-
return { paramType: 'double', formulaType: 'double', fieldTypeAssign: 'number', paramTypeString: 'DOUBLE', fieldTypeValue: 'Number', componentKey: 'NumberComponent' };
|
|
94
|
-
}
|
|
95
|
-
return { paramType: 'string', formulaType: 'string', fieldTypeAssign: 'string', paramTypeString: 'STRING', fieldTypeValue: 'Text', componentKey: 'Text' };
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Build a formula tree for a field mapping from source form to target field.
|
|
99
|
-
* The source reference is FormData.{workflowId}.{fieldId}
|
|
100
|
-
*/
|
|
101
|
-
function makeFieldMappingFormula(appId, wfId, sourceFieldId, sourceFieldName, sourceFieldKey, eventId) {
|
|
102
|
-
const childId = tempId();
|
|
103
|
-
return {
|
|
104
|
-
assign: {
|
|
105
|
-
type: "8",
|
|
106
|
-
name: "",
|
|
107
|
-
childs: [{
|
|
108
|
-
id: childId,
|
|
109
|
-
tableId: wfId,
|
|
110
|
-
paramKey: `${wfId}.${sourceFieldId}`,
|
|
111
|
-
paramName: sourceFieldId,
|
|
112
|
-
showName: sourceFieldName,
|
|
113
|
-
paramType: "string",
|
|
114
|
-
dataType: "attribute",
|
|
115
|
-
arrs: false,
|
|
116
|
-
required: false,
|
|
117
|
-
description: `${sourceFieldKey}(${sourceFieldId})`,
|
|
118
|
-
paramTypeString: "STRING",
|
|
119
|
-
dataTypeSting: "ATTRIBUTE",
|
|
120
|
-
paramId: sourceFieldId,
|
|
121
|
-
formulaId: "0",
|
|
122
|
-
mappingId: "0",
|
|
123
|
-
hideParamNameInSelect: true,
|
|
124
|
-
hideParam: false,
|
|
125
|
-
componentKey: "Text",
|
|
126
|
-
readonlyParam: false,
|
|
127
|
-
sensitiveFlag: false,
|
|
128
|
-
newdata: false,
|
|
129
|
-
parentName: `表单数据.${sourceFieldName}`,
|
|
130
|
-
name: sourceFieldName,
|
|
131
|
-
source: eventId,
|
|
132
|
-
value: `FormData.${wfId}.${sourceFieldId}`,
|
|
133
|
-
type: "3",
|
|
134
|
-
formulaType: "string",
|
|
135
|
-
frontId: sourceFieldId,
|
|
136
|
-
config: {
|
|
137
|
-
paramKey: `${wfId}.${sourceFieldId}`,
|
|
138
|
-
paramType: "string",
|
|
139
|
-
parentName: `表单数据.${sourceFieldName}`,
|
|
140
|
-
newParentName: `表单数据.${sourceFieldName}`,
|
|
141
|
-
multKey: "",
|
|
142
|
-
multName: "",
|
|
143
|
-
multTypeObj: {
|
|
144
|
-
currentName: `表单数据.${sourceFieldName}`,
|
|
145
|
-
allName: `表单数据.${sourceFieldName}`,
|
|
146
|
-
currentParamKey: `FormData.${wfId}.${sourceFieldId}`,
|
|
147
|
-
allParamKey: `FormData.${wfId}.${sourceFieldId}`,
|
|
148
|
-
},
|
|
149
|
-
comId: eventId,
|
|
150
|
-
isMultCom: false,
|
|
151
|
-
tableName: "表单数据",
|
|
152
|
-
fieldInfo: { tablePrimaryKey: "FormData", paramKey: `${wfId}.${sourceFieldId}` },
|
|
153
|
-
comType: "ApproveTrigger",
|
|
154
|
-
parentComId: 0,
|
|
155
|
-
},
|
|
156
|
-
applicationId: appId,
|
|
157
|
-
businessId: tempId(),
|
|
158
|
-
fieldType: "string",
|
|
159
|
-
position: childId,
|
|
160
|
-
}],
|
|
161
|
-
value: `textarea#${childId}#`,
|
|
162
|
-
formulaType: "string",
|
|
163
|
-
applicationId: appId,
|
|
164
|
-
config: { paramType: "string", switchType: "assign" },
|
|
165
|
-
},
|
|
166
|
-
multiSelect: false,
|
|
167
|
-
fieldType: "Text",
|
|
168
|
-
switchType: "assign",
|
|
169
|
-
assignType: "",
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
actionCmd.command('create')
|
|
173
|
-
.description('创建动作流(本表→目标表操作)并绑定到流程节点')
|
|
174
|
-
.argument('<workflowId>', '流程 ID')
|
|
175
|
-
.argument('<nodeId>', '触发节点 ID(发起/审批/归档节点的 dbId)')
|
|
176
|
-
.argument('<name>', '动作流名称')
|
|
177
|
-
.option('--target-table <id>', '目标表单 tableId(新建时需要)')
|
|
178
|
-
.option('--target-app <id>', '目标表单所属应用 ID(新建时需要)')
|
|
179
|
-
.option('--mapping <json>', '字段映射 JSON 文件,@ 开头表示文件路径。add/update 时需要')
|
|
180
|
-
.option('--constants <json>', '常量值 JSON,格式:{"目标字段ID":"固定值"},@ 开头表示文件路径')
|
|
181
|
-
.option('--formula <json>', '公式计算 JSON,格式:{"目标字段ID":{"op":"add","fields":["源ID1","源ID2"]}},op 可选 add/sub/mul/div')
|
|
182
|
-
.option('--sysvar <json>', '系统变量映射 JSON,格式:{"目标字段ID":"requestId"}。当前仅支持 requestId(流程实例ID),写入 Flow 关联流程字段(点字段跳回本流程)')
|
|
183
|
-
.option('--action-type <type>', '动作类型: add(新增,默认) / update(更新) / delete(删除)', 'add')
|
|
184
|
-
.option('--match-field <fieldId>', '匹配字段(源表字段ID)。update: 按此字段值定位记录;delete: 删除条件')
|
|
185
|
-
.option('--match-target <fieldId>', '目标表匹配字段ID(update 时:按 源match-field值 匹配 此目标字段 更新,走 updateData+filterInput,替代按数据ID更新)')
|
|
186
|
-
.option('--creator <formula>', '数据创建/更新/删除者,默认 {userid}', '{userid}')
|
|
187
|
-
.option('--event <event>', '触发时机: arrive(到达节点,默认) / leave(正向离开,提交后) / back-arrive(退回到达,退回时) / delete(删除) / save(保存) / revert(还原) / pause(暂停启用) / cancel(撤销恢复)', 'arrive')
|
|
188
|
-
.option('--node-name <name>', '节点名称(用于 saveAddActionList)', '')
|
|
189
|
-
.option('--app-id <id>', '复用已有动作流 appId,只做绑定不重建')
|
|
190
|
-
.option('--condition <rules...>', '触发条件规则,可多个,格式: "来源:字段:操作:值[:值2]"\n 来源=form 用字段ID, source=system 用系统字段中文名\n 例: --condition "form:123456:等于:续期"\n 多条规则按 --condition-relation 组合')
|
|
191
|
-
.option('--condition-relation <rel>', '条件内多条规则关系: AND(默认) / OR', 'AND')
|
|
192
|
-
.option('--condition-name <name>', '条件名称(默认 "工作流名-节点名-条件")', '')
|
|
193
|
-
.action(async (workflowId, nodeId, name, cmdOpts) => {
|
|
194
|
-
const opts = program.opts();
|
|
195
|
-
const auth = await AuthSession.fromOptions(opts);
|
|
196
|
-
if (!auth)
|
|
197
|
-
process.exit(1);
|
|
198
|
-
const client = new ApiClient(auth);
|
|
199
|
-
const baseUrl = auth.getBaseUrl();
|
|
200
|
-
const actionType = cmdOpts.actionType || 'add';
|
|
201
|
-
if (!['add', 'update', 'delete'].includes(actionType)) {
|
|
202
|
-
console.error('--action-type 必须是 add / update / delete');
|
|
203
|
-
process.exit(1);
|
|
204
|
-
}
|
|
205
|
-
// Reuse mode: only need workflowId + nodeId + --app-id
|
|
206
|
-
if (!cmdOpts.appId && (!cmdOpts.targetTable || !cmdOpts.targetApp)) {
|
|
207
|
-
console.error('新建动作流需要 --target-table 和 --target-app,或使用 --app-id 复用已有动作流');
|
|
208
|
-
process.exit(1);
|
|
209
|
-
}
|
|
210
|
-
// Read mapping (optional for delete)
|
|
211
|
-
let mapping = {};
|
|
212
|
-
if (cmdOpts.mapping) {
|
|
213
|
-
let mappingStr = cmdOpts.mapping;
|
|
214
|
-
if (mappingStr.startsWith('@')) {
|
|
215
|
-
const { readFileSync, existsSync } = await import('fs');
|
|
216
|
-
const filePath = mappingStr.slice(1);
|
|
217
|
-
if (!existsSync(filePath)) {
|
|
218
|
-
console.error(`文件不存在: ${filePath}`);
|
|
219
|
-
process.exit(1);
|
|
220
|
-
}
|
|
221
|
-
mappingStr = readFileSync(filePath, 'utf-8');
|
|
222
|
-
}
|
|
223
|
-
try {
|
|
224
|
-
mapping = JSON.parse(mappingStr);
|
|
225
|
-
}
|
|
226
|
-
catch {
|
|
227
|
-
console.error('mapping JSON 解析失败');
|
|
228
|
-
process.exit(1);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
// Read constants (optional)
|
|
232
|
-
let constants = {};
|
|
233
|
-
if (cmdOpts.constants) {
|
|
234
|
-
let constStr = cmdOpts.constants;
|
|
235
|
-
if (constStr.startsWith('@')) {
|
|
236
|
-
const { readFileSync, existsSync } = await import('fs');
|
|
237
|
-
const filePath = constStr.slice(1);
|
|
238
|
-
if (!existsSync(filePath)) {
|
|
239
|
-
console.error(`文件不存在: ${filePath}`);
|
|
240
|
-
process.exit(1);
|
|
241
|
-
}
|
|
242
|
-
constStr = readFileSync(filePath, 'utf-8');
|
|
243
|
-
}
|
|
244
|
-
try {
|
|
245
|
-
constants = JSON.parse(constStr);
|
|
246
|
-
}
|
|
247
|
-
catch {
|
|
248
|
-
console.error('constants JSON 解析失败');
|
|
249
|
-
process.exit(1);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
// Read formula (optional)
|
|
253
|
-
let formula = {};
|
|
254
|
-
if (cmdOpts.formula) {
|
|
255
|
-
let formulaStr = cmdOpts.formula;
|
|
256
|
-
if (formulaStr.startsWith('@')) {
|
|
257
|
-
const { readFileSync, existsSync } = await import('fs');
|
|
258
|
-
const filePath = formulaStr.slice(1);
|
|
259
|
-
if (!existsSync(filePath)) {
|
|
260
|
-
console.error(`文件不存在: ${filePath}`);
|
|
261
|
-
process.exit(1);
|
|
262
|
-
}
|
|
263
|
-
formulaStr = readFileSync(filePath, 'utf-8');
|
|
264
|
-
}
|
|
265
|
-
try {
|
|
266
|
-
formula = JSON.parse(formulaStr);
|
|
267
|
-
}
|
|
268
|
-
catch {
|
|
269
|
-
console.error('formula JSON 解析失败');
|
|
270
|
-
process.exit(1);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// Read sysvar mapping (optional): {"目标Flow字段ID":"requestId"}
|
|
274
|
-
let sysvarMapping = {};
|
|
275
|
-
if (cmdOpts.sysvar) {
|
|
276
|
-
let sysvarStr = cmdOpts.sysvar;
|
|
277
|
-
if (sysvarStr.startsWith('@')) {
|
|
278
|
-
const { readFileSync, existsSync } = await import('fs');
|
|
279
|
-
const filePath = sysvarStr.slice(1);
|
|
280
|
-
if (!existsSync(filePath)) {
|
|
281
|
-
console.error(`文件不存在: ${filePath}`);
|
|
282
|
-
process.exit(1);
|
|
283
|
-
}
|
|
284
|
-
sysvarStr = readFileSync(filePath, 'utf-8');
|
|
285
|
-
}
|
|
286
|
-
try {
|
|
287
|
-
sysvarMapping = JSON.parse(sysvarStr);
|
|
288
|
-
}
|
|
289
|
-
catch {
|
|
290
|
-
console.error('sysvar JSON 解析失败');
|
|
291
|
-
process.exit(1);
|
|
292
|
-
}
|
|
293
|
-
for (const [tgt, sv] of Object.entries(sysvarMapping)) {
|
|
294
|
-
if (sv !== 'requestId') {
|
|
295
|
-
console.error(`仅支持系统变量 requestId,收到: ${sv}(目标字段 ${tgt})`);
|
|
296
|
-
process.exit(1);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
// Validate formula ops
|
|
301
|
-
const FORMULA_FNS = {
|
|
302
|
-
add: { fnId: '682682659616530901', name: '+', clazz: 'com.weaver.common.formula.core.function.aggregate.Addition' },
|
|
303
|
-
sub: { fnId: '682682659616530902', name: '−', clazz: 'com.weaver.common.formula.core.function.aggregate.Subtraction' },
|
|
304
|
-
mul: { fnId: '682682659616530903', name: '×', clazz: 'com.weaver.common.formula.core.function.aggregate.Multiplication' },
|
|
305
|
-
div: { fnId: '682682659616530904', name: '÷', clazz: 'com.weaver.common.formula.core.function.aggregate.Division' },
|
|
306
|
-
};
|
|
307
|
-
for (const [tgt, f] of Object.entries(formula)) {
|
|
308
|
-
if (!FORMULA_FNS[f.op]) {
|
|
309
|
-
console.error(`不支持的公式操作: ${f.op},可选: ${Object.keys(FORMULA_FNS).join(', ')}`);
|
|
310
|
-
process.exit(1);
|
|
311
|
-
}
|
|
312
|
-
// aggregate 函数(add/sub/mul/div)支持单参(如"项目工时 += 工时金额"只需 1 源),不必强制 2
|
|
313
|
-
if (!f.fields || f.fields.length < 1) {
|
|
314
|
-
console.error(`公式至少需要 1 个字段: ${tgt}`);
|
|
315
|
-
process.exit(1);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
// Validate: add/update need mapping or constants, delete needs match-field (skip for reuse mode)
|
|
319
|
-
if (!cmdOpts.appId) {
|
|
320
|
-
const hasMapping = Object.keys(mapping).length > 0;
|
|
321
|
-
const hasConstants = Object.keys(constants).length > 0;
|
|
322
|
-
const hasFormula = Object.keys(formula).length > 0;
|
|
323
|
-
if (actionType === 'add' && !hasMapping && !hasConstants && !hasFormula) {
|
|
324
|
-
console.error('add 需要 --mapping @file.json 或 --constants @file.json 或 --formula @file.json');
|
|
325
|
-
process.exit(1);
|
|
326
|
-
}
|
|
327
|
-
if (actionType === 'delete' && !cmdOpts.matchField) {
|
|
328
|
-
console.error('delete 需要 --match-field <源表字段ID> 指定删除匹配条件');
|
|
329
|
-
process.exit(1);
|
|
330
|
-
}
|
|
331
|
-
if (actionType === 'update' && !cmdOpts.matchField) {
|
|
332
|
-
console.error('update 需要 --match-field <字段ID>');
|
|
333
|
-
process.exit(1);
|
|
334
|
-
}
|
|
335
|
-
if ((actionType === 'add' || actionType === 'update') && !hasMapping && !hasConstants && !hasFormula) {
|
|
336
|
-
console.error(`${actionType} 需要 --mapping 或 --constants 或 --formula`);
|
|
337
|
-
process.exit(1);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
// Reuse mode: if --app-id is provided, skip creation and just bind
|
|
341
|
-
if (cmdOpts.appId) {
|
|
342
|
-
const appId = cmdOpts.appId;
|
|
343
|
-
console.error(`Step 1/1: 绑定已有动作流 ${appId} 到节点 ${nodeId}...`);
|
|
344
|
-
const EVENT_MAP_BIND = {
|
|
345
|
-
arrive: { triggerType: 'pre', executeTime: ['1'], useExtendedFormat: false },
|
|
346
|
-
leave: { triggerType: 'after', executeTime: ['1'], useExtendedFormat: false },
|
|
347
|
-
delete: { triggerType: 'delete', executeTime: undefined, useExtendedFormat: false },
|
|
348
|
-
save: { triggerType: 'save', executeTime: undefined, useExtendedFormat: false },
|
|
349
|
-
revert: { triggerType: 'revert', executeTime: undefined, useExtendedFormat: false },
|
|
350
|
-
pause: { triggerType: 'stopAndOpen', executeTime: ['1'], useExtendedFormat: false },
|
|
351
|
-
cancel: { triggerType: 'cancelAndRegain', executeTime: ['1'], useExtendedFormat: false },
|
|
352
|
-
};
|
|
353
|
-
const EVENT_LABELS_BIND = {
|
|
354
|
-
arrive: '到达节点时', leave: '离开节点后', delete: '流程删除时',
|
|
355
|
-
save: '流程保存时', revert: '流程还原时', pause: '暂停/启用时', cancel: '撤销恢复时',
|
|
356
|
-
};
|
|
357
|
-
const evCfg = EVENT_MAP_BIND[cmdOpts.event] || EVENT_MAP_BIND.arrive;
|
|
358
|
-
const eventLabel = EVENT_LABELS_BIND[cmdOpts.event] || cmdOpts.event;
|
|
359
|
-
let existingActions = [];
|
|
360
|
-
const existing = await client.post(`${baseUrl}/api/bs/workflow/pathdef/addaction/getAddActionDataList`, {
|
|
361
|
-
workflowId, objId: nodeId, triggerType: 'all', isNodeFlag: '1',
|
|
362
|
-
});
|
|
363
|
-
if (existing?.code === 200 && existing?.status) {
|
|
364
|
-
existingActions = existing?.data?.data || [];
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
console.error(`❌ 无法读取节点已有动作: ${existing?.data?.msg || existing?.msg || '未知错误'}`);
|
|
368
|
-
console.error(' 请手动在页面中绑定。');
|
|
369
|
-
process.exit(1);
|
|
370
|
-
}
|
|
371
|
-
// Optional trigger condition (source=19)
|
|
372
|
-
let bindConditionKey = '';
|
|
373
|
-
if (cmdOpts.condition && cmdOpts.condition.length > 0) {
|
|
374
|
-
try {
|
|
375
|
-
bindConditionKey = await saveActionCondition(client, baseUrl, workflowId, cmdOpts.nodeName || nodeId, cmdOpts.condition, cmdOpts.conditionRelation || 'AND', cmdOpts.conditionName || '');
|
|
376
|
-
}
|
|
377
|
-
catch (e) {
|
|
378
|
-
console.error(`❌ ${e.message}`);
|
|
379
|
-
console.error(' 条件未保存,请检查 --condition 后重试。');
|
|
380
|
-
process.exit(1);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
const bindDataId = tempIdNeg();
|
|
384
|
-
const actionData = {
|
|
385
|
-
id: bindDataId, actionName: name, open: true, actionId: appId, esbName: name,
|
|
386
|
-
customName: '', actionType: 2,
|
|
387
|
-
actionData: {
|
|
388
|
-
actionSelect: '1', sysCustomAction: [],
|
|
389
|
-
paramsSet: [{ id: appId, name, eventType: 'WorkflowTrigger', interfaceCreate: false, isKeepDiary: 1 }],
|
|
390
|
-
actionSet: [{ id: appId, name, eventType: 'WorkflowTrigger', interfaceCreate: false, isKeepDiary: 1 }],
|
|
391
|
-
actionName: '', id: bindDataId, customDataId: '',
|
|
392
|
-
},
|
|
393
|
-
async: 0, triggerType: evCfg.triggerType, order: existingActions.length,
|
|
394
|
-
};
|
|
395
|
-
if (bindConditionKey) {
|
|
396
|
-
actionData.conditionKey = bindConditionKey;
|
|
397
|
-
actionData.hasRule = true;
|
|
398
|
-
}
|
|
399
|
-
if (evCfg.executeTime)
|
|
400
|
-
actionData.executeTime = evCfg.executeTime;
|
|
401
|
-
const mergedActions = [...existingActions.map(normalizeActionRow), actionData];
|
|
402
|
-
console.error(` 已有 ${existingActions.length} 个动作,归一化合并后 ${mergedActions.length} 个`);
|
|
403
|
-
const bindRes = await client.post(`${baseUrl}/api/bs/workflow/pathdef/addaction/saveAddActionList`, {
|
|
404
|
-
workflowId, objId: nodeId, triggerType: 'all',
|
|
405
|
-
data: mergedActions,
|
|
406
|
-
isNodeFlag: '1', objName: cmdOpts.nodeName || nodeId,
|
|
407
|
-
});
|
|
408
|
-
if (bindRes?.code === 200 && bindRes?.status) {
|
|
409
|
-
console.log(`动作流已绑定: ${name} (${appId}) → 节点 ${nodeId} / ${eventLabel}`);
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
console.error(`绑定失败: ${bindRes?.msg || '未知错误'}`);
|
|
413
|
-
process.exit(1);
|
|
414
|
-
}
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
// Step 1: Create ESB application container with server-assigned IDs.
|
|
418
|
-
// id must be "" so the server allocates appId + sceneId.
|
|
419
|
-
// orgId is required in detached (分权) environments — detect from orgTree.
|
|
420
|
-
let orgId = '';
|
|
421
|
-
try {
|
|
422
|
-
const entrance = await client.get(`${baseUrl}/api/bs/ebuilder/app/permit/entrance`);
|
|
423
|
-
if (entrance?.code === 200 && entrance?.status && entrance?.data?.isDetachable) {
|
|
424
|
-
const orgTree = await client.get(`${baseUrl}/api/hrm/common/getOrgTree?menuCode=eBuilder&onlySubcompany=false&containDisableDept=false&moduleCode=EBUILDER&virtualId=1&loadCount=false&isMobile=false`);
|
|
425
|
-
if (orgTree?.code === 200 && orgTree?.status && Array.isArray(orgTree?.data) && orgTree.data.length > 0) {
|
|
426
|
-
orgId = orgTree.data[0].id;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
catch { /* non-detached accounts leave orgId empty */ }
|
|
431
|
-
console.error(`Step 1/4: 创建动作流容器...${orgId ? ` (orgId: ${orgId})` : ''}`);
|
|
432
|
-
const appRes = await client.post(`${baseUrl}/api/bs/esb/setting/application/save`, {
|
|
433
|
-
type: 0,
|
|
434
|
-
name,
|
|
435
|
-
orgId,
|
|
436
|
-
id: '',
|
|
437
|
-
moudle: 'workflow',
|
|
438
|
-
appSources: [
|
|
439
|
-
{ module: 'ebuilder', businessObject: 'AppType', businessValue: cmdOpts.targetApp },
|
|
440
|
-
{ module: 'approve', businessObject: 'workflowPath', businessValue: workflowId },
|
|
441
|
-
],
|
|
442
|
-
lightId: '',
|
|
443
|
-
initData: '',
|
|
444
|
-
templateId: '',
|
|
445
|
-
templateVersionId: '',
|
|
446
|
-
});
|
|
447
|
-
if (appRes?.code !== 200 || !appRes?.status) {
|
|
448
|
-
console.error(`创建动作流失败: ${appRes?.msg || '未知错误'}`);
|
|
449
|
-
console.error(`完整响应: ${JSON.stringify(appRes)}`);
|
|
450
|
-
process.exit(1);
|
|
451
|
-
}
|
|
452
|
-
// The API may return data at different levels
|
|
453
|
-
const appData = appRes?.data || {};
|
|
454
|
-
const appId = appData?.id || '';
|
|
455
|
-
const sceneId = appData?.activeVersion || '';
|
|
456
|
-
if (!appId || !sceneId) {
|
|
457
|
-
console.error(`创建动作流异常: 未返回 appId/sceneId。完整响应: ${JSON.stringify(appRes)}`);
|
|
458
|
-
process.exit(1);
|
|
459
|
-
}
|
|
460
|
-
console.error(` 动作流 ID: ${appId} sceneId: ${sceneId}`);
|
|
461
|
-
// Step 2: Fetch target table fields to validate and get metadata
|
|
462
|
-
console.error(`Step 2/4: 校验目标表字段...`);
|
|
463
|
-
const fieldRes = await client.post(`${baseUrl}/api/bs/esb/setting/component/getEbField`, {
|
|
464
|
-
tableId: cmdOpts.targetTable,
|
|
465
|
-
appId: cmdOpts.targetApp,
|
|
466
|
-
});
|
|
467
|
-
const targetFields = fieldRes?.data?.main || [];
|
|
468
|
-
const targetDetailTables = fieldRes?.data?.detail || [];
|
|
469
|
-
const targetFieldMap = new Map();
|
|
470
|
-
for (const f of targetFields) {
|
|
471
|
-
targetFieldMap.set(f.id, f);
|
|
472
|
-
}
|
|
473
|
-
// 目标明细字段索引(明细→明细映射用)
|
|
474
|
-
const targetDetailIndex = buildTargetDetailIndex(targetDetailTables);
|
|
475
|
-
// Fetch target-form + app metadata for the designer chips
|
|
476
|
-
let formName = targetFields[0]?.showName || cmdOpts.targetTable;
|
|
477
|
-
let formIsPhysical = true;
|
|
478
|
-
let formObjType = 'physical';
|
|
479
|
-
try {
|
|
480
|
-
const formList = await client.get(`${baseUrl}/api/bs/ebuilder/form/obj/getList/${cmdOpts.targetApp}?apid=${cmdOpts.targetApp}`, { ebbusinessid: cmdOpts.targetApp });
|
|
481
|
-
const formEntry = (formList?.data || []).find((f) => f.id === cmdOpts.targetTable);
|
|
482
|
-
if (formEntry) {
|
|
483
|
-
formName = formEntry.showName || formEntry.objName || formEntry.name || formName;
|
|
484
|
-
if (formEntry.tableType)
|
|
485
|
-
formObjType = formEntry.tableType;
|
|
486
|
-
}
|
|
487
|
-
const formInfo = await client.get(`${baseUrl}/api/ebuilder/form/obj/getInfo/${cmdOpts.targetTable}`);
|
|
488
|
-
if (formInfo?.data && typeof formInfo.data.isPhysical === 'boolean')
|
|
489
|
-
formIsPhysical = formInfo.data.isPhysical;
|
|
490
|
-
}
|
|
491
|
-
catch { /* fall back to defaults */ }
|
|
492
|
-
let appName = cmdOpts.targetApp;
|
|
493
|
-
try {
|
|
494
|
-
const appList = await client.get(`${baseUrl}/api/bs/ebuilder/app/list`);
|
|
495
|
-
const appEntry = (appList?.data || []).find((a) => a.id === cmdOpts.targetApp);
|
|
496
|
-
if (appEntry?.name)
|
|
497
|
-
appName = appEntry.name;
|
|
498
|
-
}
|
|
499
|
-
catch { /* fall back to appId */ }
|
|
500
|
-
// Classify mapping into 主表映射 / 明细映射(明细→明细),并校验目标字段
|
|
501
|
-
const mainSet = new Set(targetFields.map((f) => String(f.id)));
|
|
502
|
-
const classified = classifyMapping(mapping, mainSet, targetDetailIndex);
|
|
503
|
-
const mainMapping = classified.mainMapping;
|
|
504
|
-
if (classified.errors.length > 0) {
|
|
505
|
-
for (const e of classified.errors)
|
|
506
|
-
console.error(` ❌ ${e}`);
|
|
507
|
-
console.error(`可用主表字段: ${targetFields.map((f) => `${f.id}(${f.showName})`).join(', ')}`);
|
|
508
|
-
process.exit(1);
|
|
509
|
-
}
|
|
510
|
-
// Validate constant target fields (constants 仅支持主表)
|
|
511
|
-
for (const tgtFieldId of Object.keys(constants)) {
|
|
512
|
-
if (!targetFieldMap.has(tgtFieldId)) {
|
|
513
|
-
if (targetDetailIndex.has(tgtFieldId)) {
|
|
514
|
-
console.error(`常量目标字段不支持明细表字段: ${tgtFieldId}`);
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
console.error(`常量目标字段不存在: ${tgtFieldId}`);
|
|
518
|
-
console.error(`可用目标字段: ${targetFields.map((f) => `${f.id}(${f.showName})`).join(', ')}`);
|
|
519
|
-
}
|
|
520
|
-
process.exit(1);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
// formula 目标仅支持主表字段
|
|
524
|
-
for (const tgtFieldId of Object.keys(formula)) {
|
|
525
|
-
if (targetDetailIndex.has(tgtFieldId)) {
|
|
526
|
-
console.error(`公式目标字段不支持明细表字段: ${tgtFieldId}`);
|
|
527
|
-
process.exit(1);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
// 明细映射:反查源表单明细结构并分组(仅在有明细映射时执行)
|
|
531
|
-
let detailGroups = new Map();
|
|
532
|
-
let detailSourceFormName = '';
|
|
533
|
-
if (classified.detailMappings.length > 0) {
|
|
534
|
-
if (actionType !== 'add') {
|
|
535
|
-
console.error(`❌ update/delete 含明细映射请走 py 生成器(actionflows 子 skill):`);
|
|
536
|
-
console.error(` CLI 的 update/delete 不支持明细(结构含 basisValue/rowId 行匹配/updateAdd,复刻风险高)。`);
|
|
537
|
-
console.error(` py 的 action_eb_update 契约支持 detail + requestId 定位(filterCondition),生成后用 CLI \`action create --app-id <py返回的appId>\` 绑节点。`);
|
|
538
|
-
console.error(` 详见 skill: references/workflow/guide-workflow-action.md「流程数据写入台账」④段。`);
|
|
539
|
-
process.exit(1);
|
|
540
|
-
}
|
|
541
|
-
const srcForm = await resolveSourceForm(client, baseUrl, workflowId);
|
|
542
|
-
if (!srcForm) {
|
|
543
|
-
console.error(`无法反查流程 ${workflowId} 的源表单,明细映射不可用`);
|
|
544
|
-
process.exit(1);
|
|
545
|
-
}
|
|
546
|
-
detailSourceFormName = srcForm.sourceFormName;
|
|
547
|
-
const srcField = await fetchEbField(client, baseUrl, srcForm.sourceObjId, srcForm.sourceAppId);
|
|
548
|
-
const sourceDetailMap = buildSourceDetailMap(srcField.detail);
|
|
549
|
-
const grouped = groupDetailMappings(classified.detailMappings, sourceDetailMap);
|
|
550
|
-
if (grouped.errors.length > 0) {
|
|
551
|
-
for (const e of grouped.errors)
|
|
552
|
-
console.error(` ❌ ${e}`);
|
|
553
|
-
process.exit(1);
|
|
554
|
-
}
|
|
555
|
-
detailGroups = grouped.groups;
|
|
556
|
-
console.error(` 明细映射: ${classified.detailMappings.length} 个字段 / ${detailGroups.size} 张明细表(源表单 ${detailSourceFormName})`);
|
|
557
|
-
}
|
|
558
|
-
const mapCount = Object.keys(mapping).length;
|
|
559
|
-
const constCount = Object.keys(constants).length;
|
|
560
|
-
const logParts = [];
|
|
561
|
-
if (mapCount > 0)
|
|
562
|
-
logParts.push(`${mapCount} 个字段映射`);
|
|
563
|
-
if (constCount > 0)
|
|
564
|
-
logParts.push(`${constCount} 个常量值`);
|
|
565
|
-
console.error(` 已校验 ${logParts.join(', ')}`);
|
|
566
|
-
// Step 3: Build and save design
|
|
567
|
-
const TYPE_LABEL = { add: '新建表单数据', update: '更新表单数据', delete: '删除表单数据' };
|
|
568
|
-
const TYPE_NAME = { add: 'ActionEbAdd', update: 'ActionEbUpdate', delete: 'ActionEbDelete' };
|
|
569
|
-
const LABELS = { add: [221793, 221245], update: [221794, 221248], delete: [131947, 221246] };
|
|
570
|
-
console.error(`Step 3/4: 保存动作流设计 [${actionType}]...`);
|
|
571
|
-
const eventId = tempId();
|
|
572
|
-
const actionId = tempId();
|
|
573
|
-
const outputId = tempId();
|
|
574
|
-
// Build reloadFormula list from mapping (for add and update)
|
|
575
|
-
const reloadFormula = [];
|
|
576
|
-
const settingMain = {};
|
|
577
|
-
let sourceFormName = ''; // populated later by match-field lookup, used in parentName
|
|
578
|
-
for (const [sourceFieldId, rawTargetFieldId] of Object.entries(mainMapping)) {
|
|
579
|
-
// Parse operate prefix: + for OPERATE_PLUS, - for OPERATE_MINUS, plain for OPERATE_EQUAL
|
|
580
|
-
let operate = 'OPERATE_EQUAL';
|
|
581
|
-
let targetFieldId = rawTargetFieldId;
|
|
582
|
-
if (rawTargetFieldId.startsWith('+')) {
|
|
583
|
-
operate = 'OPERATE_PLUS';
|
|
584
|
-
targetFieldId = rawTargetFieldId.slice(1);
|
|
585
|
-
}
|
|
586
|
-
else if (rawTargetFieldId.startsWith('-')) {
|
|
587
|
-
operate = 'OPERATE_MINUS';
|
|
588
|
-
targetFieldId = rawTargetFieldId.slice(1);
|
|
589
|
-
}
|
|
590
|
-
const tgtField = targetFieldMap.get(targetFieldId);
|
|
591
|
-
const tgtShowName = tgtField?.showName || targetFieldId;
|
|
592
|
-
reloadFormula.push({
|
|
593
|
-
id: tempId(),
|
|
594
|
-
tableId: workflowId,
|
|
595
|
-
paramKey: `${workflowId}.${sourceFieldId}`,
|
|
596
|
-
paramName: sourceFieldId,
|
|
597
|
-
showName: tgtShowName,
|
|
598
|
-
paramType: "string",
|
|
599
|
-
dataType: "attribute",
|
|
600
|
-
arrs: false, required: false,
|
|
601
|
-
description: `${tgtShowName}(${sourceFieldId})`,
|
|
602
|
-
paramTypeString: "STRING", dataTypeSting: "ATTRIBUTE",
|
|
603
|
-
paramId: sourceFieldId, formulaId: "0", mappingId: "0",
|
|
604
|
-
hideParamNameInSelect: true, hideParam: false,
|
|
605
|
-
componentKey: tgtField?.componentKey || "Text",
|
|
606
|
-
readonlyParam: false, sensitiveFlag: false, newdata: false,
|
|
607
|
-
parentName: `表单数据.${tgtShowName}`,
|
|
608
|
-
name: tgtShowName,
|
|
609
|
-
source: eventId,
|
|
610
|
-
value: `FormData.${workflowId}.${sourceFieldId}`,
|
|
611
|
-
type: "3", formulaType: "string", frontId: sourceFieldId,
|
|
612
|
-
config: {
|
|
613
|
-
paramKey: `${workflowId}.${sourceFieldId}`,
|
|
614
|
-
paramType: "string",
|
|
615
|
-
parentName: `表单数据.${tgtShowName}`,
|
|
616
|
-
newParentName: `表单数据.${tgtShowName}`,
|
|
617
|
-
multKey: "", multName: "",
|
|
618
|
-
multTypeObj: {
|
|
619
|
-
currentName: `表单数据.${tgtShowName}`,
|
|
620
|
-
allName: `表单数据.${tgtShowName}`,
|
|
621
|
-
currentParamKey: `FormData.${workflowId}.${sourceFieldId}`,
|
|
622
|
-
allParamKey: `FormData.${workflowId}.${sourceFieldId}`,
|
|
623
|
-
},
|
|
624
|
-
comId: eventId, isMultCom: false,
|
|
625
|
-
tableName: "表单数据",
|
|
626
|
-
fieldInfo: { tablePrimaryKey: "FormData", paramKey: `${workflowId}.${sourceFieldId}` },
|
|
627
|
-
comType: "ApproveTrigger", parentComId: 0,
|
|
628
|
-
},
|
|
629
|
-
applicationId: appId, businessId: tempId(), fieldType: "string",
|
|
630
|
-
});
|
|
631
|
-
// Build setting.main entry
|
|
632
|
-
// OPERATE_EQUAL: standard field mapping (type=10, esbAssignSelf)
|
|
633
|
-
// OPERATE_PLUS/MINUS: direct source field reference (type=3)
|
|
634
|
-
const usePlusMinus = operate === 'OPERATE_PLUS' || operate === 'OPERATE_MINUS';
|
|
635
|
-
if (usePlusMinus && actionType === 'update') {
|
|
636
|
-
// OPERATE_PLUS/MINUS: assign = direct source field reference
|
|
637
|
-
const assignId = tempId();
|
|
638
|
-
settingMain[targetFieldId] = {
|
|
639
|
-
formFieldKey: "",
|
|
640
|
-
value: {
|
|
641
|
-
original: false,
|
|
642
|
-
operate,
|
|
643
|
-
switchType: "assign",
|
|
644
|
-
fieldSet: { matchMode: "", ignoreNull: false },
|
|
645
|
-
assignType: "",
|
|
646
|
-
fieldType: "Money",
|
|
647
|
-
multiSelect: false,
|
|
648
|
-
assign: {
|
|
649
|
-
id: assignId,
|
|
650
|
-
tableId: workflowId,
|
|
651
|
-
paramKey: `${workflowId}.${sourceFieldId}`,
|
|
652
|
-
paramName: sourceFieldId,
|
|
653
|
-
showName: tgtShowName,
|
|
654
|
-
paramType: "double",
|
|
655
|
-
dataType: "attribute",
|
|
656
|
-
arrs: false, required: false,
|
|
657
|
-
description: `(${sourceFieldId})`,
|
|
658
|
-
paramTypeString: "DOUBLE", dataTypeSting: "ATTRIBUTE",
|
|
659
|
-
paramId: sourceFieldId, formulaId: "0", mappingId: "0",
|
|
660
|
-
hideParamNameInSelect: true, hideParam: false,
|
|
661
|
-
componentKey: "Money",
|
|
662
|
-
readonlyParam: false, sensitiveFlag: false, newdata: false,
|
|
663
|
-
parentName: `表单数据.${tgtShowName}`,
|
|
664
|
-
name: tgtShowName,
|
|
665
|
-
source: eventId,
|
|
666
|
-
value: `FormData.${workflowId}.${sourceFieldId}`,
|
|
667
|
-
type: "3", formulaType: "double",
|
|
668
|
-
frontId: sourceFieldId,
|
|
669
|
-
config: {
|
|
670
|
-
paramKey: `${workflowId}.${sourceFieldId}`,
|
|
671
|
-
paramType: "double",
|
|
672
|
-
parentName: `表单数据.${tgtShowName}`,
|
|
673
|
-
newParentName: `表单数据.${tgtShowName}`,
|
|
674
|
-
multKey: "", multName: "",
|
|
675
|
-
multTypeObj: {
|
|
676
|
-
currentName: `表单数据.${tgtShowName}`,
|
|
677
|
-
allName: `表单数据.${tgtShowName}`,
|
|
678
|
-
currentParamKey: `FormData.${workflowId}.${sourceFieldId}`,
|
|
679
|
-
allParamKey: `FormData.${workflowId}.${sourceFieldId}`,
|
|
680
|
-
},
|
|
681
|
-
comId: eventId, isMultCom: false,
|
|
682
|
-
tableName: "表单数据",
|
|
683
|
-
fieldInfo: { tablePrimaryKey: "FormData", paramKey: `${workflowId}.${sourceFieldId}` },
|
|
684
|
-
comType: "ApproveTrigger", parentComId: "0",
|
|
685
|
-
switchType: "assign",
|
|
686
|
-
},
|
|
687
|
-
applicationId: appId, businessId: tempId(), fieldType: "number",
|
|
688
|
-
},
|
|
689
|
-
},
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
else {
|
|
693
|
-
// Plain assign (OPERATE_EQUAL): type-3 direct source field reference, matching
|
|
694
|
-
// the browser payload. type/paramType/formulaType/componentKey are derived from
|
|
695
|
-
// the target field's componentKey (NOT hardcoded string/Text — that broke Date).
|
|
696
|
-
const ti = typeInfoFor(tgtField?.componentKey || 'Text');
|
|
697
|
-
const assignId = tempId();
|
|
698
|
-
settingMain[targetFieldId] = {
|
|
699
|
-
formFieldKey: "",
|
|
700
|
-
value: {
|
|
701
|
-
original: false,
|
|
702
|
-
switchType: "assign",
|
|
703
|
-
fieldKey: targetFieldId,
|
|
704
|
-
fieldSet: { matchMode: "" },
|
|
705
|
-
assignType: "",
|
|
706
|
-
fieldType: ti.fieldTypeValue,
|
|
707
|
-
multiSelect: false,
|
|
708
|
-
assign: {
|
|
709
|
-
id: assignId,
|
|
710
|
-
tableId: workflowId,
|
|
711
|
-
paramKey: `${workflowId}.${sourceFieldId}`,
|
|
712
|
-
paramName: sourceFieldId,
|
|
713
|
-
showName: tgtShowName,
|
|
714
|
-
paramType: ti.paramType,
|
|
715
|
-
dataType: "attribute",
|
|
716
|
-
arrs: false, required: false,
|
|
717
|
-
description: `(${sourceFieldId})`,
|
|
718
|
-
paramTypeString: ti.paramTypeString, dataTypeSting: "ATTRIBUTE",
|
|
719
|
-
paramId: sourceFieldId, formulaId: "0", mappingId: "0",
|
|
720
|
-
hideParamNameInSelect: true, hideParam: false,
|
|
721
|
-
componentKey: ti.componentKey,
|
|
722
|
-
readonlyParam: false, sensitiveFlag: false, newdata: false,
|
|
723
|
-
parentName: `表单数据.${tgtShowName}`,
|
|
724
|
-
name: tgtShowName,
|
|
725
|
-
source: eventId,
|
|
726
|
-
value: `FormData.${workflowId}.${sourceFieldId}`,
|
|
727
|
-
type: "3",
|
|
728
|
-
formulaType: ti.formulaType,
|
|
729
|
-
frontId: sourceFieldId,
|
|
730
|
-
config: {
|
|
731
|
-
paramKey: `${workflowId}.${sourceFieldId}`,
|
|
732
|
-
paramType: ti.paramType,
|
|
733
|
-
parentName: `表单数据.${tgtShowName}`,
|
|
734
|
-
newParentName: `表单数据.${tgtShowName}`,
|
|
735
|
-
multKey: "", multName: "",
|
|
736
|
-
multTypeObj: {
|
|
737
|
-
currentName: `表单数据.${tgtShowName}`,
|
|
738
|
-
allName: `表单数据.${tgtShowName}`,
|
|
739
|
-
currentParamKey: `FormData.${workflowId}.${sourceFieldId}`,
|
|
740
|
-
allParamKey: `FormData.${workflowId}.${sourceFieldId}`,
|
|
741
|
-
},
|
|
742
|
-
comId: eventId, isMultCom: false,
|
|
743
|
-
tableName: "表单数据",
|
|
744
|
-
fieldInfo: { tablePrimaryKey: "FormData", paramKey: `${workflowId}.${sourceFieldId}` },
|
|
745
|
-
comType: "ApproveTrigger", parentComId: "0",
|
|
746
|
-
switchType: "assign",
|
|
747
|
-
},
|
|
748
|
-
applicationId: appId, businessId: tempId(), fieldType: ti.fieldTypeAssign,
|
|
749
|
-
},
|
|
750
|
-
},
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
// 系统变量映射(requestId → 目标 Flow 字段):assign 用 type:8 系统变量容器 + ApprovalData 前缀
|
|
755
|
-
if (Object.keys(sysvarMapping).length > 0) {
|
|
756
|
-
// 查 workflowId 绑定的源表名(parentName 用)
|
|
757
|
-
let wfFormName = '表单数据';
|
|
758
|
-
try {
|
|
759
|
-
const wfRes = await client.get(`${baseUrl}/api/bs/workflow/pathdef/getWfFormInfo?workflowId=${workflowId}`);
|
|
760
|
-
wfFormName = wfRes?.data?.formName || wfRes?.data?.workflowName || wfFormName;
|
|
761
|
-
}
|
|
762
|
-
catch { /* 用默认 */ }
|
|
763
|
-
for (const [targetFieldId, sv] of Object.entries(sysvarMapping)) {
|
|
764
|
-
const tgtField = targetFieldMap.get(targetFieldId);
|
|
765
|
-
const tgtShowName = tgtField?.showName || targetFieldId;
|
|
766
|
-
const childId = tempId();
|
|
767
|
-
const position = tempId();
|
|
768
|
-
const sysChild = {
|
|
769
|
-
id: childId, tableId: workflowId,
|
|
770
|
-
paramKey: `${workflowId}.requestId`, paramName: 'requestId',
|
|
771
|
-
showName: '流程ID', paramType: 'string', dataType: 'attribute',
|
|
772
|
-
arrs: false, required: false, description: 'requestId',
|
|
773
|
-
paramTypeString: 'STRING', dataTypeSting: 'ATTRIBUTE',
|
|
774
|
-
paramId: '3', formulaId: '0', mappingId: '0',
|
|
775
|
-
hideParamNameInSelect: true, hideParam: false,
|
|
776
|
-
readonlyParam: false, sensitiveFlag: false, newdata: false,
|
|
777
|
-
parentName: `${wfFormName}.流程ID`, name: '流程ID',
|
|
778
|
-
source: eventId,
|
|
779
|
-
value: `ApprovalData.${workflowId}.requestId`,
|
|
780
|
-
type: '3', formulaType: 'string', frontId: '3',
|
|
781
|
-
config: {
|
|
782
|
-
paramKey: `${workflowId}.requestId`, paramType: 'string',
|
|
783
|
-
parentName: `${wfFormName}.流程ID`, newParentName: `${wfFormName}.流程ID`,
|
|
784
|
-
multKey: '', multName: '',
|
|
785
|
-
multTypeObj: {
|
|
786
|
-
currentName: `${wfFormName}.流程ID`, allName: `${wfFormName}.流程ID`,
|
|
787
|
-
currentParamKey: `ApprovalData.${workflowId}.requestId`,
|
|
788
|
-
allParamKey: `ApprovalData.${workflowId}.requestId`,
|
|
789
|
-
},
|
|
790
|
-
comId: eventId, isMultCom: false,
|
|
791
|
-
tableName: '流程数据',
|
|
792
|
-
fieldInfo: { tablePrimaryKey: 'ApprovalData', paramKey: `${workflowId}.requestId` },
|
|
793
|
-
comType: 'ApproveTrigger', parentComId: 0,
|
|
794
|
-
},
|
|
795
|
-
applicationId: appId, businessId: tempId(), fieldType: 'string',
|
|
796
|
-
position,
|
|
797
|
-
};
|
|
798
|
-
settingMain[targetFieldId] = {
|
|
799
|
-
formFieldKey: '',
|
|
800
|
-
value: {
|
|
801
|
-
original: false, operate: 'OPERATE_EQUAL', switchType: 'assign',
|
|
802
|
-
fieldKey: targetFieldId,
|
|
803
|
-
fieldSet: { matchMode: '' }, assignType: '',
|
|
804
|
-
fieldType: 'Workflow', multiSelect: true,
|
|
805
|
-
assign: {
|
|
806
|
-
type: '8', name: '', value: `multipleSelect#${position}#`,
|
|
807
|
-
formulaType: 'json', applicationId: appId,
|
|
808
|
-
config: { paramType: 'string', switchType: 'assign' },
|
|
809
|
-
childs: [sysChild],
|
|
810
|
-
},
|
|
811
|
-
},
|
|
812
|
-
};
|
|
813
|
-
reloadFormula.push(sysChild);
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
// 明细映射上下文(源明细字段 + 源明细表集合)
|
|
817
|
-
const detailCtx = { workflowId, eventId, appId, sourceFormName: detailSourceFormName };
|
|
818
|
-
if (detailGroups.size > 0) {
|
|
819
|
-
reloadFormula.push(...buildDetailReloadFormula(detailGroups, detailCtx));
|
|
820
|
-
}
|
|
821
|
-
// Constants: setting.main entries with switchType "fixvalue"
|
|
822
|
-
for (const [tgtFieldId, constValue] of Object.entries(constants)) {
|
|
823
|
-
const tgtField = targetFieldMap.get(tgtFieldId);
|
|
824
|
-
const tgtShowName = tgtField?.showName || tgtFieldId;
|
|
825
|
-
// Select/RadioBox/CheckBox 目标字段:平台存的是选项 valueKey(selectData.id),
|
|
826
|
-
// 用户通常传选项名(如"是"/"A级")。不解析的话写成名字,目标 Select 更新不上(选项对不上)。
|
|
827
|
-
let assignValue = constValue;
|
|
828
|
-
let assignName = constValue;
|
|
829
|
-
const selectData = tgtField?.selectData || [];
|
|
830
|
-
if (selectData.length > 0) {
|
|
831
|
-
const byId = selectData.find((o) => String(o.id) === String(constValue));
|
|
832
|
-
const byName = selectData.find((o) => o.name === constValue);
|
|
833
|
-
if (byId) {
|
|
834
|
-
assignValue = String(byId.id);
|
|
835
|
-
assignName = byName?.name || byId.name;
|
|
836
|
-
}
|
|
837
|
-
else if (byName) {
|
|
838
|
-
assignValue = String(byName.id);
|
|
839
|
-
assignName = byName.name;
|
|
840
|
-
}
|
|
841
|
-
else {
|
|
842
|
-
console.error(` ⚠ 目标字段 ${tgtShowName} 选项里找不到常量 "${constValue}",原样写入(可能更新不上)`);
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
settingMain[tgtFieldId] = {
|
|
846
|
-
formFieldKey: "",
|
|
847
|
-
value: {
|
|
848
|
-
original: false,
|
|
849
|
-
assign: {
|
|
850
|
-
id: tempId(),
|
|
851
|
-
name: assignName,
|
|
852
|
-
value: assignValue,
|
|
853
|
-
type: "1",
|
|
854
|
-
fieldType: "string",
|
|
855
|
-
formulaType: "string",
|
|
856
|
-
applicationId: appId,
|
|
857
|
-
config: {
|
|
858
|
-
originValue: assignValue,
|
|
859
|
-
switchType: "fixvalue",
|
|
860
|
-
},
|
|
861
|
-
},
|
|
862
|
-
multiSelect: false,
|
|
863
|
-
fieldType: "Text",
|
|
864
|
-
switchType: "fixvalue",
|
|
865
|
-
fieldSet: { matchMode: "" },
|
|
866
|
-
assignType: "",
|
|
867
|
-
},
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
// Formula: setting.main entries with switchType "assign" + type "6"
|
|
871
|
-
for (const [tgtFieldId, f] of Object.entries(formula)) {
|
|
872
|
-
const fn = FORMULA_FNS[f.op];
|
|
873
|
-
const tgtField = targetFieldMap.get(tgtFieldId);
|
|
874
|
-
const tgtShowName = tgtField?.showName || tgtFieldId;
|
|
875
|
-
const fnId = tempId();
|
|
876
|
-
// Build childs — one entry per source field
|
|
877
|
-
const childs = f.fields.map((srcFieldId, i) => ({
|
|
878
|
-
id: tempId(),
|
|
879
|
-
tableId: workflowId,
|
|
880
|
-
paramKey: `${workflowId}.${srcFieldId}`,
|
|
881
|
-
paramName: srcFieldId,
|
|
882
|
-
showName: srcFieldId,
|
|
883
|
-
paramType: "double",
|
|
884
|
-
dataType: "attribute",
|
|
885
|
-
arrs: false, required: false,
|
|
886
|
-
description: `(${srcFieldId})`,
|
|
887
|
-
paramTypeString: "DOUBLE", dataTypeSting: "ATTRIBUTE",
|
|
888
|
-
paramId: srcFieldId, formulaId: "0", mappingId: "0",
|
|
889
|
-
hideParamNameInSelect: true, hideParam: false,
|
|
890
|
-
componentKey: "Money",
|
|
891
|
-
readonlyParam: false, sensitiveFlag: false, newdata: false,
|
|
892
|
-
parentName: `表单数据.${srcFieldId}`,
|
|
893
|
-
name: srcFieldId,
|
|
894
|
-
source: eventId,
|
|
895
|
-
value: `FormData.${workflowId}.${srcFieldId}`,
|
|
896
|
-
type: "3", formulaType: "double",
|
|
897
|
-
frontId: srcFieldId,
|
|
898
|
-
config: {
|
|
899
|
-
paramKey: `${workflowId}.${srcFieldId}`,
|
|
900
|
-
paramType: "double",
|
|
901
|
-
parentName: `表单数据.${srcFieldId}`,
|
|
902
|
-
newParentName: `表单数据.${srcFieldId}`,
|
|
903
|
-
multKey: "", multName: "",
|
|
904
|
-
multTypeObj: {
|
|
905
|
-
currentName: `表单数据.${srcFieldId}`,
|
|
906
|
-
allName: `表单数据.${srcFieldId}`,
|
|
907
|
-
currentParamKey: `FormData.${workflowId}.${srcFieldId}`,
|
|
908
|
-
allParamKey: `FormData.${workflowId}.${srcFieldId}`,
|
|
909
|
-
},
|
|
910
|
-
comId: eventId, isMultCom: false,
|
|
911
|
-
tableName: "表单数据",
|
|
912
|
-
fieldInfo: { tablePrimaryKey: "FormData", paramKey: `${workflowId}.${srcFieldId}` },
|
|
913
|
-
comType: "ApproveTrigger", parentComId: "0",
|
|
914
|
-
},
|
|
915
|
-
applicationId: appId, businessId: tempId(),
|
|
916
|
-
fieldType: "number",
|
|
917
|
-
position: i === 0
|
|
918
|
-
? `${fnId}`
|
|
919
|
-
: `${fnId + 1n}`,
|
|
920
|
-
}));
|
|
921
|
-
// Build detail array (one entry per source field)
|
|
922
|
-
const detail = f.fields.map((_, i) => ({
|
|
923
|
-
id: `${683774672122327701n + BigInt(i)}`,
|
|
924
|
-
createTime: "2022-01-01 00:00:00",
|
|
925
|
-
updateTime: "2022-01-01 00:00:00",
|
|
926
|
-
creator: "5140645587252557730",
|
|
927
|
-
tenantKey: "all_teams",
|
|
928
|
-
deleteType: 0,
|
|
929
|
-
functionId: fn.fnId,
|
|
930
|
-
paramName: `param${i + 1}`,
|
|
931
|
-
isRequire: "1",
|
|
932
|
-
paramType: "Double",
|
|
933
|
-
paramComment: "",
|
|
934
|
-
position: i === 0 ? `${fnId}` : `${fnId + 1n}`,
|
|
935
|
-
}));
|
|
936
|
-
const valueStr = `${fn.fnId}#${childs.map((c) => c.position).join('#')}#`;
|
|
937
|
-
// operate: add→PLUS(累加), sub→MINUS(累减), mul/div→EQUAL
|
|
938
|
-
const OPERATE = { add: 'OPERATE_PLUS', sub: 'OPERATE_MINUS', mul: 'OPERATE_EQUAL', div: 'OPERATE_EQUAL' };
|
|
939
|
-
const operate = OPERATE[f.op] || 'OPERATE_EQUAL';
|
|
940
|
-
settingMain[tgtFieldId] = {
|
|
941
|
-
formFieldKey: "",
|
|
942
|
-
value: {
|
|
943
|
-
original: false,
|
|
944
|
-
operate,
|
|
945
|
-
switchType: "assign",
|
|
946
|
-
fieldSet: { matchMode: "" },
|
|
947
|
-
assignType: "",
|
|
948
|
-
fieldType: "Money",
|
|
949
|
-
multiSelect: false,
|
|
950
|
-
assign: {
|
|
951
|
-
id: fnId,
|
|
952
|
-
createTime: "2022-07-18 15:44:20",
|
|
953
|
-
updateTime: "2022-07-18 15:44:20",
|
|
954
|
-
creator: "5140645587252557730",
|
|
955
|
-
tenantKey: "all_teams",
|
|
956
|
-
deleteType: 0,
|
|
957
|
-
functionName: fn.name,
|
|
958
|
-
paramSize: String(f.fields.length),
|
|
959
|
-
functionDesc: `${fn.name}运算`,
|
|
960
|
-
resultType: "double",
|
|
961
|
-
clazz: fn.clazz,
|
|
962
|
-
showOrder: ["add", "sub", "mul", "div"].indexOf(f.op) + 1,
|
|
963
|
-
groupId: 1481889452974711000,
|
|
964
|
-
enable: 0,
|
|
965
|
-
detail,
|
|
966
|
-
type: "6",
|
|
967
|
-
esbFunctionDesc: { type: "function", paramCount: 0 },
|
|
968
|
-
name: fn.name,
|
|
969
|
-
childs,
|
|
970
|
-
value: valueStr,
|
|
971
|
-
formulaType: "double",
|
|
972
|
-
config: {
|
|
973
|
-
originId: fn.fnId,
|
|
974
|
-
paramSize: String(f.fields.length),
|
|
975
|
-
paramType: "double",
|
|
976
|
-
functionType: "operation",
|
|
977
|
-
detail,
|
|
978
|
-
switchType: "assign",
|
|
979
|
-
},
|
|
980
|
-
applicationId: appId,
|
|
981
|
-
businessId: tempId(),
|
|
982
|
-
fieldType: "number",
|
|
983
|
-
},
|
|
984
|
-
},
|
|
985
|
-
};
|
|
986
|
-
// formula 模式:源字段 childs push 进 reloadFormula(对齐浏览器 payload,缺它会导致累加字段值取不到)
|
|
987
|
-
reloadFormula.push(...childs);
|
|
988
|
-
}
|
|
989
|
-
// Complete setting.main: platform requires an entry for EVERY target main field.
|
|
990
|
-
// Unmapped fields use a minimal placeholder matching platform UI output.
|
|
991
|
-
for (const f of targetFields) {
|
|
992
|
-
if (!settingMain[f.id]) {
|
|
993
|
-
const fid = tempId();
|
|
994
|
-
settingMain[f.id] = {
|
|
995
|
-
formFieldKey: fid,
|
|
996
|
-
value: {
|
|
997
|
-
original: false,
|
|
998
|
-
operate: "OPERATE_EQUAL",
|
|
999
|
-
fieldKey: f.id,
|
|
1000
|
-
fieldSet: {},
|
|
1001
|
-
id: fid,
|
|
1002
|
-
primaryId: fid,
|
|
1003
|
-
multiSelect: false,
|
|
1004
|
-
},
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
// Build setting.detail: 有映射的明细表生成 basisValue + assign,无映射的保留占位
|
|
1009
|
-
const settingDetail = buildDetailSetting(targetDetailTables, detailGroups, detailCtx);
|
|
1010
|
-
// Build match-field formula for delete filterInput / update basisValueFormula
|
|
1011
|
-
let matchFormula = null;
|
|
1012
|
-
let matchFieldDisplayName = cmdOpts.matchField || '';
|
|
1013
|
-
let matchFieldConfig = null;
|
|
1014
|
-
let matchParentFormName = '';
|
|
1015
|
-
if (cmdOpts.matchField) {
|
|
1016
|
-
// Look up the EBuilder field metadata from its source form.
|
|
1017
|
-
// Iterate forms under targetApp to find which one owns the matchField.
|
|
1018
|
-
try {
|
|
1019
|
-
const formList = await client.get(`${baseUrl}/api/bs/ebuilder/form/obj/getList/${cmdOpts.targetApp}?apid=${cmdOpts.targetApp}`);
|
|
1020
|
-
const forms = formList?.data || [];
|
|
1021
|
-
for (const form of forms) {
|
|
1022
|
-
if (String(form.id) === String(cmdOpts.targetTable))
|
|
1023
|
-
continue; // skip target form itself
|
|
1024
|
-
const dsBody = new URLSearchParams({
|
|
1025
|
-
groupId: 'weaver-ebuilder-form-service', sourceId: form.id,
|
|
1026
|
-
sourceType: 'LOGIC', detailFieldsGroup: 'true',
|
|
1027
|
-
enableMerge: 'true', needTableName: 'true', params: '[]',
|
|
1028
|
-
}).toString();
|
|
1029
|
-
const dsRes = await client.postForm(`${baseUrl}/api/ebuilder/common/ds/fields`, dsBody);
|
|
1030
|
-
const srcFields = dsRes?.data?.[0]?.fields || [];
|
|
1031
|
-
const srcField = srcFields.find((f) => String(f.id) === String(cmdOpts.matchField));
|
|
1032
|
-
if (srcField) {
|
|
1033
|
-
matchFieldDisplayName = srcField.text || srcField.fieldName || srcField.name || cmdOpts.matchField;
|
|
1034
|
-
matchFieldConfig = srcField.config || null;
|
|
1035
|
-
matchParentFormName = form.name || form.formName || form.objName || '';
|
|
1036
|
-
sourceFormName = matchParentFormName;
|
|
1037
|
-
break;
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
catch { /* use fieldId as fallback */ }
|
|
1042
|
-
matchFormula = {
|
|
1043
|
-
id: tempId(),
|
|
1044
|
-
tableId: workflowId,
|
|
1045
|
-
paramKey: `${workflowId}.${cmdOpts.matchField}`,
|
|
1046
|
-
paramName: cmdOpts.matchField,
|
|
1047
|
-
showName: matchFieldDisplayName,
|
|
1048
|
-
paramType: "string", dataType: "attribute",
|
|
1049
|
-
arrs: false, required: false,
|
|
1050
|
-
description: matchFieldConfig?.dataKey ? `${matchFieldConfig.dataKey}(${cmdOpts.matchField})` : `(${cmdOpts.matchField})`,
|
|
1051
|
-
paramTypeString: "STRING", dataTypeSting: "ATTRIBUTE",
|
|
1052
|
-
paramId: cmdOpts.matchField, formulaId: "0", mappingId: "0",
|
|
1053
|
-
hideParamNameInSelect: true, hideParam: false,
|
|
1054
|
-
componentKey: "Ebuilder",
|
|
1055
|
-
fieldConfig: matchFieldConfig,
|
|
1056
|
-
readonlyParam: false, sensitiveFlag: false, newdata: false,
|
|
1057
|
-
parentName: matchParentFormName ? `${matchParentFormName}.${matchFieldDisplayName}` : `表单数据.${matchFieldDisplayName}`,
|
|
1058
|
-
name: matchFieldDisplayName,
|
|
1059
|
-
source: eventId,
|
|
1060
|
-
value: `FormData.${workflowId}.${cmdOpts.matchField}`,
|
|
1061
|
-
type: "3", formulaType: "string",
|
|
1062
|
-
frontId: cmdOpts.matchField,
|
|
1063
|
-
config: {
|
|
1064
|
-
paramKey: `${workflowId}.${cmdOpts.matchField}`,
|
|
1065
|
-
paramType: "string",
|
|
1066
|
-
parentName: matchParentFormName ? `${matchParentFormName}.${matchFieldDisplayName}` : `表单数据.${matchFieldDisplayName}`,
|
|
1067
|
-
newParentName: matchParentFormName ? `${matchParentFormName}.${matchFieldDisplayName}` : `表单数据.${matchFieldDisplayName}`,
|
|
1068
|
-
multKey: "", multName: "",
|
|
1069
|
-
multTypeObj: {
|
|
1070
|
-
currentName: matchParentFormName ? `${matchParentFormName}.${matchFieldDisplayName}` : `表单数据.${matchFieldDisplayName}`,
|
|
1071
|
-
allName: matchParentFormName ? `${matchParentFormName}.${matchFieldDisplayName}` : `表单数据.${matchFieldDisplayName}`,
|
|
1072
|
-
currentParamKey: `FormData.${workflowId}.${cmdOpts.matchField}`,
|
|
1073
|
-
allParamKey: `FormData.${workflowId}.${cmdOpts.matchField}`,
|
|
1074
|
-
},
|
|
1075
|
-
comId: eventId, isMultCom: false,
|
|
1076
|
-
tableName: "表单数据",
|
|
1077
|
-
fieldInfo: { tablePrimaryKey: "FormData", paramKey: `${workflowId}.${cmdOpts.matchField}` },
|
|
1078
|
-
comType: "ApproveTrigger", parentComId: 0,
|
|
1079
|
-
switchType: "assign",
|
|
1080
|
-
},
|
|
1081
|
-
applicationId: appId, businessId: tempId(), fieldType: "string",
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
// For delete, push matchFormula to reloadFormula (same EBuilder field formula as update)
|
|
1085
|
-
if (actionType === 'delete' && matchFormula) {
|
|
1086
|
-
reloadFormula.push(matchFormula);
|
|
1087
|
-
}
|
|
1088
|
-
// Build event node
|
|
1089
|
-
const event = {
|
|
1090
|
-
id: eventId, nodeType: "Normal", name: "流程触发",
|
|
1091
|
-
nameMultilang: "流程触发",
|
|
1092
|
-
type: "ApproveTrigger",
|
|
1093
|
-
attr: { icon: "Icon-Approval-process02" },
|
|
1094
|
-
wId: eventId,
|
|
1095
|
-
data: {
|
|
1096
|
-
module: "workflow",
|
|
1097
|
-
workflowPath: [{ id: workflowId, name, workflowtype: "-1" }],
|
|
1098
|
-
triggerType: "singleApprove",
|
|
1099
|
-
applicationName: name,
|
|
1100
|
-
actionId: appId,
|
|
1101
|
-
id: tempId(),
|
|
1102
|
-
fromCopy: false,
|
|
1103
|
-
currWorkflowCanEdit: true,
|
|
1104
|
-
approveListFormOpen: false,
|
|
1105
|
-
},
|
|
1106
|
-
triggerType: "WorkflowTrigger",
|
|
1107
|
-
canDelete: true, canEdit: true, canSwitch: true,
|
|
1108
|
-
componentName: "流程触发",
|
|
1109
|
-
componentDesc: "流程中的指定节点与时机触发动作,例如流程提交后、审批后、归档后等",
|
|
1110
|
-
componentNameLabel: 131942, componentDescLabel: 236889,
|
|
1111
|
-
comType: "ApproveTrigger", parentId: 0, isOpen: false, previousId: 0,
|
|
1112
|
-
dataId: appId, costTime: 0,
|
|
1113
|
-
itemAndLayout: EVENT_LAYOUT,
|
|
1114
|
-
};
|
|
1115
|
-
// Build action node based on type
|
|
1116
|
-
const targetFormObj = {
|
|
1117
|
-
id: cmdOpts.targetTable,
|
|
1118
|
-
text: formName,
|
|
1119
|
-
type: "FORM", groupId: cmdOpts.targetApp,
|
|
1120
|
-
isPhysical: formIsPhysical, usage: "", objType: formObjType, module: "",
|
|
1121
|
-
groupName: appName,
|
|
1122
|
-
appId: cmdOpts.targetApp,
|
|
1123
|
-
ebuilderDataConfig: {
|
|
1124
|
-
dataSetup: { dataSource: "ALL", dataPermission: "HAVE_PERMISSION_DATA" },
|
|
1125
|
-
type: "FORM",
|
|
1126
|
-
},
|
|
1127
|
-
};
|
|
1128
|
-
const appTypeArr = [{ id: cmdOpts.targetApp, name: appName }];
|
|
1129
|
-
const tableTypeArr = [{ id: cmdOpts.targetTable, name: formName }];
|
|
1130
|
-
let actionNodeData;
|
|
1131
|
-
if (actionType === 'add') {
|
|
1132
|
-
actionNodeData = {
|
|
1133
|
-
ebActionId: "-1", opType: "insert",
|
|
1134
|
-
currentApplication: appId,
|
|
1135
|
-
person: makeFixedValueFormula(appId, cmdOpts.creator),
|
|
1136
|
-
syncType: "0", workflowModule: "workflow", workflowId,
|
|
1137
|
-
setting: { opType: "insert", dataDrWithCalc: false, main: settingMain, detail: settingDetail, updateFieldCondition: { updateField: [] } },
|
|
1138
|
-
settingFields: { main: targetFields },
|
|
1139
|
-
targetForm: targetFormObj,
|
|
1140
|
-
appType: appTypeArr,
|
|
1141
|
-
tableType: tableTypeArr,
|
|
1142
|
-
workflowFields: "", applicationId: appId,
|
|
1143
|
-
appId: cmdOpts.targetApp, objId: cmdOpts.targetTable,
|
|
1144
|
-
personId: tempId(), id: tempId(),
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
else if (actionType === 'update') {
|
|
1148
|
-
// opType "id": 按数据ID更新。依据值不填,updateId 用关联字段指向目标记录
|
|
1149
|
-
const srcFieldName = cmdOpts.matchField || '';
|
|
1150
|
-
const displayName = matchFieldDisplayName || srcFieldName;
|
|
1151
|
-
const formPrefix = matchParentFormName ? `${matchParentFormName}.` : '表单数据.';
|
|
1152
|
-
const descStr = matchFieldConfig?.dataKey
|
|
1153
|
-
? `${matchFieldConfig.dataKey}(${srcFieldName})`
|
|
1154
|
-
: `(${srcFieldName})`;
|
|
1155
|
-
const updateIdFormula = matchFormula ? {
|
|
1156
|
-
id: tempId(),
|
|
1157
|
-
tableId: workflowId,
|
|
1158
|
-
paramKey: `${workflowId}.${srcFieldName}`,
|
|
1159
|
-
paramName: srcFieldName,
|
|
1160
|
-
showName: displayName,
|
|
1161
|
-
paramType: "string", dataType: "attribute",
|
|
1162
|
-
arrs: false, required: false,
|
|
1163
|
-
description: descStr,
|
|
1164
|
-
paramTypeString: "STRING", dataTypeSting: "ATTRIBUTE",
|
|
1165
|
-
paramId: srcFieldName, formulaId: "0", mappingId: "0",
|
|
1166
|
-
hideParamNameInSelect: true, hideParam: false,
|
|
1167
|
-
componentKey: "Ebuilder",
|
|
1168
|
-
fieldConfig: matchFieldConfig,
|
|
1169
|
-
readonlyParam: false, sensitiveFlag: false, newdata: false,
|
|
1170
|
-
parentName: `${formPrefix}${displayName}`,
|
|
1171
|
-
name: displayName,
|
|
1172
|
-
source: eventId,
|
|
1173
|
-
value: `FormData.${workflowId}.${srcFieldName}`,
|
|
1174
|
-
type: "3", formulaType: "string",
|
|
1175
|
-
frontId: srcFieldName,
|
|
1176
|
-
config: {
|
|
1177
|
-
paramKey: `${workflowId}.${srcFieldName}`,
|
|
1178
|
-
paramType: "string",
|
|
1179
|
-
parentName: `${formPrefix}${displayName}`,
|
|
1180
|
-
newParentName: `${formPrefix}${displayName}`,
|
|
1181
|
-
multKey: "", multName: "",
|
|
1182
|
-
multTypeObj: {
|
|
1183
|
-
currentName: `${formPrefix}${displayName}`,
|
|
1184
|
-
allName: `${formPrefix}${displayName}`,
|
|
1185
|
-
currentParamKey: `FormData.${workflowId}.${srcFieldName}`,
|
|
1186
|
-
allParamKey: `FormData.${workflowId}.${srcFieldName}`,
|
|
1187
|
-
},
|
|
1188
|
-
comId: eventId, isMultCom: false,
|
|
1189
|
-
tableName: "表单数据",
|
|
1190
|
-
fieldInfo: { tablePrimaryKey: "FormData", paramKey: `${workflowId}.${srcFieldName}` },
|
|
1191
|
-
comType: "ApproveTrigger", parentComId: 0,
|
|
1192
|
-
switchType: "assign",
|
|
1193
|
-
},
|
|
1194
|
-
applicationId: appId, businessId: tempId(), fieldType: "string",
|
|
1195
|
-
} : null;
|
|
1196
|
-
// updateData + filterInput 模式(--match-target):按「目标字段 = 源字段值」匹配更新。
|
|
1197
|
-
// 契约(真机实证):fieldUpdate 不可用(保存后右侧条件被清空),按字段匹配更新走 updateData+filterInput。
|
|
1198
|
-
let matchFilterInput = null;
|
|
1199
|
-
if (cmdOpts.matchTarget && matchFormula) {
|
|
1200
|
-
const tgtField = targetFields.find((f) => String(f.id) === String(cmdOpts.matchTarget));
|
|
1201
|
-
const filterKey = String(Date.now());
|
|
1202
|
-
const datasKey = String(Date.now() + 1);
|
|
1203
|
-
matchFilterInput = {
|
|
1204
|
-
key: filterKey, relationship: "1", isParent: true, isNewFilter: true, parentNode: "",
|
|
1205
|
-
datas: [{
|
|
1206
|
-
isParent: false, parentNode: filterKey,
|
|
1207
|
-
id: String(cmdOpts.matchTarget),
|
|
1208
|
-
fieldName: tgtField?.dataKey || '',
|
|
1209
|
-
fieldType: tgtField?.componentKey || tgtField?.type || 'Text',
|
|
1210
|
-
optionType: "",
|
|
1211
|
-
text: tgtField?.showName || cmdOpts.matchTarget,
|
|
1212
|
-
objId: cmdOpts.targetTable,
|
|
1213
|
-
compType: "Text", type: "condition",
|
|
1214
|
-
conditions: {
|
|
1215
|
-
func: "eq", isEsb: true,
|
|
1216
|
-
text: displayName || '',
|
|
1217
|
-
esbAssign: { wId: actionId, textarea: false, withoutDftNum: true },
|
|
1218
|
-
value: matchFormula,
|
|
1219
|
-
},
|
|
1220
|
-
isEsb: true, isEdit: "0",
|
|
1221
|
-
esbAssign: { wId: actionId, textarea: false, withoutDftNum: true },
|
|
1222
|
-
multiSelect: "false",
|
|
1223
|
-
formInfo: { fieldId: String(cmdOpts.matchTarget) },
|
|
1224
|
-
originBrowserType: "", module: "",
|
|
1225
|
-
mainField: true, subTableId: "",
|
|
1226
|
-
key: datasKey,
|
|
1227
|
-
}],
|
|
1228
|
-
version: 1,
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
const opType = matchFilterInput ? "updateData" : "id";
|
|
1232
|
-
actionNodeData = {
|
|
1233
|
-
ebActionId: "-1", opType, updatePolicy: "ALL",
|
|
1234
|
-
currentApplication: appId,
|
|
1235
|
-
targetForm: targetFormObj,
|
|
1236
|
-
appType: [{ id: cmdOpts.targetApp, name: appName }],
|
|
1237
|
-
tableType: [{ id: cmdOpts.targetTable, name: formName }],
|
|
1238
|
-
person: makeFixedValueFormula(appId, cmdOpts.creator),
|
|
1239
|
-
setting: { main: settingMain, detail: [], dataDrWithCalc: false, deleteMainFields: [], updateFieldCondition: { updateField: [] } },
|
|
1240
|
-
// settingFields 提供目标表字段定义(Select 字段带 selectData 选项),
|
|
1241
|
-
// 缺失会导致目标 Select 字段更新不上(平台按 selectData.id=valueKey 落值)
|
|
1242
|
-
settingFields: { main: targetFields },
|
|
1243
|
-
basisValueFormula: null,
|
|
1244
|
-
filterInput: matchFilterInput,
|
|
1245
|
-
dataSource: { type: "FORM", groupId: cmdOpts.targetApp, id: cmdOpts.targetTable },
|
|
1246
|
-
needAdd: false, nodataFlag: false, nullOpflag: false,
|
|
1247
|
-
syncType: "0",
|
|
1248
|
-
updateId: matchFilterInput ? null : updateIdFormula,
|
|
1249
|
-
workflowFields: "", workflowModule: "workflow", workflowId,
|
|
1250
|
-
type: "ActionEbUpdate", applicationId: appId,
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
1253
|
-
else {
|
|
1254
|
-
// delete — filterInput matches against target table's "数据ID" system field (id=5)
|
|
1255
|
-
const filterKey = String(Date.now());
|
|
1256
|
-
const datasKey = String(Date.now() + 1);
|
|
1257
|
-
// delete 匹配目标:--match-target 提供时按业务字段匹配(如 台账.项目名称 = 流程.项目名称,
|
|
1258
|
-
// 用于退回删台账等场景),否则默认匹配目标表 数据ID(id=5) = 源字段值(需发起时回写记录ID)。
|
|
1259
|
-
const tgtFieldD = cmdOpts.matchTarget ? targetFields.find((f) => String(f.id) === String(cmdOpts.matchTarget)) : null;
|
|
1260
|
-
const delDatas = [{
|
|
1261
|
-
isParent: false, parentNode: filterKey,
|
|
1262
|
-
id: tgtFieldD ? String(cmdOpts.matchTarget) : "5",
|
|
1263
|
-
fieldName: tgtFieldD ? (tgtFieldD.dataKey || '') : 'id',
|
|
1264
|
-
fieldType: tgtFieldD ? (tgtFieldD.componentKey || tgtFieldD.type || 'Text') : 'Number',
|
|
1265
|
-
optionType: "",
|
|
1266
|
-
text: tgtFieldD ? (tgtFieldD.showName || String(cmdOpts.matchTarget)) : '数据ID',
|
|
1267
|
-
objId: cmdOpts.targetTable,
|
|
1268
|
-
compType: "Text",
|
|
1269
|
-
type: "condition",
|
|
1270
|
-
conditions: {
|
|
1271
|
-
func: "eq",
|
|
1272
|
-
isEsb: true,
|
|
1273
|
-
text: matchFieldDisplayName || '',
|
|
1274
|
-
esbAssign: { wId: actionId, textarea: false, withoutDftNum: true },
|
|
1275
|
-
value: matchFormula || {},
|
|
1276
|
-
},
|
|
1277
|
-
isEsb: true,
|
|
1278
|
-
isEdit: "0",
|
|
1279
|
-
esbAssign: { wId: actionId, textarea: false, withoutDftNum: true },
|
|
1280
|
-
multiSelect: "false",
|
|
1281
|
-
formInfo: { fieldId: tgtFieldD ? String(cmdOpts.matchTarget) : "5" },
|
|
1282
|
-
originBrowserType: "", module: "",
|
|
1283
|
-
mainField: true, subTableId: "",
|
|
1284
|
-
key: datasKey,
|
|
1285
|
-
}];
|
|
1286
|
-
actionNodeData = {
|
|
1287
|
-
currentApplication: appId,
|
|
1288
|
-
person: makeFixedValueFormula(appId, cmdOpts.creator),
|
|
1289
|
-
filterInput: {
|
|
1290
|
-
key: filterKey, relationship: "1",
|
|
1291
|
-
isParent: true, isNewFilter: true, parentNode: "",
|
|
1292
|
-
datas: delDatas,
|
|
1293
|
-
version: 1,
|
|
1294
|
-
},
|
|
1295
|
-
dataSource: { type: "FORM", groupId: cmdOpts.targetApp, id: cmdOpts.targetTable },
|
|
1296
|
-
targetForm: targetFormObj,
|
|
1297
|
-
appType: [{ id: cmdOpts.targetApp, name: appName }],
|
|
1298
|
-
tableType: [{ id: cmdOpts.targetTable, name: formName }],
|
|
1299
|
-
type: "ActionEbDelete", ebActionId: "-1",
|
|
1300
|
-
nullOpflag: false,
|
|
1301
|
-
appId: cmdOpts.targetApp,
|
|
1302
|
-
objId: cmdOpts.targetTable,
|
|
1303
|
-
personId: tempId(),
|
|
1304
|
-
id: tempId(),
|
|
1305
|
-
applicationId: appId,
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
const actionNode = {
|
|
1309
|
-
nodeType: "Normal", id: actionId, wId: actionId,
|
|
1310
|
-
name: TYPE_LABEL[actionType],
|
|
1311
|
-
nameMultilang: TYPE_LABEL[actionType],
|
|
1312
|
-
type: TYPE_NAME[actionType],
|
|
1313
|
-
typeName: TYPE_LABEL[actionType],
|
|
1314
|
-
attr: { icon: "Icon-e-builder03" },
|
|
1315
|
-
data: actionNodeData,
|
|
1316
|
-
canDelete: true, canEdit: true,
|
|
1317
|
-
fields: Object.keys(actionNodeData).filter(k => !['type'].includes(k)),
|
|
1318
|
-
designerResult: makeDesignerResult(),
|
|
1319
|
-
componentName: TYPE_LABEL[actionType],
|
|
1320
|
-
componentDesc: `${TYPE_LABEL[actionType].replace('表单数据', '指定e-builder应用下的表单数据')}`,
|
|
1321
|
-
componentNameLabel: LABELS[actionType][0],
|
|
1322
|
-
componentDescLabel: LABELS[actionType][1],
|
|
1323
|
-
isOpen: false,
|
|
1324
|
-
comType: TYPE_NAME[actionType],
|
|
1325
|
-
parentId: 0, previousId: eventId,
|
|
1326
|
-
branchs: [], multKey: "", multName: "",
|
|
1327
|
-
itemAndLayout: actionType === 'delete' ? DELETE_LAYOUT : (actionType === 'update' ? UPDATE_LAYOUT : buildActionLayout(cmdOpts.targetApp)),
|
|
1328
|
-
ignoreFlowCheck: true,
|
|
1329
|
-
};
|
|
1330
|
-
// Build output node — align with browser saveDesign format
|
|
1331
|
-
const output = {
|
|
1332
|
-
nodeType: "Normal",
|
|
1333
|
-
id: outputId,
|
|
1334
|
-
wId: outputId,
|
|
1335
|
-
name: "终止",
|
|
1336
|
-
nameMultilang: "终止",
|
|
1337
|
-
type: "Output",
|
|
1338
|
-
typeName: "终止",
|
|
1339
|
-
sources: [{ wId: actionId }],
|
|
1340
|
-
attr: { icon: "Icon-termination-1", iconColor: "var(--danger)" },
|
|
1341
|
-
canDelete: true,
|
|
1342
|
-
canEdit: true,
|
|
1343
|
-
designerResult: makeDesignerResult(),
|
|
1344
|
-
componentName: "终止",
|
|
1345
|
-
componentDesc: "终止执行动作流",
|
|
1346
|
-
componentNameLabel: 244710,
|
|
1347
|
-
componentDescLabel: 288303,
|
|
1348
|
-
isOpen: false,
|
|
1349
|
-
comType: "Output",
|
|
1350
|
-
parentId: 0,
|
|
1351
|
-
data: {
|
|
1352
|
-
outputStatus: "1",
|
|
1353
|
-
pageAction: "0",
|
|
1354
|
-
reminder: "0",
|
|
1355
|
-
fixedData: [],
|
|
1356
|
-
triggerFlag: false,
|
|
1357
|
-
reminderMsgFormula: "",
|
|
1358
|
-
nextAction: false,
|
|
1359
|
-
customOutputData: "",
|
|
1360
|
-
currentApplication: appId,
|
|
1361
|
-
applicationId: appId,
|
|
1362
|
-
},
|
|
1363
|
-
previousId: actionId,
|
|
1364
|
-
branchs: [],
|
|
1365
|
-
multKey: "",
|
|
1366
|
-
multName: "",
|
|
1367
|
-
itemAndLayout: OUTPUT_LAYOUT,
|
|
1368
|
-
ignoreFlowCheck: true,
|
|
1369
|
-
};
|
|
1370
|
-
const designPayload = {
|
|
1371
|
-
ajaxUrl: "/api/bs/esb/setting/flow/design/saveDesign",
|
|
1372
|
-
saveAndStart: true,
|
|
1373
|
-
appId,
|
|
1374
|
-
sceneId,
|
|
1375
|
-
event,
|
|
1376
|
-
actions: [actionNode, output],
|
|
1377
|
-
addIds: [],
|
|
1378
|
-
deleteActions: [],
|
|
1379
|
-
version: 1,
|
|
1380
|
-
delCheckMsg: [],
|
|
1381
|
-
addCheckMsg: [],
|
|
1382
|
-
assistLayer: '{"nodes":[],"layout":{}}',
|
|
1383
|
-
versionConfig: '{}',
|
|
1384
|
-
saveNewVersion: false,
|
|
1385
|
-
lightId: '',
|
|
1386
|
-
initData: '',
|
|
1387
|
-
secretKey: '',
|
|
1388
|
-
appName: name,
|
|
1389
|
-
reloadFormula,
|
|
1390
|
-
};
|
|
1391
|
-
const designRes = await client.post(`${baseUrl}/api/bs/esb/setting/flow/design/saveDesign`, designPayload);
|
|
1392
|
-
if (designRes?.code !== 200 || !designRes?.status) {
|
|
1393
|
-
console.error(`保存设计失败: ${designRes?.msg || '未知错误'}`);
|
|
1394
|
-
process.exit(1);
|
|
1395
|
-
}
|
|
1396
|
-
const newSceneId = designRes?.data?.sceneId || designRes?.data?.activeVersion || sceneId;
|
|
1397
|
-
console.error(` 设计已保存 sceneId: ${newSceneId}`);
|
|
1398
|
-
// Step 4: Bind to workflow node
|
|
1399
|
-
console.error(`Step 4/4: 绑定动作流到节点 ${nodeId}...`);
|
|
1400
|
-
const EVENT_MAP = {
|
|
1401
|
-
arrive: { triggerType: 'pre', executeTime: ['1'], useExtendedFormat: false },
|
|
1402
|
-
leave: { triggerType: 'after', executeTime: ['1'], useExtendedFormat: false },
|
|
1403
|
-
'back-arrive': { triggerType: 'pre', executeTime: ['2'], useExtendedFormat: false },
|
|
1404
|
-
delete: { triggerType: 'delete', executeTime: undefined, useExtendedFormat: false },
|
|
1405
|
-
save: { triggerType: 'save', executeTime: undefined, useExtendedFormat: false },
|
|
1406
|
-
revert: { triggerType: 'revert', executeTime: undefined, useExtendedFormat: false },
|
|
1407
|
-
pause: { triggerType: 'stopAndOpen', executeTime: ['1'], useExtendedFormat: false },
|
|
1408
|
-
cancel: { triggerType: 'cancelAndRegain', executeTime: ['1'], useExtendedFormat: false },
|
|
1409
|
-
};
|
|
1410
|
-
const EVENT_LABELS = {
|
|
1411
|
-
arrive: '到达节点时', leave: '正向离开(提交后)', 'back-arrive': '退回到达(退回时)',
|
|
1412
|
-
delete: '流程删除时', save: '流程保存时', revert: '流程还原时', pause: '暂停/启用时', cancel: '撤销恢复时',
|
|
1413
|
-
};
|
|
1414
|
-
const evCfg = EVENT_MAP[cmdOpts.event] || EVENT_MAP.arrive;
|
|
1415
|
-
const eventLabel = EVENT_LABELS[cmdOpts.event] || cmdOpts.event;
|
|
1416
|
-
const nodeName = cmdOpts.nodeName || nodeId;
|
|
1417
|
-
const bindDataId = evCfg.useExtendedFormat ? tempId() : tempIdNeg();
|
|
1418
|
-
// Optional trigger condition: saveCondition (source=19) → conditionKey, then bind with hasRule
|
|
1419
|
-
let actionConditionKey = '';
|
|
1420
|
-
if (cmdOpts.condition && cmdOpts.condition.length > 0) {
|
|
1421
|
-
try {
|
|
1422
|
-
actionConditionKey = await saveActionCondition(client, baseUrl, workflowId, nodeName, cmdOpts.condition, cmdOpts.conditionRelation || 'AND', cmdOpts.conditionName || '');
|
|
1423
|
-
}
|
|
1424
|
-
catch (e) {
|
|
1425
|
-
console.error(`❌ ${e.message}`);
|
|
1426
|
-
console.error(' 动作流已创建但未绑定条件,请检查 --condition 后重试。');
|
|
1427
|
-
console.error(` appId=${appId}`);
|
|
1428
|
-
process.exit(1);
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
// Standard format (arrive/pre, delete, save)
|
|
1432
|
-
const standardData = {
|
|
1433
|
-
id: bindDataId, actionName: name, open: true, actionId: appId, esbName: name,
|
|
1434
|
-
customName: '', actionType: 2,
|
|
1435
|
-
actionData: {
|
|
1436
|
-
actionSelect: '1', sysCustomAction: [],
|
|
1437
|
-
paramsSet: [{ id: appId, name, eventType: 'WorkflowTrigger', interfaceCreate: false, isKeepDiary: 1 }],
|
|
1438
|
-
actionSet: [{ id: appId, name, eventType: 'WorkflowTrigger', interfaceCreate: false, isKeepDiary: 1 }],
|
|
1439
|
-
actionName: '', id: bindDataId, customDataId: '',
|
|
1440
|
-
},
|
|
1441
|
-
async: 0, triggerType: evCfg.triggerType, order: 0,
|
|
1442
|
-
};
|
|
1443
|
-
if (actionConditionKey) {
|
|
1444
|
-
standardData.conditionKey = actionConditionKey;
|
|
1445
|
-
standardData.hasRule = true;
|
|
1446
|
-
}
|
|
1447
|
-
if (evCfg.executeTime)
|
|
1448
|
-
standardData.executeTime = evCfg.executeTime;
|
|
1449
|
-
// Fetch existing actions and merge — never overwrite
|
|
1450
|
-
let existingActions = [];
|
|
1451
|
-
const existing = await client.post(`${baseUrl}/api/bs/workflow/pathdef/addaction/getAddActionDataList`, {
|
|
1452
|
-
workflowId, objId: nodeId, triggerType: 'all', isNodeFlag: '1',
|
|
1453
|
-
});
|
|
1454
|
-
if (existing?.code === 200 && existing?.status) {
|
|
1455
|
-
existingActions = existing?.data?.data || [];
|
|
1456
|
-
}
|
|
1457
|
-
else {
|
|
1458
|
-
console.error(`❌ 无法读取节点已有动作: ${existing?.data?.msg || existing?.msg || '未知错误'}`);
|
|
1459
|
-
console.error(' 动作流已创建但未绑定,请手动在页面中绑定。');
|
|
1460
|
-
console.error(` appId=${appId}`);
|
|
1461
|
-
process.exit(1);
|
|
1462
|
-
}
|
|
1463
|
-
// New row always uses the standard write format (matches browser payload).
|
|
1464
|
-
// Existing rows are normalized from read format back to write format — re-sending
|
|
1465
|
-
// raw read rows corrupts the node (every later read returns 500).
|
|
1466
|
-
const actionData = standardData;
|
|
1467
|
-
actionData.order = existingActions.length;
|
|
1468
|
-
const mergedActions = [...existingActions.map(normalizeActionRow), actionData];
|
|
1469
|
-
console.error(` 已有 ${existingActions.length} 个动作,归一化合并后 ${mergedActions.length} 个`);
|
|
1470
|
-
const bindPayload = {
|
|
1471
|
-
workflowId, objId: nodeId, triggerType: 'all',
|
|
1472
|
-
data: mergedActions,
|
|
1473
|
-
isNodeFlag: '1', objName: nodeName,
|
|
1474
|
-
};
|
|
1475
|
-
const bindRes = await client.post(`${baseUrl}/api/bs/workflow/pathdef/addaction/saveAddActionList`, bindPayload);
|
|
1476
|
-
if (bindRes?.code === 200 && bindRes?.status) {
|
|
1477
|
-
const msg = opts.json
|
|
1478
|
-
? JSON.stringify({ success: true, appId, sceneId: newSceneId, workflowId, nodeId, name, mapping: Object.keys(mapping).length, event: cmdOpts.event })
|
|
1479
|
-
: `动作流已创建并绑定: ${name}\n appId: ${appId}\n sceneId: ${newSceneId}\n 节点: ${nodeId}\n 触发: ${eventLabel}\n 字段映射: ${Object.keys(mapping).length} 个`;
|
|
1480
|
-
console.log(msg);
|
|
1481
|
-
}
|
|
1482
|
-
else {
|
|
1483
|
-
console.error(`绑定失败: ${bindRes?.msg || '未知错误'}`);
|
|
1484
|
-
console.error(`动作流已创建(appId=${appId}),需手动绑定到节点`);
|
|
1485
|
-
process.exit(1);
|
|
1486
|
-
}
|
|
1487
|
-
});
|
|
1488
|
-
actionCmd.command('get')
|
|
1489
|
-
.description('查看动作流设计')
|
|
1490
|
-
.argument('<sceneId>', '场景 ID(activeVersion)')
|
|
1491
|
-
.action(async (sceneId) => {
|
|
1492
|
-
const opts = program.opts();
|
|
1493
|
-
const auth = await AuthSession.fromOptions(opts);
|
|
1494
|
-
if (!auth)
|
|
1495
|
-
process.exit(1);
|
|
1496
|
-
const client = new ApiClient(auth);
|
|
1497
|
-
const baseUrl = auth.getBaseUrl();
|
|
1498
|
-
const data = await client.get(`${baseUrl}/api/bs/esb/setting/flow/design/getDesignBySceneId/${sceneId}`);
|
|
1499
|
-
if (data?.code === 200 && data?.status) {
|
|
1500
|
-
if (opts.json) {
|
|
1501
|
-
console.log(JSON.stringify(data.data, null, 2));
|
|
1502
|
-
}
|
|
1503
|
-
else {
|
|
1504
|
-
const ev = data.data?.event || {};
|
|
1505
|
-
const actions = data.data?.actions || [];
|
|
1506
|
-
console.log(`动作流: ${data.data?.appName || '(未命名)'}`);
|
|
1507
|
-
console.log(`appId: ${data.data?.appId} sceneId: ${sceneId}`);
|
|
1508
|
-
console.log(`触发: ${ev.triggerTypeName || ev.triggerType} (${ev.typeName || ev.type})`);
|
|
1509
|
-
console.log(`节点数: ${actions.length}`);
|
|
1510
|
-
for (const a of actions) {
|
|
1511
|
-
const ext = a.type === 'ActionEbAdd' ? `→ ${a.data?.targetForm?.text || ''}`
|
|
1512
|
-
: a.type === 'ActionEbUpdate' ? `→ ${a.data?.targetForm?.text || ''}`
|
|
1513
|
-
: a.type === 'ActionEbDelete' ? `→ ${a.data?.targetForm?.text || ''}`
|
|
1514
|
-
: '';
|
|
1515
|
-
console.log(` - ${a.name} [${a.type}]${ext ? ' ' + ext : ''}`);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
else {
|
|
1520
|
-
console.error(`查询失败: ${data?.msg || '未知错误'}`);
|
|
1521
|
-
process.exit(1);
|
|
1522
|
-
}
|
|
1523
|
-
});
|
|
17
|
+
const actionCmd = wf.command('action').description('动作流管理(生成请用 `e10-cli actionflow generate`;本组为查/清/删/禁用)');
|
|
1524
18
|
actionCmd.command('list-node')
|
|
1525
19
|
.description('列出流程节点绑定的动作(getAddActionDataList)')
|
|
1526
20
|
.argument('<workflowId>', '流程 ID')
|
|
@@ -1586,9 +80,8 @@ export function registerWorkflowActionCommands(wf, program) {
|
|
|
1586
80
|
return;
|
|
1587
81
|
}
|
|
1588
82
|
const ids = rows.map((r) => String(r.id));
|
|
1589
|
-
// objName:从任意行的 objName 取,或回退空串(deleteAddAction 实测 objName 非必需,但带节点名更稳)
|
|
1590
83
|
const objName = rows[0]?.objName || '';
|
|
1591
|
-
// 2. deleteAddAction
|
|
84
|
+
// 2. deleteAddAction 批量删除绑定(saveAddActionList 空 data 删不掉悬空绑定;
|
|
1592
85
|
// 浏览器删节点动作走 deleteAddAction + delList=row.id 数组)
|
|
1593
86
|
const delRes = await client.post(`${baseUrl}/api/bs/workflow/pathdef/addaction/deleteAddAction`, {
|
|
1594
87
|
workflowId, objId: nodeId, triggerType: cmdOpts.triggerType,
|
|
@@ -1604,48 +97,6 @@ export function registerWorkflowActionCommands(wf, program) {
|
|
|
1604
97
|
console.log(msg);
|
|
1605
98
|
console.error(' 注:动作流实体记录未删,如需彻底清理用 `workflow action delete <appId> <name>`');
|
|
1606
99
|
});
|
|
1607
|
-
actionCmd.command('fields')
|
|
1608
|
-
.description('获取目标表单可用字段(用于编写 mapping)')
|
|
1609
|
-
.argument('<tableId>', '目标表单 tableId')
|
|
1610
|
-
.argument('<appId>', '目标表单所属应用 ID')
|
|
1611
|
-
.action(async (tableId, appId) => {
|
|
1612
|
-
const opts = program.opts();
|
|
1613
|
-
const auth = await AuthSession.fromOptions(opts);
|
|
1614
|
-
if (!auth)
|
|
1615
|
-
process.exit(1);
|
|
1616
|
-
const client = new ApiClient(auth);
|
|
1617
|
-
const baseUrl = auth.getBaseUrl();
|
|
1618
|
-
const data = await client.post(`${baseUrl}/api/bs/esb/setting/component/getEbField`, {
|
|
1619
|
-
tableId,
|
|
1620
|
-
appId,
|
|
1621
|
-
});
|
|
1622
|
-
if (data?.code === 200 && data?.status) {
|
|
1623
|
-
const main = data.data?.main || [];
|
|
1624
|
-
if (opts.json) {
|
|
1625
|
-
console.log(JSON.stringify(data.data, null, 2));
|
|
1626
|
-
}
|
|
1627
|
-
else {
|
|
1628
|
-
console.log(`目标表 ${tableId} 字段 (${main.length}):\n`);
|
|
1629
|
-
for (const f of main) {
|
|
1630
|
-
console.log(` ${f.id} ${f.showName} [${f.componentKey || f.type}] ${f.dataKey || ''}`);
|
|
1631
|
-
}
|
|
1632
|
-
const detail = data.data?.detail || [];
|
|
1633
|
-
if (detail.length > 0) {
|
|
1634
|
-
console.log(`\n明细表 (${detail.length}):`);
|
|
1635
|
-
for (const dt of detail) {
|
|
1636
|
-
console.log(` [明细表] ${dt.tableName} detailTableId=${dt.detailTableId}`);
|
|
1637
|
-
for (const f of dt.fields || []) {
|
|
1638
|
-
console.log(` ${f.id} ${f.showName} [${f.componentKey || f.type}] ${f.dataKey || ''}`);
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
else {
|
|
1645
|
-
console.error(`查询失败: ${data?.msg || '未知错误'}`);
|
|
1646
|
-
process.exit(1);
|
|
1647
|
-
}
|
|
1648
|
-
});
|
|
1649
100
|
actionCmd.command('disable')
|
|
1650
101
|
.description('禁用动作流(禁用后可删除)')
|
|
1651
102
|
.argument('<appId>', '动作流 appId')
|
|
@@ -1794,34 +245,4 @@ export function registerWorkflowActionCommands(wf, program) {
|
|
|
1794
245
|
}
|
|
1795
246
|
});
|
|
1796
247
|
}
|
|
1797
|
-
/**
|
|
1798
|
-
* 保存动作流的触发条件(source=19,sourceId=-1),返回 conditionKey。
|
|
1799
|
-
* 供 workflow action create --condition 使用:同一节点多个动作流各自挂条件,
|
|
1800
|
-
* 提交时按条件命中与否决定走哪个动作。
|
|
1801
|
-
*/
|
|
1802
|
-
async function saveActionCondition(client, baseUrl, workflowId, nodeName, conditionRules, relation, conditionName) {
|
|
1803
|
-
// 1. Fetch form fields(动作条件用 source=19)
|
|
1804
|
-
let formFields = [];
|
|
1805
|
-
try {
|
|
1806
|
-
const fbRes = await client.post(`${baseUrl}/api/workflow/pathdef/common/browser/complete/conditionFieldBrowser`, { browserMultiple: false, sourceId: '-1', tab: 'formField', source: 19, workflowId, newly: 1, searchValue: '' });
|
|
1807
|
-
formFields = fbRes?.data?.data || [];
|
|
1808
|
-
}
|
|
1809
|
-
catch { /* best effort */ }
|
|
1810
|
-
// 2. Parse rules → childrens(与链接条件同构)
|
|
1811
|
-
const { childrens, errors } = buildConditionChildrens(conditionRules, formFields);
|
|
1812
|
-
if (errors.length > 0) {
|
|
1813
|
-
throw new Error(`触发条件解析错误:\n${errors.map((e) => ` ❌ ${e}`).join('\n')}`);
|
|
1814
|
-
}
|
|
1815
|
-
if (childrens.length === 0) {
|
|
1816
|
-
throw new Error('至少需要一条有效的 --condition');
|
|
1817
|
-
}
|
|
1818
|
-
const name = conditionName || `${nodeName}-条件`;
|
|
1819
|
-
const relationNum = relation === 'OR' ? 2 : 1;
|
|
1820
|
-
// 3. saveCondition → conditionKey
|
|
1821
|
-
const saved = await saveWorkflowCondition(client, baseUrl, {
|
|
1822
|
-
workflowId, source: 19, sourceId: '-1', conditionName: name, childrens, relation: relationNum,
|
|
1823
|
-
});
|
|
1824
|
-
console.error(` 触发条件已保存: key=${saved.conditionKey} (${name})`);
|
|
1825
|
-
return saved.conditionKey;
|
|
1826
|
-
}
|
|
1827
248
|
//# sourceMappingURL=workflow-action.js.map
|