weaver-e10-builder 1.0.7-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 +872 -42
- 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 -1586
- 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 +111 -30
- package/dist/commands/workflow-create-workflow.js.map +1 -1
- package/dist/commands/workflow-node-robot.js +1 -1
- package/dist/commands/workflow-node-robot.js.map +1 -1
- package/dist/commands/workflow-node-validate.d.ts.map +1 -1
- package/dist/commands/workflow-node-validate.js +56 -45
- package/dist/commands/workflow-node-validate.js.map +1 -1
- package/dist/commands/workflow-numbering.d.ts.map +1 -1
- package/dist/commands/workflow-numbering.js +98 -2
- package/dist/commands/workflow-numbering.js.map +1 -1
- package/dist/commands/workflow-operator-sign.d.ts +3 -0
- package/dist/commands/workflow-operator-sign.d.ts.map +1 -0
- package/dist/commands/workflow-operator-sign.js +118 -0
- package/dist/commands/workflow-operator-sign.js.map +1 -0
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +83 -6
- package/dist/commands/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 +4 -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/dist/services/workflow-initiator.d.ts +15 -0
- package/dist/services/workflow-initiator.d.ts.map +1 -0
- package/dist/services/workflow-initiator.js +77 -0
- package/dist/services/workflow-initiator.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,999 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 动态赋值的字段引用、公式树与资源对象构造。
|
|
3
|
+
* 对齐 Python 版 core/formula_service.py(黄金参照)。
|
|
4
|
+
*/
|
|
5
|
+
import { genSfId } from './id_generator.js';
|
|
6
|
+
import { resolveSystemParameter } from './system_params.js';
|
|
7
|
+
import { getWorkflowContextFields, getWorkflowContextFieldsByKey, getWorkflowDetailNames, getTargetFormFields, findInMetadata, workflowFieldId, } from './runtime_metadata.js';
|
|
8
|
+
const SOURCE_COMPONENT_KEY_TO_PARAMTYPE = {
|
|
9
|
+
Text: 'string', TextArea: 'string', String: 'string', AutoSerial: 'string', Barcode: 'string',
|
|
10
|
+
Date: 'date', DateComponent: 'datetime', DateTimeComponent: 'datetime', DateTime: 'datetime', Time: 'string',
|
|
11
|
+
NumberComponent: 'number', Number: 'number', Calculation: 'number', Money: 'number', Rate: 'number', Formula: 'number',
|
|
12
|
+
Switch: 'boolean', Boolean: 'boolean',
|
|
13
|
+
RadioBox: 'string', Checkbox: 'string', Select: 'string', MultiSelect: 'string', Radio: 'string',
|
|
14
|
+
Employee: 'string', Department: 'string', SubCompany: 'string', Position: 'string', Role: 'string', Group: 'string',
|
|
15
|
+
Ebuilder: 'string', RelateBrowser: 'string', Browser: 'string', Connect: 'string', Area: 'string', Folder: 'string',
|
|
16
|
+
File: 'string', Image: 'string', Attachment: 'string',
|
|
17
|
+
Summary: 'number', CrossStatement: 'number',
|
|
18
|
+
};
|
|
19
|
+
const VALUE_TYPE_ALIASES = {
|
|
20
|
+
text: 'Text', string: 'Text', Text: 'Text',
|
|
21
|
+
integer: 'Number', int: 'Number', Number: 'Number',
|
|
22
|
+
long: 'Number', float: 'Number', double: 'Number',
|
|
23
|
+
decimal: 'Number', number: 'Number',
|
|
24
|
+
boolean: 'Boolean', bool: 'Boolean', Boolean: 'Boolean',
|
|
25
|
+
date: 'Date', Date: 'Date', time: 'Time', Time: 'Time',
|
|
26
|
+
datetime: 'DateTime', DateTime: 'DateTime',
|
|
27
|
+
};
|
|
28
|
+
// ── 字段解析 ────────────────────────────────────────────────
|
|
29
|
+
export function resolveSourceFieldType(paramKey, meta) {
|
|
30
|
+
if (!paramKey)
|
|
31
|
+
return 'string';
|
|
32
|
+
const pk = String(paramKey);
|
|
33
|
+
const parts = pk.lastIndexOf('.') >= 0 ? [pk.slice(0, pk.lastIndexOf('.')), pk.slice(pk.lastIndexOf('.') + 1)] : [pk];
|
|
34
|
+
if (parts.length !== 2)
|
|
35
|
+
return pk.trimEnd().endsWith('[]') ? 'json' : 'string';
|
|
36
|
+
const head = parts[0];
|
|
37
|
+
const tail = parts[1].replace(/\[\]$/, '');
|
|
38
|
+
if (!tail)
|
|
39
|
+
return pk.trimEnd().endsWith('[]') ? 'json' : 'string';
|
|
40
|
+
const fieldId = String(tail);
|
|
41
|
+
if (!meta || typeof meta !== 'object')
|
|
42
|
+
return pk.trimEnd().endsWith('[]') ? 'json' : 'string';
|
|
43
|
+
const formId = String(meta._workflow_id || meta._event_form_id || '');
|
|
44
|
+
if (!formId)
|
|
45
|
+
return pk.trimEnd().endsWith('[]') ? 'json' : 'string';
|
|
46
|
+
const ctxFields = getWorkflowContextFields()[formId] || {};
|
|
47
|
+
const ctxByKey = getWorkflowContextFieldsByKey()[formId] || {};
|
|
48
|
+
const exactField = ctxByKey[pk];
|
|
49
|
+
if (exactField && typeof exactField === 'object') {
|
|
50
|
+
const exactType = String(exactField.paramType || exactField.paramTypeString || '');
|
|
51
|
+
if (exactType && exactType !== 'None')
|
|
52
|
+
return exactType === exactType.toUpperCase() ? exactType.toLowerCase() : exactType;
|
|
53
|
+
}
|
|
54
|
+
for (const f of Object.values(ctxFields)) {
|
|
55
|
+
if (!f || typeof f !== 'object')
|
|
56
|
+
continue;
|
|
57
|
+
const fpk = String(f.paramKey || '');
|
|
58
|
+
const ftail = fpk.includes('.') ? fpk.slice(fpk.lastIndexOf('.') + 1).replace(/\[\]$/, '') : fpk.replace(/\[\]$/, '');
|
|
59
|
+
if (ftail !== fieldId)
|
|
60
|
+
continue;
|
|
61
|
+
const pt = String(f.paramType || f.paramTypeString || '');
|
|
62
|
+
if (pt && pt !== 'None')
|
|
63
|
+
return pt === pt.toUpperCase() ? pt.toLowerCase() : pt;
|
|
64
|
+
}
|
|
65
|
+
const fieldMeta = getTargetFormFields()[formId]?.[fieldId];
|
|
66
|
+
if (fieldMeta && typeof fieldMeta === 'object') {
|
|
67
|
+
const ck = String(fieldMeta.componentKey || fieldMeta.type || '');
|
|
68
|
+
if (ck && SOURCE_COMPONENT_KEY_TO_PARAMTYPE[ck])
|
|
69
|
+
return SOURCE_COMPONENT_KEY_TO_PARAMTYPE[ck];
|
|
70
|
+
}
|
|
71
|
+
return pk.trimEnd().endsWith('[]') ? 'json' : 'string';
|
|
72
|
+
}
|
|
73
|
+
const SYSTEM_FIELD_LABELS = {
|
|
74
|
+
id: '数据ID', name: '数据名称', creator: '创建者', createTime: '创建时间',
|
|
75
|
+
lastUpdateTime: '最后更新时间', lastUpdateUser: '最后更新人',
|
|
76
|
+
};
|
|
77
|
+
export function resolveSourceFieldLabel(paramKey, meta, fallback = '') {
|
|
78
|
+
if (!meta || typeof meta !== 'object')
|
|
79
|
+
return String(fallback || paramKey);
|
|
80
|
+
const pk = String(paramKey || '');
|
|
81
|
+
const tail = pk.includes('.') ? pk.slice(pk.lastIndexOf('.') + 1).replace(/\[\]$/, '') : pk.replace(/\[\]$/, '');
|
|
82
|
+
const formId = String(meta._workflow_id || meta._event_form_id || '');
|
|
83
|
+
if (formId) {
|
|
84
|
+
const exactField = getWorkflowContextFieldsByKey()[formId]?.[pk];
|
|
85
|
+
if (exactField && typeof exactField === 'object') {
|
|
86
|
+
const label = exactField.showName || exactField.paramName || exactField.content || exactField.name;
|
|
87
|
+
if (label)
|
|
88
|
+
return String(label);
|
|
89
|
+
}
|
|
90
|
+
for (const field of Object.values(getWorkflowContextFields()[formId] || {})) {
|
|
91
|
+
if (!field || typeof field !== 'object')
|
|
92
|
+
continue;
|
|
93
|
+
const fieldPk = String(field.paramKey || '');
|
|
94
|
+
const ftail = fieldPk.includes('.') ? fieldPk.slice(fieldPk.lastIndexOf('.') + 1).replace(/\[\]$/, '') : fieldPk.replace(/\[\]$/, '');
|
|
95
|
+
if (fieldPk === pk || ftail === tail) {
|
|
96
|
+
const label = field.showName || field.paramName || field.content || field.name;
|
|
97
|
+
if (label)
|
|
98
|
+
return String(label);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const field = getTargetFormFields()[formId]?.[tail];
|
|
102
|
+
if (field && typeof field === 'object') {
|
|
103
|
+
const label = field.showName || field.name || field.label || field.content;
|
|
104
|
+
if (label)
|
|
105
|
+
return String(label);
|
|
106
|
+
}
|
|
107
|
+
const sysLabel = SYSTEM_FIELD_LABELS[tail];
|
|
108
|
+
if (sysLabel)
|
|
109
|
+
return sysLabel;
|
|
110
|
+
}
|
|
111
|
+
return String(fallback || paramKey);
|
|
112
|
+
}
|
|
113
|
+
const SYSTEM_ALIASES = {
|
|
114
|
+
id: '数据ID', name: '标题', creator: '创建者', create_time: '创建时间',
|
|
115
|
+
update_time: '最后更新时间', updater: '最后更新人', data_status: '数据状态',
|
|
116
|
+
};
|
|
117
|
+
export function resolveParamKey(workflowId, key) {
|
|
118
|
+
if (!key)
|
|
119
|
+
return key;
|
|
120
|
+
const keyStr = String(key);
|
|
121
|
+
if (keyStr.startsWith('dataResponse.') || keyStr.includes('.dataResponse.'))
|
|
122
|
+
return keyStr;
|
|
123
|
+
if (workflowId && keyStr.includes('.')) {
|
|
124
|
+
const idx = keyStr.lastIndexOf('.');
|
|
125
|
+
const head = keyStr.slice(0, idx);
|
|
126
|
+
const tail = keyStr.slice(idx + 1);
|
|
127
|
+
const label = SYSTEM_ALIASES[tail.replace(/\[\]$/, '')];
|
|
128
|
+
if (head === String(workflowId) && label) {
|
|
129
|
+
for (const field of Object.values(getWorkflowContextFields()[String(workflowId)] || {})) {
|
|
130
|
+
if (!field || typeof field !== 'object')
|
|
131
|
+
continue;
|
|
132
|
+
if (String(field.showName || field.name || '') !== label)
|
|
133
|
+
continue;
|
|
134
|
+
const resolved = String(field.paramKey || '');
|
|
135
|
+
if (resolved)
|
|
136
|
+
return resolved;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const fieldId = workflowFieldId(String(workflowId), keyStr);
|
|
141
|
+
if (workflowId && fieldId && fieldId !== keyStr)
|
|
142
|
+
return `${workflowId}.${fieldId}`;
|
|
143
|
+
return keyStr;
|
|
144
|
+
}
|
|
145
|
+
// ── Formula 对象生成器 ───────────────────────────────────────
|
|
146
|
+
function makeConfigStr(config) {
|
|
147
|
+
return JSON.stringify(config);
|
|
148
|
+
}
|
|
149
|
+
export function formulaFixed(value, fieldType = 'string') {
|
|
150
|
+
const fid = genSfId();
|
|
151
|
+
return {
|
|
152
|
+
configObject: { paramType: fieldType, switchType: 'fixvalue' },
|
|
153
|
+
formulaType: fieldType,
|
|
154
|
+
name: String(value),
|
|
155
|
+
id: fid,
|
|
156
|
+
type: '1',
|
|
157
|
+
value: String(value),
|
|
158
|
+
childs: [],
|
|
159
|
+
config: makeConfigStr({ originValue: value, switchType: 'fixvalue', formulaVersion: 'V1' }),
|
|
160
|
+
sortWeight: 0.0,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export function formulaFixedForAssignSwitch(value, fieldType = 'string') {
|
|
164
|
+
const bean = formulaFixed(value, fieldType);
|
|
165
|
+
bean.fieldType = fieldType;
|
|
166
|
+
bean.config = { originValue: value, switchType: 'fixvalue', formulaVersion: 'V1' };
|
|
167
|
+
return bean;
|
|
168
|
+
}
|
|
169
|
+
export function ftNorm(fieldType) {
|
|
170
|
+
return {
|
|
171
|
+
Text: 'string', String: 'string', string: 'string',
|
|
172
|
+
Number: 'number', NumberComponent: 'number', number: 'number',
|
|
173
|
+
DateComponent: 'date', Date: 'date', date: 'date',
|
|
174
|
+
DateTime: 'datetime', datetime: 'datetime',
|
|
175
|
+
}[fieldType] ?? (fieldType || 'string');
|
|
176
|
+
}
|
|
177
|
+
export function formulaContext(sourceComponentId, fieldKey, opts = {}) {
|
|
178
|
+
const fid = genSfId();
|
|
179
|
+
const sourceId = String(sourceComponentId || '0');
|
|
180
|
+
const fieldName = String(opts.name || fieldKey);
|
|
181
|
+
const componentType = opts.componentType || 'ApproveTrigger';
|
|
182
|
+
const fieldType = opts.fieldType || 'string';
|
|
183
|
+
return {
|
|
184
|
+
formulaType: ftNorm(fieldType),
|
|
185
|
+
name: fieldName,
|
|
186
|
+
businessId: String(opts.businessId || '0'),
|
|
187
|
+
id: fid,
|
|
188
|
+
source: sourceId,
|
|
189
|
+
type: '3',
|
|
190
|
+
value: `FormData.${fieldKey}`,
|
|
191
|
+
frontId: String(fieldKey),
|
|
192
|
+
paramKey: String(fieldKey),
|
|
193
|
+
paramType: fieldType,
|
|
194
|
+
childs: [],
|
|
195
|
+
config: makeConfigStr({
|
|
196
|
+
paramKey: String(fieldKey),
|
|
197
|
+
paramType: fieldType,
|
|
198
|
+
parentName: fieldName,
|
|
199
|
+
newParentName: fieldName,
|
|
200
|
+
multKey: '',
|
|
201
|
+
multName: '',
|
|
202
|
+
multTypeObj: {
|
|
203
|
+
allName: fieldName, currentName: fieldName,
|
|
204
|
+
currentParamKey: `FormData.${fieldKey}`, allParamKey: `FormData.${fieldKey}`,
|
|
205
|
+
},
|
|
206
|
+
comId: sourceId,
|
|
207
|
+
isMultCom: Boolean(opts.isMult),
|
|
208
|
+
tableName: '表单数据',
|
|
209
|
+
fieldInfo: { paramKey: String(fieldKey), tablePrimaryKey: 'FormData' },
|
|
210
|
+
comType: componentType,
|
|
211
|
+
parentComId: String(opts.parentComId || '0'),
|
|
212
|
+
switchType: 'assign',
|
|
213
|
+
formulaVersion: 'V1',
|
|
214
|
+
}),
|
|
215
|
+
sortWeight: 0.0,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* 多次执行组件的“当次循环”上下文。它不是 FormData:平台返回的是 CycleParams,
|
|
220
|
+
* 前端也依赖 comType/isMultCom 来显示“循环(当次循环)”。
|
|
221
|
+
*/
|
|
222
|
+
export function formulaCurrentLoopContext(sourceComponentId, fieldKey, opts = {}) {
|
|
223
|
+
const fid = genSfId();
|
|
224
|
+
const sourceId = String(sourceComponentId || '0');
|
|
225
|
+
const fieldName = String(opts.name || fieldKey);
|
|
226
|
+
const fieldType = opts.fieldType || 'int';
|
|
227
|
+
const primaryKey = 'CycleParams';
|
|
228
|
+
const valuePath = `${primaryKey}.${fieldKey}`;
|
|
229
|
+
const parentName = String(opts.parentName || `循环.${fieldName}`);
|
|
230
|
+
const rawField = opts.rawField && typeof opts.rawField === 'object' ? opts.rawField : {};
|
|
231
|
+
const renderedFieldType = ['int', 'integer', 'long', 'double', 'number'].includes(String(fieldType).toLowerCase()) ? 'number' : ftNorm(fieldType);
|
|
232
|
+
return {
|
|
233
|
+
// 保留 getComponentContext 的原始字段信息;编辑器用这些字段回显参数路径。
|
|
234
|
+
...rawField,
|
|
235
|
+
formulaType: ftNorm(fieldType), name: fieldName, businessId: String(opts.businessId || '0'),
|
|
236
|
+
// 前端在点击“循环(当次循环)”时额外生成 assignId,用它区分每个
|
|
237
|
+
// 当次循环引用;缺少时编辑器只显示类型,不能回显所属组件和参数路径。
|
|
238
|
+
assignId: genSfId(), id: fid, source: sourceId, type: '3', value: valuePath,
|
|
239
|
+
frontId: String(opts.frontId || rawField.id || rawField.paramId || fieldKey),
|
|
240
|
+
paramId: String(rawField.paramId || opts.frontId || rawField.id || fieldKey),
|
|
241
|
+
paramName: String(rawField.paramName || fieldName),
|
|
242
|
+
showName: String(rawField.showName || fieldName),
|
|
243
|
+
parentName, paramKey: String(fieldKey), paramType: fieldType, fieldType: renderedFieldType,
|
|
244
|
+
childs: [],
|
|
245
|
+
config: {
|
|
246
|
+
// 这是赋值目标的类型(消息标题/内容为 string),与来源字段 paramType 分开。
|
|
247
|
+
paramKey: String(fieldKey), paramType: String(opts.targetFieldType || 'string'),
|
|
248
|
+
parentName, newParentName: parentName,
|
|
249
|
+
multKey: '', multName: '',
|
|
250
|
+
multTypeObj: { allName: parentName, currentName: parentName, currentParamKey: valuePath, allParamKey: valuePath },
|
|
251
|
+
comId: sourceId, isMultCom: true, tableName: '循环参数',
|
|
252
|
+
fieldInfo: { paramKey: String(fieldKey), tablePrimaryKey: primaryKey },
|
|
253
|
+
comType: 'MultipleExecution', parentComId: '0',
|
|
254
|
+
},
|
|
255
|
+
sortWeight: 0.0,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
export function formulaSystemVar(varName = '{userid}') {
|
|
259
|
+
const resolved = resolveSystemParameter(varName);
|
|
260
|
+
const fid = genSfId();
|
|
261
|
+
return {
|
|
262
|
+
configObject: { paramType: 'string' },
|
|
263
|
+
formulaType: 'string',
|
|
264
|
+
name: resolved,
|
|
265
|
+
id: fid,
|
|
266
|
+
type: '9',
|
|
267
|
+
value: resolved,
|
|
268
|
+
childs: [],
|
|
269
|
+
config: makeConfigStr({ paramType: 'string', formulaVersion: 'V1' }),
|
|
270
|
+
sortWeight: 0.0,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
export function formulaContainerString(childFormulas, valuePlaceholder = '', appId = '') {
|
|
274
|
+
const fid = genSfId();
|
|
275
|
+
// 设计器按 position 而不是 FormulaBean.id 还原富文本/模板片段。手工编辑后
|
|
276
|
+
// 会把 textarea 的占位符替换成这一串 position;生成时就应直接使用同一协议。
|
|
277
|
+
const positions = [];
|
|
278
|
+
for (const c of childFormulas) {
|
|
279
|
+
c.parentId = fid;
|
|
280
|
+
c.position ??= genSfId();
|
|
281
|
+
positions.push(String(c.position));
|
|
282
|
+
}
|
|
283
|
+
const requiresEditorConfig = childFormulas.some((child) => child?.config && typeof child.config === 'object' && child.config.isMultCom === true);
|
|
284
|
+
const config = { paramType: 'string', switchType: 'assign', formulaVersion: 'V1' };
|
|
285
|
+
return {
|
|
286
|
+
configObject: { paramType: 'string', switchType: 'assign' },
|
|
287
|
+
formulaType: 'string',
|
|
288
|
+
name: '',
|
|
289
|
+
id: fid,
|
|
290
|
+
type: '8',
|
|
291
|
+
applicationId: appId,
|
|
292
|
+
value: valuePlaceholder || `textarea#${positions.join('#')}#`,
|
|
293
|
+
childs: childFormulas,
|
|
294
|
+
// 循环当次引用由设计器以对象 config 回显;普通 FormulaBean 仍保留历史字符串格式。
|
|
295
|
+
config: requiresEditorConfig ? { paramType: 'string', switchType: 'assign' } : makeConfigStr(config),
|
|
296
|
+
parentId: 0,
|
|
297
|
+
sortWeight: 0.0,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
export function buildPersonObject(personId, personName) {
|
|
301
|
+
const pid = String(personId);
|
|
302
|
+
const pname = String(personName || pid);
|
|
303
|
+
return {
|
|
304
|
+
templateType: 'default', stopDepartment: false, departmentId: '', mobile: '', pid: '',
|
|
305
|
+
avatar: { name: pname, appPreviewPath: '/api/app/file/preview?type=redirect&fileId=', previewPath: '/api/file/preview?type=redirect&fileId=', userId: pid },
|
|
306
|
+
title: pname, contentDesc: pname, leaf: true, userid: pid, isLeaf: true, content: pname,
|
|
307
|
+
name: pname, id: pid, position: '', department: '', mainId: pid, cid: '', statusCode: 'normal',
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
export function buildShareList(receiver, meta, appId = '', eventId = '') {
|
|
311
|
+
if (!receiver || typeof receiver !== 'object')
|
|
312
|
+
return [];
|
|
313
|
+
const objType = String(receiver.type || 'user');
|
|
314
|
+
if (objType === 'context' || objType === 'user_reference') {
|
|
315
|
+
const key = String(receiver.key || receiver.paramKey || receiver.id || '');
|
|
316
|
+
if (!key)
|
|
317
|
+
return [];
|
|
318
|
+
const label = String(receiver.label || receiver.name || key);
|
|
319
|
+
// 接收人同样属于动态赋值:必须保留真实触发组件、字段 id 和参数路径,
|
|
320
|
+
// 不能复用默认 ApproveTrigger 壳,否则定时/表单触发器会在设计器中被误判。
|
|
321
|
+
const objIdFormula = buildAssignBean({ kind: 'context', paramKey: key, label }, key, 'string', meta, appId, String(eventId || genSfId()));
|
|
322
|
+
return [{
|
|
323
|
+
sourceId: String(eventId || genSfId()), permissionId: 'esb', permissionType: 1, objType: 'resource',
|
|
324
|
+
user_type: '1', targetId: key, sourceType: 1, targetType: 1, id: genSfId(), obj_id: objIdFormula,
|
|
325
|
+
}];
|
|
326
|
+
}
|
|
327
|
+
const objtypeForDesigner = objType === 'user' ? 'resource' : objType;
|
|
328
|
+
if (objType === 'all' || objType === 'allExternal') {
|
|
329
|
+
return [{
|
|
330
|
+
sourceId: String(eventId || genSfId()), permissionId: 'esb', permissionType: 1,
|
|
331
|
+
objType: objtypeForDesigner, sourceType: 1, targetType: 1, id: genSfId(),
|
|
332
|
+
}];
|
|
333
|
+
}
|
|
334
|
+
const valueField = objType === 'user' ? 'obj_id' : `obj_id_${objType}`;
|
|
335
|
+
let persons = receiver.persons;
|
|
336
|
+
if (!Array.isArray(persons)) {
|
|
337
|
+
const pid = String(receiver.id ?? '').trim();
|
|
338
|
+
const pname = String(receiver.name ?? receiver.label ?? '').trim();
|
|
339
|
+
persons = pid ? [{ id: pid, name: pname }] : [];
|
|
340
|
+
}
|
|
341
|
+
if (!persons.length)
|
|
342
|
+
return [];
|
|
343
|
+
const userType = String(receiver.userType || '1');
|
|
344
|
+
let seclevel = receiver.seclevel;
|
|
345
|
+
if (Array.isArray(seclevel) && seclevel.length === 2)
|
|
346
|
+
seclevel = { min: parseInt(String(seclevel[0]), 10), max: parseInt(String(seclevel[1]), 10) };
|
|
347
|
+
const roleLevel = objType === 'role' ? String(receiver.roleLevel || '') : '';
|
|
348
|
+
const positionLevel = objType === 'position' ? String(receiver.positionLevel || '') : '';
|
|
349
|
+
const positionLevelSubcompany = objType === 'position' ? receiver.positionLevelSubcompany : null;
|
|
350
|
+
const positionLevelDepartment = objType === 'position' ? receiver.positionLevelDepartment : null;
|
|
351
|
+
const positionAttribute = objType === 'position' ? receiver.positionAttribute : null;
|
|
352
|
+
const departmentAttribute = objType === 'department' || objType === 'subcompany' ? receiver.departmentAttribute : null;
|
|
353
|
+
const shareList = [];
|
|
354
|
+
for (const p of persons) {
|
|
355
|
+
const pid = String(p.id ?? '').trim();
|
|
356
|
+
const pname = String(p.name ?? p.label ?? pid).trim();
|
|
357
|
+
if (!pid)
|
|
358
|
+
continue;
|
|
359
|
+
const personObj = buildPersonObject(pid, pname);
|
|
360
|
+
const objIdFormula = {
|
|
361
|
+
formulaType: 'string', name: pid, id: genSfId(), position: genSfId(), type: '1',
|
|
362
|
+
applicationId: String(appId), value: pid, fieldType: 'string',
|
|
363
|
+
config: { switchType: 'fixvalue', originValue: [personObj] },
|
|
364
|
+
};
|
|
365
|
+
const entry = {
|
|
366
|
+
sourceId: String(eventId || genSfId()), permissionId: 'esb', permissionType: 1,
|
|
367
|
+
objType: objtypeForDesigner, targetId: pid, sourceType: 1, targetType: 1, id: genSfId(),
|
|
368
|
+
};
|
|
369
|
+
if (objType === 'user')
|
|
370
|
+
entry.user_type = userType;
|
|
371
|
+
entry[valueField] = objIdFormula;
|
|
372
|
+
if (seclevel && typeof seclevel === 'object')
|
|
373
|
+
entry.seclevel = seclevel;
|
|
374
|
+
if (roleLevel)
|
|
375
|
+
entry.role_level = roleLevel;
|
|
376
|
+
if (positionLevel)
|
|
377
|
+
entry.position_level = positionLevel;
|
|
378
|
+
if (Array.isArray(positionLevelSubcompany) && positionLevelSubcompany.length)
|
|
379
|
+
entry.position_level_subcompany = positionLevelSubcompany;
|
|
380
|
+
if (Array.isArray(positionLevelDepartment) && positionLevelDepartment.length)
|
|
381
|
+
entry.position_level_department = positionLevelDepartment;
|
|
382
|
+
if (Array.isArray(positionAttribute) && positionAttribute.length)
|
|
383
|
+
entry.position_attribute = positionAttribute;
|
|
384
|
+
if (Array.isArray(departmentAttribute) && departmentAttribute.length)
|
|
385
|
+
entry.department_attribute = departmentAttribute;
|
|
386
|
+
shareList.push(entry);
|
|
387
|
+
}
|
|
388
|
+
return shareList;
|
|
389
|
+
}
|
|
390
|
+
export function buildPersonFormula(personRef, meta, appId = '', forSendMessage = false, directPerson = false) {
|
|
391
|
+
const person = findInMetadata(meta, 'persons', personRef);
|
|
392
|
+
const ptype = person ? (person.type ?? personRef.type ?? 'role') : (personRef.type ?? 'role');
|
|
393
|
+
const pid = personRef.id ?? '';
|
|
394
|
+
if (forSendMessage) {
|
|
395
|
+
if (ptype === 'role')
|
|
396
|
+
return formulaSystemVar('{userid}');
|
|
397
|
+
if (ptype === 'context' || ptype === 'user_reference') {
|
|
398
|
+
const ckey = String(personRef.key || personRef.paramKey || pid || '');
|
|
399
|
+
return buildAssignBean({ kind: 'context', paramKey: ckey, label: String(personRef.label || personRef.name || ckey) }, ckey, 'string', meta, appId);
|
|
400
|
+
}
|
|
401
|
+
return formulaFixed(pid || personRef.name || '');
|
|
402
|
+
}
|
|
403
|
+
if (directPerson) {
|
|
404
|
+
if (ptype === 'context')
|
|
405
|
+
return formulaContext('', pid);
|
|
406
|
+
const pname = String(personRef.name || personRef.label || '');
|
|
407
|
+
if (pid && pname && pid !== '{userid}' && pid !== 'currentUser') {
|
|
408
|
+
const personObj = buildPersonObject(pid, pname);
|
|
409
|
+
return {
|
|
410
|
+
formulaType: 'string', name: pid, businessId: genSfId(), id: genSfId(), position: genSfId(),
|
|
411
|
+
type: '1', applicationId: String(appId), value: pid, fieldType: 'string', childs: [],
|
|
412
|
+
config: { switchType: 'fixvalue', originValue: [personObj], formulaVersion: 'V1' },
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
return {
|
|
416
|
+
formulaType: 'string', name: '{userid}', businessId: genSfId(), id: genSfId(), position: genSfId(),
|
|
417
|
+
type: '9', value: '{userid}', childs: [],
|
|
418
|
+
config: { paramType: 'string', formulaVersion: 'V1' },
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
let child;
|
|
422
|
+
if (ptype === 'context') {
|
|
423
|
+
const ckey = String(personRef.key || personRef.paramKey || pid || '');
|
|
424
|
+
const src = String(meta._upstream_w_id || '');
|
|
425
|
+
const wfId = String(meta._workflow_id || '');
|
|
426
|
+
const pk = resolveParamKey(wfId, ckey);
|
|
427
|
+
const ft = resolveSourceFieldType(pk, meta);
|
|
428
|
+
const disp = String(personRef.label || personRef.name || ckey);
|
|
429
|
+
let pname = String(meta._upstream_workflow_name || '');
|
|
430
|
+
if (!pname)
|
|
431
|
+
pname = String(meta._upstream_form_name || '');
|
|
432
|
+
const full = pname ? `${pname}.${disp}` : `表单数据.${disp}`;
|
|
433
|
+
child = assignFlatContextDirect(pk, disp, src, appId, ft, full, meta);
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
child = formulaSystemVar('{userid}');
|
|
437
|
+
child.position = genSfId();
|
|
438
|
+
child.configObject.paramType = 'string';
|
|
439
|
+
child.config = makeConfigStr({ paramType: 'string' });
|
|
440
|
+
}
|
|
441
|
+
return formulaContainerString([child], '', appId);
|
|
442
|
+
}
|
|
443
|
+
export function formulaConstant(constantId, name = '', fieldType = 'string', appId = '') {
|
|
444
|
+
const fid = genSfId();
|
|
445
|
+
const ft = ftNorm(fieldType);
|
|
446
|
+
return {
|
|
447
|
+
configObject: { paramType: ft, switchType: 'assign' },
|
|
448
|
+
formulaType: ft, name, id: fid, type: '5', applicationId: appId,
|
|
449
|
+
value: String(constantId), childs: [],
|
|
450
|
+
config: makeConfigStr({ paramType: ft, switchType: 'assign', formulaVersion: 'V1' }),
|
|
451
|
+
parentId: 0, sortWeight: 0.0,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
export function formulaTransform(ruleId, name = '', fieldType = 'string', appId = '') {
|
|
455
|
+
const fid = genSfId();
|
|
456
|
+
const ft = ftNorm(fieldType);
|
|
457
|
+
return {
|
|
458
|
+
configObject: { paramType: ft, switchType: 'assign' },
|
|
459
|
+
formulaType: ft, name, id: fid, type: '4', applicationId: appId,
|
|
460
|
+
value: String(ruleId), childs: [],
|
|
461
|
+
config: makeConfigStr({ paramType: ft, switchType: 'assign', formulaVersion: 'V1' }),
|
|
462
|
+
parentId: 0, sortWeight: 0.0,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
const FORMULA_FN_MAP = {
|
|
466
|
+
add: { fnId: '682682659616530901', name: '+', clazz: 'com.weaver.common.formula.core.function.aggregate.Addition', functionType: 'operation' },
|
|
467
|
+
sub: { fnId: '682682659616530902', name: '−', clazz: 'com.weaver.common.formula.core.function.aggregate.Subtraction', functionType: 'operation' },
|
|
468
|
+
mul: { fnId: '682682659616530903', name: '×', clazz: 'com.weaver.common.formula.core.function.aggregate.Multiplication', functionType: 'operation' },
|
|
469
|
+
div: { fnId: '682682659616530904', name: '÷', clazz: 'com.weaver.common.formula.core.function.aggregate.Division', functionType: 'operation' },
|
|
470
|
+
};
|
|
471
|
+
export function getFormulaFn(op) {
|
|
472
|
+
return FORMULA_FN_MAP[String(op).toLowerCase()] ?? FORMULA_FN_MAP.add;
|
|
473
|
+
}
|
|
474
|
+
export function formulaFunction(funcId, name, childs, fieldType = 'string', excelFunc = null, functionType = null, detail = null, appId = '') {
|
|
475
|
+
const fid = genSfId();
|
|
476
|
+
const ft = ftNorm(fieldType);
|
|
477
|
+
const childIds = childs.filter((c) => c && typeof c === 'object').map((c) => String(c.id));
|
|
478
|
+
const value = `${funcId}#${childIds.join('#')}#`;
|
|
479
|
+
const config = {
|
|
480
|
+
paramType: ft,
|
|
481
|
+
originId: String(funcId),
|
|
482
|
+
paramSize: String(childs.length),
|
|
483
|
+
excelFunc: excelFunc || { formatString: name, type: 'function', name, validForm: 'current_data', paramCount: childs.length, paramArray: [], paramData: [], returnType: ft },
|
|
484
|
+
functionType: functionType || ft,
|
|
485
|
+
detail: detail || [],
|
|
486
|
+
formulaVersion: 'V1',
|
|
487
|
+
};
|
|
488
|
+
return {
|
|
489
|
+
configObject: { paramType: ft, switchType: 'assign' },
|
|
490
|
+
formulaType: ft, name, id: fid, detail: detail || [], type: '6', applicationId: appId,
|
|
491
|
+
value, childs, config: makeConfigStr(config), parentId: 0, sortWeight: 0.0,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
export function buildAssignBean(raw, fieldId, fieldType, meta, appId, defaultSourceId = '') {
|
|
495
|
+
if (!meta || typeof meta !== 'object')
|
|
496
|
+
meta = {};
|
|
497
|
+
const rawValue = raw && typeof raw === 'object' ? (raw.value ?? raw) : raw;
|
|
498
|
+
let ref;
|
|
499
|
+
if (raw && typeof raw === 'object' && ('kind' in raw || 'assignmentKind' in raw))
|
|
500
|
+
ref = raw;
|
|
501
|
+
else if (rawValue && typeof rawValue === 'object')
|
|
502
|
+
ref = rawValue;
|
|
503
|
+
else
|
|
504
|
+
ref = raw;
|
|
505
|
+
const kind = ref && typeof ref === 'object' ? (ref.kind || ref.assignmentKind || ref.type) : null;
|
|
506
|
+
if (kind === 'context' || (ref && typeof ref === 'object' && 'sourceRef' in ref)) {
|
|
507
|
+
const src = ref && typeof ref === 'object' ? (ref.sourceRef ?? ref) : ref;
|
|
508
|
+
let key = '';
|
|
509
|
+
if (src && typeof src === 'object')
|
|
510
|
+
key = src.key || src.paramKey || src.fieldKey || '';
|
|
511
|
+
if (!key)
|
|
512
|
+
key = fieldId;
|
|
513
|
+
let sourceId = src && typeof src === 'object' ? (src.comId ?? src.source ?? '') : '';
|
|
514
|
+
if (['', 'event', 'event_1', 'trigger'].includes(String(sourceId)))
|
|
515
|
+
sourceId = defaultSourceId;
|
|
516
|
+
const label = src && typeof src === 'object' ? (src.label ?? src.name ?? key) : key;
|
|
517
|
+
const isCurrentLoop = src && typeof src === 'object' && (String(src.scope ?? src.contextScope ?? '') === 'current_loop' ||
|
|
518
|
+
String(src.componentType ?? '') === 'MultipleExecution');
|
|
519
|
+
if (isCurrentLoop) {
|
|
520
|
+
if (!sourceId)
|
|
521
|
+
throw new Error('[context] 当次循环引用缺少所属循环 source');
|
|
522
|
+
const resolved = src._resolvedContext && typeof src._resolvedContext === 'object' ? src._resolvedContext : {};
|
|
523
|
+
return formulaCurrentLoopContext(String(sourceId), String(key), {
|
|
524
|
+
name: String(resolved.label ?? label), businessId: appId,
|
|
525
|
+
fieldType: String(resolved.fieldType ?? src.fieldType ?? src.valueType ?? 'int'),
|
|
526
|
+
frontId: String(resolved.fieldId ?? src.frontId ?? key),
|
|
527
|
+
parentName: String(resolved.parentName ?? `循环.${resolved.label ?? label}`),
|
|
528
|
+
rawField: resolved.rawField,
|
|
529
|
+
targetFieldType: fieldType,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
const wfId = String(meta._workflow_id || '');
|
|
533
|
+
const resolvedKey = resolveParamKey(wfId, String(key));
|
|
534
|
+
// 不能用 formulaContext 的默认 ApproveTrigger 壳:定时/表单/日期触发器的
|
|
535
|
+
// 动态文本会因此在设计器中只显示固定前缀。这里统一生成带真实来源组件、
|
|
536
|
+
// frontId 和 paramKey 的上下文 FormulaBean。
|
|
537
|
+
const sourceFieldType = resolveSourceFieldType(resolvedKey, meta) || String(src.fieldType || src.valueType || 'string');
|
|
538
|
+
let sourceName = String(meta._upstream_workflow_name || meta._upstream_form_name || '');
|
|
539
|
+
const parentName = sourceName ? `${sourceName}.${String(label)}` : `表单数据.${String(label)}`;
|
|
540
|
+
const contextBean = assignFlatContextDirect(resolvedKey, String(label), String(sourceId), appId, sourceFieldType, parentName, meta);
|
|
541
|
+
attachEsbAssign(contextBean, meta, String(sourceId));
|
|
542
|
+
return contextBean;
|
|
543
|
+
}
|
|
544
|
+
if (kind === 'system_variable') {
|
|
545
|
+
const key = ref && typeof ref === 'object' ? (ref.key ?? '{userid}') : '{userid}';
|
|
546
|
+
return formulaSystemVar(key);
|
|
547
|
+
}
|
|
548
|
+
if (kind === 'constant') {
|
|
549
|
+
const cid = ref && typeof ref === 'object' ? (ref.id || ref.key) : null;
|
|
550
|
+
if (!cid)
|
|
551
|
+
throw new Error(`[constant] 缺少已解析的常量 id; ref=${JSON.stringify(ref)}`);
|
|
552
|
+
return formulaConstant(cid, ref?.name ?? '', fieldType, appId);
|
|
553
|
+
}
|
|
554
|
+
if (kind === 'transform') {
|
|
555
|
+
const rid = ref && typeof ref === 'object' ? (ref.id || ref.key) : null;
|
|
556
|
+
if (!rid)
|
|
557
|
+
throw new Error(`[transform] 缺少已解析的转换规则 id; ref=${JSON.stringify(ref)}`);
|
|
558
|
+
return formulaTransform(rid, ref?.name ?? '', fieldType, appId);
|
|
559
|
+
}
|
|
560
|
+
if (kind === 'formula') {
|
|
561
|
+
const fId = ref && typeof ref === 'object' ? ref.id : null;
|
|
562
|
+
if (!fId)
|
|
563
|
+
throw new Error(`[formula] 缺少已解析的函数 id; ref=${JSON.stringify(ref)}`);
|
|
564
|
+
const childs = [];
|
|
565
|
+
for (const arg of (ref?.arguments ?? [])) {
|
|
566
|
+
if (arg && typeof arg === 'object')
|
|
567
|
+
childs.push(buildAssignBean(arg.value ?? arg, arg.name ?? fieldId, fieldType, meta, appId));
|
|
568
|
+
else
|
|
569
|
+
childs.push(buildAssignBean(arg, fieldId, fieldType, meta, appId));
|
|
570
|
+
}
|
|
571
|
+
return formulaFunction(fId, ref?.name ?? '', childs, fieldType, ref?.excelFunc ?? null, (ref?.functionType || ref?.valueType) ?? null, ref?.detail ?? null, appId);
|
|
572
|
+
}
|
|
573
|
+
let val = ref && typeof ref === 'object' ? (ref.value ?? '') : ref;
|
|
574
|
+
if (val && typeof val === 'object')
|
|
575
|
+
val = val.value ?? '';
|
|
576
|
+
if (!(typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean'))
|
|
577
|
+
val = val == null ? '' : String(val);
|
|
578
|
+
return formulaFixed(String(val), ftNorm(fieldType));
|
|
579
|
+
}
|
|
580
|
+
export function normalizeConstantAssignment(value, defaultFieldType = 'Text') {
|
|
581
|
+
if (!value || typeof value !== 'object') {
|
|
582
|
+
return [{ kind: 'fixed', value: value != null ? String(value) : '' }, defaultFieldType];
|
|
583
|
+
}
|
|
584
|
+
if ('kind' in value || 'assignmentKind' in value) {
|
|
585
|
+
const ft = VALUE_TYPE_ALIASES[value.valueType ?? ''] ?? defaultFieldType;
|
|
586
|
+
return [value, ft];
|
|
587
|
+
}
|
|
588
|
+
if ('systemValue' in value) {
|
|
589
|
+
const key = String(value.systemValue);
|
|
590
|
+
const sysVar = resolveSystemParameter(key);
|
|
591
|
+
const ft = VALUE_TYPE_ALIASES[value.valueType ?? ''] ?? defaultFieldType;
|
|
592
|
+
return [{ kind: 'system_variable', key: sysVar }, ft];
|
|
593
|
+
}
|
|
594
|
+
if ('value' in value) {
|
|
595
|
+
const ft = VALUE_TYPE_ALIASES[value.valueType ?? ''] ?? defaultFieldType;
|
|
596
|
+
const assignment = { kind: 'fixed', value: value.value };
|
|
597
|
+
if (value.label !== undefined)
|
|
598
|
+
assignment.label = value.label;
|
|
599
|
+
return [assignment, ft];
|
|
600
|
+
}
|
|
601
|
+
return [value, defaultFieldType];
|
|
602
|
+
}
|
|
603
|
+
export function resolveEnumConstant(value, fieldMeta) {
|
|
604
|
+
if (!fieldMeta || typeof fieldMeta !== 'object')
|
|
605
|
+
return value;
|
|
606
|
+
const componentKey = String(fieldMeta.componentKey || fieldMeta.type || '');
|
|
607
|
+
if (!['Select', 'RadioBox', 'Checkbox', 'MultiSelect', 'Radio'].includes(componentKey))
|
|
608
|
+
return value;
|
|
609
|
+
let rawValue;
|
|
610
|
+
if (value && typeof value === 'object') {
|
|
611
|
+
if (value.kind || value.assignmentKind || value.label !== undefined)
|
|
612
|
+
return value;
|
|
613
|
+
rawValue = value.value;
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
rawValue = value;
|
|
617
|
+
}
|
|
618
|
+
const options = fieldMeta.selectData || (fieldMeta.fieldConfig || {}).options || [];
|
|
619
|
+
for (const option of options) {
|
|
620
|
+
if (!option || typeof option !== 'object')
|
|
621
|
+
continue;
|
|
622
|
+
const optionValue = String(option.valueKey || option.value || option.id || '');
|
|
623
|
+
const optionName = String(option.name || option.label || '');
|
|
624
|
+
if (String(rawValue) === optionValue || String(rawValue) === optionName) {
|
|
625
|
+
return { value: optionValue, label: optionName || String(rawValue) };
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
throw new Error(`枚举字段 '${fieldMeta.showName || fieldMeta.name || ''}' 的固定值 '${rawValue}' 未在实时选项中找到,拒绝伪造 option valueKey`);
|
|
629
|
+
}
|
|
630
|
+
export function lookupTargetFieldMeta(targetFieldId, result) {
|
|
631
|
+
const targetForm = result.targetForm || {};
|
|
632
|
+
const targetFormId = String(targetForm.id || '');
|
|
633
|
+
const direct = getTargetFormFields()[targetFormId]?.[String(targetFieldId)];
|
|
634
|
+
if (direct && typeof direct === 'object')
|
|
635
|
+
return direct;
|
|
636
|
+
const matches = [];
|
|
637
|
+
for (const fields of Object.values(getTargetFormFields())) {
|
|
638
|
+
if (fields && typeof fields === 'object' && fields[String(targetFieldId)] && typeof fields[String(targetFieldId)] === 'object') {
|
|
639
|
+
matches.push(fields[String(targetFieldId)]);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return matches.length === 1 ? matches[0] : null;
|
|
643
|
+
}
|
|
644
|
+
// ── 扁平 assign 公式 ─────────────────────────────────────────
|
|
645
|
+
function assignFlatFixed(valueStr, appId, fieldType = 'string') {
|
|
646
|
+
const fid = genSfId();
|
|
647
|
+
return {
|
|
648
|
+
id: fid, name: valueStr, value: valueStr, type: '1', fieldType, formulaType: fieldType,
|
|
649
|
+
applicationId: appId || '', config: { originValue: valueStr, switchType: 'fixvalue' },
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
export function assignFlatContext(paramKey, fieldLabel, sourceId, appId, fieldType = 'string', parentName = '', tempFormulaId = '', tableId = '', componentKey = 'Text', paramKeyFull = '', valueFull = '') {
|
|
653
|
+
const fid = genSfId();
|
|
654
|
+
const src = String(sourceId) || '0';
|
|
655
|
+
const pname = String(parentName || fieldLabel);
|
|
656
|
+
const val = valueFull || (tableId ? `FormData.${tableId}.${paramKey}` : `FormData.${paramKey}`);
|
|
657
|
+
const pkey = paramKeyFull || (tableId ? `${tableId}.${paramKey}` : String(paramKey));
|
|
658
|
+
return {
|
|
659
|
+
id: fid, name: String(fieldLabel), value: val, type: '3', fieldType, formulaType: fieldType,
|
|
660
|
+
businessId: appId || '', applicationId: appId || '', source: src,
|
|
661
|
+
paramTypeString: 'STRING', dataTypeSting: 'ATTRIBUTE',
|
|
662
|
+
config: makeConfigStr({
|
|
663
|
+
switchType: 'assign', comId: src, paramKey: pkey, paramType: fieldType,
|
|
664
|
+
parentName: pname, newParentName: pname, multName: '', multKey: '',
|
|
665
|
+
multTypeObj: { currentName: pname, allName: pname, currentParamKey: val, allParamKey: val },
|
|
666
|
+
isMultCom: false, comType: 'ApproveTrigger', tableName: '表单数据',
|
|
667
|
+
fieldInfo: { tablePrimaryKey: 'FormData', paramKey: pkey },
|
|
668
|
+
tempFormulaId: tempFormulaId || '', formulaVersion: 'V1',
|
|
669
|
+
}),
|
|
670
|
+
parentName: pname, tempFormulaId: tempFormulaId || '',
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
export function assignFlatContextDirect(paramKey, fieldLabel, sourceId, appId, fieldType = 'string', parentName = '', meta = null) {
|
|
674
|
+
const fid = genSfId();
|
|
675
|
+
const src = String(sourceId) || '0';
|
|
676
|
+
const pkey = String(paramKey);
|
|
677
|
+
const pname = String(parentName || `表单数据.${fieldLabel}`);
|
|
678
|
+
const tail = pkey.includes('.') ? pkey.slice(pkey.lastIndexOf('.') + 1).replace(/\[\]$/, '') : pkey.replace(/\[\]$/, '');
|
|
679
|
+
const plainApprovalShape = !/^\d+$/.test(tail) && !pkey.includes('[].') && !pkey.includes('[]. ');
|
|
680
|
+
let frontId = '';
|
|
681
|
+
let ctxComponentKey = '';
|
|
682
|
+
const wfId = String(meta?._workflow_id || meta?._event_form_id || '');
|
|
683
|
+
const ctxFields = wfId ? (getWorkflowContextFields()[wfId] || {}) : {};
|
|
684
|
+
const pkeyTail = pkey.includes('.') ? pkey.slice(pkey.lastIndexOf('.') + 1).replace(/\[\]$/, '') : pkey.replace(/\[\]$/, '');
|
|
685
|
+
for (const field of Object.values(ctxFields)) {
|
|
686
|
+
if (!field || typeof field !== 'object')
|
|
687
|
+
continue;
|
|
688
|
+
const candidate = String(field.paramKey || '');
|
|
689
|
+
const candTail = candidate.includes('.') ? candidate.slice(candidate.lastIndexOf('.') + 1).replace(/\[\]$/, '') : candidate.replace(/\[\]$/, '');
|
|
690
|
+
if (candidate !== pkey && candTail !== pkeyTail)
|
|
691
|
+
continue;
|
|
692
|
+
if (String(field.id || ''))
|
|
693
|
+
frontId = String(field.id);
|
|
694
|
+
ctxComponentKey = String(field.componentKey || '');
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
let isApproval = plainApprovalShape && !ctxComponentKey;
|
|
698
|
+
if (pkey.startsWith('dataResponse.') && String(meta?._upstream_component_type || '') === 'DateTrigger')
|
|
699
|
+
isApproval = false;
|
|
700
|
+
if (isApproval && meta && typeof meta === 'object') {
|
|
701
|
+
const formId = String(meta._event_form_id || '');
|
|
702
|
+
const pkeyHead = pkey.includes('.') ? pkey.slice(0, pkey.indexOf('.')) : '';
|
|
703
|
+
if (formId && pkeyHead === formId)
|
|
704
|
+
isApproval = false;
|
|
705
|
+
}
|
|
706
|
+
// frontId 必须 = 字段 id(paramKey 尾段),设计器用它在字段浏览器里定位字段;
|
|
707
|
+
// 清空会导致设计器「动态赋值」找不到字段标红(真机验证 2026-08-19,场景12)。
|
|
708
|
+
if (!frontId)
|
|
709
|
+
frontId = pkeyTail;
|
|
710
|
+
const prefix = isApproval ? 'ApprovalData' : 'FormData';
|
|
711
|
+
let sourceComponent = 'ApproveTrigger';
|
|
712
|
+
if (meta && typeof meta === 'object' && meta._upstream_component_type)
|
|
713
|
+
sourceComponent = String(meta._upstream_component_type);
|
|
714
|
+
const result = {
|
|
715
|
+
formulaType: fieldType, name: String(fieldLabel), businessId: appId || '', id: fid,
|
|
716
|
+
source: src, type: '3', value: `${prefix}.${pkey}`,
|
|
717
|
+
frontId, paramKey: pkey, parentName: pname, childs: [],
|
|
718
|
+
config: {
|
|
719
|
+
paramKey: pkey, isMultCom: false, comType: sourceComponent, switchType: 'assign', formulaVersion: 'V1',
|
|
720
|
+
fieldInfo: { paramKey: pkey, tablePrimaryKey: prefix },
|
|
721
|
+
tableName: isApproval ? '流程数据' : '表单数据',
|
|
722
|
+
paramType: fieldType, parentName: pname, multName: '', multKey: '',
|
|
723
|
+
multTypeObj: {
|
|
724
|
+
allName: pname, currentName: pname,
|
|
725
|
+
currentParamKey: `${prefix}.${pkey}`, allParamKey: `${prefix}.${pkey}`,
|
|
726
|
+
},
|
|
727
|
+
comId: src, newParentName: pname,
|
|
728
|
+
},
|
|
729
|
+
parentId: '0',
|
|
730
|
+
};
|
|
731
|
+
if (frontId)
|
|
732
|
+
result.frontId = frontId;
|
|
733
|
+
return result;
|
|
734
|
+
}
|
|
735
|
+
function assignFlatEsbChild(paramKey, fieldLabel, sourceId, appId, fieldType = 'string', detailParamKey = '', detailLabel = '', workflowName = '') {
|
|
736
|
+
const fid = genSfId();
|
|
737
|
+
const src = String(sourceId) || '0';
|
|
738
|
+
const tailPart = paramKey.includes('.') ? paramKey.slice(paramKey.lastIndexOf('.') + 1) : paramKey;
|
|
739
|
+
const subId = tailPart.replace(/\[\]$/, '');
|
|
740
|
+
const detailPk = detailParamKey || (paramKey.includes('[]') ? paramKey.slice(0, paramKey.indexOf('[]')) + '[]' : '');
|
|
741
|
+
const detailVal = `FormData.${detailPk}`;
|
|
742
|
+
const parentName = workflowName ? `${workflowName}.${fieldLabel}[]` : `${fieldLabel}[]`;
|
|
743
|
+
const subName = workflowName ? `${workflowName}.${fieldLabel}` : String(fieldLabel);
|
|
744
|
+
const allName = workflowName && detailLabel ? `${workflowName}.${detailLabel}[]` : parentName;
|
|
745
|
+
return {
|
|
746
|
+
id: fid, name: String(fieldLabel), value: subId, type: '10', fieldType, formulaType: fieldType,
|
|
747
|
+
applicationId: appId || '',
|
|
748
|
+
config: {
|
|
749
|
+
paramKey: String(paramKey), basisType: 'formSetting', switchType: 'sub', level: 1,
|
|
750
|
+
id: subId, source: src, formulaVersion: 'V1', value: detailVal,
|
|
751
|
+
config: {
|
|
752
|
+
paramKey: detailPk, isMultCom: false, comType: 'ApproveTrigger', switchType: 'assign', parentComId: 0,
|
|
753
|
+
fieldInfo: { paramKey: detailPk, tablePrimaryKey: 'FormData' },
|
|
754
|
+
tableName: '表单数据', paramType: fieldType, parentName, multName: '', multKey: '',
|
|
755
|
+
multTypeObj: {
|
|
756
|
+
allName, currentName: subName,
|
|
757
|
+
currentParamKey: paramKey.startsWith('FormData.') ? String(paramKey) : `FormData.${paramKey}`,
|
|
758
|
+
allParamKey: detailVal,
|
|
759
|
+
},
|
|
760
|
+
comId: src, newParentName: parentName,
|
|
761
|
+
},
|
|
762
|
+
originValue: subId, content: String(fieldLabel),
|
|
763
|
+
},
|
|
764
|
+
childs: [], parentId: '0',
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
function assignFlatSystemVar(varName = '{userid}', appId = '', fieldType = 'string') {
|
|
768
|
+
const fid = genSfId();
|
|
769
|
+
return {
|
|
770
|
+
id: fid, name: varName, value: varName, type: '9', fieldType, formulaType: fieldType,
|
|
771
|
+
applicationId: appId || '', config: { switchType: 'assign', paramType: fieldType },
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
// ── build_setting_entry(核心)──────────────────────────────
|
|
775
|
+
/**
|
|
776
|
+
* 给上下文类公式(type 3/8/10 等)补 esbAssign.wId —— 与 workflow_compiler.buildFilterInput 的 esbWid 同源。
|
|
777
|
+
* 设计器「动态赋值」对话框用 esbAssign.wId 在 orginFlowDatas 定位「当前组件」(mapping/updateId 所属的数据动作节点);
|
|
778
|
+
* 缺失时定位不到,会把该条赋值渲染为「已删除」。wId 优先取当前节点 id(meta._upstream_node_id),
|
|
779
|
+
* 其次公式的 source,再次 meta._upstream_w_id,最后时间戳前缀兜底(对齐 filterInput 修复)。
|
|
780
|
+
*/
|
|
781
|
+
export function attachEsbAssign(bean, meta, fallbackSource = '') {
|
|
782
|
+
if (!bean || typeof bean !== 'object' || Array.isArray(bean))
|
|
783
|
+
return;
|
|
784
|
+
const formulaType = String(bean.type || bean.formulaType || '');
|
|
785
|
+
if (!['3', '8', '10', '4', '6'].includes(formulaType))
|
|
786
|
+
return;
|
|
787
|
+
let esbWid = String(meta && typeof meta === 'object' ? (meta._upstream_node_id || '') : '');
|
|
788
|
+
if (!esbWid && bean.source)
|
|
789
|
+
esbWid = String(bean.source);
|
|
790
|
+
if (!esbWid && meta && typeof meta === 'object')
|
|
791
|
+
esbWid = String(meta._upstream_w_id || '');
|
|
792
|
+
if (!esbWid)
|
|
793
|
+
esbWid = String(fallbackSource || '');
|
|
794
|
+
if (!esbWid)
|
|
795
|
+
esbWid = String(Date.now()).slice(0, 13);
|
|
796
|
+
bean.esbAssign = { wId: esbWid, textarea: false, withoutDftNum: true };
|
|
797
|
+
}
|
|
798
|
+
export function buildSettingEntry(fieldId, assignment, fieldType = 'Text', meta = {}, appId = '', defaultSourceId = '', operate = 'OPERATE_EQUAL', componentType = '', detailMode = false, assignmentMode = '') {
|
|
799
|
+
if (!meta || typeof meta !== 'object')
|
|
800
|
+
meta = {};
|
|
801
|
+
const rawValue = assignment && typeof assignment === 'object' ? (assignment.value ?? assignment) : assignment;
|
|
802
|
+
let ref;
|
|
803
|
+
if (assignment && typeof assignment === 'object' && ('kind' in assignment || 'assignmentKind' in assignment))
|
|
804
|
+
ref = assignment;
|
|
805
|
+
else if (rawValue && typeof rawValue === 'object')
|
|
806
|
+
ref = rawValue;
|
|
807
|
+
else
|
|
808
|
+
ref = assignment;
|
|
809
|
+
let kind = ref && typeof ref === 'object' ? (ref.kind || ref.assignmentKind || ref.type) : null;
|
|
810
|
+
if (kind === null || kind === undefined)
|
|
811
|
+
kind = 'fixed';
|
|
812
|
+
const assignId = genSfId();
|
|
813
|
+
const ft = ftNorm(fieldType);
|
|
814
|
+
let flat;
|
|
815
|
+
let switchT;
|
|
816
|
+
if (kind === 'context') {
|
|
817
|
+
let key = '';
|
|
818
|
+
if (ref && typeof ref === 'object')
|
|
819
|
+
key = ref.paramKey || ref.key || ref.fieldKey || '';
|
|
820
|
+
const label = ref && typeof ref === 'object' ? (ref.label ?? ref.name ?? key) : key;
|
|
821
|
+
let src = ref && typeof ref === 'object' ? (ref.source ?? ref.comId ?? '') : '';
|
|
822
|
+
if (['', 'event', 'event_1', 'trigger'].includes(String(src)))
|
|
823
|
+
src = defaultSourceId;
|
|
824
|
+
if (String(key).includes('[].') || String(key).includes('[]. ')) {
|
|
825
|
+
const workflowId = String(meta._workflow_id || '');
|
|
826
|
+
const pkeyFull = !String(key).startsWith(workflowId + '.') ? (workflowId ? `${workflowId}.${String(key)}` : String(key)) : String(key);
|
|
827
|
+
const subLabel = String(label || key);
|
|
828
|
+
let detailLabel = String((ref && typeof ref === 'object') ? (ref.detailLabel || ref.parentName || '') : '');
|
|
829
|
+
if (!detailLabel)
|
|
830
|
+
detailLabel = pkeyFull.split('[]')[0].includes('.') ? pkeyFull.split('[]')[0].slice(pkeyFull.split('[]')[0].lastIndexOf('.') + 1) : pkeyFull.split('[]')[0];
|
|
831
|
+
const pkHead = pkeyFull.includes('.') ? pkeyFull.slice(0, pkeyFull.indexOf('.')) : '';
|
|
832
|
+
const pkSubf = pkeyFull.split('[]')[0].includes('.') ? pkeyFull.split('[]')[0].slice(pkeyFull.split('[]')[0].lastIndexOf('.') + 1) : '';
|
|
833
|
+
const realDtl = getWorkflowDetailNames()[pkHead]?.[pkSubf];
|
|
834
|
+
if (realDtl)
|
|
835
|
+
detailLabel = realDtl;
|
|
836
|
+
const workflowName = String(meta._upstream_workflow_name || '');
|
|
837
|
+
flat = assignFlatEsbChild(pkeyFull, subLabel, String(src), appId, ft, undefined, detailLabel, workflowName);
|
|
838
|
+
switchT = 'sub';
|
|
839
|
+
attachEsbAssign(flat, meta, String(src));
|
|
840
|
+
return {
|
|
841
|
+
formFieldKey: '',
|
|
842
|
+
value: {
|
|
843
|
+
original: false, operate, switchType: 'sub', fieldKey: fieldId, assignType: '',
|
|
844
|
+
fieldType, assignId: String(flat.id || ''), assign: flat, multiSelect: false,
|
|
845
|
+
},
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
else if (assignmentMode === 'direct' && operate === 'OPERATE_EQUAL') {
|
|
849
|
+
const workflowId = String(meta._workflow_id || '');
|
|
850
|
+
const paramKeyFull = resolveParamKey(workflowId, String(key));
|
|
851
|
+
flat = assignFlatContextDirect(paramKeyFull, String(label || key), String(src), appId, 'string', String(meta._upstream_workflow_name || ''), meta);
|
|
852
|
+
switchT = 'assign';
|
|
853
|
+
}
|
|
854
|
+
else if (assignmentMode === 'nested' && operate === 'OPERATE_EQUAL') {
|
|
855
|
+
let formName = '';
|
|
856
|
+
let tableId = '';
|
|
857
|
+
let workflowId = '';
|
|
858
|
+
if (meta && typeof meta === 'object') {
|
|
859
|
+
formName = String(meta._upstream_form_name || '');
|
|
860
|
+
tableId = String(meta._upstream_table_id || '');
|
|
861
|
+
workflowId = String(meta._workflow_id || '');
|
|
862
|
+
}
|
|
863
|
+
const srcFieldId = workflowFieldId(workflowId, String(key));
|
|
864
|
+
const wfName = String(meta._upstream_workflow_name || '');
|
|
865
|
+
const pkTail = String(key).includes('.') ? String(key).slice(String(key).lastIndexOf('.') + 1).replace(/\[\]$/, '') : String(key).replace(/\[\]$/, '');
|
|
866
|
+
let parentName;
|
|
867
|
+
if (!/^\d+$/.test(pkTail) && wfName)
|
|
868
|
+
parentName = `${wfName}.${label || key}`;
|
|
869
|
+
else if (formName)
|
|
870
|
+
parentName = `${formName}.${label || key}`;
|
|
871
|
+
else
|
|
872
|
+
parentName = String(label || key);
|
|
873
|
+
if (String(key).includes('[].') || String(key).includes('[]. ')) {
|
|
874
|
+
const subId = String(key).includes('[].') ? String(key).split('[].')[1].includes('.') ? String(key).split('[].')[1].slice(String(key).split('[].')[1].lastIndexOf('.') + 1) : String(key).split('[].')[1] : String(key);
|
|
875
|
+
flat = {
|
|
876
|
+
id: genSfId(), name: String(label || key), value: subId, type: '10', fieldType: 'string', formulaType: 'string',
|
|
877
|
+
applicationId: appId || '',
|
|
878
|
+
config: {
|
|
879
|
+
originValue: subId, switchType: 'sub', level: 1, basisType: 'formSetting',
|
|
880
|
+
},
|
|
881
|
+
};
|
|
882
|
+
switchT = 'sub';
|
|
883
|
+
}
|
|
884
|
+
else {
|
|
885
|
+
const pkey = resolveParamKey(workflowId, String(key));
|
|
886
|
+
const pval = `FormData.${pkey}`;
|
|
887
|
+
if (!detailMode) {
|
|
888
|
+
const pkTail2 = pkey.includes('.') ? pkey.slice(pkey.lastIndexOf('.') + 1) : pkey;
|
|
889
|
+
const wfName2 = String(meta._upstream_workflow_name || '');
|
|
890
|
+
let directParent;
|
|
891
|
+
if (!/^\d+$/.test(pkTail2) && wfName2)
|
|
892
|
+
directParent = `${wfName2}.${label || key}`;
|
|
893
|
+
else if (formName)
|
|
894
|
+
directParent = `${formName}.${label || pkey}`;
|
|
895
|
+
else
|
|
896
|
+
directParent = `表单数据.${label || key}`;
|
|
897
|
+
flat = assignFlatContextDirect(pkey, String(label || key), String(src), appId, ft, directParent, meta);
|
|
898
|
+
switchT = 'assign';
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
const child = assignFlatContext(String(key), String(label || key), String(src), appId, ft, parentName, '', tableId, 'Text', pkey, pval);
|
|
902
|
+
const container = formulaContainerString([child], '', appId);
|
|
903
|
+
const childId = String(child.id || '');
|
|
904
|
+
if (childId && typeof child.config === 'string') {
|
|
905
|
+
const cfg = JSON.parse(child.config);
|
|
906
|
+
cfg.tempFormulaId = container.id;
|
|
907
|
+
child.config = JSON.stringify(cfg);
|
|
908
|
+
}
|
|
909
|
+
child.tempFormulaId = container.id;
|
|
910
|
+
const containerSwitch = detailMode && pval.includes('[].') ? 'sub' : 'assign';
|
|
911
|
+
flat = {
|
|
912
|
+
id: container.id, name: '', value: container.value, type: '8', fieldType: ft, formulaType: ft,
|
|
913
|
+
applicationId: appId || '', childs: container.childs,
|
|
914
|
+
config: { paramType: ft, switchType: containerSwitch, formulaVersion: 'V1' },
|
|
915
|
+
};
|
|
916
|
+
switchT = containerSwitch;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
else {
|
|
921
|
+
const wfId = String(meta._workflow_id || '');
|
|
922
|
+
const pkey = resolveParamKey(wfId, String(key));
|
|
923
|
+
let srcName = String(meta._upstream_workflow_name || '');
|
|
924
|
+
if (!srcName)
|
|
925
|
+
srcName = String(meta._upstream_form_name || '');
|
|
926
|
+
const directParent = srcName ? `${srcName}.${label || key}` : `表单数据.${label || key}`;
|
|
927
|
+
flat = assignFlatContextDirect(pkey, String(label || key), String(src), appId, ft, directParent, meta);
|
|
928
|
+
switchT = 'assign';
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
else if (kind === 'system_variable') {
|
|
932
|
+
const key = ref && typeof ref === 'object' ? (ref.key ?? '{userid}') : '{userid}';
|
|
933
|
+
flat = assignFlatSystemVar(String(key), appId, ft);
|
|
934
|
+
switchT = 'assign';
|
|
935
|
+
}
|
|
936
|
+
else if (kind === 'fixed') {
|
|
937
|
+
let val = '';
|
|
938
|
+
if (ref && typeof ref === 'object') {
|
|
939
|
+
const hasNestedBrowserValue = Boolean(ref.value && typeof ref.value === 'object');
|
|
940
|
+
const browserValue = hasNestedBrowserValue ? ref.value : ref;
|
|
941
|
+
// { kind:'fixed', value:'选项ID', label:'选项名' } 是普通标量赋值,不是 Browser。
|
|
942
|
+
// 只有嵌套 Browser 值,或对象本身带真实 id 时才走 Browser 数组结构。
|
|
943
|
+
const isBrowserValue = hasNestedBrowserValue || (browserValue && typeof browserValue === 'object' && browserValue.id != null);
|
|
944
|
+
if (isBrowserValue && browserValue && typeof browserValue === 'object' && (browserValue.id ?? browserValue.value) != null && (browserValue.name ?? browserValue.text ?? browserValue.label) != null) {
|
|
945
|
+
const origin = Array.isArray(browserValue) ? browserValue : [browserValue];
|
|
946
|
+
const ids = origin.map((item) => String(item.id ?? item.value)).join(',');
|
|
947
|
+
flat = formulaFixedForAssignSwitch(ids, ft);
|
|
948
|
+
flat.name = origin.map((item) => String(item.name ?? item.text ?? item.label)).join(',');
|
|
949
|
+
flat.applicationId = String(appId);
|
|
950
|
+
flat.config = { originValue: origin, switchType: 'fixvalue', formulaVersion: 'V1' };
|
|
951
|
+
switchT = 'fixvalue';
|
|
952
|
+
attachEsbAssign(flat, meta, defaultSourceId);
|
|
953
|
+
return {
|
|
954
|
+
formFieldKey: '',
|
|
955
|
+
value: { original: false, operate, switchType: switchT, fieldKey: String(fieldId), assignType: '', multiSelect: Array.isArray(browserValue), fieldType, assign: flat, assignId: String(assignId) },
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
val = ref.value ?? '';
|
|
959
|
+
if (val && typeof val === 'object')
|
|
960
|
+
val = val.value ?? '';
|
|
961
|
+
}
|
|
962
|
+
else
|
|
963
|
+
val = ref;
|
|
964
|
+
if (!(typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean'))
|
|
965
|
+
val = val != null ? String(val) : '';
|
|
966
|
+
flat = assignFlatFixed(String(val), appId, ft);
|
|
967
|
+
if (ref && typeof ref === 'object' && ref.label !== undefined)
|
|
968
|
+
flat.name = String(ref.label);
|
|
969
|
+
switchT = 'fixvalue';
|
|
970
|
+
}
|
|
971
|
+
else if (kind === 'constant' || kind === 'transform' || kind === 'formula') {
|
|
972
|
+
const bean = buildAssignBean(assignment, fieldId, fieldType, meta, appId, defaultSourceId);
|
|
973
|
+
const flatId = bean.id || assignId;
|
|
974
|
+
flat = Object.fromEntries(Object.entries(bean).filter(([k]) => !['configObject', 'childs', 'parentId', 'sortWeight', 'position'].includes(k)));
|
|
975
|
+
if (bean.childs)
|
|
976
|
+
flat.childs = bean.childs;
|
|
977
|
+
flat.applicationId ??= String(appId);
|
|
978
|
+
flat.id ??= String(flatId);
|
|
979
|
+
switchT = bean.type !== '1' ? 'assign' : 'fixvalue';
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
let val = '';
|
|
983
|
+
if (ref && typeof ref === 'object')
|
|
984
|
+
val = ref.value ?? '';
|
|
985
|
+
else if (typeof ref === 'string' || typeof ref === 'number' || typeof ref === 'boolean')
|
|
986
|
+
val = ref;
|
|
987
|
+
flat = assignFlatFixed(String(val), appId, ft);
|
|
988
|
+
switchT = 'fixvalue';
|
|
989
|
+
}
|
|
990
|
+
attachEsbAssign(flat, meta, defaultSourceId);
|
|
991
|
+
return {
|
|
992
|
+
formFieldKey: '',
|
|
993
|
+
value: {
|
|
994
|
+
original: false, operate, switchType: switchT, fieldKey: String(fieldId), assignType: '',
|
|
995
|
+
multiSelect: false, fieldType, assign: flat, assignId: String(assignId),
|
|
996
|
+
},
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
//# sourceMappingURL=formula_service.js.map
|