openyida 2026.7.18 ā 2026.7.21
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/README.md +37 -2
- package/bin/yida.js +113 -18
- package/docs/capabilities.md +202 -0
- package/lib/agent-center/agent-center.js +2 -3
- package/lib/app/app-list.js +3 -4
- package/lib/app/build-page.js +13 -6
- package/lib/app/check-page.js +16 -6
- package/lib/app/compile.js +17 -7
- package/lib/app/create-app.js +14 -2
- package/lib/app/create-form/api-path.js +25 -0
- package/lib/app/create-form/args.js +13 -0
- package/lib/app/create-form/commands.js +4 -0
- package/lib/app/create-form/definition-reader.js +23 -23
- package/lib/app/create-form/field-normalizers.js +26 -7
- package/lib/app/create-form/schema-patch.js +4 -1
- package/lib/app/create-form.js +155 -68
- package/lib/app/create-page.js +47 -10
- package/lib/app/generate-page.js +20 -1
- package/lib/app/get-form-config.js +2 -1
- package/lib/app/get-schema.js +67 -15
- package/lib/app/import-app.js +94 -42
- package/lib/app/list-forms.js +4 -8
- package/lib/app/page-ir.js +140 -0
- package/lib/app/publish.js +289 -556
- package/lib/app/schema-field-resolution.js +370 -0
- package/lib/app/services/app-reader.js +85 -0
- package/lib/app/services/app-service.js +235 -0
- package/lib/app/services/canvas-page-compiler.js +91 -0
- package/lib/app/services/canvas-page-schema-builder.js +149 -0
- package/lib/app/services/field-bindings.js +68 -0
- package/lib/app/services/form-compiler.js +1922 -0
- package/lib/app/services/form-mode-service.js +182 -0
- package/lib/app/services/form-schema-patcher.js +333 -0
- package/lib/app/services/form-schema-reader.js +59 -0
- package/lib/app/services/form-service.js +379 -0
- package/lib/app/services/form-validation.js +562 -0
- package/lib/app/services/native-page-compiler.js +92 -0
- package/lib/app/services/native-page-schema-builder.js +428 -0
- package/lib/app/services/page-resource-service.js +185 -0
- package/lib/app/update-app.js +22 -9
- package/lib/app/update-form-config.js +4 -2
- package/lib/asset/asset-cmd.js +19 -6
- package/lib/auth/oauth-loopback.js +376 -15
- package/lib/auth/token-auth.js +34 -3
- package/lib/auth/token-store.js +22 -4
- package/lib/basic-info/basic-info.js +2 -1
- package/lib/bridge/bridge.js +43 -18
- package/lib/core/agent-capabilities.js +5 -3
- package/lib/core/command-errors.js +38 -0
- package/lib/core/command-manifest.js +59 -1
- package/lib/core/copy.js +12 -0
- package/lib/core/doctor.js +15 -4
- package/lib/core/env-cmd.js +1 -1
- package/lib/core/env.js +7 -6
- package/lib/core/i18n.js +66 -8
- package/lib/core/legacy-schema-guard.js +408 -0
- package/lib/core/locales/en.js +38 -46
- package/lib/core/locales/zh.js +30 -46
- package/lib/core/sample.js +12 -2
- package/lib/core/utils.js +334 -66
- package/lib/core/yida-client.js +108 -5
- package/lib/corp-efficiency/corp-efficiency.js +2 -2
- package/lib/corp-manager/corp-manager.js +3 -3
- package/lib/formula/evaluate.js +11 -68
- package/lib/formula/field-refs.js +83 -0
- package/lib/i18n-management/i18n-management.js +2 -3
- package/lib/process/configure-process.js +44 -1992
- package/lib/process/create-process.js +54 -87
- package/lib/process/preview-process.js +20 -8
- package/lib/process/services/process-compiler.js +2056 -0
- package/lib/process/services/process-reader.js +232 -0
- package/lib/process/services/process-resource-service.js +571 -0
- package/lib/process/services/process-service.js +122 -0
- package/lib/process/services/process-stage-checkpoint.js +246 -0
- package/lib/report/append.js +7 -26
- package/lib/report/http.js +31 -5
- package/lib/report/index.js +10 -2
- package/lib/samples/yida-canvas-custom-page/business-list.canvas.jsx +63 -14
- package/lib/samples/yida-canvas-custom-page/dashboard-overview.canvas.jsx +176 -32
- package/lib/samples/yida-canvas-custom-page/dashboard-starter.canvas.jsx +5 -2
- package/lib/samples/yida-canvas-custom-page/data-management.canvas.jsx +228 -14
- package/lib/samples/yida-canvas-custom-page/portal-shell-home.canvas.jsx +2 -2
- package/lib/samples/yida-canvas-custom-page/split-pane-detail.canvas.jsx +206 -10
- package/lib/samples/yida-custom-page/data-management.oyd.jsx +14 -3
- package/lib/samples/yida-custom-page/design-tokens.js +2 -2
- package/lib/samples/yida-custom-page/detail-profile.oyd.jsx +1 -1
- package/lib/samples/yida-custom-page/portal-shell-home.oyd.jsx +7 -2
- package/lib/samples/yida-custom-page/split-pane-detail.oyd.jsx +2 -1
- package/lib/schema/adapters/app-adapter.js +210 -0
- package/lib/schema/adapters/form-adapter.js +1362 -0
- package/lib/schema/adapters/keys.js +19 -0
- package/lib/schema/adapters/page-adapter.js +566 -0
- package/lib/schema/adapters/process-adapter.js +519 -0
- package/lib/schema/applier.js +1878 -0
- package/lib/schema/apply-store.js +1083 -0
- package/lib/schema/command.js +645 -0
- package/lib/schema/dependency-graph.js +83 -0
- package/lib/schema/errors.js +481 -0
- package/lib/schema/hash.js +9 -0
- package/lib/schema/manifest-limits.js +177 -0
- package/lib/schema/manifest-loader.js +309 -0
- package/lib/schema/manifest-schema-v1.json +193 -0
- package/lib/schema/normalize-manifest.js +281 -0
- package/lib/schema/page-canvas-foundation.js +447 -0
- package/lib/schema/page-data-source-builder.js +561 -0
- package/lib/schema/page-foundation.js +556 -0
- package/lib/schema/page-source-loader.js +314 -0
- package/lib/schema/planner.js +691 -0
- package/lib/schema/remote-dispatch-boundary.js +39 -0
- package/lib/schema/remote-missing.js +21 -0
- package/lib/schema/remote-reader.js +189 -0
- package/lib/schema/resource-registry.js +157 -0
- package/lib/schema/server-revision.js +71 -0
- package/lib/schema/sort.js +28 -0
- package/lib/schema/state-store.js +589 -0
- package/package.json +10 -8
- package/scripts/check-release-risks.js +254 -0
- package/scripts/generate-command-docs.js +6 -1
- package/scripts/i18n-baseline.json +11 -11
- package/scripts/postinstall.js +8 -12
- package/scripts/validate-ci.sh +15 -11
- package/scripts/validate-i18n.js +30 -9
- package/scripts/validate-package-size.js +5 -2
- package/scripts/validate-skills.js +4 -0
- package/scripts/validate-structure.js +15 -0
- package/yida-skills/SKILL.md +117 -30
- package/yida-skills/references/schema-as-code-phase1.md +99 -0
- package/yida-skills/references/setup-and-env.md +59 -59
- package/yida-skills/references/task-retrospective.md +6 -6
- package/yida-skills/skills/yida-app/SKILL.md +78 -17
- package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +18 -7
- package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +3 -3
- package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +15 -0
- package/yida-skills/skills/yida-create-app/SKILL.md +21 -3
- package/yida-skills/skills/yida-create-form-page/SKILL.md +19 -1
- package/yida-skills/skills/yida-create-page/SKILL.md +16 -3
- package/yida-skills/skills/yida-create-process/SKILL.md +100 -4
- package/yida-skills/skills/yida-custom-page/SKILL.md +19 -4
- package/yida-skills/skills/yida-dashboard/SKILL.md +1 -1
- package/yida-skills/skills/yida-dashboard/references/pitfalls.md +1 -1
- package/yida-skills/skills/yida-get-schema/SKILL.md +49 -5
- package/yida-skills/skills/yida-i18n/SKILL.md +1 -1
- package/yida-skills/skills/yida-integration/SKILL.md +7 -1
- package/yida-skills/skills/yida-login/SKILL.md +50 -99
- package/yida-skills/skills/yida-page-config/SKILL.md +7 -1
- package/yida-skills/skills/yida-page-uiux/references/app/blueprint.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/app/navigation-patterns.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/app/role-journey.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/dashboard/app-blueprint.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/dashboard/chart-contracts.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/dashboard/component-contracts.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/dashboard/layout-patterns.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/dashboard/theme-recipes.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/detail/object-narrative.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/detail/section-patterns.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/detail/timeline-and-related.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/landing/assets-workflow.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/landing/industry-playbooks.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/landing/research-levels.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/landing/section-patterns.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/list/drawer-detail.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/list/empty-loading-error.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/list/filter-patterns.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/list/table-patterns.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/scenes/screen.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/workbench/entry-patterns.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/workbench/portal-layouts.md +0 -1
- package/yida-skills/skills/yida-page-uiux/references/workbench/task-feed.md +0 -1
- package/yida-skills/skills/yida-page-uiux/workflow/output-decision-block.md +1 -1
- package/yida-skills/skills/yida-process-rule/SKILL.md +35 -1
- package/yida-skills/skills/yida-publish-page/SKILL.md +46 -4
- package/yida-skills/skills/yida-report/SKILL.md +9 -235
- package/yida-skills/skills/yida-report/references/schema-builder-details.md +239 -0
- package/yida-skills/skills/yida-skill-evaluator/SKILL.md +170 -0
- package/yida-skills/skills-index.json +238 -54
- package/lib/core/locales/ar.js +0 -834
- package/lib/core/locales/de.js +0 -834
- package/lib/core/locales/es.js +0 -834
- package/lib/core/locales/fr.js +0 -834
- package/lib/core/locales/hi.js +0 -834
- package/lib/core/locales/ja.js +0 -1227
- package/lib/core/locales/ko.js +0 -836
- package/lib/core/locales/pt.js +0 -834
- package/lib/core/locales/vi.js +0 -834
- package/lib/core/locales/zh-HK.js +0 -1263
- package/project/pages/src/demo-birthday-game.oyd.jsx +0 -832
- package/project/pages/src/demo-chip-insight.oyd.jsx +0 -983
- package/project/pages/src/demo-compat-smoke.oyd.jsx +0 -58
- package/project/pages/src/demo-crm-batch-entry.oyd.jsx +0 -805
- package/project/pages/src/demo-crm-dashboard.oyd.jsx +0 -677
- package/project/pages/src/demo-future-vision-2026.oyd.jsx +0 -1102
- package/project/pages/src/demo-ppt.oyd.jsx +0 -1192
- package/project/pages/src/demo-salary-calculator.oyd.jsx +0 -904
- package/project/pages/src/openyida-knowledge-doc.oyd.jsx +0 -1714
- package/yida-skills/skills/large-file-write/SKILL.md +0 -93
- package/yida-skills/skills/large-file-write/references/write-patterns.md +0 -147
- package/yida-skills/skills/large-file-write/scripts/write.js +0 -157
- package/yida-skills/skills/sls-log-workbench/SKILL.md +0 -134
- package/yida-skills/skills/sls-log-workbench/references/workbench-reference.md +0 -130
- package/yida-skills/skills/sls-log-workbench/sls-query.js +0 -295
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* configure-process.js -
|
|
4
|
-
*
|
|
5
|
-
* ēØę³ļ¼openyida configure-process <appType> <formUuid> <processDefinitionFile> [processCode]
|
|
6
|
-
*
|
|
7
|
-
* åč½ļ¼
|
|
8
|
-
* ę ¹ę®ęµēØå®ä¹ JSON ęä»¶ļ¼čŖåØé
ē½®å®ęęµēØč”Øåēå®”ę¹ęµēØć
|
|
9
|
-
* ęÆęę”ä»¶åęÆćåµå„åęÆćå®”ę¹čē¹ćåꮵęéćęéčē¹ć跳转č§åć
|
|
10
|
-
*
|
|
11
|
-
* ę øåæęµēØļ¼
|
|
12
|
-
* 1. č·å processCodeļ¼ä¼å
使ēØä¼ å
„åę°ļ¼å¦åéčæ switchFormType + getAppPlatFormParam čŖåØč·åļ¼
|
|
13
|
-
* 2. ę„询ęµēØēę¬å蔨ļ¼č·åå½åå·²ååøēę¬ē processId
|
|
14
|
-
* 3. å建ę°ęµēØēę¬č稿
|
|
15
|
-
* 4. ę ¹ę®ęµēØå®ä¹ JSON ę建 processJson å viewJsonļ¼äø„ę ¼å¹é
å®ęēå®ę ¼å¼ļ¼
|
|
16
|
-
* 5. č°ēØ saveProcessById äæåęµēØ
|
|
17
|
-
* 6. č°ēØ publishProcessById ååøęµēØ
|
|
3
|
+
* configure-process.js - å®ęęµēØč§åé
ē½® legacy adapter
|
|
18
4
|
*/
|
|
19
5
|
|
|
20
6
|
'use strict';
|
|
@@ -22,1981 +8,31 @@
|
|
|
22
8
|
const fs = require('fs');
|
|
23
9
|
const path = require('path');
|
|
24
10
|
const { CliError } = require('../core/cli-error');
|
|
25
|
-
const { createAuthRef
|
|
11
|
+
const { createAuthRef } = require('../core/yida-client');
|
|
26
12
|
const { t } = require('../core/i18n');
|
|
27
|
-
const { buildYidaI18n } = require('../core/yida-i18n');
|
|
28
13
|
const { warn } = require('../core/chalk');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const COMPONENT_TO_RULE_TYPE = {
|
|
49
|
-
TextField: 'rule_text',
|
|
50
|
-
TextareaField: 'rule_text',
|
|
51
|
-
NumberField: 'rule_number',
|
|
52
|
-
SelectField: 'rule_select',
|
|
53
|
-
RadioField: 'rule_radio',
|
|
54
|
-
DateField: 'rule_date',
|
|
55
|
-
EmployeeField: 'rule_employee',
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const NODE_TYPE_ALIASES = {
|
|
59
|
-
approval: 'approval',
|
|
60
|
-
approver: 'approval',
|
|
61
|
-
approvalnode: 'approval',
|
|
62
|
-
operator: 'operator',
|
|
63
|
-
executor: 'operator',
|
|
64
|
-
handler: 'operator',
|
|
65
|
-
fill: 'operator',
|
|
66
|
-
filler: 'operator',
|
|
67
|
-
formfill: 'operator',
|
|
68
|
-
operatornode: 'operator',
|
|
69
|
-
multiapproval: 'multiApproval',
|
|
70
|
-
multiapprover: 'multiApproval',
|
|
71
|
-
multiapprovalnode: 'multiApproval',
|
|
72
|
-
carbon: 'carbon',
|
|
73
|
-
cc: 'carbon',
|
|
74
|
-
copy: 'carbon',
|
|
75
|
-
copynode: 'carbon',
|
|
76
|
-
carbonnode: 'carbon',
|
|
77
|
-
route: 'route',
|
|
78
|
-
branch: 'route',
|
|
79
|
-
branchnode: 'route',
|
|
80
|
-
conditioncontainer: 'route',
|
|
81
|
-
conditionnode: 'route',
|
|
82
|
-
parallel: 'parallel',
|
|
83
|
-
parallelbranch: 'parallel',
|
|
84
|
-
connector: 'ConnectorNode',
|
|
85
|
-
connectornode: 'ConnectorNode',
|
|
86
|
-
groovy: 'GroovyNode',
|
|
87
|
-
groovynode: 'GroovyNode',
|
|
88
|
-
javascript: 'JavaScriptNode',
|
|
89
|
-
js: 'JavaScriptNode',
|
|
90
|
-
javascriptnode: 'JavaScriptNode',
|
|
91
|
-
initiateapproval: 'InitiateApprovalNode',
|
|
92
|
-
subprocess: 'InitiateApprovalNode',
|
|
93
|
-
initiateapprovalnode: 'InitiateApprovalNode',
|
|
94
|
-
sendmessage: 'SendMessageNode',
|
|
95
|
-
message: 'SendMessageNode',
|
|
96
|
-
sendmessagenode: 'SendMessageNode',
|
|
97
|
-
sendemail: 'SendEmailNode',
|
|
98
|
-
email: 'SendEmailNode',
|
|
99
|
-
sendemailnode: 'SendEmailNode',
|
|
100
|
-
getdata: 'GetSingleDataNode',
|
|
101
|
-
getsingledata: 'GetSingleDataNode',
|
|
102
|
-
getsingledatanode: 'GetSingleDataNode',
|
|
103
|
-
getbatchdata: 'GetBatchDataNode',
|
|
104
|
-
getbatchdatanode: 'GetBatchDataNode',
|
|
105
|
-
adddata: 'AddDataNode',
|
|
106
|
-
createdata: 'AddDataNode',
|
|
107
|
-
adddatanode: 'AddDataNode',
|
|
108
|
-
updatedata: 'UpdateDataNode',
|
|
109
|
-
updatedatanode: 'UpdateDataNode',
|
|
110
|
-
deletedata: 'DeleteDataNode',
|
|
111
|
-
deletedatanode: 'DeleteDataNode',
|
|
112
|
-
sendcard: 'SendCardNode',
|
|
113
|
-
sendcardnode: 'SendCardNode',
|
|
114
|
-
cardnode: 'CardNode',
|
|
115
|
-
updatecard: 'UpdateCardNode',
|
|
116
|
-
updatecardnode: 'UpdateCardNode',
|
|
117
|
-
cardupdate: 'CardUpdateNode',
|
|
118
|
-
cardupdatenode: 'CardUpdateNode',
|
|
119
|
-
cycle: 'CycleContainer',
|
|
120
|
-
foreach: 'CycleContainer',
|
|
121
|
-
cyclecontainer: 'CycleContainer',
|
|
122
|
-
ai: 'AINode',
|
|
123
|
-
ainode: 'AINode',
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const CONNECTOR_MODE_TO_PROCESS_TYPE = {
|
|
127
|
-
1: 'innerConnector',
|
|
128
|
-
3: 'thirdConnector',
|
|
129
|
-
5: 'httpConnector',
|
|
130
|
-
9: 'faasConnector',
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const GENERIC_NODE_CONFIGS = {
|
|
134
|
-
ConnectorNode: {
|
|
135
|
-
processType: 'innerConnector',
|
|
136
|
-
title: ['čæę„åØ', 'Connector', 'ć³ććÆćæ'],
|
|
137
|
-
propKeys: ['connectorRules'],
|
|
138
|
-
},
|
|
139
|
-
GroovyNode: {
|
|
140
|
-
processType: 'CodeExecutor',
|
|
141
|
-
title: ['Groovy', 'Groovy', 'Groovy'],
|
|
142
|
-
propKeys: ['groovy'],
|
|
143
|
-
},
|
|
144
|
-
JavaScriptNode: {
|
|
145
|
-
processType: 'CodeExecutor',
|
|
146
|
-
title: ['JavaScript', 'JavaScript', 'JavaScript'],
|
|
147
|
-
propKeys: ['JavaScript'],
|
|
148
|
-
propAliases: { javascript: 'JavaScript' },
|
|
149
|
-
},
|
|
150
|
-
InitiateApprovalNode: {
|
|
151
|
-
processType: 'initiateApproval',
|
|
152
|
-
title: ['åęµēØ', 'Sub process', 'ćµćććć»ć¹'],
|
|
153
|
-
propKeys: ['initiateApprovalRules'],
|
|
154
|
-
},
|
|
155
|
-
SendMessageNode: {
|
|
156
|
-
processType: 'sendMessage',
|
|
157
|
-
title: ['ę¶ęÆéē„', 'Message notification', 'ć”ćć»ć¼ćøéē„'],
|
|
158
|
-
propKeys: ['sendMessageRules'],
|
|
159
|
-
},
|
|
160
|
-
SendEmailNode: {
|
|
161
|
-
processType: 'sendEmail',
|
|
162
|
-
title: ['åéé®ä»¶', 'Send email', 'ć”ć¼ć«éäæ”'],
|
|
163
|
-
propKeys: ['sendEmailRules'],
|
|
164
|
-
},
|
|
165
|
-
GetSingleDataNode: {
|
|
166
|
-
processType: 'dataRetrieve',
|
|
167
|
-
title: ['č·ååę”ę°ę®', 'Get single data', 'åäøćć¼ćæåå¾'],
|
|
168
|
-
propKeys: ['getData'],
|
|
169
|
-
},
|
|
170
|
-
GetBatchDataNode: {
|
|
171
|
-
processType: 'dataRetrieve',
|
|
172
|
-
title: ['č·åå¤ę”ę°ę®', 'Get batch data', 'č¤ę°ćć¼ćæåå¾'],
|
|
173
|
-
propKeys: ['getData'],
|
|
174
|
-
},
|
|
175
|
-
AddDataNode: {
|
|
176
|
-
processType: 'dataCreate',
|
|
177
|
-
title: ['ę°å¢ę°ę®', 'Add data', 'ćć¼ćæčæ½å '],
|
|
178
|
-
propKeys: ['addDataRules'],
|
|
179
|
-
},
|
|
180
|
-
UpdateDataNode: {
|
|
181
|
-
processType: 'dataUpdate',
|
|
182
|
-
title: ['ę“ę°ę°ę®', 'Update data', 'ćć¼ćæę“ę°'],
|
|
183
|
-
propKeys: ['updateDataRules'],
|
|
184
|
-
},
|
|
185
|
-
DeleteDataNode: {
|
|
186
|
-
processType: 'dataDelete',
|
|
187
|
-
title: ['å é¤ę°ę®', 'Delete data', 'ćć¼ćæåé¤'],
|
|
188
|
-
propKeys: ['deleteData'],
|
|
189
|
-
},
|
|
190
|
-
SendCardNode: {
|
|
191
|
-
processType: 'sendCard',
|
|
192
|
-
title: ['åéå”ē', 'Send card', 'ć«ć¼ćéäæ”'],
|
|
193
|
-
propKeys: ['sendCardRules', 'cardRules'],
|
|
194
|
-
},
|
|
195
|
-
CardNode: {
|
|
196
|
-
processType: 'sendCard',
|
|
197
|
-
title: ['åéå”ē', 'Send card', 'ć«ć¼ćéäæ”'],
|
|
198
|
-
propKeys: ['sendCardRules', 'cardRules'],
|
|
199
|
-
},
|
|
200
|
-
UpdateCardNode: {
|
|
201
|
-
processType: 'updateCard',
|
|
202
|
-
title: ['ę“ę°å”ē', 'Update card', 'ć«ć¼ćę“ę°'],
|
|
203
|
-
propKeys: ['updateCardRules', 'cardUpdateRules'],
|
|
204
|
-
},
|
|
205
|
-
CardUpdateNode: {
|
|
206
|
-
processType: 'updateCard',
|
|
207
|
-
title: ['ę“ę°å”ē', 'Update card', 'ć«ć¼ćę“ę°'],
|
|
208
|
-
propKeys: ['updateCardRules', 'cardUpdateRules'],
|
|
209
|
-
},
|
|
210
|
-
CycleContainer: {
|
|
211
|
-
processType: 'foreach',
|
|
212
|
-
title: ['å¾ŖēÆ', 'Loop', 'ć«ć¼ć'],
|
|
213
|
-
propKeys: ['cycleContainerRules'],
|
|
214
|
-
propAliases: { cycleRules: 'cycleContainerRules', foreachRules: 'cycleContainerRules' },
|
|
215
|
-
},
|
|
216
|
-
AINode: {
|
|
217
|
-
processType: 'AIExecutor',
|
|
218
|
-
title: ['AI å·„ä½ęµ', 'AI workflow', 'AI ćÆć¼ćÆććć¼'],
|
|
219
|
-
propKeys: ['workFlowRules'],
|
|
220
|
-
propAliases: { workflowRules: 'workFlowRules' },
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// āā č¾
å©å½ę° āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
225
|
-
|
|
226
|
-
function generateUuid() {
|
|
227
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
228
|
-
const r = (Math.random() * 16) | 0;
|
|
229
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
230
|
-
return v.toString(16);
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
let nodeIdCounter = 1;
|
|
235
|
-
function generateNodeId() {
|
|
236
|
-
return 'node_oc' + Date.now().toString(36) + (nodeIdCounter++).toString(36);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function i18n(zhText, enText, jaText) {
|
|
240
|
-
return buildYidaI18n(zhText, {
|
|
241
|
-
en_US: enText || zhText,
|
|
242
|
-
ja_JP: jaText || zhText,
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function isPlainObject(value) {
|
|
247
|
-
return value && typeof value === 'object' && !Array.isArray(value);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function normalizeList(value) {
|
|
251
|
-
if (value === undefined || value === null || value === '') {
|
|
252
|
-
return [];
|
|
253
|
-
}
|
|
254
|
-
return Array.isArray(value) ? value : [value];
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function clonePlain(value) {
|
|
258
|
-
if (value === undefined) {
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
return JSON.parse(JSON.stringify(value));
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function normalizeNodeType(node) {
|
|
265
|
-
if (!node) {
|
|
266
|
-
return '';
|
|
267
|
-
}
|
|
268
|
-
if (node.componentName && GENERIC_NODE_CONFIGS[node.componentName]) {
|
|
269
|
-
return node.componentName;
|
|
270
|
-
}
|
|
271
|
-
const rawType = pickFirstDefined(node.type, node.kind, node.nodeType, node.componentName);
|
|
272
|
-
if (!rawType) {
|
|
273
|
-
return '';
|
|
274
|
-
}
|
|
275
|
-
const raw = String(rawType).trim();
|
|
276
|
-
const normalized = raw.toLowerCase().replace(/[-_\s]/g, '');
|
|
277
|
-
return NODE_TYPE_ALIASES[normalized] || raw;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function getNodeName(node, fallback) {
|
|
281
|
-
const value = pickFirstDefined(
|
|
282
|
-
node && node.name,
|
|
283
|
-
node && node.title,
|
|
284
|
-
node && node.props && node.props.name,
|
|
285
|
-
fallback
|
|
286
|
-
);
|
|
287
|
-
if (isPlainObject(value)) {
|
|
288
|
-
return pickFirstDefined(value.zh_CN, value.en_US, value.ja_JP, fallback) || fallback;
|
|
289
|
-
}
|
|
290
|
-
return String(value || fallback || '');
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function getNodeDescription(node) {
|
|
294
|
-
const value = pickFirstDefined(
|
|
295
|
-
node && node.description,
|
|
296
|
-
node && node.props && node.props.description,
|
|
297
|
-
''
|
|
298
|
-
);
|
|
299
|
-
if (isPlainObject(value)) {
|
|
300
|
-
return pickFirstDefined(value.zh_CN, value.en_US, value.ja_JP, '') || '';
|
|
301
|
-
}
|
|
302
|
-
return String(value || '');
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function pickFirstDefined() {
|
|
306
|
-
for (let i = 0; i < arguments.length; i++) {
|
|
307
|
-
if (arguments[i] !== undefined && arguments[i] !== null && arguments[i] !== '') {
|
|
308
|
-
return arguments[i];
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return undefined;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function getEntityId(item) {
|
|
315
|
-
if (typeof item === 'string' || typeof item === 'number') {
|
|
316
|
-
return String(item);
|
|
317
|
-
}
|
|
318
|
-
if (!isPlainObject(item)) {
|
|
319
|
-
return '';
|
|
320
|
-
}
|
|
321
|
-
return String(pickFirstDefined(item.id, item.userId, item.workNo, item.value, item.uuid, item.roleId, item.code) || '');
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
function getEntityLabel(item, id) {
|
|
325
|
-
if (!isPlainObject(item)) {
|
|
326
|
-
return id;
|
|
327
|
-
}
|
|
328
|
-
return String(pickFirstDefined(item.label, item.name, item.nickName, item.userName, item.title, id) || id);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
function normalizeApprovalMode(value) {
|
|
332
|
-
const mode = String(value || 'all');
|
|
333
|
-
const aliases = {
|
|
334
|
-
countersign: 'all',
|
|
335
|
-
counterSign: 'all',
|
|
336
|
-
and: 'all',
|
|
337
|
-
all: 'all',
|
|
338
|
-
or: 'or',
|
|
339
|
-
any: 'or',
|
|
340
|
-
one: 'or',
|
|
341
|
-
oneByOne: 'oneByOne',
|
|
342
|
-
serial: 'oneByOne',
|
|
343
|
-
sequence: 'oneByOne',
|
|
344
|
-
};
|
|
345
|
-
return aliases[mode] || mode;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function createBaseApproverRules(type, description, approver) {
|
|
349
|
-
return {
|
|
350
|
-
type: type,
|
|
351
|
-
mode: approver.mode || 'ApprovalNode_rules_only',
|
|
352
|
-
approverList: approver.approverList || [{ type: 'ext_target_approval' }],
|
|
353
|
-
multiApproverType: normalizeApprovalMode(approver.multiApproverType || approver.approvalMode || 'all'),
|
|
354
|
-
conditionalMode: approver.conditionalMode || 'conditional',
|
|
355
|
-
description: description,
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function getFriendlyApproverKind(approver) {
|
|
360
|
-
if (typeof approver === 'string') {
|
|
361
|
-
const text = approver.trim();
|
|
362
|
-
if (!text || text === 'originator' || text === 'self' || text === 'starter' || text === 'åčµ·äŗŗ') {
|
|
363
|
-
return 'originator';
|
|
364
|
-
}
|
|
365
|
-
return null;
|
|
366
|
-
}
|
|
367
|
-
if (!isPlainObject(approver)) {
|
|
368
|
-
return null;
|
|
369
|
-
}
|
|
370
|
-
const rawKind = String(approver.kind || approver.approverType || approver.type || '').trim();
|
|
371
|
-
if (!rawKind || rawKind.indexOf('ext_target_') === 0) {
|
|
372
|
-
return null;
|
|
373
|
-
}
|
|
374
|
-
const normalized = rawKind.toLowerCase().replace(/[-_\s]/g, '');
|
|
375
|
-
const kindMap = {
|
|
376
|
-
originator: 'originator',
|
|
377
|
-
self: 'originator',
|
|
378
|
-
starter: 'originator',
|
|
379
|
-
user: 'user',
|
|
380
|
-
users: 'user',
|
|
381
|
-
member: 'user',
|
|
382
|
-
members: 'user',
|
|
383
|
-
person: 'user',
|
|
384
|
-
employee: 'user',
|
|
385
|
-
designee: 'user',
|
|
386
|
-
specifiedmember: 'user',
|
|
387
|
-
role: 'role',
|
|
388
|
-
roles: 'role',
|
|
389
|
-
deptleader: 'deptLeader',
|
|
390
|
-
departmentleader: 'deptLeader',
|
|
391
|
-
departmenthead: 'deptLeader',
|
|
392
|
-
supervisor: 'deptLeader',
|
|
393
|
-
manager: 'deptLeader',
|
|
394
|
-
directleader: 'directLeader',
|
|
395
|
-
directsupervisor: 'directLeader',
|
|
396
|
-
};
|
|
397
|
-
return kindMap[normalized] || null;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function normalizeUserApprovers(approver) {
|
|
401
|
-
const source = normalizeList(
|
|
402
|
-
pickFirstDefined(
|
|
403
|
-
approver.users,
|
|
404
|
-
approver.members,
|
|
405
|
-
approver.employees,
|
|
406
|
-
approver.userIds,
|
|
407
|
-
approver.ids,
|
|
408
|
-
approver.approvals,
|
|
409
|
-
approver.value
|
|
410
|
-
)
|
|
411
|
-
);
|
|
412
|
-
return source.map(function (item) {
|
|
413
|
-
const id = getEntityId(item);
|
|
414
|
-
if (!id) {
|
|
415
|
-
throw new Error('å®”ę¹äŗŗ user é
ē½®ē¼ŗå° id/userId/value');
|
|
416
|
-
}
|
|
417
|
-
const user = {
|
|
418
|
-
id: id,
|
|
419
|
-
label: getEntityLabel(item, id),
|
|
420
|
-
type: isPlainObject(item) ? (item.type || 'employee') : 'employee',
|
|
421
|
-
roleType: isPlainObject(item) ? (item.roleType || 'DINGTALK') : 'DINGTALK',
|
|
422
|
-
};
|
|
423
|
-
if (isPlainObject(item) && item.avatar) {
|
|
424
|
-
user.avatar = item.avatar;
|
|
425
|
-
}
|
|
426
|
-
return user;
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function normalizeRoleApprovers(approver) {
|
|
431
|
-
const source = normalizeList(
|
|
432
|
-
pickFirstDefined(
|
|
433
|
-
approver.roles,
|
|
434
|
-
approver.roleIds,
|
|
435
|
-
approver.ids,
|
|
436
|
-
approver.approvals,
|
|
437
|
-
approver.value
|
|
438
|
-
)
|
|
439
|
-
);
|
|
440
|
-
return source.map(function (item) {
|
|
441
|
-
const id = getEntityId(item);
|
|
442
|
-
if (!id) {
|
|
443
|
-
throw new Error('å®”ę¹äŗŗ role é
ē½®ē¼ŗå° id/uuid/roleId/value');
|
|
444
|
-
}
|
|
445
|
-
return {
|
|
446
|
-
id: id,
|
|
447
|
-
label: getEntityLabel(item, id),
|
|
448
|
-
type: isPlainObject(item) ? (item.type || 'role') : 'role',
|
|
449
|
-
roleType: isPlainObject(item)
|
|
450
|
-
? (item.roleType || approver.roleType || 'YIDA')
|
|
451
|
-
: (approver.roleType || 'YIDA'),
|
|
452
|
-
};
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
function buildMultiRoles(roles) {
|
|
457
|
-
const grouped = {};
|
|
458
|
-
roles.forEach(function (role) {
|
|
459
|
-
const roleType = role.roleType || 'YIDA';
|
|
460
|
-
if (!grouped[roleType]) {
|
|
461
|
-
grouped[roleType] = [];
|
|
462
|
-
}
|
|
463
|
-
grouped[roleType].push(role.id);
|
|
464
|
-
});
|
|
465
|
-
return Object.keys(grouped).map(function (roleType) {
|
|
466
|
-
return {
|
|
467
|
-
roleId: grouped[roleType],
|
|
468
|
-
roleExtType: roleType,
|
|
469
|
-
};
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
function getApproverSource(approver, direct) {
|
|
474
|
-
const value = pickFirstDefined(
|
|
475
|
-
approver.source,
|
|
476
|
-
approver.originator,
|
|
477
|
-
approver.userIdVar,
|
|
478
|
-
direct ? approver.directSupervisorSource : approver.supervisorSource,
|
|
479
|
-
'originator'
|
|
480
|
-
);
|
|
481
|
-
const label = pickFirstDefined(
|
|
482
|
-
approver.sourceLabel,
|
|
483
|
-
approver.originatorLabel,
|
|
484
|
-
value === 'originator' ? 'åčµ·äŗŗ' : value
|
|
485
|
-
);
|
|
486
|
-
return {
|
|
487
|
-
value: String(value),
|
|
488
|
-
label: String(label),
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function formatLevelDescription(sourceLabel, level, direct) {
|
|
493
|
-
return sourceLabel + 'ē第' + level + 'ēŗ§' + (direct ? 'ē“å±äø»ē®”' : '主箔');
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
function buildOriginatorApproverConfig(node, approver) {
|
|
497
|
-
const raw = isPlainObject(approver) ? approver : {};
|
|
498
|
-
return {
|
|
499
|
-
approvalType: 'ext_target_approval_originator',
|
|
500
|
-
approvals: [['originator']],
|
|
501
|
-
processProps: raw.processProps || raw.props || {},
|
|
502
|
-
approverRules: Object.assign(
|
|
503
|
-
createBaseApproverRules('ext_target_approval_originator', raw.description || 'åčµ·äŗŗę¬äŗŗ', raw),
|
|
504
|
-
raw.approverRules || {}
|
|
505
|
-
),
|
|
506
|
-
description: raw.nodeDescription || node.description || '请éę©å®”ę¹äŗŗ',
|
|
507
|
-
carbonReceiver: { type: 'VARIABLE', value: [['originator']] },
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function buildUserApproverConfig(node, approver) {
|
|
512
|
-
const users = normalizeUserApprovers(approver);
|
|
513
|
-
if (users.length === 0) {
|
|
514
|
-
throw new Error('å®”ę¹äŗŗ user é
ē½®č³å°éč¦äøäøŖ users/userIds/approvals');
|
|
515
|
-
}
|
|
516
|
-
const userIds = users.map(function (user) { return user.id; });
|
|
517
|
-
const description = approver.description || users.map(function (user) { return user.label; }).join(', ');
|
|
518
|
-
const approvalMode = normalizeApprovalMode(approver.multiApproverType || approver.approvalMode || 'all');
|
|
519
|
-
const approverRules = Object.assign(
|
|
520
|
-
createBaseApproverRules('ext_target_approval', description, approver),
|
|
521
|
-
{
|
|
522
|
-
approvals: users,
|
|
523
|
-
approvalType_ext_target_approval: approvalMode,
|
|
524
|
-
},
|
|
525
|
-
approver.approverRules || {}
|
|
526
|
-
);
|
|
527
|
-
return {
|
|
528
|
-
approvalType: 'ext_target_approval',
|
|
529
|
-
approvals: userIds,
|
|
530
|
-
processProps: Object.assign({ multiApprove: approvalMode }, approver.processProps || approver.props || {}),
|
|
531
|
-
approverRules: approverRules,
|
|
532
|
-
description: approver.nodeDescription || node.description || '请éę©å®”ę¹äŗŗ',
|
|
533
|
-
carbonReceiver: { type: 'NORMAL', value: userIds },
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
function buildRoleApproverConfig(node, approver) {
|
|
538
|
-
const roles = normalizeRoleApprovers(approver);
|
|
539
|
-
if (roles.length === 0) {
|
|
540
|
-
throw new Error('å®”ę¹äŗŗ role é
ē½®č³å°éč¦äøäøŖ roles/roleIds/approvals');
|
|
541
|
-
}
|
|
542
|
-
const roleIds = roles.map(function (role) { return role.id; });
|
|
543
|
-
const description = approver.description || roles.map(function (role) { return role.label; }).join(', ');
|
|
544
|
-
const approvalMode = normalizeApprovalMode(approver.multiApproverType || approver.approvalMode || 'all');
|
|
545
|
-
const approverRules = Object.assign(
|
|
546
|
-
createBaseApproverRules('ext_target_approval_role', description, approver),
|
|
547
|
-
{
|
|
548
|
-
roles: roles,
|
|
549
|
-
approvalType_ext_target_approval_role: approvalMode,
|
|
550
|
-
},
|
|
551
|
-
approver.approverRules || {}
|
|
552
|
-
);
|
|
553
|
-
return {
|
|
554
|
-
approvalType: 'ext_target_approval_role',
|
|
555
|
-
processProps: Object.assign({
|
|
556
|
-
multiRoles: buildMultiRoles(roles),
|
|
557
|
-
multiApprove: approvalMode,
|
|
558
|
-
}, approver.processProps || approver.props || {}),
|
|
559
|
-
approverRules: approverRules,
|
|
560
|
-
description: approver.nodeDescription || node.description || '请éę©å®”ę¹äŗŗ',
|
|
561
|
-
carbonReceiver: { type: 'ROLE', value: roleIds },
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
function buildDeptLeaderApproverConfig(node, approver) {
|
|
566
|
-
const source = getApproverSource(approver, false);
|
|
567
|
-
const level = String(pickFirstDefined(approver.level, approver.supervisorLevel, 1));
|
|
568
|
-
const approvalMode = normalizeApprovalMode(approver.multiApproverType || approver.approvalMode || 'all');
|
|
569
|
-
const needLeaderReplace = pickFirstDefined(approver.needLeaderReplace, true);
|
|
570
|
-
const ignoreNoLeaderDept = pickFirstDefined(approver.ignoreNoLeaderDept, false);
|
|
571
|
-
const description = approver.description || formatLevelDescription(source.label, level, false);
|
|
572
|
-
const approverRules = Object.assign(
|
|
573
|
-
createBaseApproverRules('ext_target_dept_leader', description, approver),
|
|
574
|
-
{
|
|
575
|
-
approvalType_ext_target_dept_leader: approvalMode,
|
|
576
|
-
supervisorType: source,
|
|
577
|
-
supervisorLevel: level,
|
|
578
|
-
ignoreNoLeaderDept: String(ignoreNoLeaderDept),
|
|
579
|
-
needLeaderReplace: Boolean(needLeaderReplace),
|
|
580
|
-
},
|
|
581
|
-
approver.approverRules || {}
|
|
582
|
-
);
|
|
583
|
-
return {
|
|
584
|
-
approvalType: 'ext_target_dept_leader',
|
|
585
|
-
processProps: Object.assign({
|
|
586
|
-
key: 'DeptLeaderApproverRule_1.0.0',
|
|
587
|
-
userIdVar: source.value,
|
|
588
|
-
reportLevel: Number(level),
|
|
589
|
-
ignoreNoLeaderDept: String(ignoreNoLeaderDept),
|
|
590
|
-
needLeaderReplace: String(Boolean(needLeaderReplace)),
|
|
591
|
-
multiApprove: approvalMode,
|
|
592
|
-
}, approver.processProps || approver.props || {}),
|
|
593
|
-
approverRules: approverRules,
|
|
594
|
-
description: approver.nodeDescription || node.description || '请éę©å®”ę¹äŗŗ',
|
|
595
|
-
carbonReceiver: {
|
|
596
|
-
type: 'MANAGER',
|
|
597
|
-
value: {
|
|
598
|
-
originator: source.value,
|
|
599
|
-
level: Number(level),
|
|
600
|
-
},
|
|
601
|
-
},
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
function buildDirectLeaderApproverConfig(node, approver) {
|
|
606
|
-
const source = getApproverSource(approver, true);
|
|
607
|
-
const level = String(pickFirstDefined(approver.level, approver.directSupervisorLevel, 1));
|
|
608
|
-
const approvalMode = normalizeApprovalMode(approver.multiApproverType || approver.approvalMode || 'all');
|
|
609
|
-
const needDeptLeaderReplace = pickFirstDefined(approver.needDeptLeaderReplace, true);
|
|
610
|
-
const description = approver.description || formatLevelDescription(source.label, level, true);
|
|
611
|
-
const approverRules = Object.assign(
|
|
612
|
-
createBaseApproverRules('ext_target_direct_leader', description, approver),
|
|
613
|
-
{
|
|
614
|
-
approvalType_ext_target_direct_leader: approvalMode,
|
|
615
|
-
directSupervisorType: source,
|
|
616
|
-
directSupervisorLevel: level,
|
|
617
|
-
needDeptLeaderReplace: Boolean(needDeptLeaderReplace),
|
|
618
|
-
},
|
|
619
|
-
approver.approverRules || {}
|
|
620
|
-
);
|
|
621
|
-
return {
|
|
622
|
-
approvalType: 'ext_target_direct_leader',
|
|
623
|
-
processProps: Object.assign({
|
|
624
|
-
key: 'DirectLeaderApproverRule_1.0.0',
|
|
625
|
-
userIdVar: source.value,
|
|
626
|
-
reportLevel: Number(level),
|
|
627
|
-
needDeptLeaderReplace: String(Boolean(needDeptLeaderReplace)),
|
|
628
|
-
multiApprove: approvalMode,
|
|
629
|
-
}, approver.processProps || approver.props || {}),
|
|
630
|
-
approverRules: approverRules,
|
|
631
|
-
description: approver.nodeDescription || node.description || '请éę©å®”ę¹äŗŗ',
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
function buildFriendlyApproverConfig(node, approver) {
|
|
636
|
-
const kind = getFriendlyApproverKind(approver);
|
|
637
|
-
if (!kind) {
|
|
638
|
-
return null;
|
|
639
|
-
}
|
|
640
|
-
const raw = isPlainObject(approver) ? approver : {};
|
|
641
|
-
if (kind === 'originator') {
|
|
642
|
-
return buildOriginatorApproverConfig(node, raw);
|
|
643
|
-
}
|
|
644
|
-
if (kind === 'user') {
|
|
645
|
-
return buildUserApproverConfig(node, raw);
|
|
646
|
-
}
|
|
647
|
-
if (kind === 'role') {
|
|
648
|
-
return buildRoleApproverConfig(node, raw);
|
|
649
|
-
}
|
|
650
|
-
if (kind === 'deptLeader') {
|
|
651
|
-
return buildDeptLeaderApproverConfig(node, raw);
|
|
652
|
-
}
|
|
653
|
-
if (kind === 'directLeader') {
|
|
654
|
-
return buildDirectLeaderApproverConfig(node, raw);
|
|
655
|
-
}
|
|
656
|
-
return null;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
// āā ę建宔ę¹/ęéåØä½å蔨 āāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
660
|
-
|
|
661
|
-
function buildActions() {
|
|
662
|
-
const actionDefs = [
|
|
663
|
-
{ action: 'agree', zh: 'åę', en: 'Agree', ja: 'åę', hidden: false },
|
|
664
|
-
{ action: 'disagree', zh: 'ęē»', en: 'Disagree', ja: 'ęå¦', hidden: false },
|
|
665
|
-
{ action: 'save', zh: 'äæå', en: 'Save', ja: 'äæå', hidden: true },
|
|
666
|
-
{ action: 'forward', zh: '转交', en: 'Forward', ja: '転é', hidden: true },
|
|
667
|
-
{ action: 'append', zh: 'å ē¾', en: 'Append', ja: 'ęæčŖč
ćčæ½å ', hidden: true },
|
|
668
|
-
{ action: 'return', zh: 'éå', en: 'Return', ja: 'å·®ćę»ć', hidden: true },
|
|
669
|
-
];
|
|
670
|
-
|
|
671
|
-
return actionDefs.map(function (def) {
|
|
672
|
-
return {
|
|
673
|
-
hidden: def.hidden,
|
|
674
|
-
name: i18n(def.zh, def.en, def.ja),
|
|
675
|
-
action: def.action,
|
|
676
|
-
text: i18n(def.zh, def.en, def.ja),
|
|
677
|
-
alias: i18n(def.zh, def.en, def.ja),
|
|
678
|
-
};
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
// āā ę建ę”ä»¶č§åļ¼äø„ę ¼å¹é
å®ęēå®ę ¼å¼ļ¼āāāāāāāāāāāāā
|
|
683
|
-
|
|
684
|
-
function buildConditionRules(rules, logic) {
|
|
685
|
-
const conditionCode = logic === 'OR' ? '||' : '&&';
|
|
686
|
-
const groupId = 'group-' + generateUuid();
|
|
687
|
-
|
|
688
|
-
const builtRules = rules.map(function (rule) {
|
|
689
|
-
const opDisplay = OP_CODE_TO_DISPLAY[rule.op] || rule.op;
|
|
690
|
-
const ruleType = COMPONENT_TO_RULE_TYPE[rule.componentType] || 'rule_text';
|
|
691
|
-
|
|
692
|
-
const ruleObj = {
|
|
693
|
-
id: rule.fieldId,
|
|
694
|
-
op: opDisplay,
|
|
695
|
-
operators: [],
|
|
696
|
-
value: rule.value,
|
|
697
|
-
componentType: rule.componentType || 'TextField',
|
|
698
|
-
ruleId: 'item-' + generateUuid(),
|
|
699
|
-
parentId: groupId,
|
|
700
|
-
extValue: 'value',
|
|
701
|
-
ruleValue: rule.value,
|
|
702
|
-
name: rule.fieldName || rule.fieldId,
|
|
703
|
-
valueType: 'literal',
|
|
704
|
-
ruleType: ruleType,
|
|
705
|
-
opCode: rule.op,
|
|
706
|
-
};
|
|
707
|
-
|
|
708
|
-
// NumberField éč¦ formula åꮵļ¼å®ęęå”端ēØå®ę建ę°åęÆč¾å
¬å¼
|
|
709
|
-
if (rule.componentType === 'NumberField') {
|
|
710
|
-
const opSymbolMap = {
|
|
711
|
-
GreaterThan: '>',
|
|
712
|
-
Bigger: '>',
|
|
713
|
-
GreaterThanOrEqual: '>=',
|
|
714
|
-
LessThan: '<',
|
|
715
|
-
LessThanOrEqual: '<=',
|
|
716
|
-
Equal: '==',
|
|
717
|
-
NotEqual: '!=',
|
|
718
|
-
};
|
|
719
|
-
const opSymbol = opSymbolMap[rule.op] || '==';
|
|
720
|
-
ruleObj.formula = '${' + rule.fieldId + '}' + opSymbol + rule.value;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
return ruleObj;
|
|
724
|
-
});
|
|
725
|
-
|
|
726
|
-
return {
|
|
727
|
-
condition: logic === 'OR' ? 'OR' : 'AND',
|
|
728
|
-
rules: builtRules,
|
|
729
|
-
ruleId: groupId,
|
|
730
|
-
conditionCode: conditionCode,
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// āā ę建跳转č§åļ¼routeRuleļ¼āāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
735
|
-
|
|
736
|
-
function buildRouteRule(routeRuleDefs, currentNodeId, nodeNameToIdMap) {
|
|
737
|
-
if (!routeRuleDefs || routeRuleDefs.length === 0) {
|
|
738
|
-
return {
|
|
739
|
-
rules: [],
|
|
740
|
-
triggerRule: 'n',
|
|
741
|
-
ruleIfMiss: 'terminate',
|
|
742
|
-
defaultNextId: [],
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
const rules = routeRuleDefs.map(function (ruleDef, index) {
|
|
747
|
-
// č§£ę跳转ē®ę
|
|
748
|
-
const targetNodeId = nodeNameToIdMap[ruleDef.jumpTo];
|
|
749
|
-
if (!targetNodeId) {
|
|
750
|
-
warn(' ā ļø routeRule 跳转ē®ę "' + ruleDef.jumpTo + '" ęŖę¾å°åƹåŗčē¹');
|
|
751
|
-
return null;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
// ę建ę”ä»¶č§å
|
|
755
|
-
const conditionGroupId = 'group-' + generateUuid();
|
|
756
|
-
const conditionRules = [];
|
|
757
|
-
|
|
758
|
-
if (ruleDef.when === 'disagree' || ruleDef.when === 'agree') {
|
|
759
|
-
// åŗäŗå®”ę¹ē»ęē跳转ļ¼å
ē½®čęåꮵ approvalResultļ¼
|
|
760
|
-
conditionRules.push({
|
|
761
|
-
componentType: 'SelectField',
|
|
762
|
-
id: 'approvalResult',
|
|
763
|
-
extValue: 'value',
|
|
764
|
-
name: 'å®”ę¹ē»ę',
|
|
765
|
-
op: 'ēäŗ',
|
|
766
|
-
opCode: 'Equal',
|
|
767
|
-
parentId: conditionGroupId,
|
|
768
|
-
ruleId: 'item-' + generateUuid(),
|
|
769
|
-
ruleType: 'rule_text',
|
|
770
|
-
ruleValue: ruleDef.when,
|
|
771
|
-
value: ruleDef.when,
|
|
772
|
-
valueType: 'literal',
|
|
773
|
-
});
|
|
774
|
-
} else if (ruleDef.fieldRules && ruleDef.fieldRules.length > 0) {
|
|
775
|
-
// åŗäŗč”Øååꮵē跳转ę”ä»¶
|
|
776
|
-
ruleDef.fieldRules.forEach(function (fieldRule) {
|
|
777
|
-
const opDisplay = OP_CODE_TO_DISPLAY[fieldRule.op] || fieldRule.op;
|
|
778
|
-
const ruleType = COMPONENT_TO_RULE_TYPE[fieldRule.componentType] || 'rule_text';
|
|
779
|
-
conditionRules.push({
|
|
780
|
-
componentType: fieldRule.componentType,
|
|
781
|
-
id: fieldRule.fieldId,
|
|
782
|
-
extValue: 'value',
|
|
783
|
-
name: fieldRule.fieldName,
|
|
784
|
-
op: opDisplay,
|
|
785
|
-
opCode: fieldRule.op,
|
|
786
|
-
parentId: conditionGroupId,
|
|
787
|
-
ruleId: 'item-' + generateUuid(),
|
|
788
|
-
ruleType: ruleType,
|
|
789
|
-
ruleValue: fieldRule.value,
|
|
790
|
-
value: fieldRule.value,
|
|
791
|
-
valueType: 'literal',
|
|
792
|
-
});
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
const conditionNodeId = generateNodeId();
|
|
797
|
-
return {
|
|
798
|
-
type: 'condition',
|
|
799
|
-
nodeId: conditionNodeId,
|
|
800
|
-
prevId: currentNodeId,
|
|
801
|
-
nextId: [targetNodeId],
|
|
802
|
-
props: {
|
|
803
|
-
calculate: 'condition',
|
|
804
|
-
isDefault: false,
|
|
805
|
-
conditions: {
|
|
806
|
-
condition: (ruleDef.logic || 'AND'),
|
|
807
|
-
conditionCode: (ruleDef.logic === 'OR' ? '||' : '&&'),
|
|
808
|
-
ruleId: conditionGroupId,
|
|
809
|
-
rules: conditionRules,
|
|
810
|
-
},
|
|
811
|
-
priority: index + 1,
|
|
812
|
-
},
|
|
813
|
-
};
|
|
814
|
-
}).filter(function (rule) { return rule !== null; });
|
|
815
|
-
|
|
816
|
-
return {
|
|
817
|
-
rules: rules,
|
|
818
|
-
triggerRule: rules.length > 0 ? 'y' : 'n',
|
|
819
|
-
ruleIfMiss: 'terminate',
|
|
820
|
-
defaultNextId: [],
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// āā éå½åé
nodeId āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
825
|
-
|
|
826
|
-
function assignNodeIdsRecursive(nodes, nameToIdMap) {
|
|
827
|
-
nodes.forEach(function (node) {
|
|
828
|
-
const nodeType = normalizeNodeType(node);
|
|
829
|
-
if (nodeType === 'route') {
|
|
830
|
-
node._nodeId = generateNodeId();
|
|
831
|
-
const conditions = node.conditions || [];
|
|
832
|
-
conditions.forEach(function (cond) {
|
|
833
|
-
cond._nodeId = generateNodeId();
|
|
834
|
-
if (cond.childNodes && cond.childNodes.length > 0) {
|
|
835
|
-
assignNodeIdsRecursive(cond.childNodes, nameToIdMap);
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
} else if (nodeType === 'parallel') {
|
|
839
|
-
node._nodeId = generateNodeId();
|
|
840
|
-
if (node.name) {
|
|
841
|
-
nameToIdMap[node.name] = node._nodeId;
|
|
842
|
-
}
|
|
843
|
-
const branches = getParallelBranches(node);
|
|
844
|
-
branches.forEach(function (branch) {
|
|
845
|
-
branch._nodeId = generateNodeId();
|
|
846
|
-
const childNodes = getBranchChildNodes(branch);
|
|
847
|
-
if (childNodes.length > 0) {
|
|
848
|
-
assignNodeIdsRecursive(childNodes, nameToIdMap);
|
|
849
|
-
}
|
|
850
|
-
});
|
|
851
|
-
} else if (GENERIC_NODE_CONFIGS[nodeType]) {
|
|
852
|
-
node._nodeId = generateNodeId();
|
|
853
|
-
if (node.name) {
|
|
854
|
-
nameToIdMap[node.name] = node._nodeId;
|
|
855
|
-
}
|
|
856
|
-
const childNodes = getGenericChildNodes(node);
|
|
857
|
-
if (childNodes.length > 0) {
|
|
858
|
-
assignNodeIdsRecursive(childNodes, nameToIdMap);
|
|
859
|
-
}
|
|
860
|
-
} else {
|
|
861
|
-
node._nodeId = generateNodeId();
|
|
862
|
-
if (node.name) {
|
|
863
|
-
nameToIdMap[node.name] = node._nodeId;
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
// āā éå½ę建čē¹ āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
870
|
-
|
|
871
|
-
function buildNodeListRecursive(nodes, exitNodeId, nameToIdMap) {
|
|
872
|
-
const processNodes = [];
|
|
873
|
-
const viewNodes = [];
|
|
874
|
-
|
|
875
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
876
|
-
const node = nodes[i];
|
|
877
|
-
const nextNodeId = i + 1 < nodes.length ? nodes[i + 1]._nodeId : exitNodeId;
|
|
878
|
-
const nodeType = normalizeNodeType(node);
|
|
879
|
-
|
|
880
|
-
if (nodeType === 'route') {
|
|
881
|
-
const routeResult = buildRouteNode(node, nextNodeId, nameToIdMap);
|
|
882
|
-
processNodes.push(routeResult.processNode);
|
|
883
|
-
viewNodes.push(routeResult.viewNode);
|
|
884
|
-
} else if (nodeType === 'parallel') {
|
|
885
|
-
const parallelResult = buildParallelNode(node, nextNodeId, nameToIdMap);
|
|
886
|
-
processNodes.push(parallelResult.processNode);
|
|
887
|
-
viewNodes.push(parallelResult.viewNode);
|
|
888
|
-
} else if (nodeType === 'approval' || nodeType === 'operator' || nodeType === 'multiApproval') {
|
|
889
|
-
const approvalResult = buildApprovalNode(node, nextNodeId, nameToIdMap, nodeType);
|
|
890
|
-
processNodes.push(approvalResult.processNode);
|
|
891
|
-
viewNodes.push(approvalResult.viewNode);
|
|
892
|
-
} else if (nodeType === 'carbon') {
|
|
893
|
-
const carbonResult = buildCarbonNode(node, nextNodeId);
|
|
894
|
-
processNodes.push(carbonResult.processNode);
|
|
895
|
-
viewNodes.push(carbonResult.viewNode);
|
|
896
|
-
} else if (GENERIC_NODE_CONFIGS[nodeType]) {
|
|
897
|
-
const genericResult = buildGenericNode(node, nextNodeId, nameToIdMap, nodeType);
|
|
898
|
-
processNodes.push(genericResult.processNode);
|
|
899
|
-
viewNodes.push(genericResult.viewNode);
|
|
900
|
-
} else {
|
|
901
|
-
throw new Error('äøęÆęēęµēØčē¹ē±»å: ' + (node.type || node.componentName || node.kind || JSON.stringify(node)));
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
return { processNodes, viewNodes };
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
function wireChildProcessNodes(childProcessNodes, parentNodeId) {
|
|
909
|
-
if (childProcessNodes.length === 0) {
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
childProcessNodes[0].prevId = parentNodeId;
|
|
913
|
-
for (let i = 1; i < childProcessNodes.length; i++) {
|
|
914
|
-
childProcessNodes[i].prevId = childProcessNodes[i - 1].nodeId;
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// āā ę建宔ę¹čē¹ āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
919
|
-
|
|
920
|
-
function buildApproverConfig(node) {
|
|
921
|
-
const approverInput = node.approverConfig
|
|
922
|
-
|| node.approver
|
|
923
|
-
|| node.executor
|
|
924
|
-
|| node.operator
|
|
925
|
-
|| node.receiver
|
|
926
|
-
|| node.receivers;
|
|
927
|
-
const friendlyApprover = buildFriendlyApproverConfig(node, approverInput);
|
|
928
|
-
if (friendlyApprover) {
|
|
929
|
-
return friendlyApprover;
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
const rawApprover = node.approverConfig || (approverInput && typeof approverInput === 'object' ? approverInput : null);
|
|
933
|
-
if (rawApprover) {
|
|
934
|
-
return {
|
|
935
|
-
approvalType: rawApprover.approvalType || rawApprover.type || 'ext_target_approval_originator',
|
|
936
|
-
approvals: rawApprover.approvals || [['originator']],
|
|
937
|
-
processProps: rawApprover.processProps || rawApprover.props || {},
|
|
938
|
-
approverRules: rawApprover.approverRules || {
|
|
939
|
-
type: rawApprover.approvalType || rawApprover.type || 'ext_target_approval_originator',
|
|
940
|
-
mode: 'ApprovalNode_rules_only',
|
|
941
|
-
approverList: rawApprover.approverList || [{ type: 'ext_target_approval' }],
|
|
942
|
-
multiApproverType: rawApprover.multiApproverType || 'all',
|
|
943
|
-
conditionalMode: rawApprover.conditionalMode || 'conditional',
|
|
944
|
-
description: rawApprover.description || 'čŖå®ä¹å®”ę¹äŗŗ',
|
|
945
|
-
},
|
|
946
|
-
description: rawApprover.description || node.description || '请éę©å®”ę¹äŗŗ',
|
|
947
|
-
carbonReceiver: rawApprover.carbonReceiver,
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
if (node.approvalType || node.approvals || node.approverRules || node.processProps) {
|
|
952
|
-
return {
|
|
953
|
-
approvalType: node.approvalType || 'ext_target_approval_originator',
|
|
954
|
-
approvals: node.approvals || [['originator']],
|
|
955
|
-
processProps: node.processProps || {},
|
|
956
|
-
approverRules: node.approverRules || {
|
|
957
|
-
type: node.approvalType || 'ext_target_approval_originator',
|
|
958
|
-
mode: 'ApprovalNode_rules_only',
|
|
959
|
-
approverList: [{ type: 'ext_target_approval' }],
|
|
960
|
-
multiApproverType: 'all',
|
|
961
|
-
conditionalMode: 'conditional',
|
|
962
|
-
description: node.description || 'čŖå®ä¹å®”ę¹äŗŗ',
|
|
963
|
-
},
|
|
964
|
-
description: node.description || '请éę©å®”ę¹äŗŗ',
|
|
965
|
-
carbonReceiver: node.carbonReceiver,
|
|
966
|
-
};
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
return buildOriginatorApproverConfig(node, {});
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
function buildApprovalNode(node, nextNodeId, nameToIdMap, nodeType) {
|
|
973
|
-
const nodeId = node._nodeId;
|
|
974
|
-
const routeRule = buildRouteRule(node.routeRules || [], nodeId, nameToIdMap);
|
|
975
|
-
const approverConfig = buildApproverConfig(node);
|
|
976
|
-
const approvalNodeType = nodeType || normalizeNodeType(node);
|
|
977
|
-
const componentName = approvalNodeType === 'operator'
|
|
978
|
-
? 'OperatorNode'
|
|
979
|
-
: (approvalNodeType === 'multiApproval' ? 'MultiApprovalNode' : 'ApprovalNode');
|
|
980
|
-
const titleText = approvalNodeType === 'operator'
|
|
981
|
-
? ['åēäŗŗ', 'Executor', 'å®č”č
']
|
|
982
|
-
: (approvalNodeType === 'multiApproval'
|
|
983
|
-
? ['å®”ę¹äŗŗ', 'Approver', 'ęæčŖč
']
|
|
984
|
-
: ['å®”ę¹äŗŗ', 'Approver', 'ęæčŖč
']);
|
|
985
|
-
const defaultName = approvalNodeType === 'operator' ? 'åēäŗŗ' : 'å®”ę¹äŗŗ';
|
|
986
|
-
const displayName = getNodeName(node, defaultName);
|
|
987
|
-
const nodeDescription = approverConfig.description || getNodeDescription(node) || '请éę©å®”ę¹äŗŗ';
|
|
988
|
-
|
|
989
|
-
// ę建åꮵęéļ¼formConfig.behaviorListļ¼
|
|
990
|
-
// å
¼å®¹äø¤ē§č¾å
„ę ¼å¼ļ¼
|
|
991
|
-
// 1. node.formConfig.behaviorListļ¼ęØčļ¼äø SKILL.md ę攣äøč“ļ¼
|
|
992
|
-
// 2. node.fieldPermissionsļ¼ę§ę ¼å¼ļ¼ååå
¼å®¹ļ¼
|
|
993
|
-
let formConfig = undefined;
|
|
994
|
-
if (node.formConfig && node.formConfig.behaviorList && node.formConfig.behaviorList.length > 0) {
|
|
995
|
-
const behaviorList = node.formConfig.behaviorList.map(function (fp) {
|
|
996
|
-
return {
|
|
997
|
-
fieldId: fp.fieldId,
|
|
998
|
-
fieldBehavior: fp.fieldBehavior || fp.behavior || 'READONLY',
|
|
999
|
-
};
|
|
1000
|
-
});
|
|
1001
|
-
formConfig = { behaviorList: behaviorList };
|
|
1002
|
-
} else if (node.fieldPermissions && node.fieldPermissions.length > 0) {
|
|
1003
|
-
const behaviorList = node.fieldPermissions.map(function (fp) {
|
|
1004
|
-
return {
|
|
1005
|
-
fieldId: fp.fieldId,
|
|
1006
|
-
fieldBehavior: fp.fieldBehavior || fp.behavior || 'READONLY',
|
|
1007
|
-
};
|
|
1008
|
-
});
|
|
1009
|
-
formConfig = { behaviorList: behaviorList };
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
const processNodeProps = {
|
|
1013
|
-
conditionalMode: 'conditional',
|
|
1014
|
-
actions: buildActions(),
|
|
1015
|
-
appendActions: buildActions(),
|
|
1016
|
-
openDigitalSign: false,
|
|
1017
|
-
noActionersType: 'stopProcess',
|
|
1018
|
-
routeRule: routeRule,
|
|
1019
|
-
};
|
|
1020
|
-
if (approverConfig.approvals !== undefined) {
|
|
1021
|
-
processNodeProps.approvals = approverConfig.approvals;
|
|
1022
|
-
}
|
|
1023
|
-
Object.assign(processNodeProps, approverConfig.processProps);
|
|
1024
|
-
if (formConfig) {
|
|
1025
|
-
processNodeProps.formConfig = formConfig;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
const processNode = {
|
|
1029
|
-
name: i18n(displayName, titleText[1], displayName),
|
|
1030
|
-
description: nodeDescription,
|
|
1031
|
-
type: 'approval',
|
|
1032
|
-
approvalType: approverConfig.approvalType,
|
|
1033
|
-
nodeId: nodeId,
|
|
1034
|
-
prevId: '',
|
|
1035
|
-
nextId: [nextNodeId],
|
|
1036
|
-
props: processNodeProps,
|
|
1037
|
-
childNodes: [],
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
const viewNodeProps = {
|
|
1041
|
-
nodeName: componentName,
|
|
1042
|
-
name: i18n(displayName, titleText[1], displayName),
|
|
1043
|
-
description: nodeDescription,
|
|
1044
|
-
approverRules: approverConfig.approverRules,
|
|
1045
|
-
actions: {
|
|
1046
|
-
normalActions: buildActions(),
|
|
1047
|
-
appendActions: buildActions(),
|
|
1048
|
-
},
|
|
1049
|
-
routeRule: routeRule,
|
|
1050
|
-
};
|
|
1051
|
-
if (formConfig) {
|
|
1052
|
-
viewNodeProps.formConfig = formConfig;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
const viewNode = {
|
|
1056
|
-
componentName: componentName,
|
|
1057
|
-
id: nodeId,
|
|
1058
|
-
props: viewNodeProps,
|
|
1059
|
-
title: i18n(titleText[0], titleText[1], titleText[2]),
|
|
1060
|
-
};
|
|
1061
|
-
|
|
1062
|
-
return { processNode, viewNode };
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
// āā ę建ęéčē¹ āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
1066
|
-
|
|
1067
|
-
function buildCarbonNode(node, nextNodeId) {
|
|
1068
|
-
const nodeId = node._nodeId;
|
|
1069
|
-
const approverConfig = buildApproverConfig(node);
|
|
1070
|
-
const carbonReceiver = approverConfig.carbonReceiver || { type: 'VARIABLE', value: approverConfig.approvals || [['originator']] };
|
|
1071
|
-
const displayName = getNodeName(node, 'ęéäŗŗ');
|
|
1072
|
-
const nodeDescription = getNodeDescription(node) || '请éę©ęéäŗŗ';
|
|
1073
|
-
|
|
1074
|
-
const processNode = {
|
|
1075
|
-
name: i18n(displayName, 'CC', displayName),
|
|
1076
|
-
description: '',
|
|
1077
|
-
type: 'carbon',
|
|
1078
|
-
approvalType: approverConfig.approvalType,
|
|
1079
|
-
nodeId: nodeId,
|
|
1080
|
-
prevId: '',
|
|
1081
|
-
nextId: [nextNodeId],
|
|
1082
|
-
props: {
|
|
1083
|
-
conditionalMode: 'conditional',
|
|
1084
|
-
params: [
|
|
1085
|
-
{ key: 'nodeId', value: nodeId },
|
|
1086
|
-
{ key: 'instId', value: '#procInstId' },
|
|
1087
|
-
{ key: 'userId', value: '#originator' },
|
|
1088
|
-
{ key: 'receiver', value: carbonReceiver },
|
|
1089
|
-
],
|
|
1090
|
-
...approverConfig.processProps,
|
|
1091
|
-
},
|
|
1092
|
-
childNodes: [],
|
|
1093
|
-
};
|
|
1094
|
-
|
|
1095
|
-
const viewNode = {
|
|
1096
|
-
componentName: 'CarbonNode',
|
|
1097
|
-
id: nodeId,
|
|
1098
|
-
props: {
|
|
1099
|
-
nodeName: 'CarbonNode',
|
|
1100
|
-
name: i18n(displayName, 'CC', displayName),
|
|
1101
|
-
description: nodeDescription,
|
|
1102
|
-
approverRules: approverConfig.approverRules,
|
|
1103
|
-
},
|
|
1104
|
-
title: i18n('ęéäŗŗ', 'CC', 'å
±ęå
'),
|
|
1105
|
-
};
|
|
1106
|
-
|
|
1107
|
-
return { processNode, viewNode };
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
// āā ę建ēå®ē»ä»¶čē¹ļ¼čæę„åØćę°ę®ćę¶ęÆć代ē ćåęµēØēļ¼āā
|
|
1111
|
-
|
|
1112
|
-
function getGenericChildNodes(node) {
|
|
1113
|
-
const childNodes = node.childNodes || node.children || node.nodes || [];
|
|
1114
|
-
return Array.isArray(childNodes) ? childNodes : [];
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
function buildGenericNodeProps(node, componentName) {
|
|
1118
|
-
const config = GENERIC_NODE_CONFIGS[componentName] || {};
|
|
1119
|
-
const props = Object.assign({}, node.props || {});
|
|
1120
|
-
const displayName = getNodeName(node, config.title ? config.title[0] : componentName);
|
|
1121
|
-
const description = getNodeDescription(node);
|
|
1122
|
-
|
|
1123
|
-
if (!props.name) {
|
|
1124
|
-
props.name = i18n(displayName, config.title ? config.title[1] : displayName, displayName);
|
|
1125
|
-
}
|
|
1126
|
-
if (!props.nodeName) {
|
|
1127
|
-
props.nodeName = componentName;
|
|
1128
|
-
}
|
|
1129
|
-
if (!props.description && description) {
|
|
1130
|
-
props.description = description;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
Object.keys(config.propAliases || {}).forEach(function (sourceKey) {
|
|
1134
|
-
const targetKey = config.propAliases[sourceKey];
|
|
1135
|
-
if (node[sourceKey] !== undefined && props[targetKey] === undefined) {
|
|
1136
|
-
props[targetKey] = clonePlain(node[sourceKey]);
|
|
1137
|
-
}
|
|
1138
|
-
});
|
|
1139
|
-
|
|
1140
|
-
(config.propKeys || []).forEach(function (key) {
|
|
1141
|
-
if (node[key] !== undefined && props[key] === undefined) {
|
|
1142
|
-
props[key] = clonePlain(node[key]);
|
|
1143
|
-
}
|
|
1144
|
-
});
|
|
1145
|
-
|
|
1146
|
-
if (node.viewProps && isPlainObject(node.viewProps)) {
|
|
1147
|
-
Object.assign(props, clonePlain(node.viewProps));
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
return props;
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
function getGenericProcessType(componentName, node, props) {
|
|
1154
|
-
if (node.processType || node.processNodeType) {
|
|
1155
|
-
return node.processType || node.processNodeType;
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
if (componentName === 'ConnectorNode') {
|
|
1159
|
-
const connectorRules = props.connectorRules || {};
|
|
1160
|
-
const connector = connectorRules.connector || {};
|
|
1161
|
-
const mode = connector.mode || connectorRules.mode;
|
|
1162
|
-
return CONNECTOR_MODE_TO_PROCESS_TYPE[mode] || GENERIC_NODE_CONFIGS[componentName].processType;
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
return GENERIC_NODE_CONFIGS[componentName].processType;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
function pickRuleAssignments(ruleContainer) {
|
|
1169
|
-
if (!ruleContainer) {
|
|
1170
|
-
return [];
|
|
1171
|
-
}
|
|
1172
|
-
if (Array.isArray(ruleContainer.assignments)) {
|
|
1173
|
-
return clonePlain(ruleContainer.assignments);
|
|
1174
|
-
}
|
|
1175
|
-
if (ruleContainer.inputs && Array.isArray(ruleContainer.inputs.assignments)) {
|
|
1176
|
-
return clonePlain(ruleContainer.inputs.assignments);
|
|
1177
|
-
}
|
|
1178
|
-
if (Array.isArray(ruleContainer.rules)) {
|
|
1179
|
-
return ruleContainer.rules
|
|
1180
|
-
.map(function (rule) {
|
|
1181
|
-
if (Array.isArray(rule && rule.rules)) {
|
|
1182
|
-
return clonePlain(rule.rules);
|
|
1183
|
-
}
|
|
1184
|
-
return null;
|
|
1185
|
-
})
|
|
1186
|
-
.filter(Boolean)
|
|
1187
|
-
.reduce(function (all, rules) {
|
|
1188
|
-
return all.concat(rules);
|
|
1189
|
-
}, []);
|
|
1190
|
-
}
|
|
1191
|
-
return [];
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
function buildConnectorProcessProps(props) {
|
|
1195
|
-
const connectorRules = props.connectorRules || {};
|
|
1196
|
-
const inputs = Object.assign({}, clonePlain(connectorRules.inputs || {}), {
|
|
1197
|
-
url: connectorRules.url,
|
|
1198
|
-
method: connectorRules.method,
|
|
1199
|
-
body: connectorRules.body,
|
|
1200
|
-
connection: connectorRules.connectionId || connectorRules.connection,
|
|
1201
|
-
connectorId: connectorRules.connectorId,
|
|
1202
|
-
actionId: connectorRules.actionId,
|
|
1203
|
-
});
|
|
1204
|
-
const assignments = pickRuleAssignments(connectorRules);
|
|
1205
|
-
|
|
1206
|
-
if (assignments.length > 0) {
|
|
1207
|
-
inputs.assignments = assignments;
|
|
1208
|
-
}
|
|
1209
|
-
if (connectorRules.openDevSchemaType === 'integrationObject') {
|
|
1210
|
-
inputs.openDevSchemaType = 'integrationObject';
|
|
1211
|
-
inputs.connectorOrgId = connectorRules.connector && connectorRules.connector.orgId;
|
|
1212
|
-
inputs.integrationObject = connectorRules.integrationObject;
|
|
1213
|
-
inputs.integrationObjectPath = connectorRules.integrationObjectPath;
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
Object.keys(inputs).forEach(function (key) {
|
|
1217
|
-
if (inputs[key] === undefined) {
|
|
1218
|
-
delete inputs[key];
|
|
1219
|
-
}
|
|
1220
|
-
});
|
|
1221
|
-
|
|
1222
|
-
return { inputs };
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
function buildCodeExecutorProcessProps(props, componentName) {
|
|
1226
|
-
const codeConfig = componentName === 'GroovyNode' ? props.groovy : props.JavaScript;
|
|
1227
|
-
if (!codeConfig) {
|
|
1228
|
-
return {};
|
|
1229
|
-
}
|
|
1230
|
-
const outputs = Array.isArray(codeConfig.outputs)
|
|
1231
|
-
? codeConfig.outputs.map(function (output) {
|
|
1232
|
-
return {
|
|
1233
|
-
description: output.desc || output.description,
|
|
1234
|
-
name: output.name,
|
|
1235
|
-
type: output.type,
|
|
1236
|
-
valueType: output.valueType,
|
|
1237
|
-
};
|
|
1238
|
-
})
|
|
1239
|
-
: undefined;
|
|
1240
|
-
return {
|
|
1241
|
-
inputs: clonePlain(codeConfig.inputs),
|
|
1242
|
-
action: clonePlain(codeConfig.action),
|
|
1243
|
-
scriptType: codeConfig.scriptType,
|
|
1244
|
-
outputsSchema: outputs,
|
|
1245
|
-
};
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
function buildGetDataProcessProps(props) {
|
|
1249
|
-
const getData = props.getData || {};
|
|
1250
|
-
return {
|
|
1251
|
-
type: props.type,
|
|
1252
|
-
filterType: getData.filterType,
|
|
1253
|
-
sort: clonePlain(getData.sort),
|
|
1254
|
-
sourceId: getData.sourceId,
|
|
1255
|
-
appType: getData.appType,
|
|
1256
|
-
originalType: getData.originalType,
|
|
1257
|
-
subSourceId: getData.subSourceId,
|
|
1258
|
-
condition: clonePlain(getData.condition),
|
|
1259
|
-
quantity: getData.quantity === undefined ? undefined : String(getData.quantity),
|
|
1260
|
-
dataRules: clonePlain(getData.dataRules),
|
|
1261
|
-
assignments: clonePlain(getData.assignments),
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
function buildAddDataProcessProps(props) {
|
|
1266
|
-
const addDataRules = props.addDataRules || {};
|
|
1267
|
-
return {
|
|
1268
|
-
formUuid: addDataRules.formUuid || '',
|
|
1269
|
-
appType: addDataRules.appType || '',
|
|
1270
|
-
subFormUuid: addDataRules.subFormUuid || '',
|
|
1271
|
-
insertType: addDataRules.insertType || '',
|
|
1272
|
-
type: addDataRules.type || '',
|
|
1273
|
-
sourceId: addDataRules.sourceId || '',
|
|
1274
|
-
assignments: pickRuleAssignments(addDataRules),
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
function buildAIProcessProps(props) {
|
|
1279
|
-
const workFlowRules = props.workFlowRules || {};
|
|
1280
|
-
return {
|
|
1281
|
-
type: 'aiFlow',
|
|
1282
|
-
action: workFlowRules.flowId ? { flowId: workFlowRules.flowId } : undefined,
|
|
1283
|
-
outputs: clonePlain(workFlowRules.outputs),
|
|
1284
|
-
yidaFieldIdList: clonePlain(workFlowRules.yidaFieldIdList),
|
|
1285
|
-
};
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
function pruneUndefined(value) {
|
|
1289
|
-
if (!isPlainObject(value)) {
|
|
1290
|
-
return value;
|
|
1291
|
-
}
|
|
1292
|
-
Object.keys(value).forEach(function (key) {
|
|
1293
|
-
if (value[key] === undefined) {
|
|
1294
|
-
delete value[key];
|
|
1295
|
-
}
|
|
1296
|
-
});
|
|
1297
|
-
return value;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
function buildGenericProcessProps(props, node, componentName) {
|
|
1301
|
-
let processProps;
|
|
1302
|
-
|
|
1303
|
-
if (componentName === 'ConnectorNode') {
|
|
1304
|
-
processProps = buildConnectorProcessProps(props);
|
|
1305
|
-
} else if (componentName === 'GroovyNode' || componentName === 'JavaScriptNode') {
|
|
1306
|
-
processProps = buildCodeExecutorProcessProps(props, componentName);
|
|
1307
|
-
} else if (componentName === 'InitiateApprovalNode') {
|
|
1308
|
-
processProps = clonePlain(props.initiateApprovalRules || {});
|
|
1309
|
-
} else if (componentName === 'SendMessageNode') {
|
|
1310
|
-
processProps = clonePlain(props.sendMessageRules || {});
|
|
1311
|
-
delete processProps.description;
|
|
1312
|
-
} else if (componentName === 'SendEmailNode') {
|
|
1313
|
-
processProps = clonePlain(props.sendEmailRules || {});
|
|
1314
|
-
} else if (componentName === 'GetSingleDataNode' || componentName === 'GetBatchDataNode') {
|
|
1315
|
-
processProps = buildGetDataProcessProps(props);
|
|
1316
|
-
} else if (componentName === 'AddDataNode') {
|
|
1317
|
-
processProps = buildAddDataProcessProps(props);
|
|
1318
|
-
} else if (componentName === 'UpdateDataNode') {
|
|
1319
|
-
processProps = clonePlain(props.updateDataRules || {});
|
|
1320
|
-
} else if (componentName === 'DeleteDataNode') {
|
|
1321
|
-
processProps = clonePlain(props.deleteData || {});
|
|
1322
|
-
} else if (componentName === 'SendCardNode') {
|
|
1323
|
-
processProps = clonePlain(props.sendCardRules || {});
|
|
1324
|
-
} else if (componentName === 'UpdateCardNode') {
|
|
1325
|
-
processProps = clonePlain(props.updateCardRules || {});
|
|
1326
|
-
} else if (componentName === 'CardNode') {
|
|
1327
|
-
processProps = clonePlain(props.cardRules || {});
|
|
1328
|
-
} else if (componentName === 'CardUpdateNode') {
|
|
1329
|
-
processProps = clonePlain(props.cardUpdateRules || {});
|
|
1330
|
-
} else if (componentName === 'CycleContainer') {
|
|
1331
|
-
processProps = clonePlain(props.cycleContainerRules || {});
|
|
1332
|
-
} else if (componentName === 'AINode') {
|
|
1333
|
-
processProps = buildAIProcessProps(props);
|
|
1334
|
-
} else {
|
|
1335
|
-
processProps = clonePlain(props);
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
delete processProps.name;
|
|
1339
|
-
delete processProps.nodeName;
|
|
1340
|
-
delete processProps.description;
|
|
1341
|
-
delete processProps.title;
|
|
1342
|
-
pruneUndefined(processProps);
|
|
1343
|
-
if (node.processProps && isPlainObject(node.processProps)) {
|
|
1344
|
-
Object.assign(processProps, clonePlain(node.processProps));
|
|
1345
|
-
}
|
|
1346
|
-
return processProps;
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
function buildGenericNode(node, nextNodeId, nameToIdMap, componentName) {
|
|
1350
|
-
const nodeId = node._nodeId;
|
|
1351
|
-
const config = GENERIC_NODE_CONFIGS[componentName];
|
|
1352
|
-
const props = buildGenericNodeProps(node, componentName);
|
|
1353
|
-
const displayName = getNodeName(node, config.title[0]);
|
|
1354
|
-
const description = getNodeDescription(node);
|
|
1355
|
-
const childNodes = getGenericChildNodes(node);
|
|
1356
|
-
let childProcessNodes = [];
|
|
1357
|
-
let childViewNodes = [];
|
|
1358
|
-
|
|
1359
|
-
if (childNodes.length > 0) {
|
|
1360
|
-
const childResult = buildNodeListRecursive(childNodes, nextNodeId, nameToIdMap);
|
|
1361
|
-
childProcessNodes = childResult.processNodes;
|
|
1362
|
-
childViewNodes = childResult.viewNodes;
|
|
1363
|
-
wireChildProcessNodes(childProcessNodes, nodeId);
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
const processNode = {
|
|
1367
|
-
name: i18n(displayName, config.title[1], displayName),
|
|
1368
|
-
description: description,
|
|
1369
|
-
type: getGenericProcessType(componentName, node, props),
|
|
1370
|
-
nodeId: nodeId,
|
|
1371
|
-
prevId: '',
|
|
1372
|
-
nextId: childProcessNodes.length > 0 ? [childProcessNodes[0].nodeId] : [nextNodeId],
|
|
1373
|
-
props: buildGenericProcessProps(props, node, componentName),
|
|
1374
|
-
childNodes: childProcessNodes.map(clonePlain),
|
|
1375
|
-
};
|
|
1376
|
-
|
|
1377
|
-
if (node.approvalType) {
|
|
1378
|
-
processNode.approvalType = node.approvalType;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
const viewNode = {
|
|
1382
|
-
componentName: componentName,
|
|
1383
|
-
id: nodeId,
|
|
1384
|
-
props: props,
|
|
1385
|
-
title: i18n(config.title[0], config.title[1], config.title[2]),
|
|
1386
|
-
};
|
|
1387
|
-
|
|
1388
|
-
if (childViewNodes.length > 0) {
|
|
1389
|
-
viewNode.children = childViewNodes;
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
return { processNode, viewNode };
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
// āā ę建ę”ä»¶åęÆč·Æē±čē¹ āāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
1396
|
-
|
|
1397
|
-
function buildRouteNode(node, exitNodeId, nameToIdMap) {
|
|
1398
|
-
const routeNodeId = node._nodeId;
|
|
1399
|
-
const conditions = node.conditions || [];
|
|
1400
|
-
|
|
1401
|
-
const conditionNodeIds = [];
|
|
1402
|
-
const conditionProcessNodes = [];
|
|
1403
|
-
const conditionViewNodes = [];
|
|
1404
|
-
|
|
1405
|
-
// ę建ęÆäøŖę”ä»¶åęÆ
|
|
1406
|
-
conditions.forEach(function (cond, index) {
|
|
1407
|
-
const condNodeId = cond._nodeId;
|
|
1408
|
-
conditionNodeIds.push(condNodeId);
|
|
1409
|
-
|
|
1410
|
-
// éå½ę建ę”ä»¶åęÆå
ēåčē¹
|
|
1411
|
-
let childProcessNodes = [];
|
|
1412
|
-
let childViewNodes = [];
|
|
1413
|
-
if (cond.childNodes && cond.childNodes.length > 0) {
|
|
1414
|
-
const childResult = buildNodeListRecursive(cond.childNodes, exitNodeId, nameToIdMap);
|
|
1415
|
-
childProcessNodes = childResult.processNodes;
|
|
1416
|
-
childViewNodes = childResult.viewNodes;
|
|
1417
|
-
wireChildProcessNodes(childProcessNodes, condNodeId);
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
// ę建ę”ä»¶č§å
|
|
1421
|
-
const conditionProps = {
|
|
1422
|
-
priority: index + 1,
|
|
1423
|
-
isDefault: false,
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
// ę建ę”ä»¶č§å
|
|
1427
|
-
const condRules = buildConditionRules(cond.rules || [], cond.logic || 'AND');
|
|
1428
|
-
const condDescription = cond.name || '';
|
|
1429
|
-
|
|
1430
|
-
if (cond.rules && cond.rules.length > 0) {
|
|
1431
|
-
conditionProps.conditions = {
|
|
1432
|
-
condition: condRules.condition || 'AND',
|
|
1433
|
-
rules: condRules.rules || [],
|
|
1434
|
-
ruleId: condRules.ruleId || 'group-' + generateUuid(),
|
|
1435
|
-
conditionCode: condRules.conditionCode || '&&',
|
|
1436
|
-
};
|
|
1437
|
-
conditionProps.calculate = 'condition';
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
// ę”ä»¶čē¹ē nextIdļ¼å¦ęęåčē¹ļ¼ęå第äøäøŖåčē¹ļ¼å¦åęååŗå£čē¹
|
|
1441
|
-
const condNextId = (childProcessNodes.length > 0)
|
|
1442
|
-
? [childProcessNodes[0].nodeId]
|
|
1443
|
-
: [exitNodeId];
|
|
1444
|
-
|
|
1445
|
-
const condProcessNode = {
|
|
1446
|
-
name: i18n(condDescription || 'ę”ä»¶', 'Condition', condDescription || 'ę”ä»¶'),
|
|
1447
|
-
description: '',
|
|
1448
|
-
type: 'condition',
|
|
1449
|
-
nodeId: condNodeId,
|
|
1450
|
-
prevId: routeNodeId,
|
|
1451
|
-
nextId: condNextId,
|
|
1452
|
-
props: conditionProps,
|
|
1453
|
-
childNodes: childProcessNodes.map(clonePlain),
|
|
1454
|
-
};
|
|
1455
|
-
|
|
1456
|
-
conditionProcessNodes.push(condProcessNode);
|
|
1457
|
-
|
|
1458
|
-
// ę建 condition viewNodeļ¼åø¦åµå„ conditions å
č£
ļ¼
|
|
1459
|
-
const condViewNode = {
|
|
1460
|
-
componentName: 'ConditionNode',
|
|
1461
|
-
id: condNodeId,
|
|
1462
|
-
props: {
|
|
1463
|
-
name: i18n(condDescription || 'ę”ä»¶', 'Condition', condDescription || 'ę”ä»¶'),
|
|
1464
|
-
description: '',
|
|
1465
|
-
conditions: {
|
|
1466
|
-
calculate: 'condition',
|
|
1467
|
-
conditions: {
|
|
1468
|
-
condition: condRules.condition || 'AND',
|
|
1469
|
-
rules: condRules.rules || [],
|
|
1470
|
-
ruleId: condRules.ruleId || 'group-' + generateUuid(),
|
|
1471
|
-
conditionCode: condRules.conditionCode || '&&',
|
|
1472
|
-
},
|
|
1473
|
-
isDefault: false,
|
|
1474
|
-
priority: index + 1,
|
|
1475
|
-
description: condDescription,
|
|
1476
|
-
},
|
|
1477
|
-
},
|
|
1478
|
-
};
|
|
1479
|
-
|
|
1480
|
-
if (childViewNodes.length > 0) {
|
|
1481
|
-
condViewNode.children = childViewNodes;
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
conditionViewNodes.push(condViewNode);
|
|
1485
|
-
});
|
|
1486
|
-
|
|
1487
|
-
// ę·»å é»č®¤ę”ä»¶åęÆļ¼"å
¶ä»ę
åµ"ļ¼
|
|
1488
|
-
const defaultCondNodeId = generateNodeId();
|
|
1489
|
-
conditionNodeIds.push(defaultCondNodeId);
|
|
1490
|
-
|
|
1491
|
-
const defaultCondProcessNode = {
|
|
1492
|
-
name: i18n('å
¶ä»ę
åµ', 'Other situations', 'ćć®ä»ć®å “å'),
|
|
1493
|
-
description: '',
|
|
1494
|
-
type: 'condition',
|
|
1495
|
-
nodeId: defaultCondNodeId,
|
|
1496
|
-
prevId: routeNodeId,
|
|
1497
|
-
nextId: [exitNodeId],
|
|
1498
|
-
props: {
|
|
1499
|
-
priority: 2147483647,
|
|
1500
|
-
isDefault: true,
|
|
1501
|
-
},
|
|
1502
|
-
childNodes: [],
|
|
1503
|
-
};
|
|
1504
|
-
|
|
1505
|
-
conditionProcessNodes.push(defaultCondProcessNode);
|
|
1506
|
-
|
|
1507
|
-
const defaultCondViewNode = {
|
|
1508
|
-
componentName: 'ConditionNode',
|
|
1509
|
-
id: defaultCondNodeId,
|
|
1510
|
-
props: {
|
|
1511
|
-
isDefault: true,
|
|
1512
|
-
buttons: [{ name: 'å
³é' }],
|
|
1513
|
-
name: i18n('å
¶ä»ę
åµ', 'Other situations', 'ćć®ä»ć®å “å'),
|
|
1514
|
-
description: '',
|
|
1515
|
-
},
|
|
1516
|
-
};
|
|
1517
|
-
|
|
1518
|
-
conditionViewNodes.push(defaultCondViewNode);
|
|
1519
|
-
|
|
1520
|
-
// ę建 route processNode
|
|
1521
|
-
const routeProcessNode = {
|
|
1522
|
-
name: i18n('ConditionNode', 'ConditionNode', 'ę”ä»¶ćć¼ć'),
|
|
1523
|
-
description: '',
|
|
1524
|
-
type: 'route',
|
|
1525
|
-
nodeId: routeNodeId,
|
|
1526
|
-
prevId: '',
|
|
1527
|
-
nextId: conditionNodeIds,
|
|
1528
|
-
props: { outgoingType: 'priority' },
|
|
1529
|
-
childNodes: conditionProcessNodes,
|
|
1530
|
-
};
|
|
1531
|
-
|
|
1532
|
-
// ę建 route viewNodeļ¼ConditionContainerļ¼
|
|
1533
|
-
const routeViewNode = {
|
|
1534
|
-
componentName: 'ConditionContainer',
|
|
1535
|
-
id: routeNodeId,
|
|
1536
|
-
props: {},
|
|
1537
|
-
title: 'ę”ä»¶åęÆ',
|
|
1538
|
-
children: conditionViewNodes,
|
|
1539
|
-
};
|
|
1540
|
-
|
|
1541
|
-
return { processNode: routeProcessNode, viewNode: routeViewNode };
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
// āā ę建并č”åęÆčē¹ āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
1545
|
-
|
|
1546
|
-
function getParallelBranches(node) {
|
|
1547
|
-
const branches = node.branches || node.conditions || node.parallelBranches || [];
|
|
1548
|
-
return Array.isArray(branches) ? branches : [];
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
function getBranchChildNodes(branch) {
|
|
1552
|
-
const childNodes = branch.childNodes || branch.nodes || branch.children || [];
|
|
1553
|
-
return Array.isArray(childNodes) ? childNodes : [];
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
function buildAllDataConditionProps(branch, priority, isDefault) {
|
|
1557
|
-
return {
|
|
1558
|
-
calculate: 'all',
|
|
1559
|
-
conditions: {
|
|
1560
|
-
condition: 'AND',
|
|
1561
|
-
rules: [
|
|
1562
|
-
{
|
|
1563
|
-
id: 'originator',
|
|
1564
|
-
op: 'ēäŗ',
|
|
1565
|
-
operators: [],
|
|
1566
|
-
componentType: 'EmployeeField',
|
|
1567
|
-
},
|
|
1568
|
-
],
|
|
1569
|
-
},
|
|
1570
|
-
isDefault: isDefault,
|
|
1571
|
-
priority: priority,
|
|
1572
|
-
description: branch.description || 'ęęę°ę®ååÆčæå
„',
|
|
1573
|
-
};
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
function buildParallelBranchConditionProps(branch, index) {
|
|
1577
|
-
const priority = Number(pickFirstDefined(branch.priority, index + 1));
|
|
1578
|
-
const isDefault = Boolean(branch.isDefault);
|
|
1579
|
-
const rawConditions = branch.conditionProps
|
|
1580
|
-
|| branch.condition
|
|
1581
|
-
|| (isPlainObject(branch.conditions) ? branch.conditions : null);
|
|
1582
|
-
|
|
1583
|
-
if (isPlainObject(rawConditions) && rawConditions.calculate) {
|
|
1584
|
-
const props = Object.assign({}, rawConditions, {
|
|
1585
|
-
isDefault: isDefault,
|
|
1586
|
-
priority: priority,
|
|
1587
|
-
});
|
|
1588
|
-
if (!props.description && branch.description) {
|
|
1589
|
-
props.description = branch.description;
|
|
1590
|
-
}
|
|
1591
|
-
return props;
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
if (isPlainObject(rawConditions) && (rawConditions.rules || rawConditions.condition)) {
|
|
1595
|
-
return {
|
|
1596
|
-
calculate: 'condition',
|
|
1597
|
-
conditions: rawConditions,
|
|
1598
|
-
isDefault: isDefault,
|
|
1599
|
-
priority: priority,
|
|
1600
|
-
description: branch.description || branch.name || '',
|
|
1601
|
-
};
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
if (branch.rules && branch.rules.length > 0) {
|
|
1605
|
-
const condRules = buildConditionRules(branch.rules, branch.logic || 'AND');
|
|
1606
|
-
return {
|
|
1607
|
-
calculate: 'condition',
|
|
1608
|
-
conditions: {
|
|
1609
|
-
condition: condRules.condition || 'AND',
|
|
1610
|
-
rules: condRules.rules || [],
|
|
1611
|
-
ruleId: condRules.ruleId || 'group-' + generateUuid(),
|
|
1612
|
-
conditionCode: condRules.conditionCode || '&&',
|
|
1613
|
-
},
|
|
1614
|
-
isDefault: isDefault,
|
|
1615
|
-
priority: priority,
|
|
1616
|
-
description: branch.description || branch.name || '',
|
|
1617
|
-
};
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
return buildAllDataConditionProps(branch, priority, isDefault);
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
function buildParallelBranchProcessProps(conditionProps) {
|
|
1624
|
-
const props = {};
|
|
1625
|
-
if (conditionProps.isDefault !== undefined) {
|
|
1626
|
-
props.isDefault = conditionProps.isDefault;
|
|
1627
|
-
}
|
|
1628
|
-
if (conditionProps.conditions !== undefined) {
|
|
1629
|
-
props.conditions = clonePlain(conditionProps.conditions);
|
|
1630
|
-
}
|
|
1631
|
-
if (conditionProps.calculate !== undefined) {
|
|
1632
|
-
props.calculate = conditionProps.calculate;
|
|
1633
|
-
}
|
|
1634
|
-
if (conditionProps.expression !== undefined) {
|
|
1635
|
-
props.expression = conditionProps.expression;
|
|
1636
|
-
}
|
|
1637
|
-
return props;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
function buildParallelNode(node, exitNodeId, nameToIdMap) {
|
|
1641
|
-
const parallelNodeId = node._nodeId;
|
|
1642
|
-
const branches = getParallelBranches(node);
|
|
1643
|
-
|
|
1644
|
-
if (branches.length === 0) {
|
|
1645
|
-
throw new Error('parallel čē¹č³å°éč¦äøäøŖ branches åęÆ');
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
const branchNodeIds = [];
|
|
1649
|
-
const branchProcessNodes = [];
|
|
1650
|
-
const branchViewNodes = [];
|
|
1651
|
-
|
|
1652
|
-
branches.forEach(function (branch, index) {
|
|
1653
|
-
const branchNodeId = branch._nodeId;
|
|
1654
|
-
const branchName = branch.name || ('ę”ä»¶' + (index + 1));
|
|
1655
|
-
const branchConditionProps = buildParallelBranchConditionProps(branch, index);
|
|
1656
|
-
const childNodes = getBranchChildNodes(branch);
|
|
1657
|
-
|
|
1658
|
-
branchNodeIds.push(branchNodeId);
|
|
1659
|
-
|
|
1660
|
-
let childProcessNodes = [];
|
|
1661
|
-
let childViewNodes = [];
|
|
1662
|
-
if (childNodes.length > 0) {
|
|
1663
|
-
const childResult = buildNodeListRecursive(childNodes, exitNodeId, nameToIdMap);
|
|
1664
|
-
childProcessNodes = childResult.processNodes;
|
|
1665
|
-
childViewNodes = childResult.viewNodes;
|
|
1666
|
-
wireChildProcessNodes(childProcessNodes, branchNodeId);
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
const branchNextId = childProcessNodes.length > 0
|
|
1670
|
-
? [childProcessNodes[0].nodeId]
|
|
1671
|
-
: [exitNodeId];
|
|
1672
|
-
|
|
1673
|
-
const branchProcessNode = {
|
|
1674
|
-
name: i18n(branchName, 'Parallel branch', branchName),
|
|
1675
|
-
description: '',
|
|
1676
|
-
type: 'condition',
|
|
1677
|
-
nodeId: branchNodeId,
|
|
1678
|
-
prevId: parallelNodeId,
|
|
1679
|
-
nextId: branchNextId,
|
|
1680
|
-
props: buildParallelBranchProcessProps(branchConditionProps),
|
|
1681
|
-
childNodes: childProcessNodes.map(clonePlain),
|
|
1682
|
-
};
|
|
1683
|
-
|
|
1684
|
-
branchProcessNodes.push(branchProcessNode);
|
|
1685
|
-
|
|
1686
|
-
const branchViewNode = {
|
|
1687
|
-
componentName: 'ParallelNode',
|
|
1688
|
-
id: branchNodeId,
|
|
1689
|
-
props: {
|
|
1690
|
-
name: branchConditionProps.isDefault
|
|
1691
|
-
? i18n(branchName, 'Other situations', branchName)
|
|
1692
|
-
: branchName,
|
|
1693
|
-
description: branch.description || '',
|
|
1694
|
-
conditions: clonePlain(branchConditionProps),
|
|
1695
|
-
},
|
|
1696
|
-
};
|
|
1697
|
-
|
|
1698
|
-
if (branchConditionProps.isDefault) {
|
|
1699
|
-
branchViewNode.props.buttons = branch.buttons || [{ name: 'å
³é' }];
|
|
1700
|
-
}
|
|
1701
|
-
|
|
1702
|
-
if (childViewNodes.length > 0) {
|
|
1703
|
-
branchViewNode.children = childViewNodes;
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
branchViewNodes.push(branchViewNode);
|
|
1707
|
-
});
|
|
1708
|
-
|
|
1709
|
-
const parallelProcessNode = {
|
|
1710
|
-
name: i18n(node.name || 'ParallelNode', node.name || 'ParallelNode', node.name || 'ParallelNode'),
|
|
1711
|
-
description: '',
|
|
1712
|
-
type: 'route',
|
|
1713
|
-
nodeId: parallelNodeId,
|
|
1714
|
-
prevId: '',
|
|
1715
|
-
nextId: branchNodeIds,
|
|
1716
|
-
props: { outgoingType: 'multiple' },
|
|
1717
|
-
childNodes: branchProcessNodes,
|
|
1718
|
-
};
|
|
1719
|
-
|
|
1720
|
-
const parallelViewNode = {
|
|
1721
|
-
componentName: 'ConditionContainer',
|
|
1722
|
-
id: parallelNodeId,
|
|
1723
|
-
props: {
|
|
1724
|
-
name: i18n(node.name || 'å¹¶č”åęÆ', node.name || 'ParallelNode', node.name || 'äø¦č”åå²'),
|
|
1725
|
-
},
|
|
1726
|
-
title: node.title || 'å¹¶č”åęÆ',
|
|
1727
|
-
type: 'parallel',
|
|
1728
|
-
children: branchViewNodes,
|
|
1729
|
-
};
|
|
1730
|
-
|
|
1731
|
-
return { processNode: parallelProcessNode, viewNode: parallelViewNode };
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
function appendOpenDetailParam(url, paramName) {
|
|
1735
|
-
if (!url) {
|
|
1736
|
-
return url;
|
|
1737
|
-
}
|
|
1738
|
-
if (new RegExp('([?&])' + paramName + '=').test(url)) {
|
|
1739
|
-
return url;
|
|
1740
|
-
}
|
|
1741
|
-
const separator = url.endsWith('?') || url.endsWith('&')
|
|
1742
|
-
? ''
|
|
1743
|
-
: (url.indexOf('?') === -1 ? '?' : '&');
|
|
1744
|
-
return url + separator + paramName + '=';
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
// āā ę建å®ę“ē processJson å viewJson āāāāāāāāāāāāāā
|
|
1748
|
-
|
|
1749
|
-
function buildProcessAndViewJson(definition, processCode, formUuid, baseUrl, appType) {
|
|
1750
|
-
const finishNodeId = generateNodeId();
|
|
1751
|
-
const nodes = definition.nodes || [];
|
|
1752
|
-
|
|
1753
|
-
// 第äøéļ¼éå½åé
nodeId å¹¶ę¶éåē§°ę å°
|
|
1754
|
-
const nodeNameToIdMap = {};
|
|
1755
|
-
assignNodeIdsRecursive(nodes, nodeNameToIdMap);
|
|
1756
|
-
|
|
1757
|
-
// å°ē»ęčē¹å å
„ę å°
|
|
1758
|
-
nodeNameToIdMap['ē»ę'] = finishNodeId;
|
|
1759
|
-
nodeNameToIdMap['finish'] = finishNodeId;
|
|
1760
|
-
nodeNameToIdMap['end'] = finishNodeId;
|
|
1761
|
-
|
|
1762
|
-
// 第äŗéļ¼éå½ę建ęęčē¹
|
|
1763
|
-
const middleResult = buildNodeListRecursive(nodes, finishNodeId, nodeNameToIdMap);
|
|
1764
|
-
|
|
1765
|
-
// 设置锶å±čē¹ē prevId
|
|
1766
|
-
if (middleResult.processNodes.length > 0) {
|
|
1767
|
-
middleResult.processNodes[0].prevId = 'sid_instStart';
|
|
1768
|
-
for (let mi = 1; mi < middleResult.processNodes.length; mi++) {
|
|
1769
|
-
middleResult.processNodes[mi].prevId = middleResult.processNodes[mi - 1].nodeId;
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
const firstMiddleNodeId = middleResult.processNodes.length > 0
|
|
1774
|
-
? middleResult.processNodes[0].nodeId
|
|
1775
|
-
: finishNodeId;
|
|
1776
|
-
|
|
1777
|
-
// ē»č£
åčµ·čē¹
|
|
1778
|
-
const applyProcessNode = {
|
|
1779
|
-
name: i18n('åčµ·', 'start', 'éå§'),
|
|
1780
|
-
description: '',
|
|
1781
|
-
type: 'apply',
|
|
1782
|
-
nodeId: 'sid_instStart',
|
|
1783
|
-
prevId: '',
|
|
1784
|
-
nextId: [firstMiddleNodeId],
|
|
1785
|
-
props: {},
|
|
1786
|
-
childNodes: [],
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
|
-
// ē»č£
ē»ęčē¹
|
|
1790
|
-
const finishProcessNode = {
|
|
1791
|
-
name: i18n('ē»ę', 'end', 'ēµäŗ'),
|
|
1792
|
-
description: '',
|
|
1793
|
-
type: 'finish',
|
|
1794
|
-
nodeId: finishNodeId,
|
|
1795
|
-
prevId: '',
|
|
1796
|
-
nextId: [],
|
|
1797
|
-
props: {},
|
|
1798
|
-
childNodes: [],
|
|
1799
|
-
};
|
|
1800
|
-
|
|
1801
|
-
// ē»č£
processJson
|
|
1802
|
-
const processNodes = [applyProcessNode];
|
|
1803
|
-
middleResult.processNodes.forEach(function (node) {
|
|
1804
|
-
processNodes.push(node);
|
|
1805
|
-
});
|
|
1806
|
-
processNodes.push(finishProcessNode);
|
|
1807
|
-
|
|
1808
|
-
const defaultProcessDetailUrl = baseUrl + '/alibaba/web/' + appType + '/inst/taskDetail.htm';
|
|
1809
|
-
const defaultProcessMobileDetailUrl = baseUrl + '/alibaba/mobile/' + appType + '/inst/detail/taskDetail/';
|
|
1810
|
-
|
|
1811
|
-
const processJson = {
|
|
1812
|
-
props: {
|
|
1813
|
-
allowWithdraw: true,
|
|
1814
|
-
allowCollaboration: true,
|
|
1815
|
-
allowTemporaryStorage: true,
|
|
1816
|
-
processCode: processCode,
|
|
1817
|
-
processDetailUrl: definition.processDetailUrl
|
|
1818
|
-
|| (definition.detailUrls && (definition.detailUrls.web || definition.detailUrls.pc))
|
|
1819
|
-
|| definition.customDetailPageUrl
|
|
1820
|
-
|| defaultProcessDetailUrl,
|
|
1821
|
-
processInitUrl: baseUrl + '/alibaba/web/' + appType + '/inst/instStart.htm?processCode=' + processCode,
|
|
1822
|
-
processMobileDetailUrl: definition.processMobileDetailUrl
|
|
1823
|
-
|| (definition.detailUrls && definition.detailUrls.mobile)
|
|
1824
|
-
|| (definition.customDetailPageUrl ? appendOpenDetailParam(definition.customDetailPageUrl, 'formInstId') : null)
|
|
1825
|
-
|| defaultProcessMobileDetailUrl,
|
|
1826
|
-
bindingForm: formUuid,
|
|
1827
|
-
stopAssociationRulesIfFailed: false,
|
|
1828
|
-
noRecordRecall: false,
|
|
1829
|
-
untimedRule: [],
|
|
1830
|
-
},
|
|
1831
|
-
nodes: processNodes,
|
|
1832
|
-
flowConfig: {},
|
|
1833
|
-
formulaRules: [],
|
|
1834
|
-
approvalSummary: [],
|
|
1835
|
-
nodeI18nKeyMap: {},
|
|
1836
|
-
};
|
|
1837
|
-
|
|
1838
|
-
// ē»č£
viewJson
|
|
1839
|
-
const viewChildren = [];
|
|
1840
|
-
|
|
1841
|
-
viewChildren.push({
|
|
1842
|
-
componentName: 'ApplyNode',
|
|
1843
|
-
id: generateNodeId(),
|
|
1844
|
-
props: {
|
|
1845
|
-
nodeName: 'ApplyNode',
|
|
1846
|
-
name: i18n('åčµ·', 'start', 'éå§'),
|
|
1847
|
-
},
|
|
1848
|
-
});
|
|
1849
|
-
|
|
1850
|
-
middleResult.viewNodes.forEach(function (node) {
|
|
1851
|
-
viewChildren.push(node);
|
|
1852
|
-
});
|
|
1853
|
-
|
|
1854
|
-
viewChildren.push({
|
|
1855
|
-
componentName: 'EndNode',
|
|
1856
|
-
id: finishNodeId,
|
|
1857
|
-
props: {
|
|
1858
|
-
name: i18n('ē»ę', 'end', 'ēµäŗ'),
|
|
1859
|
-
},
|
|
1860
|
-
});
|
|
1861
|
-
|
|
1862
|
-
const viewJson = {
|
|
1863
|
-
schema: {
|
|
1864
|
-
componentName: 'CanvasEngine',
|
|
1865
|
-
id: generateNodeId(),
|
|
1866
|
-
props: {},
|
|
1867
|
-
children: viewChildren,
|
|
1868
|
-
},
|
|
1869
|
-
bindingForm: formUuid,
|
|
1870
|
-
formulaRules: [],
|
|
1871
|
-
globalSetting: {
|
|
1872
|
-
enableSignature: false,
|
|
1873
|
-
stopAssociationRulesIfFailed: false,
|
|
1874
|
-
nodeMerge: false,
|
|
1875
|
-
originatorMerge: false,
|
|
1876
|
-
allNodeMerge: false,
|
|
1877
|
-
behaviorList: [],
|
|
1878
|
-
needOpenDigitalSignNodes: [],
|
|
1879
|
-
approvalSummary: [],
|
|
1880
|
-
noRecordRecall: false,
|
|
1881
|
-
untimedRule: [],
|
|
1882
|
-
},
|
|
1883
|
-
};
|
|
1884
|
-
|
|
1885
|
-
return { processJson, viewJson };
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
// āā API č°ēØå½ę° āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
1889
|
-
|
|
1890
|
-
function queryProcessVersions(authRef, appType, processCode, status) {
|
|
1891
|
-
const requestPath = '/alibaba/web/' + appType + '/query/process/pageProcessVersion.json';
|
|
1892
|
-
return createYidaClient({ authRef }).get(requestPath, {
|
|
1893
|
-
_api: 'Process.getProcessVersionInfo',
|
|
1894
|
-
_mock: 'false',
|
|
1895
|
-
_locale_time_zone_offset: '28800000',
|
|
1896
|
-
processCode: processCode,
|
|
1897
|
-
appType: appType,
|
|
1898
|
-
status: status || '',
|
|
1899
|
-
pageIndex: 1,
|
|
1900
|
-
pageSize: 10,
|
|
1901
|
-
orderByModifyTime: 'desc',
|
|
1902
|
-
_stamp: Date.now(),
|
|
1903
|
-
});
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
function switchFormType(authRef, appType, formUuid) {
|
|
1907
|
-
const requestPath = '/' + appType + '/query/formdesign/switchFormType.json'
|
|
1908
|
-
+ '?_api=Nav.transformForm&_mock=false&_stamp=' + Date.now();
|
|
1909
|
-
return createYidaClient({ authRef }).postForm(requestPath, {
|
|
1910
|
-
_locale_time_zone_offset: '28800000',
|
|
1911
|
-
toFormType: 'process',
|
|
1912
|
-
formUuid: formUuid,
|
|
1913
|
-
});
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
function getProcessCodeFromAppParam(authRef, appType, formUuid) {
|
|
1917
|
-
const requestPath = '/' + appType + '/query/app/getAppPlatFormParam.json';
|
|
1918
|
-
return createYidaClient({ authRef }).get(requestPath, {
|
|
1919
|
-
_api: 'nattyFetch',
|
|
1920
|
-
_mock: 'false',
|
|
1921
|
-
_locale_time_zone_offset: '28800000',
|
|
1922
|
-
pageIndex: 1,
|
|
1923
|
-
pageSize: 50,
|
|
1924
|
-
_stamp: Date.now(),
|
|
1925
|
-
}).then(function (result) {
|
|
1926
|
-
if (result.success && result.content && result.content.formNavigationList) {
|
|
1927
|
-
const navList = result.content.formNavigationList;
|
|
1928
|
-
for (let i = 0; i < navList.length; i++) {
|
|
1929
|
-
if (navList[i].formUuid === formUuid && navList[i].processCode) {
|
|
1930
|
-
return navList[i].processCode;
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
return null;
|
|
1935
|
-
});
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
function getProcessCodeFromSchema(authRef, appType, formUuid) {
|
|
1939
|
-
const requestPath = '/dingtalk/web/' + appType + '/query/formdesign/getFormSchema.json';
|
|
1940
|
-
return createYidaClient({ authRef }).get(requestPath, {
|
|
1941
|
-
formUuid,
|
|
1942
|
-
schemaVersion: 'V5',
|
|
1943
|
-
}).then(function (result) {
|
|
1944
|
-
if (result.success && result.content) {
|
|
1945
|
-
const schemaStr = typeof result.content === 'string' ? result.content : JSON.stringify(result.content);
|
|
1946
|
-
const matches = schemaStr.match(/TPROC[A-Za-z0-9_-]+/g);
|
|
1947
|
-
if (matches && matches.length > 0) {
|
|
1948
|
-
const unique = [];
|
|
1949
|
-
const seen = {};
|
|
1950
|
-
matches.forEach(function (m) {
|
|
1951
|
-
if (!seen[m]) { seen[m] = true; unique.push(m); }
|
|
1952
|
-
});
|
|
1953
|
-
return unique[0];
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
return null;
|
|
1957
|
-
});
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
function newDraftProcess(authRef, appType, processCode, formUuid, processId, processVersion) {
|
|
1961
|
-
const requestPath = '/' + appType + '/query/simpleProcess/newDraftProcess.json';
|
|
1962
|
-
return createYidaClient({ authRef }).postForm(requestPath, () => {
|
|
1963
|
-
const postObj = {
|
|
1964
|
-
_locale_time_zone_offset: '28800000',
|
|
1965
|
-
formUuid: formUuid,
|
|
1966
|
-
processCode: processCode,
|
|
1967
|
-
};
|
|
1968
|
-
if (processId) {postObj.processId = String(processId);}
|
|
1969
|
-
if (processVersion !== undefined && processVersion !== null) {postObj.processVersion = String(processVersion);}
|
|
1970
|
-
return postObj;
|
|
1971
|
-
});
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
function saveProcessById(authRef, appType, formUuid, processCode, processId, processVersion, processJsonStr, viewJsonStr) {
|
|
1975
|
-
const requestPath = '/alibaba/web/' + appType + '/query/simpleProcess/saveProcessById.json';
|
|
1976
|
-
return createYidaClient({ authRef }).postForm(requestPath, {
|
|
1977
|
-
formUuid: formUuid,
|
|
1978
|
-
isOnline: 'true',
|
|
1979
|
-
json: processJsonStr,
|
|
1980
|
-
needReportLine: 'y',
|
|
1981
|
-
processCode: processCode,
|
|
1982
|
-
processId: String(processId),
|
|
1983
|
-
processVersion: String(processVersion),
|
|
1984
|
-
viewJson: viewJsonStr,
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
function publishProcessById(authRef, appType, formUuid, processCode, processId, processVersion) {
|
|
1989
|
-
const requestPath = '/alibaba/web/' + appType + '/query/simpleProcess/publishProcessById.json';
|
|
1990
|
-
return createYidaClient({ authRef }).postForm(requestPath, {
|
|
1991
|
-
formUuid: formUuid,
|
|
1992
|
-
processCode: processCode,
|
|
1993
|
-
processId: String(processId),
|
|
1994
|
-
processVersion: String(processVersion),
|
|
1995
|
-
});
|
|
1996
|
-
}
|
|
14
|
+
const {
|
|
15
|
+
assertLegacyDirectWriteAllowed,
|
|
16
|
+
extractLegacyGuardArgs,
|
|
17
|
+
} = require('../core/legacy-schema-guard');
|
|
18
|
+
const {
|
|
19
|
+
buildApproverConfig,
|
|
20
|
+
buildProcessAndViewJson,
|
|
21
|
+
} = require('./services/process-compiler');
|
|
22
|
+
const {
|
|
23
|
+
getProcessCodeFromAppParam,
|
|
24
|
+
getProcessCodeFromSchema,
|
|
25
|
+
newDraftProcess,
|
|
26
|
+
publishProcessById,
|
|
27
|
+
queryProcessVersions,
|
|
28
|
+
saveProcessById,
|
|
29
|
+
switchFormType,
|
|
30
|
+
} = require('./services/process-service');
|
|
1997
31
|
|
|
1998
32
|
function parseArgs(args) {
|
|
1999
|
-
|
|
33
|
+
const guardSplit = extractLegacyGuardArgs(args || []);
|
|
34
|
+
const directArgs = guardSplit.args;
|
|
35
|
+
if (!Array.isArray(directArgs) || directArgs.length < 3) {
|
|
2000
36
|
warn(t('configure_process.usage'));
|
|
2001
37
|
throw new CliError(t('configure_process.usage'), {
|
|
2002
38
|
code: 'CONFIGURE_PROCESS_INVALID_ARGUMENTS',
|
|
@@ -2004,10 +40,11 @@ function parseArgs(args) {
|
|
|
2004
40
|
}
|
|
2005
41
|
|
|
2006
42
|
return {
|
|
2007
|
-
appType:
|
|
2008
|
-
formUuid:
|
|
2009
|
-
processDefinitionFile: path.resolve(
|
|
2010
|
-
processCodeArg:
|
|
43
|
+
appType: directArgs[0],
|
|
44
|
+
formUuid: directArgs[1],
|
|
45
|
+
processDefinitionFile: path.resolve(directArgs[2]),
|
|
46
|
+
processCodeArg: directArgs[3] || null,
|
|
47
|
+
legacyGuardOptions: guardSplit.guardOptions,
|
|
2011
48
|
};
|
|
2012
49
|
}
|
|
2013
50
|
|
|
@@ -2026,6 +63,14 @@ async function run(args) {
|
|
|
2026
63
|
const formUuid = parsed.formUuid;
|
|
2027
64
|
const processDefinitionFile = parsed.processDefinitionFile;
|
|
2028
65
|
const processCodeArg = parsed.processCodeArg;
|
|
66
|
+
assertLegacyDirectWriteAllowed({
|
|
67
|
+
command: 'configure-process',
|
|
68
|
+
resourceType: 'process',
|
|
69
|
+
action: 'update',
|
|
70
|
+
appType,
|
|
71
|
+
formUuid,
|
|
72
|
+
processCode: processCodeArg,
|
|
73
|
+
}, { guardOptions: parsed.legacyGuardOptions });
|
|
2029
74
|
|
|
2030
75
|
warn('š§ ' + t('configure_process.title'));
|
|
2031
76
|
warn(' ' + t('configure_process.app_id') + ': ' + appType);
|
|
@@ -2081,7 +126,7 @@ async function run(args) {
|
|
|
2081
126
|
}
|
|
2082
127
|
}
|
|
2083
128
|
|
|
2084
|
-
// ę¹ę³ 1:
|
|
129
|
+
// ę¹ę³ 1: ä»ē²¾ē”®č”ØåęµēØē»å®ę„å£ęå
|
|
2085
130
|
warn(' ' + t('configure_process.method1') + '...');
|
|
2086
131
|
processCode = await getProcessCodeFromAppParam(authRef, appType, formUuid);
|
|
2087
132
|
if (processCode) {
|
|
@@ -2177,7 +222,14 @@ async function run(args) {
|
|
|
2177
222
|
|
|
2178
223
|
// 6. ę建 processJson å viewJson
|
|
2179
224
|
warn('\nšļø ' + t('configure_process.building_json') + '...');
|
|
2180
|
-
const result = buildProcessAndViewJson(
|
|
225
|
+
const result = buildProcessAndViewJson(
|
|
226
|
+
definition,
|
|
227
|
+
processCode,
|
|
228
|
+
formUuid,
|
|
229
|
+
authRef.baseUrl,
|
|
230
|
+
appType,
|
|
231
|
+
{ onWarning: warn }
|
|
232
|
+
);
|
|
2181
233
|
const processJsonStr = JSON.stringify(result.processJson);
|
|
2182
234
|
const viewJsonStr = JSON.stringify(result.viewJson);
|
|
2183
235
|
warn(' ā
processJson: ' + processJsonStr.length + ' chars');
|