gbflowengine 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +271 -271
  2. package/dist/gbflowengine.css +1 -1
  3. package/dist/gbflowengine.js +8232 -6913
  4. package/dist/gbflowengine.js.map +1 -1
  5. package/dist/gbflowengine.umd.cjs +2 -2
  6. package/dist/gbflowengine.umd.cjs.map +1 -1
  7. package/package.json +85 -84
  8. package/src/center/DefinitionInspect.vue +291 -291
  9. package/src/center/FlowCenter.vue +33 -33
  10. package/src/center/index.js +29 -29
  11. package/src/center/storage.js +748 -748
  12. package/src/core/flow/condition.js +160 -160
  13. package/src/core/flow/customNode.js +385 -385
  14. package/src/core/flow/defaults.js +124 -124
  15. package/src/core/flow/flowConstant.js +265 -265
  16. package/src/core/flow/flowNodeUtils.js +29 -29
  17. package/src/core/flow/index.js +47 -47
  18. package/src/core/flow/node.js +44 -44
  19. package/src/core/flow/nodeFactory.js +58 -58
  20. package/src/core/flow/prediction.js +325 -325
  21. package/src/core/flow/schema.js +864 -864
  22. package/src/definition/FlowDefinitionDesigner.vue +338 -338
  23. package/src/definition/index.js +9 -9
  24. package/src/index.js +39 -39
  25. package/src/storage.js +200 -200
  26. package/src/testing/FlowTestPanel.vue +2502 -2502
  27. package/src/testing/UserConfigDrawer.vue +376 -376
  28. package/src/testing/diagram/FlowProgressDiagram.vue +318 -318
  29. package/src/testing/diagramModel.js +517 -517
  30. package/src/testing/index.js +23 -23
  31. package/src/testing/mock.js +246 -246
  32. package/src/testing/oaExecutors.js +51 -51
  33. package/src/testing/oaSeed.js +467 -467
  34. package/src/testing/sample.js +412 -412
  35. package/src/testing/seed.js +122 -122
  36. package/src/utils/format.js +27 -27
  37. package/src/visual/FlowCanvas.vue +440 -440
  38. package/src/visual/NodeProgressDetail.vue +43 -43
  39. package/src/visual/NodeStatusBadge.vue +17 -17
  40. package/src/visual/NodeWrap.vue +46 -46
  41. package/src/visual/ScWorkflow.vue +49 -49
  42. package/src/visual/SelectDialog.vue +459 -459
  43. package/src/visual/conditionHelpers.js +116 -116
  44. package/src/visual/index.js +6 -6
  45. package/src/visual/nodes/AddNode.vue +222 -222
  46. package/src/visual/nodes/ApproverNode.vue +347 -347
  47. package/src/visual/nodes/BranchNode.vue +441 -441
  48. package/src/visual/nodes/CustomNode.vue +339 -339
  49. package/src/visual/nodes/EndNode.vue +21 -21
  50. package/src/visual/nodes/PassNode.vue +100 -100
  51. package/src/visual/nodes/PromoterNode.vue +134 -134
  52. package/src/visual/nodes/RejectNode.vue +100 -100
  53. package/src/visual/nodes/SendNode.vue +151 -151
  54. package/src/visual/styles.scss +879 -879
  55. package/src/visual/useScNodeStatus.js +18 -18
  56. package/src/workbench/OaWorkbench.vue +1341 -1341
  57. package/src/workbench/components/ApprovalWorkspace.vue +2090 -2090
  58. package/src/workbench/components/CategoryIcon.vue +74 -74
  59. package/src/workbench/components/NotificationIcon.vue +73 -73
  60. package/src/workbench/components/ProcessSteps.vue +557 -557
  61. package/src/workbench/components/ResubmitDialog.vue +227 -227
  62. package/src/workbench/components/SidebarNav.vue +138 -138
  63. package/src/workbench/components/StartFlowDialog.vue +1058 -1058
  64. package/src/workbench/components/UserAvatar.vue +68 -68
  65. package/src/workbench/model.js +1080 -1080
  66. package/src/workbench/pages/DesignPage.vue +798 -798
  67. package/src/workbench/pages/HomePage.vue +1050 -1050
  68. package/src/workbench/pages/MonitorPage.vue +1029 -1029
  69. package/src/workbench/pages/NotificationsPage.vue +554 -554
  70. package/src/workbench/pages/RequestsPage.vue +644 -644
  71. package/src/workbench/pages/TaskCenterPage.vue +1155 -1155
  72. package/src/workbench/pages/TemplatesPage.vue +680 -680
  73. package/src/workbench/styles.scss +555 -555
  74. package/types/center.d.ts +5 -5
  75. package/types/core.d.ts +479 -479
  76. package/types/definition.d.ts +4 -4
  77. package/types/index.d.ts +34 -34
  78. package/types/testing.d.ts +20 -20
  79. package/types/visual.d.ts +20 -20
@@ -1,339 +1,339 @@
1
- <template>
2
- <div class="node-wrap">
3
- <div class="node-wrap-box" :class="statusClass" @click="show">
4
- <div class="title" style="background: #6f5cf1">
5
- <el-icon class="icon"><SetUp /></el-icon>
6
- <span>{{ nodeConfig.nodeName }}</span>
7
- <NodeStatusBadge :status="statusInfo" />
8
- <el-icon class="close" @click.stop="delNode()"><Close /></el-icon>
9
- </div>
10
- <div v-if="!statusInfo" class="content">
11
- <span v-if="summary">{{ summary }}</span>
12
- <span v-else class="placeholder">请配置执行方式</span>
13
- <span class="sc-node-policy">{{ policyText }}</span>
14
- </div>
15
- <NodeProgressDetail v-else :status="statusInfo" />
16
- </div>
17
- <AddNode
18
- v-model="nodeConfig.childNode"
19
- :parent-node="nodeConfig"
20
- :readonly="isReadonly"
21
- @update:model-value="updateChild"
22
- />
23
-
24
- <el-drawer
25
- title="自定义节点设置"
26
- v-model="drawer"
27
- destroy-on-close
28
- append-to-body
29
- :size="560"
30
- >
31
- <template #header>
32
- <div class="node-wrap-drawer__title">
33
- <label v-if="!isEditTitle" @click="editTitle">
34
- {{ form.nodeName }}
35
- <el-icon class="node-wrap-drawer__title-edit"><Edit /></el-icon>
36
- </label>
37
- <el-input
38
- v-if="isEditTitle"
39
- ref="nodeTitle"
40
- v-model="form.nodeName"
41
- clearable
42
- @blur="saveTitle"
43
- @keyup.enter="saveTitle"
44
- />
45
- </div>
46
- </template>
47
- <el-container>
48
- <el-main style="padding: 0 20px 20px 20px">
49
- <el-form label-position="top">
50
- <el-form-item label="执行方式">
51
- <el-radio-group v-model="form.custom.executorType">
52
- <el-radio-button value="http">HTTP 请求</el-radio-button>
53
- <el-radio-button value="method">已注册方法</el-radio-button>
54
- </el-radio-group>
55
- </el-form-item>
56
-
57
- <template v-if="form.custom.executorType === 'http'">
58
- <el-form-item label="请求方法与地址">
59
- <div class="sc-custom-request-line">
60
- <el-select v-model="form.custom.method" class="sc-custom-method">
61
- <el-option
62
- v-for="method in CUSTOM_HTTP_METHODS"
63
- :key="method"
64
- :label="method"
65
- :value="method"
66
- />
67
- </el-select>
68
- <el-input
69
- v-model="form.custom.url"
70
- placeholder="https://api.example.com/check 或 /gateway/check"
71
- />
72
- </div>
73
- <p class="sc-custom-hint">
74
- 支持表单变量插值,例如
75
- <code>{{ amountPlaceholder }}</code>
76
- <span v-if="formVariables.length">
77
- ,可用字段:{{ formVariables.map((item) => item.variableName || item.variable).slice(0, 6).join('、') }}
78
- </span>
79
- </p>
80
- </el-form-item>
81
-
82
- <el-form-item label="请求头">
83
- <div class="sc-custom-headers">
84
- <div
85
- v-for="(header, index) in form.custom.headers"
86
- :key="index"
87
- class="sc-custom-header-row"
88
- >
89
- <el-input v-model="header.key" placeholder="Header" />
90
- <el-input v-model="header.value" placeholder="值,支持变量插值" />
91
- <el-button
92
- link
93
- type="danger"
94
- :icon="Delete"
95
- aria-label="删除请求头"
96
- @click="removeHeader(index)"
97
- />
98
- </div>
99
- </div>
100
- <el-button link type="primary" :icon="Plus" @click="addHeader">
101
- 添加请求头
102
- </el-button>
103
- <p class="sc-custom-hint">
104
- 认证信息建议通过企业网关或已注册方法注入,不要直接写在流程定义中。
105
- </p>
106
- </el-form-item>
107
-
108
- <el-form-item label="请求体">
109
- <el-input
110
- v-model="form.custom.body"
111
- type="textarea"
112
- :rows="4"
113
- :disabled="['GET', 'HEAD'].includes(form.custom.method)"
114
- :placeholder="bodyPlaceholder"
115
- />
116
- <p class="sc-custom-hint">
117
- JSON 模板,支持变量插值;GET / HEAD 请求会忽略请求体。
118
- </p>
119
- </el-form-item>
120
-
121
- </template>
122
-
123
- <template v-else>
124
- <el-form-item label="已注册方法名">
125
- <el-input
126
- v-model="form.custom.methodKey"
127
- placeholder="例如 demo.verifySupplier"
128
- />
129
- <p class="sc-custom-hint">
130
- 宿主通过
131
- <code>customExecutors</code>
132
- 注册同名异步方法;方法返回的 JSON 会作为节点执行结果。
133
- </p>
134
- </el-form-item>
135
- </template>
136
-
137
- <el-form-item label="执行超时">
138
- <el-input-number
139
- v-model="form.custom.timeoutMs"
140
- :min="1000"
141
- :max="120000"
142
- :step="1000"
143
- />
144
- <span class="sc-custom-unit">毫秒</span>
145
- </el-form-item>
146
-
147
- <el-form-item label="结果变量">
148
- <el-input
149
- v-model="form.custom.resultVariable"
150
- placeholder="例如 supplierRisk,可留空"
151
- />
152
- <p class="sc-custom-hint">
153
- <template v-if="form.custom.executorType === 'http'">
154
- 执行结果会写入流程变量;HTTP 结果结构为
155
- <code>{ status, ok, headers, data }</code>。
156
- </template>
157
- <template v-else>
158
- 方法返回值会写入流程变量,可在下游节点或条件中使用。
159
- </template>
160
- </p>
161
- </el-form-item>
162
-
163
- <el-form-item label="失败处理">
164
- <el-radio-group v-model="form.custom.onError">
165
- <el-radio value="terminate">终止流程</el-radio>
166
- <el-radio value="continue">记录失败并继续</el-radio>
167
- </el-radio-group>
168
- </el-form-item>
169
-
170
- <el-alert
171
- v-if="form.custom.executorType === 'http'"
172
- type="info"
173
- :closable="false"
174
- show-icon
175
- title="浏览器直连外部地址受 CORS 与网络策略限制;生产环境建议通过企业网关代理请求。"
176
- />
177
- </el-form>
178
- </el-main>
179
- <el-footer>
180
- <el-button type="primary" @click="save">保存</el-button>
181
- <el-button @click="drawer = false">取消</el-button>
182
- </el-footer>
183
- </el-container>
184
- </el-drawer>
185
- </div>
186
- </template>
187
-
188
- <script setup>
189
- import { computed, inject, ref, unref } from 'vue'
190
- import { ElMessage } from 'element-plus'
191
- import { Close, Delete, Edit, Plus, SetUp } from '@element-plus/icons-vue'
192
- import AddNode from './AddNode.vue'
193
- import NodeStatusBadge from '../NodeStatusBadge.vue'
194
- import NodeProgressDetail from '../NodeProgressDetail.vue'
195
- import { useScNodeStatus } from '../useScNodeStatus.js'
196
- import {
197
- CUSTOM_HTTP_METHODS,
198
- customNodeSummary,
199
- normalizeCustomNodeConfig,
200
- validateCustomNodeConfig
201
- } from '../../core/flow/index.js'
202
-
203
- defineOptions({ name: 'ScCustomNode' })
204
-
205
- const props = defineProps({
206
- modelValue: { type: Object, required: true }
207
- })
208
-
209
- const emit = defineEmits(['update:modelValue'])
210
-
211
- const readonly = inject('scReadonly', ref(false))
212
- const injectedVariables = inject('scFormVariables', ref([]))
213
- const isReadonly = computed(() => readonly.value === true)
214
- const nodeConfig = computed(() => props.modelValue)
215
- const formVariables = computed(() => unref(injectedVariables) || [])
216
- const { statusInfo, statusClass } = useScNodeStatus(nodeConfig)
217
-
218
- const summary = computed(() =>
219
- nodeConfig.value.custom ? customNodeSummary(nodeConfig.value.custom) : ''
220
- )
221
- const policyText = computed(() => {
222
- const custom = normalizeCustomNodeConfig(nodeConfig.value.custom)
223
- return custom.onError === 'continue'
224
- ? '执行失败后记录异常并继续流转'
225
- : '执行失败后终止流程'
226
- })
227
- const amountPlaceholder = '{{amount}}'
228
- const bodyPlaceholder = computed(
229
- () => '{\n "amount": "{{amount}}",\n "applicant": "{{reason}}"\n}'
230
- )
231
-
232
- const drawer = ref(false)
233
- const isEditTitle = ref(false)
234
- const nodeTitle = ref(null)
235
- const form = ref({ nodeName: '', custom: normalizeCustomNodeConfig() })
236
-
237
- const updateChild = (child) => {
238
- const next = JSON.parse(JSON.stringify(nodeConfig.value))
239
- next.childNode = child
240
- emit('update:modelValue', next)
241
- }
242
-
243
- const show = () => {
244
- if (isReadonly.value) return
245
- form.value = {
246
- ...JSON.parse(JSON.stringify(nodeConfig.value)),
247
- custom: normalizeCustomNodeConfig(nodeConfig.value.custom)
248
- }
249
- isEditTitle.value = false
250
- drawer.value = true
251
- }
252
-
253
- const editTitle = () => {
254
- isEditTitle.value = true
255
- requestAnimationFrame(() => nodeTitle.value?.focus())
256
- }
257
-
258
- const saveTitle = () => {
259
- isEditTitle.value = false
260
- }
261
-
262
- const addHeader = () => {
263
- form.value.custom.headers.push({ key: '', value: '' })
264
- }
265
-
266
- const removeHeader = (index) => {
267
- form.value.custom.headers.splice(index, 1)
268
- }
269
-
270
- const save = () => {
271
- const source = JSON.parse(JSON.stringify(nodeConfig.value))
272
- source.nodeName = String(form.value.nodeName || '').trim() || '自定义节点'
273
- source.custom = normalizeCustomNodeConfig(form.value.custom)
274
- const report = validateCustomNodeConfig(source.custom)
275
- if (report.errors.length) {
276
- ElMessage.warning(`${report.errors[0].message},发布前请补全配置`)
277
- }
278
- emit('update:modelValue', source)
279
- drawer.value = false
280
- }
281
-
282
- const delNode = () => {
283
- if (isReadonly.value) return
284
- emit('update:modelValue', nodeConfig.value.childNode)
285
- }
286
- </script>
287
-
288
- <style scoped lang="scss">
289
- .sc-custom-request-line {
290
- display: flex;
291
- gap: 8px;
292
- width: 100%;
293
- }
294
-
295
- .sc-custom-method {
296
- width: 114px;
297
- flex-shrink: 0;
298
- }
299
-
300
- .sc-custom-hint {
301
- margin: 5px 0 0;
302
- color: #94a3b8;
303
- font-size: 12px;
304
- line-height: 1.6;
305
-
306
- code {
307
- padding: 1px 4px;
308
- border-radius: 3px;
309
- background: #f1f5f9;
310
- color: #475569;
311
- font-size: 11px;
312
- }
313
- }
314
-
315
- .sc-custom-headers {
316
- display: flex;
317
- flex-direction: column;
318
- gap: 7px;
319
- width: 100%;
320
- margin-bottom: 4px;
321
- }
322
-
323
- .sc-custom-header-row {
324
- display: flex;
325
- align-items: center;
326
- gap: 6px;
327
-
328
- .el-input:first-child {
329
- width: 38%;
330
- flex-shrink: 0;
331
- }
332
- }
333
-
334
- .sc-custom-unit {
335
- margin-left: 8px;
336
- color: #94a3b8;
337
- font-size: 12px;
338
- }
339
- </style>
1
+ <template>
2
+ <div class="node-wrap">
3
+ <div class="node-wrap-box" :class="statusClass" @click="show">
4
+ <div class="title" style="background: #6f5cf1">
5
+ <el-icon class="icon"><SetUp /></el-icon>
6
+ <span>{{ nodeConfig.nodeName }}</span>
7
+ <NodeStatusBadge :status="statusInfo" />
8
+ <el-icon class="close" @click.stop="delNode()"><Close /></el-icon>
9
+ </div>
10
+ <div v-if="!statusInfo" class="content">
11
+ <span v-if="summary">{{ summary }}</span>
12
+ <span v-else class="placeholder">请配置执行方式</span>
13
+ <span class="sc-node-policy">{{ policyText }}</span>
14
+ </div>
15
+ <NodeProgressDetail v-else :status="statusInfo" />
16
+ </div>
17
+ <AddNode
18
+ v-model="nodeConfig.childNode"
19
+ :parent-node="nodeConfig"
20
+ :readonly="isReadonly"
21
+ @update:model-value="updateChild"
22
+ />
23
+
24
+ <el-drawer
25
+ title="自定义节点设置"
26
+ v-model="drawer"
27
+ destroy-on-close
28
+ append-to-body
29
+ :size="560"
30
+ >
31
+ <template #header>
32
+ <div class="node-wrap-drawer__title">
33
+ <label v-if="!isEditTitle" @click="editTitle">
34
+ {{ form.nodeName }}
35
+ <el-icon class="node-wrap-drawer__title-edit"><Edit /></el-icon>
36
+ </label>
37
+ <el-input
38
+ v-if="isEditTitle"
39
+ ref="nodeTitle"
40
+ v-model="form.nodeName"
41
+ clearable
42
+ @blur="saveTitle"
43
+ @keyup.enter="saveTitle"
44
+ />
45
+ </div>
46
+ </template>
47
+ <el-container>
48
+ <el-main style="padding: 0 20px 20px 20px">
49
+ <el-form label-position="top">
50
+ <el-form-item label="执行方式">
51
+ <el-radio-group v-model="form.custom.executorType">
52
+ <el-radio-button value="http">HTTP 请求</el-radio-button>
53
+ <el-radio-button value="method">已注册方法</el-radio-button>
54
+ </el-radio-group>
55
+ </el-form-item>
56
+
57
+ <template v-if="form.custom.executorType === 'http'">
58
+ <el-form-item label="请求方法与地址">
59
+ <div class="sc-custom-request-line">
60
+ <el-select v-model="form.custom.method" class="sc-custom-method">
61
+ <el-option
62
+ v-for="method in CUSTOM_HTTP_METHODS"
63
+ :key="method"
64
+ :label="method"
65
+ :value="method"
66
+ />
67
+ </el-select>
68
+ <el-input
69
+ v-model="form.custom.url"
70
+ placeholder="https://api.example.com/check 或 /gateway/check"
71
+ />
72
+ </div>
73
+ <p class="sc-custom-hint">
74
+ 支持表单变量插值,例如
75
+ <code>{{ amountPlaceholder }}</code>
76
+ <span v-if="formVariables.length">
77
+ ,可用字段:{{ formVariables.map((item) => item.variableName || item.variable).slice(0, 6).join('、') }}
78
+ </span>
79
+ </p>
80
+ </el-form-item>
81
+
82
+ <el-form-item label="请求头">
83
+ <div class="sc-custom-headers">
84
+ <div
85
+ v-for="(header, index) in form.custom.headers"
86
+ :key="index"
87
+ class="sc-custom-header-row"
88
+ >
89
+ <el-input v-model="header.key" placeholder="Header" />
90
+ <el-input v-model="header.value" placeholder="值,支持变量插值" />
91
+ <el-button
92
+ link
93
+ type="danger"
94
+ :icon="Delete"
95
+ aria-label="删除请求头"
96
+ @click="removeHeader(index)"
97
+ />
98
+ </div>
99
+ </div>
100
+ <el-button link type="primary" :icon="Plus" @click="addHeader">
101
+ 添加请求头
102
+ </el-button>
103
+ <p class="sc-custom-hint">
104
+ 认证信息建议通过企业网关或已注册方法注入,不要直接写在流程定义中。
105
+ </p>
106
+ </el-form-item>
107
+
108
+ <el-form-item label="请求体">
109
+ <el-input
110
+ v-model="form.custom.body"
111
+ type="textarea"
112
+ :rows="4"
113
+ :disabled="['GET', 'HEAD'].includes(form.custom.method)"
114
+ :placeholder="bodyPlaceholder"
115
+ />
116
+ <p class="sc-custom-hint">
117
+ JSON 模板,支持变量插值;GET / HEAD 请求会忽略请求体。
118
+ </p>
119
+ </el-form-item>
120
+
121
+ </template>
122
+
123
+ <template v-else>
124
+ <el-form-item label="已注册方法名">
125
+ <el-input
126
+ v-model="form.custom.methodKey"
127
+ placeholder="例如 demo.verifySupplier"
128
+ />
129
+ <p class="sc-custom-hint">
130
+ 宿主通过
131
+ <code>customExecutors</code>
132
+ 注册同名异步方法;方法返回的 JSON 会作为节点执行结果。
133
+ </p>
134
+ </el-form-item>
135
+ </template>
136
+
137
+ <el-form-item label="执行超时">
138
+ <el-input-number
139
+ v-model="form.custom.timeoutMs"
140
+ :min="1000"
141
+ :max="120000"
142
+ :step="1000"
143
+ />
144
+ <span class="sc-custom-unit">毫秒</span>
145
+ </el-form-item>
146
+
147
+ <el-form-item label="结果变量">
148
+ <el-input
149
+ v-model="form.custom.resultVariable"
150
+ placeholder="例如 supplierRisk,可留空"
151
+ />
152
+ <p class="sc-custom-hint">
153
+ <template v-if="form.custom.executorType === 'http'">
154
+ 执行结果会写入流程变量;HTTP 结果结构为
155
+ <code>{ status, ok, headers, data }</code>。
156
+ </template>
157
+ <template v-else>
158
+ 方法返回值会写入流程变量,可在下游节点或条件中使用。
159
+ </template>
160
+ </p>
161
+ </el-form-item>
162
+
163
+ <el-form-item label="失败处理">
164
+ <el-radio-group v-model="form.custom.onError">
165
+ <el-radio value="terminate">终止流程</el-radio>
166
+ <el-radio value="continue">记录失败并继续</el-radio>
167
+ </el-radio-group>
168
+ </el-form-item>
169
+
170
+ <el-alert
171
+ v-if="form.custom.executorType === 'http'"
172
+ type="info"
173
+ :closable="false"
174
+ show-icon
175
+ title="浏览器直连外部地址受 CORS 与网络策略限制;生产环境建议通过企业网关代理请求。"
176
+ />
177
+ </el-form>
178
+ </el-main>
179
+ <el-footer>
180
+ <el-button type="primary" @click="save">保存</el-button>
181
+ <el-button @click="drawer = false">取消</el-button>
182
+ </el-footer>
183
+ </el-container>
184
+ </el-drawer>
185
+ </div>
186
+ </template>
187
+
188
+ <script setup>
189
+ import { computed, inject, ref, unref } from 'vue'
190
+ import { ElMessage } from 'element-plus'
191
+ import { Close, Delete, Edit, Plus, SetUp } from 'gbicons'
192
+ import AddNode from './AddNode.vue'
193
+ import NodeStatusBadge from '../NodeStatusBadge.vue'
194
+ import NodeProgressDetail from '../NodeProgressDetail.vue'
195
+ import { useScNodeStatus } from '../useScNodeStatus.js'
196
+ import {
197
+ CUSTOM_HTTP_METHODS,
198
+ customNodeSummary,
199
+ normalizeCustomNodeConfig,
200
+ validateCustomNodeConfig
201
+ } from '../../core/flow/index.js'
202
+
203
+ defineOptions({ name: 'ScCustomNode' })
204
+
205
+ const props = defineProps({
206
+ modelValue: { type: Object, required: true }
207
+ })
208
+
209
+ const emit = defineEmits(['update:modelValue'])
210
+
211
+ const readonly = inject('scReadonly', ref(false))
212
+ const injectedVariables = inject('scFormVariables', ref([]))
213
+ const isReadonly = computed(() => readonly.value === true)
214
+ const nodeConfig = computed(() => props.modelValue)
215
+ const formVariables = computed(() => unref(injectedVariables) || [])
216
+ const { statusInfo, statusClass } = useScNodeStatus(nodeConfig)
217
+
218
+ const summary = computed(() =>
219
+ nodeConfig.value.custom ? customNodeSummary(nodeConfig.value.custom) : ''
220
+ )
221
+ const policyText = computed(() => {
222
+ const custom = normalizeCustomNodeConfig(nodeConfig.value.custom)
223
+ return custom.onError === 'continue'
224
+ ? '执行失败后记录异常并继续流转'
225
+ : '执行失败后终止流程'
226
+ })
227
+ const amountPlaceholder = '{{amount}}'
228
+ const bodyPlaceholder = computed(
229
+ () => '{\n "amount": "{{amount}}",\n "applicant": "{{reason}}"\n}'
230
+ )
231
+
232
+ const drawer = ref(false)
233
+ const isEditTitle = ref(false)
234
+ const nodeTitle = ref(null)
235
+ const form = ref({ nodeName: '', custom: normalizeCustomNodeConfig() })
236
+
237
+ const updateChild = (child) => {
238
+ const next = JSON.parse(JSON.stringify(nodeConfig.value))
239
+ next.childNode = child
240
+ emit('update:modelValue', next)
241
+ }
242
+
243
+ const show = () => {
244
+ if (isReadonly.value) return
245
+ form.value = {
246
+ ...JSON.parse(JSON.stringify(nodeConfig.value)),
247
+ custom: normalizeCustomNodeConfig(nodeConfig.value.custom)
248
+ }
249
+ isEditTitle.value = false
250
+ drawer.value = true
251
+ }
252
+
253
+ const editTitle = () => {
254
+ isEditTitle.value = true
255
+ requestAnimationFrame(() => nodeTitle.value?.focus())
256
+ }
257
+
258
+ const saveTitle = () => {
259
+ isEditTitle.value = false
260
+ }
261
+
262
+ const addHeader = () => {
263
+ form.value.custom.headers.push({ key: '', value: '' })
264
+ }
265
+
266
+ const removeHeader = (index) => {
267
+ form.value.custom.headers.splice(index, 1)
268
+ }
269
+
270
+ const save = () => {
271
+ const source = JSON.parse(JSON.stringify(nodeConfig.value))
272
+ source.nodeName = String(form.value.nodeName || '').trim() || '自定义节点'
273
+ source.custom = normalizeCustomNodeConfig(form.value.custom)
274
+ const report = validateCustomNodeConfig(source.custom)
275
+ if (report.errors.length) {
276
+ ElMessage.warning(`${report.errors[0].message},发布前请补全配置`)
277
+ }
278
+ emit('update:modelValue', source)
279
+ drawer.value = false
280
+ }
281
+
282
+ const delNode = () => {
283
+ if (isReadonly.value) return
284
+ emit('update:modelValue', nodeConfig.value.childNode)
285
+ }
286
+ </script>
287
+
288
+ <style scoped lang="scss">
289
+ .sc-custom-request-line {
290
+ display: flex;
291
+ gap: 8px;
292
+ width: 100%;
293
+ }
294
+
295
+ .sc-custom-method {
296
+ width: 114px;
297
+ flex-shrink: 0;
298
+ }
299
+
300
+ .sc-custom-hint {
301
+ margin: 5px 0 0;
302
+ color: #94a3b8;
303
+ font-size: 12px;
304
+ line-height: 1.6;
305
+
306
+ code {
307
+ padding: 1px 4px;
308
+ border-radius: 3px;
309
+ background: #f1f5f9;
310
+ color: #475569;
311
+ font-size: 11px;
312
+ }
313
+ }
314
+
315
+ .sc-custom-headers {
316
+ display: flex;
317
+ flex-direction: column;
318
+ gap: 7px;
319
+ width: 100%;
320
+ margin-bottom: 4px;
321
+ }
322
+
323
+ .sc-custom-header-row {
324
+ display: flex;
325
+ align-items: center;
326
+ gap: 6px;
327
+
328
+ .el-input:first-child {
329
+ width: 38%;
330
+ flex-shrink: 0;
331
+ }
332
+ }
333
+
334
+ .sc-custom-unit {
335
+ margin-left: 8px;
336
+ color: #94a3b8;
337
+ font-size: 12px;
338
+ }
339
+ </style>