gbflowengine 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +270 -2
- package/dist/gbflowengine.css +1 -0
- package/dist/gbflowengine.js +19682 -0
- package/dist/gbflowengine.js.map +1 -0
- package/dist/gbflowengine.umd.cjs +5 -0
- package/dist/gbflowengine.umd.cjs.map +1 -0
- package/package.json +83 -4
- package/src/center/DefinitionInspect.vue +291 -0
- package/src/center/FlowCenter.vue +33 -0
- package/src/center/index.js +29 -0
- package/src/center/storage.js +748 -0
- package/src/core/flow/condition.js +160 -0
- package/src/core/flow/customNode.js +385 -0
- package/src/core/flow/defaults.js +124 -0
- package/src/core/flow/flowConstant.js +265 -0
- package/src/core/flow/flowNodeUtils.js +30 -0
- package/src/core/flow/index.js +47 -0
- package/src/core/flow/node.js +44 -0
- package/src/core/flow/nodeFactory.js +58 -0
- package/src/core/flow/prediction.js +325 -0
- package/src/core/flow/runtime/auto.js +83 -0
- package/src/core/flow/runtime/decide.js +329 -0
- package/src/core/flow/runtime/event.js +28 -0
- package/src/core/flow/runtime/execute.js +357 -0
- package/src/core/flow/runtime/helpers.js +52 -0
- package/src/core/flow/runtime/query.js +146 -0
- package/src/core/flow/runtime/reject.js +137 -0
- package/src/core/flow/runtime/token.js +269 -0
- package/src/core/flow/runtime.js +129 -0
- package/src/core/flow/schema.js +864 -0
- package/src/definition/FlowDefinitionDesigner.vue +338 -0
- package/src/definition/index.js +9 -0
- package/src/index.js +39 -0
- package/src/storage.js +200 -0
- package/src/testing/FlowTestPanel.vue +2502 -0
- package/src/testing/UserConfigDrawer.vue +376 -0
- package/src/testing/diagram/FlowProgressDiagram.vue +318 -0
- package/src/testing/diagramModel.js +517 -0
- package/src/testing/index.js +23 -0
- package/src/testing/mock.js +246 -0
- package/src/testing/oaExecutors.js +51 -0
- package/src/testing/oaSeed.js +467 -0
- package/src/testing/sample.js +412 -0
- package/src/testing/seed.js +122 -0
- package/src/utils/format.js +27 -0
- package/src/visual/FlowCanvas.vue +441 -0
- package/src/visual/NodeProgressDetail.vue +43 -0
- package/src/visual/NodeStatusBadge.vue +17 -0
- package/src/visual/NodeWrap.vue +47 -0
- package/src/visual/ScWorkflow.vue +50 -0
- package/src/visual/SelectDialog.vue +460 -0
- package/src/visual/conditionHelpers.js +117 -0
- package/src/visual/index.js +6 -0
- package/src/visual/nodes/AddNode.vue +223 -0
- package/src/visual/nodes/ApproverNode.vue +348 -0
- package/src/visual/nodes/BranchNode.vue +442 -0
- package/src/visual/nodes/CustomNode.vue +339 -0
- package/src/visual/nodes/EndNode.vue +22 -0
- package/src/visual/nodes/PassNode.vue +101 -0
- package/src/visual/nodes/PromoterNode.vue +135 -0
- package/src/visual/nodes/RejectNode.vue +101 -0
- package/src/visual/nodes/SendNode.vue +152 -0
- package/src/visual/styles.scss +879 -0
- package/src/visual/useScNodeStatus.js +18 -0
- package/src/workbench/OaWorkbench.vue +1341 -0
- package/src/workbench/components/ApprovalWorkspace.vue +2090 -0
- package/src/workbench/components/CategoryIcon.vue +74 -0
- package/src/workbench/components/NotificationIcon.vue +73 -0
- package/src/workbench/components/ProcessSteps.vue +557 -0
- package/src/workbench/components/ResubmitDialog.vue +227 -0
- package/src/workbench/components/SidebarNav.vue +138 -0
- package/src/workbench/components/StartFlowDialog.vue +1058 -0
- package/src/workbench/components/UserAvatar.vue +68 -0
- package/src/workbench/custom-tasks.js +130 -0
- package/src/workbench/model.js +1080 -0
- package/src/workbench/pages/DesignPage.vue +798 -0
- package/src/workbench/pages/HomePage.vue +1050 -0
- package/src/workbench/pages/MonitorPage.vue +1029 -0
- package/src/workbench/pages/NotificationsPage.vue +554 -0
- package/src/workbench/pages/RequestsPage.vue +644 -0
- package/src/workbench/pages/TaskCenterPage.vue +1155 -0
- package/src/workbench/pages/TemplatesPage.vue +680 -0
- package/src/workbench/persistence.js +89 -0
- package/src/workbench/shared.js +18 -0
- package/src/workbench/styles.scss +555 -0
- package/src/workbench/useWorkbench.js +955 -0
- package/types/center.d.ts +5 -0
- package/types/core.d.ts +479 -0
- package/types/definition.d.ts +4 -0
- package/types/index.d.ts +34 -0
- package/types/testing.d.ts +20 -0
- package/types/visual.d.ts +20 -0
|
@@ -0,0 +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 '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>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="end-node" :class="statusClass">
|
|
3
|
+
<div class="end-node-circle"></div>
|
|
4
|
+
<div class="end-node-text">{{ nodeConfig.nodeName || '流程结束' }}</div>
|
|
5
|
+
<NodeStatusBadge :status="statusInfo" />
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import { computed } from 'vue'
|
|
11
|
+
import NodeStatusBadge from '../NodeStatusBadge.vue'
|
|
12
|
+
import { useScNodeStatus } from '../useScNodeStatus.js'
|
|
13
|
+
|
|
14
|
+
defineOptions({ name: 'ScEndNode' })
|
|
15
|
+
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
modelValue: { type: Object, required: true }
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const nodeConfig = computed(() => props.modelValue)
|
|
21
|
+
const { statusInfo, statusClass } = useScNodeStatus(nodeConfig)
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="node-wrap">
|
|
3
|
+
<div class="node-wrap-box" :class="statusClass" @click="show">
|
|
4
|
+
<div class="title" style="background: #1bc47d">
|
|
5
|
+
<el-icon class="icon"><Select /></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 class="content">
|
|
11
|
+
<span>到达此节点后流程直接通过</span>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<AddNode v-model="nodeConfig.childNode" :parent-node="nodeConfig" :readonly="isReadonly" @update:model-value="updateChild" />
|
|
15
|
+
<el-drawer title="直接通过" v-model="drawer" destroy-on-close append-to-body :size="500">
|
|
16
|
+
<template #header>
|
|
17
|
+
<div class="node-wrap-drawer__title">
|
|
18
|
+
<label v-if="!isEditTitle" @click="editTitle">
|
|
19
|
+
{{ form.nodeName }}
|
|
20
|
+
<el-icon class="node-wrap-drawer__title-edit"><Edit /></el-icon>
|
|
21
|
+
</label>
|
|
22
|
+
<el-input v-if="isEditTitle" ref="nodeTitle" v-model="form.nodeName" clearable @blur="saveTitle" @keyup.enter="saveTitle" />
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
<el-container>
|
|
26
|
+
<el-main style="padding: 0 20px 20px 20px">
|
|
27
|
+
<el-form label-position="top">
|
|
28
|
+
<el-form-item label="节点说明">
|
|
29
|
+
<el-alert title="流程执行到此节点时直接结束并标记为通过,常用于条件分支中的绿色通道。" type="success" :closable="false" />
|
|
30
|
+
</el-form-item>
|
|
31
|
+
</el-form>
|
|
32
|
+
</el-main>
|
|
33
|
+
<el-footer>
|
|
34
|
+
<el-button type="primary" @click="save">保存</el-button>
|
|
35
|
+
<el-button @click="drawer = false">取消</el-button>
|
|
36
|
+
</el-footer>
|
|
37
|
+
</el-container>
|
|
38
|
+
</el-drawer>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script setup>
|
|
43
|
+
import { computed, inject, ref } from 'vue'
|
|
44
|
+
import { Close, Edit, Select } from 'gbicons'
|
|
45
|
+
import AddNode from './AddNode.vue'
|
|
46
|
+
import NodeStatusBadge from '../NodeStatusBadge.vue'
|
|
47
|
+
import { useScNodeStatus } from '../useScNodeStatus.js'
|
|
48
|
+
|
|
49
|
+
defineOptions({ name: 'ScPassNode' })
|
|
50
|
+
|
|
51
|
+
const props = defineProps({
|
|
52
|
+
modelValue: { type: Object, required: true },
|
|
53
|
+
parentNode: { type: Object, default: null }
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const emit = defineEmits(['update:modelValue'])
|
|
57
|
+
|
|
58
|
+
const readonly = inject('scReadonly', ref(false))
|
|
59
|
+
const isReadonly = computed(() => readonly.value === true)
|
|
60
|
+
const nodeConfig = computed(() => props.modelValue)
|
|
61
|
+
const { statusInfo, statusClass } = useScNodeStatus(nodeConfig)
|
|
62
|
+
|
|
63
|
+
const drawer = ref(false)
|
|
64
|
+
const isEditTitle = ref(false)
|
|
65
|
+
const nodeTitle = ref(null)
|
|
66
|
+
const form = ref({})
|
|
67
|
+
|
|
68
|
+
const updateChild = (child) => {
|
|
69
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
70
|
+
next.childNode = child
|
|
71
|
+
emit('update:modelValue', next)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const show = () => {
|
|
75
|
+
if (isReadonly.value) return
|
|
76
|
+
form.value = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
77
|
+
isEditTitle.value = false
|
|
78
|
+
drawer.value = true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const editTitle = () => {
|
|
82
|
+
isEditTitle.value = true
|
|
83
|
+
requestAnimationFrame(() => nodeTitle.value?.focus())
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const saveTitle = () => {
|
|
87
|
+
isEditTitle.value = false
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const save = () => {
|
|
91
|
+
const source = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
92
|
+
source.nodeName = form.value.nodeName
|
|
93
|
+
emit('update:modelValue', source)
|
|
94
|
+
drawer.value = false
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const delNode = () => {
|
|
98
|
+
if (isReadonly.value) return
|
|
99
|
+
emit('update:modelValue', nodeConfig.value.childNode)
|
|
100
|
+
}
|
|
101
|
+
</script>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="node-wrap">
|
|
3
|
+
<div class="node-wrap-box start-node" :class="statusClass" @click="show">
|
|
4
|
+
<div class="title" style="background: #576a95">
|
|
5
|
+
<el-icon class="icon"><UserFilled /></el-icon>
|
|
6
|
+
<span>{{ nodeConfig.nodeName }}</span>
|
|
7
|
+
<NodeStatusBadge :status="statusInfo" />
|
|
8
|
+
</div>
|
|
9
|
+
<div class="content">
|
|
10
|
+
<span>{{ toText(nodeConfig) }}</span>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<AddNode v-model="nodeConfig.childNode" :parent-node="nodeConfig" :readonly="isReadonly" @update:model-value="updateChild" />
|
|
14
|
+
<el-drawer title="发起人" v-model="drawer" destroy-on-close append-to-body :size="500">
|
|
15
|
+
<template #header>
|
|
16
|
+
<div class="node-wrap-drawer__title">
|
|
17
|
+
<label v-if="!isEditTitle" @click="editTitle">
|
|
18
|
+
{{ form.nodeName }}
|
|
19
|
+
<el-icon class="node-wrap-drawer__title-edit"><Edit /></el-icon>
|
|
20
|
+
</label>
|
|
21
|
+
<el-input v-if="isEditTitle" ref="nodeTitle" v-model="form.nodeName" clearable @blur="saveTitle" @keyup.enter="saveTitle" />
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
<el-container>
|
|
25
|
+
<el-main style="padding: 0 20px 20px 20px">
|
|
26
|
+
<el-form label-position="top">
|
|
27
|
+
<el-form-item label="谁可以发起此审批">
|
|
28
|
+
<el-button type="primary" :icon="Plus" round @click="selectHandle(2, roleProxy)">选择角色</el-button>
|
|
29
|
+
<div class="tags-list">
|
|
30
|
+
<el-tag v-for="(role, index) in form.roleList" :key="role.id" type="info" closable @close="delRole(index)">
|
|
31
|
+
{{ role.name }}
|
|
32
|
+
</el-tag>
|
|
33
|
+
</div>
|
|
34
|
+
</el-form-item>
|
|
35
|
+
<el-alert v-if="!form.roleList || form.roleList.length == 0" title="不指定则默认所有人都可发起此审批" type="info" :closable="false" />
|
|
36
|
+
</el-form>
|
|
37
|
+
</el-main>
|
|
38
|
+
<el-footer>
|
|
39
|
+
<el-button type="primary" @click="save">保存</el-button>
|
|
40
|
+
<el-button @click="drawer = false">取消</el-button>
|
|
41
|
+
</el-footer>
|
|
42
|
+
</el-container>
|
|
43
|
+
</el-drawer>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script setup>
|
|
48
|
+
import { computed, inject, ref } from 'vue'
|
|
49
|
+
import { Edit, Plus, UserFilled } from 'gbicons'
|
|
50
|
+
import AddNode from './AddNode.vue'
|
|
51
|
+
import NodeStatusBadge from '../NodeStatusBadge.vue'
|
|
52
|
+
import { useScNodeStatus } from '../useScNodeStatus.js'
|
|
53
|
+
|
|
54
|
+
defineOptions({ name: 'ScPromoterNode' })
|
|
55
|
+
|
|
56
|
+
const props = defineProps({
|
|
57
|
+
modelValue: { type: Object, required: true }
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const emit = defineEmits(['update:modelValue'])
|
|
61
|
+
|
|
62
|
+
const select = inject('select', null)
|
|
63
|
+
const readonly = inject('scReadonly', ref(false))
|
|
64
|
+
|
|
65
|
+
const isReadonly = computed(() => readonly.value === true)
|
|
66
|
+
const nodeConfig = computed(() => props.modelValue)
|
|
67
|
+
const { statusInfo, statusClass } = useScNodeStatus(nodeConfig)
|
|
68
|
+
|
|
69
|
+
const drawer = ref(false)
|
|
70
|
+
const isEditTitle = ref(false)
|
|
71
|
+
const nodeTitle = ref(null)
|
|
72
|
+
const form = ref({})
|
|
73
|
+
|
|
74
|
+
const roleProxy = computed({
|
|
75
|
+
get: () => (form.value.roleList || []).map((role) => ({ id: role.id, name: role.roleName || role.name })),
|
|
76
|
+
set: () => {}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const updateChild = (child) => {
|
|
80
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
81
|
+
next.childNode = child
|
|
82
|
+
emit('update:modelValue', next)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const show = () => {
|
|
86
|
+
if (isReadonly.value) return
|
|
87
|
+
const source = nodeConfig.value
|
|
88
|
+
form.value = {
|
|
89
|
+
...JSON.parse(JSON.stringify(source)),
|
|
90
|
+
roleList: (source.roleList || []).map((id) => ({
|
|
91
|
+
id,
|
|
92
|
+
name: source.roleNameMap?.[id] || `角色${id}`
|
|
93
|
+
}))
|
|
94
|
+
}
|
|
95
|
+
isEditTitle.value = false
|
|
96
|
+
drawer.value = true
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const editTitle = () => {
|
|
100
|
+
isEditTitle.value = true
|
|
101
|
+
requestAnimationFrame(() => nodeTitle.value?.focus())
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const saveTitle = () => {
|
|
105
|
+
isEditTitle.value = false
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const selectHandle = (type, data) => {
|
|
109
|
+
select?.(type, data)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const delRole = (index) => {
|
|
113
|
+
form.value.roleList.splice(index, 1)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const save = () => {
|
|
117
|
+
const source = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
118
|
+
const list = form.value.roleList || []
|
|
119
|
+
source.nodeName = form.value.nodeName
|
|
120
|
+
source.roleList = list.map((role) => role.id)
|
|
121
|
+
source.roleNameMap = list.reduce((result, role) => {
|
|
122
|
+
result[role.id] = role.name
|
|
123
|
+
return result
|
|
124
|
+
}, {})
|
|
125
|
+
emit('update:modelValue', source)
|
|
126
|
+
drawer.value = false
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const toText = (node) => {
|
|
130
|
+
if (node.roleList && node.roleList.length > 0) {
|
|
131
|
+
return node.roleList.map((id) => node.roleNameMap?.[id] || `角色${id}`).join('、')
|
|
132
|
+
}
|
|
133
|
+
return '所有人'
|
|
134
|
+
}
|
|
135
|
+
</script>
|