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.
- package/README.md +271 -271
- package/dist/gbflowengine.css +1 -1
- package/dist/gbflowengine.js +8232 -6913
- package/dist/gbflowengine.js.map +1 -1
- package/dist/gbflowengine.umd.cjs +2 -2
- package/dist/gbflowengine.umd.cjs.map +1 -1
- package/package.json +85 -84
- package/src/center/DefinitionInspect.vue +291 -291
- package/src/center/FlowCenter.vue +33 -33
- package/src/center/index.js +29 -29
- package/src/center/storage.js +748 -748
- package/src/core/flow/condition.js +160 -160
- package/src/core/flow/customNode.js +385 -385
- package/src/core/flow/defaults.js +124 -124
- package/src/core/flow/flowConstant.js +265 -265
- package/src/core/flow/flowNodeUtils.js +29 -29
- package/src/core/flow/index.js +47 -47
- package/src/core/flow/node.js +44 -44
- package/src/core/flow/nodeFactory.js +58 -58
- package/src/core/flow/prediction.js +325 -325
- package/src/core/flow/schema.js +864 -864
- package/src/definition/FlowDefinitionDesigner.vue +338 -338
- package/src/definition/index.js +9 -9
- package/src/index.js +39 -39
- package/src/storage.js +200 -200
- package/src/testing/FlowTestPanel.vue +2502 -2502
- package/src/testing/UserConfigDrawer.vue +376 -376
- package/src/testing/diagram/FlowProgressDiagram.vue +318 -318
- package/src/testing/diagramModel.js +517 -517
- package/src/testing/index.js +23 -23
- package/src/testing/mock.js +246 -246
- package/src/testing/oaExecutors.js +51 -51
- package/src/testing/oaSeed.js +467 -467
- package/src/testing/sample.js +412 -412
- package/src/testing/seed.js +122 -122
- package/src/utils/format.js +27 -27
- package/src/visual/FlowCanvas.vue +440 -440
- package/src/visual/NodeProgressDetail.vue +43 -43
- package/src/visual/NodeStatusBadge.vue +17 -17
- package/src/visual/NodeWrap.vue +46 -46
- package/src/visual/ScWorkflow.vue +49 -49
- package/src/visual/SelectDialog.vue +459 -459
- package/src/visual/conditionHelpers.js +116 -116
- package/src/visual/index.js +6 -6
- package/src/visual/nodes/AddNode.vue +222 -222
- package/src/visual/nodes/ApproverNode.vue +347 -347
- package/src/visual/nodes/BranchNode.vue +441 -441
- package/src/visual/nodes/CustomNode.vue +339 -339
- package/src/visual/nodes/EndNode.vue +21 -21
- package/src/visual/nodes/PassNode.vue +100 -100
- package/src/visual/nodes/PromoterNode.vue +134 -134
- package/src/visual/nodes/RejectNode.vue +100 -100
- package/src/visual/nodes/SendNode.vue +151 -151
- package/src/visual/styles.scss +879 -879
- package/src/visual/useScNodeStatus.js +18 -18
- package/src/workbench/OaWorkbench.vue +1341 -1341
- package/src/workbench/components/ApprovalWorkspace.vue +2090 -2090
- package/src/workbench/components/CategoryIcon.vue +74 -74
- package/src/workbench/components/NotificationIcon.vue +73 -73
- package/src/workbench/components/ProcessSteps.vue +557 -557
- package/src/workbench/components/ResubmitDialog.vue +227 -227
- package/src/workbench/components/SidebarNav.vue +138 -138
- package/src/workbench/components/StartFlowDialog.vue +1058 -1058
- package/src/workbench/components/UserAvatar.vue +68 -68
- package/src/workbench/model.js +1080 -1080
- package/src/workbench/pages/DesignPage.vue +798 -798
- package/src/workbench/pages/HomePage.vue +1050 -1050
- package/src/workbench/pages/MonitorPage.vue +1029 -1029
- package/src/workbench/pages/NotificationsPage.vue +554 -554
- package/src/workbench/pages/RequestsPage.vue +644 -644
- package/src/workbench/pages/TaskCenterPage.vue +1155 -1155
- package/src/workbench/pages/TemplatesPage.vue +680 -680
- package/src/workbench/styles.scss +555 -555
- package/types/center.d.ts +5 -5
- package/types/core.d.ts +479 -479
- package/types/definition.d.ts +4 -4
- package/types/index.d.ts +34 -34
- package/types/testing.d.ts +20 -20
- package/types/visual.d.ts +20 -20
|
@@ -1,2502 +1,2502 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flow-workbench">
|
|
3
|
-
<aside v-if="showInstanceList" class="flow-workbench__sidebar">
|
|
4
|
-
<div class="wb-panel wb-panel--list">
|
|
5
|
-
<div class="wb-panel__head">
|
|
6
|
-
<div>
|
|
7
|
-
<h3>流程实例</h3>
|
|
8
|
-
<span>{{ instances.length }} 个流程实例</span>
|
|
9
|
-
</div>
|
|
10
|
-
<div class="wb-instance-tools">
|
|
11
|
-
<el-tooltip content="导出实例" placement="top">
|
|
12
|
-
<el-button link :icon="Download" @click="exportInstances" />
|
|
13
|
-
</el-tooltip>
|
|
14
|
-
<el-tooltip content="导入实例" placement="top">
|
|
15
|
-
<el-button link :icon="Upload" @click="triggerInstanceImport" />
|
|
16
|
-
</el-tooltip>
|
|
17
|
-
<el-button type="primary" size="small" :icon="Plus" @click="openCreate">
|
|
18
|
-
发起流程
|
|
19
|
-
</el-button>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<div class="wb-filters">
|
|
24
|
-
<button
|
|
25
|
-
v-for="filter in FILTERS"
|
|
26
|
-
:key="filter.value"
|
|
27
|
-
type="button"
|
|
28
|
-
class="wb-filter"
|
|
29
|
-
:class="{ 'is-active': statusFilter === filter.value }"
|
|
30
|
-
@click="statusFilter = filter.value"
|
|
31
|
-
>
|
|
32
|
-
{{ filter.label }}
|
|
33
|
-
<span>{{ filterCount(filter.value) }}</span>
|
|
34
|
-
</button>
|
|
35
|
-
</div>
|
|
36
|
-
|
|
37
|
-
<div class="wb-instance-list">
|
|
38
|
-
<div
|
|
39
|
-
v-for="instance in filteredInstances"
|
|
40
|
-
:key="instance.id"
|
|
41
|
-
class="wb-instance"
|
|
42
|
-
:class="{ 'is-active': instance.id === activeId }"
|
|
43
|
-
@click="selectInstance(instance.id)"
|
|
44
|
-
>
|
|
45
|
-
<div class="wb-instance__top">
|
|
46
|
-
<span class="wb-instance__name">{{ instance.name }}</span>
|
|
47
|
-
<el-tag size="small" :type="statusMetaOf(instance).type">
|
|
48
|
-
{{ statusMetaOf(instance).label }}
|
|
49
|
-
</el-tag>
|
|
50
|
-
</div>
|
|
51
|
-
<div class="wb-instance__meta">
|
|
52
|
-
<span>{{ instance.initiator?.name || '未知发起人' }}</span>
|
|
53
|
-
<span>{{ formatDateTime(instance.createdAt) }}</span>
|
|
54
|
-
</div>
|
|
55
|
-
<div class="wb-instance__node">当前节点:{{ currentNodeText(instance) }}</div>
|
|
56
|
-
<div class="wb-instance__foot">
|
|
57
|
-
<span v-if="pendingCountForInstance(instance)" class="wb-instance__pending">
|
|
58
|
-
我的待办 {{ pendingCountForInstance(instance) }}
|
|
59
|
-
</span>
|
|
60
|
-
<span v-else class="wb-instance__progress">{{ instanceProgress(instance) }}</span>
|
|
61
|
-
<el-button
|
|
62
|
-
link
|
|
63
|
-
type="danger"
|
|
64
|
-
:icon="Delete"
|
|
65
|
-
class="wb-instance__delete"
|
|
66
|
-
@click.stop="removeInstance(instance)"
|
|
67
|
-
/>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
|
|
71
|
-
<el-empty
|
|
72
|
-
v-if="!filteredInstances.length"
|
|
73
|
-
:description="instances.length ? '当前筛选下没有实例' : '还没有流程实例,点击「发起流程」开始'"
|
|
74
|
-
:image-size="64"
|
|
75
|
-
/>
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<div class="wb-panel__foot">流程实例保存在本机浏览器</div>
|
|
79
|
-
</div>
|
|
80
|
-
</aside>
|
|
81
|
-
|
|
82
|
-
<main class="flow-workbench__main">
|
|
83
|
-
<div v-if="activeInstance" class="wb-panel wb-panel--detail">
|
|
84
|
-
<div class="wb-detail__head">
|
|
85
|
-
<div class="wb-detail__title">
|
|
86
|
-
<h2>{{ activeInstance.name }}</h2>
|
|
87
|
-
<el-tag :type="activeStatusMeta.type" size="small">
|
|
88
|
-
{{ activeStatusMeta.label }}
|
|
89
|
-
</el-tag>
|
|
90
|
-
<el-tag v-if="activeState?.cycle > 1" size="small" type="warning" effect="plain">
|
|
91
|
-
第 {{ activeState.cycle }} 轮
|
|
92
|
-
</el-tag>
|
|
93
|
-
<el-tag
|
|
94
|
-
v-if="activeInstance.definitionVersion"
|
|
95
|
-
size="small"
|
|
96
|
-
type="info"
|
|
97
|
-
effect="plain"
|
|
98
|
-
>
|
|
99
|
-
v{{ activeInstance.definitionVersion }}
|
|
100
|
-
</el-tag>
|
|
101
|
-
<span class="wb-detail__time">{{ formatDateTime(activeInstance.createdAt) }}</span>
|
|
102
|
-
</div>
|
|
103
|
-
<div class="wb-detail__meta">
|
|
104
|
-
发起人:{{ activeInstance.initiator?.name || '未知' }}
|
|
105
|
-
<template v-if="activeInstance.initiator?.deptName">
|
|
106
|
-
· {{ activeInstance.initiator.deptName }}
|
|
107
|
-
</template>
|
|
108
|
-
<span class="wb-dot">·</span>
|
|
109
|
-
{{ currentNodeText(activeInstance) }}
|
|
110
|
-
</div>
|
|
111
|
-
<div class="wb-detail__actions">
|
|
112
|
-
<el-button
|
|
113
|
-
v-if="isActiveRunning"
|
|
114
|
-
size="small"
|
|
115
|
-
:icon="VideoPlay"
|
|
116
|
-
:loading="autoRunning"
|
|
117
|
-
@click="autoRun"
|
|
118
|
-
>
|
|
119
|
-
自动推进
|
|
120
|
-
</el-button>
|
|
121
|
-
<el-button v-if="canRevokeActive" size="small" plain @click="revokeActive">
|
|
122
|
-
撤回
|
|
123
|
-
</el-button>
|
|
124
|
-
<el-button v-if="isActiveRunning" size="small" type="danger" plain @click="stopActive">
|
|
125
|
-
管理员终止
|
|
126
|
-
</el-button>
|
|
127
|
-
</div>
|
|
128
|
-
</div>
|
|
129
|
-
|
|
130
|
-
<el-tabs v-model="activeTab" class="wb-detail__tabs">
|
|
131
|
-
<el-tab-pane label="流程图" name="chart">
|
|
132
|
-
<div class="wb-detail__chart">
|
|
133
|
-
<FlowProgressDiagram
|
|
134
|
-
:workflow="activeInstance.definition.workflow"
|
|
135
|
-
:state="activeState"
|
|
136
|
-
:prediction="activePrediction"
|
|
137
|
-
/>
|
|
138
|
-
</div>
|
|
139
|
-
</el-tab-pane>
|
|
140
|
-
|
|
141
|
-
<el-tab-pane label="表单" name="form">
|
|
142
|
-
<div class="wb-detail__scroll">
|
|
143
|
-
<div class="wb-info-bar">
|
|
144
|
-
<span>发起人</span>
|
|
145
|
-
<strong>{{ activeState?.initiator?.name || activeInstance.initiator?.name }}</strong>
|
|
146
|
-
<span class="wb-muted">{{ activeState?.initiator?.deptName || '' }}</span>
|
|
147
|
-
<span class="wb-info-bar__time">{{ formatDateTime(activeState?.startedAt) }}</span>
|
|
148
|
-
</div>
|
|
149
|
-
<el-descriptions v-if="activeVariables.length" :column="2" border size="small">
|
|
150
|
-
<el-descriptions-item
|
|
151
|
-
v-for="row in activeVariables"
|
|
152
|
-
:key="row.key"
|
|
153
|
-
:label="row.label"
|
|
154
|
-
>
|
|
155
|
-
{{ row.value }}
|
|
156
|
-
</el-descriptions-item>
|
|
157
|
-
</el-descriptions>
|
|
158
|
-
<el-empty v-else description="本流程未填写表单数据" :image-size="60" />
|
|
159
|
-
<el-collapse class="wb-snapshot">
|
|
160
|
-
<el-collapse-item title="表单变量 JSON" name="variables">
|
|
161
|
-
<pre>{{ JSON.stringify(activeState?.variables || {}, null, 2) }}</pre>
|
|
162
|
-
</el-collapse-item>
|
|
163
|
-
</el-collapse>
|
|
164
|
-
</div>
|
|
165
|
-
</el-tab-pane>
|
|
166
|
-
|
|
167
|
-
<el-tab-pane label="轨迹" name="trace">
|
|
168
|
-
<div class="wb-detail__scroll">
|
|
169
|
-
<el-timeline v-if="timeline.length" class="wb-timeline">
|
|
170
|
-
<el-timeline-item
|
|
171
|
-
v-for="event in timeline"
|
|
172
|
-
:key="event.id"
|
|
173
|
-
:timestamp="formatDateTime(event.at)"
|
|
174
|
-
:type="eventType(event)"
|
|
175
|
-
placement="top"
|
|
176
|
-
>
|
|
177
|
-
<div class="wb-event">
|
|
178
|
-
<el-tag
|
|
179
|
-
v-if="activeState?.cycle > 1 && event.cycle"
|
|
180
|
-
size="small"
|
|
181
|
-
type="info"
|
|
182
|
-
effect="plain"
|
|
183
|
-
>
|
|
184
|
-
第 {{ event.cycle }} 轮
|
|
185
|
-
</el-tag>
|
|
186
|
-
{{ eventTitle(event) }}
|
|
187
|
-
</div>
|
|
188
|
-
<div v-if="eventMeta(event)" class="wb-event__meta">{{ eventMeta(event) }}</div>
|
|
189
|
-
</el-timeline-item>
|
|
190
|
-
</el-timeline>
|
|
191
|
-
<el-empty v-else description="暂无流程记录" :image-size="60" />
|
|
192
|
-
|
|
193
|
-
<div v-if="activeState?.ccRecords?.length" class="wb-trace-block">
|
|
194
|
-
<h4>抄送记录</h4>
|
|
195
|
-
<div v-for="record in activeState.ccRecords" :key="record.id" class="wb-cc-row">
|
|
196
|
-
<span>{{ record.nodeName }}</span>
|
|
197
|
-
<el-tag
|
|
198
|
-
v-for="user in record.users"
|
|
199
|
-
:key="user.id"
|
|
200
|
-
size="small"
|
|
201
|
-
type="warning"
|
|
202
|
-
effect="plain"
|
|
203
|
-
>
|
|
204
|
-
{{ user.name }}
|
|
205
|
-
</el-tag>
|
|
206
|
-
</div>
|
|
207
|
-
</div>
|
|
208
|
-
|
|
209
|
-
<div v-if="activeState?.warnings?.length" class="wb-trace-block">
|
|
210
|
-
<h4>运行提醒</h4>
|
|
211
|
-
<el-alert
|
|
212
|
-
v-for="(warning, index) in activeState.warnings"
|
|
213
|
-
:key="`${warning.code}_${index}`"
|
|
214
|
-
:title="warning.message"
|
|
215
|
-
type="warning"
|
|
216
|
-
:closable="false"
|
|
217
|
-
show-icon
|
|
218
|
-
class="wb-alert"
|
|
219
|
-
/>
|
|
220
|
-
</div>
|
|
221
|
-
|
|
222
|
-
<el-collapse class="wb-snapshot">
|
|
223
|
-
<el-collapse-item title="运行快照 JSON" name="state">
|
|
224
|
-
<pre>{{ stateJSON }}</pre>
|
|
225
|
-
</el-collapse-item>
|
|
226
|
-
</el-collapse>
|
|
227
|
-
</div>
|
|
228
|
-
</el-tab-pane>
|
|
229
|
-
</el-tabs>
|
|
230
|
-
</div>
|
|
231
|
-
|
|
232
|
-
<div v-else class="wb-panel wb-panel--empty">
|
|
233
|
-
<el-empty description="选择左侧流程实例,或发起一个新的流程">
|
|
234
|
-
<el-button type="primary" :icon="Plus" @click="openCreate">发起流程</el-button>
|
|
235
|
-
</el-empty>
|
|
236
|
-
</div>
|
|
237
|
-
</main>
|
|
238
|
-
|
|
239
|
-
<aside class="flow-workbench__rail">
|
|
240
|
-
<div class="wb-panel wb-panel--users">
|
|
241
|
-
<div class="wb-panel__head">
|
|
242
|
-
<div>
|
|
243
|
-
<h3>用户</h3>
|
|
244
|
-
<span>点击切换当前操作人</span>
|
|
245
|
-
</div>
|
|
246
|
-
<el-button link type="primary" :icon="Setting" @click="emit('manage-users')">
|
|
247
|
-
用户管理
|
|
248
|
-
</el-button>
|
|
249
|
-
</div>
|
|
250
|
-
<div class="wb-user-list">
|
|
251
|
-
<button
|
|
252
|
-
v-for="user in org.users"
|
|
253
|
-
:key="user.id"
|
|
254
|
-
type="button"
|
|
255
|
-
class="wb-user"
|
|
256
|
-
:class="{ 'is-active': sameId(user.id, currentUserId) }"
|
|
257
|
-
@click="currentUserId = user.id"
|
|
258
|
-
>
|
|
259
|
-
<span class="wb-user__avatar">{{ (user.realName || '用').slice(0, 1) }}</span>
|
|
260
|
-
<span class="wb-user__main">
|
|
261
|
-
<span class="wb-user__name">
|
|
262
|
-
{{ user.realName }}
|
|
263
|
-
<span v-if="sameId(user.id, currentUserId)" class="wb-user__current">当前</span>
|
|
264
|
-
</span>
|
|
265
|
-
<span class="wb-user__meta">
|
|
266
|
-
{{ deptName(user.deptId) }} · {{ roleNamesOf(user) || user.title || '成员' }}
|
|
267
|
-
</span>
|
|
268
|
-
</span>
|
|
269
|
-
<span v-if="pendingCountForUser(user.id)" class="wb-user__badge">
|
|
270
|
-
{{ pendingCountForUser(user.id) }}
|
|
271
|
-
</span>
|
|
272
|
-
</button>
|
|
273
|
-
</div>
|
|
274
|
-
</div>
|
|
275
|
-
|
|
276
|
-
<div class="wb-panel wb-panel--tasks">
|
|
277
|
-
<div class="wb-panel__head">
|
|
278
|
-
<div>
|
|
279
|
-
<h3>我的待办</h3>
|
|
280
|
-
<span>{{ currentUser?.realName || '未选择' }} · {{ globalPendingItems.length }} 个</span>
|
|
281
|
-
</div>
|
|
282
|
-
</div>
|
|
283
|
-
|
|
284
|
-
<el-empty
|
|
285
|
-
v-if="!globalPendingItems.length"
|
|
286
|
-
:description="emptyTaskText"
|
|
287
|
-
:image-size="56"
|
|
288
|
-
/>
|
|
289
|
-
<article
|
|
290
|
-
v-for="item in globalPendingItems"
|
|
291
|
-
:key="`${item.instanceId}_${item.task.id}`"
|
|
292
|
-
class="wb-task"
|
|
293
|
-
>
|
|
294
|
-
<div class="wb-task__head">
|
|
295
|
-
<strong>{{ item.task.nodeName }}</strong>
|
|
296
|
-
<el-tag
|
|
297
|
-
size="small"
|
|
298
|
-
:type="item.task.kind === 'submit' ? 'warning' : 'info'"
|
|
299
|
-
>
|
|
300
|
-
{{ item.task.kind === 'submit' ? '待重新提交' : signLabelOf(item.task) }}
|
|
301
|
-
</el-tag>
|
|
302
|
-
</div>
|
|
303
|
-
<button
|
|
304
|
-
type="button"
|
|
305
|
-
class="wb-task__instance"
|
|
306
|
-
@click="selectInstance(item.instanceId)"
|
|
307
|
-
>
|
|
308
|
-
{{ item.instanceName }}
|
|
309
|
-
</button>
|
|
310
|
-
<div v-if="item.task.kind !== 'submit'" class="wb-task__progress">
|
|
311
|
-
已同意 {{ item.task.approvedBy.length }} / {{ item.task.approvers.length }}
|
|
312
|
-
</div>
|
|
313
|
-
<div class="wb-task__approvers">
|
|
314
|
-
<el-tag
|
|
315
|
-
v-for="approver in item.task.approvers"
|
|
316
|
-
:key="approver.id"
|
|
317
|
-
size="small"
|
|
318
|
-
:type="hasApproved(item.task, approver) ? 'success' : 'primary'"
|
|
319
|
-
effect="plain"
|
|
320
|
-
>
|
|
321
|
-
{{ approver.name }}{{ hasApproved(item.task, approver) ? ' ✓' : '' }}
|
|
322
|
-
</el-tag>
|
|
323
|
-
</div>
|
|
324
|
-
<div v-if="item.task.dueAt" class="wb-task__deadline">
|
|
325
|
-
超时时间 {{ formatDateTime(item.task.dueAt) }} ·
|
|
326
|
-
{{ item.task.termMode === 1 ? '自动拒绝' : '自动通过' }}
|
|
327
|
-
</div>
|
|
328
|
-
<div v-if="lastComment(item.task)" class="wb-task__comment">
|
|
329
|
-
“{{ lastComment(item.task) }}”
|
|
330
|
-
</div>
|
|
331
|
-
<div
|
|
332
|
-
v-if="item.task.kind !== 'submit' && rejectPolicySummary(item.task)"
|
|
333
|
-
class="wb-task__policy"
|
|
334
|
-
>
|
|
335
|
-
{{ rejectPolicySummary(item.task) }}
|
|
336
|
-
</div>
|
|
337
|
-
<div class="wb-task__actions">
|
|
338
|
-
<template v-if="item.task.kind === 'submit'">
|
|
339
|
-
<el-button
|
|
340
|
-
type="primary"
|
|
341
|
-
size="small"
|
|
342
|
-
@click="openGlobalTask(item, 'resubmit')"
|
|
343
|
-
>
|
|
344
|
-
重新提交
|
|
345
|
-
</el-button>
|
|
346
|
-
</template>
|
|
347
|
-
<template v-else>
|
|
348
|
-
<el-button type="success" size="small" @click="openGlobalTask(item, 'approve')">
|
|
349
|
-
同意
|
|
350
|
-
</el-button>
|
|
351
|
-
<el-button type="danger" plain size="small" @click="openGlobalTask(item, 'reject')">
|
|
352
|
-
拒绝
|
|
353
|
-
</el-button>
|
|
354
|
-
<el-button
|
|
355
|
-
v-if="canTransfer(item.task)"
|
|
356
|
-
plain
|
|
357
|
-
size="small"
|
|
358
|
-
@click="openGlobalTask(item, 'transfer')"
|
|
359
|
-
>
|
|
360
|
-
转交
|
|
361
|
-
</el-button>
|
|
362
|
-
</template>
|
|
363
|
-
</div>
|
|
364
|
-
</article>
|
|
365
|
-
|
|
366
|
-
<div v-if="globalCcItems.length" class="wb-cc-list">
|
|
367
|
-
<h4>我的抄送</h4>
|
|
368
|
-
<div
|
|
369
|
-
v-for="item in globalCcItems"
|
|
370
|
-
:key="`${item.instanceId}_${item.record.id}`"
|
|
371
|
-
class="wb-cc-row"
|
|
372
|
-
>
|
|
373
|
-
<button
|
|
374
|
-
type="button"
|
|
375
|
-
class="wb-task__instance"
|
|
376
|
-
@click="selectInstance(item.instanceId)"
|
|
377
|
-
>
|
|
378
|
-
{{ item.instanceName }}
|
|
379
|
-
</button>
|
|
380
|
-
<span>{{ item.record.nodeName }}</span>
|
|
381
|
-
<el-tag
|
|
382
|
-
v-for="user in item.record.users"
|
|
383
|
-
:key="user.id"
|
|
384
|
-
size="small"
|
|
385
|
-
type="warning"
|
|
386
|
-
effect="plain"
|
|
387
|
-
>
|
|
388
|
-
{{ user.name }}
|
|
389
|
-
</el-tag>
|
|
390
|
-
</div>
|
|
391
|
-
</div>
|
|
392
|
-
</div>
|
|
393
|
-
</aside>
|
|
394
|
-
|
|
395
|
-
<el-dialog
|
|
396
|
-
v-model="createVisible"
|
|
397
|
-
title="发起流程"
|
|
398
|
-
width="1120px"
|
|
399
|
-
append-to-body
|
|
400
|
-
destroy-on-close
|
|
401
|
-
class="wb-create-dialog"
|
|
402
|
-
>
|
|
403
|
-
<el-tabs v-model="createTab" class="wb-create__tabs">
|
|
404
|
-
<el-tab-pane label="填写表单" name="form">
|
|
405
|
-
<div class="wb-create">
|
|
406
|
-
<div class="wb-create__form">
|
|
407
|
-
<FormViewer
|
|
408
|
-
ref="createFormRef"
|
|
409
|
-
:form-config="createDefinition?.form?.components || []"
|
|
410
|
-
/>
|
|
411
|
-
</div>
|
|
412
|
-
<aside class="wb-create__side">
|
|
413
|
-
<div class="wb-create__field">
|
|
414
|
-
<label>流程定义</label>
|
|
415
|
-
<el-select
|
|
416
|
-
v-model="createDefinitionId"
|
|
417
|
-
filterable
|
|
418
|
-
@change="handleCreateDefinitionChange"
|
|
419
|
-
>
|
|
420
|
-
<el-option
|
|
421
|
-
v-for="item in availableDefinitions"
|
|
422
|
-
:key="item.meta?.id"
|
|
423
|
-
:label="item.meta?.name || '未命名流程'"
|
|
424
|
-
:value="item.meta?.id"
|
|
425
|
-
/>
|
|
426
|
-
</el-select>
|
|
427
|
-
</div>
|
|
428
|
-
|
|
429
|
-
<div class="wb-create__field">
|
|
430
|
-
<label>发起人</label>
|
|
431
|
-
<el-select v-model="createInitiatorId" filterable>
|
|
432
|
-
<el-option
|
|
433
|
-
v-for="user in org.users"
|
|
434
|
-
:key="user.id"
|
|
435
|
-
:label="`${user.realName} · ${deptName(user.deptId)}`"
|
|
436
|
-
:value="user.id"
|
|
437
|
-
/>
|
|
438
|
-
</el-select>
|
|
439
|
-
</div>
|
|
440
|
-
|
|
441
|
-
<div v-if="createCcNodes.length" class="wb-create__cc">
|
|
442
|
-
<h4>发起人自选抄送</h4>
|
|
443
|
-
<div v-for="node in createCcNodes" :key="node.nodeId" class="wb-create__cc-row">
|
|
444
|
-
<span>{{ node.nodeName }}</span>
|
|
445
|
-
<el-select
|
|
446
|
-
v-model="createCcSelections[node.nodeId]"
|
|
447
|
-
multiple
|
|
448
|
-
collapse-tags
|
|
449
|
-
collapse-tags-tooltip
|
|
450
|
-
clearable
|
|
451
|
-
placeholder="不额外抄送"
|
|
452
|
-
>
|
|
453
|
-
<el-option
|
|
454
|
-
v-for="user in org.users"
|
|
455
|
-
:key="user.id"
|
|
456
|
-
:label="`${user.realName} · ${deptName(user.deptId)}`"
|
|
457
|
-
:value="user.id"
|
|
458
|
-
/>
|
|
459
|
-
</el-select>
|
|
460
|
-
</div>
|
|
461
|
-
</div>
|
|
462
|
-
|
|
463
|
-
<el-alert
|
|
464
|
-
type="info"
|
|
465
|
-
:closable="false"
|
|
466
|
-
show-icon
|
|
467
|
-
title="发起后将在本机创建流程实例,可在左侧流程列表中处理待办。"
|
|
468
|
-
/>
|
|
469
|
-
</aside>
|
|
470
|
-
</div>
|
|
471
|
-
</el-tab-pane>
|
|
472
|
-
|
|
473
|
-
<el-tab-pane label="流程图预测" name="prediction">
|
|
474
|
-
<div class="wb-create__preview">
|
|
475
|
-
<div class="wb-create__preview-head">
|
|
476
|
-
<span>基于当前表单数据和测试组织预测,不会创建实例</span>
|
|
477
|
-
<el-button size="small" :icon="DataAnalysis" @click="refreshCreatePrediction">
|
|
478
|
-
刷新预测
|
|
479
|
-
</el-button>
|
|
480
|
-
</div>
|
|
481
|
-
<div v-if="createPrediction" class="wb-create__preview-chart">
|
|
482
|
-
<FlowProgressDiagram
|
|
483
|
-
:workflow="createDefinition?.workflow"
|
|
484
|
-
:prediction="createPrediction"
|
|
485
|
-
/>
|
|
486
|
-
</div>
|
|
487
|
-
<el-empty v-else description="点击「刷新预测」生成流程图" :image-size="60" />
|
|
488
|
-
</div>
|
|
489
|
-
</el-tab-pane>
|
|
490
|
-
</el-tabs>
|
|
491
|
-
|
|
492
|
-
<template #footer>
|
|
493
|
-
<div class="wb-create__footer">
|
|
494
|
-
<span class="wb-muted">审批人按用户与角色配置解析</span>
|
|
495
|
-
<el-button @click="createVisible = false">取消</el-button>
|
|
496
|
-
<el-button :icon="DataAnalysis" :loading="predicting" @click="previewCreate">
|
|
497
|
-
预测流程图
|
|
498
|
-
</el-button>
|
|
499
|
-
<el-button type="primary" :icon="VideoPlay" :loading="startingNew" @click="startNewTest">
|
|
500
|
-
发起流程
|
|
501
|
-
</el-button>
|
|
502
|
-
</div>
|
|
503
|
-
</template>
|
|
504
|
-
</el-dialog>
|
|
505
|
-
|
|
506
|
-
<el-dialog
|
|
507
|
-
v-model="action.visible"
|
|
508
|
-
:title="actionTitle"
|
|
509
|
-
:width="action.type === 'resubmit' ? '920px' : '480px'"
|
|
510
|
-
append-to-body
|
|
511
|
-
destroy-on-close
|
|
512
|
-
@opened="handleActionOpened"
|
|
513
|
-
>
|
|
514
|
-
<div v-if="action.task" class="wb-dialog-task">
|
|
515
|
-
<span>节点</span>
|
|
516
|
-
<strong>{{ action.task.nodeName }}</strong>
|
|
517
|
-
<span class="wb-muted">当前身份:{{ currentUser?.realName }}</span>
|
|
518
|
-
</div>
|
|
519
|
-
<div v-if="action.type === 'resubmit'" class="wb-resubmit">
|
|
520
|
-
<el-alert
|
|
521
|
-
type="warning"
|
|
522
|
-
:closable="false"
|
|
523
|
-
show-icon
|
|
524
|
-
title="流程已退回,请修改表单后重新提交"
|
|
525
|
-
class="wb-resubmit__tip"
|
|
526
|
-
/>
|
|
527
|
-
<FormViewer ref="resubmitFormRef" :form-config="resubmitFormConfig" />
|
|
528
|
-
</div>
|
|
529
|
-
<el-form v-else label-width="84px">
|
|
530
|
-
<el-form-item v-if="action.type === 'transfer'" label="转交给">
|
|
531
|
-
<el-select v-model="action.targetUserId" filterable placeholder="选择目标用户" style="width: 100%">
|
|
532
|
-
<el-option
|
|
533
|
-
v-for="user in transferCandidates"
|
|
534
|
-
:key="user.id"
|
|
535
|
-
:label="`${user.realName} · ${deptName(user.deptId)}`"
|
|
536
|
-
:value="user.id"
|
|
537
|
-
/>
|
|
538
|
-
</el-select>
|
|
539
|
-
</el-form-item>
|
|
540
|
-
<el-form-item label="审批意见">
|
|
541
|
-
<el-input
|
|
542
|
-
v-model="action.comment"
|
|
543
|
-
type="textarea"
|
|
544
|
-
:rows="3"
|
|
545
|
-
:placeholder="action.type === 'reject' ? '请输入拒绝原因(可选)' : '请输入意见(可选)'"
|
|
546
|
-
/>
|
|
547
|
-
</el-form-item>
|
|
548
|
-
</el-form>
|
|
549
|
-
<el-alert
|
|
550
|
-
v-if="action.type === 'reject'"
|
|
551
|
-
:type="actionRejectInfo?.wouldTerminate ? 'error' : 'warning'"
|
|
552
|
-
:closable="false"
|
|
553
|
-
show-icon
|
|
554
|
-
:title="`拒绝后处理:${actionRejectInfo?.strategy === 'terminate' ? '直接结束,不通过审批' : rejectStrategyOf(action.task)}`"
|
|
555
|
-
:description="rejectImpactText"
|
|
556
|
-
/>
|
|
557
|
-
<template #footer>
|
|
558
|
-
<el-button @click="action.visible = false">取消</el-button>
|
|
559
|
-
<el-button
|
|
560
|
-
:type="action.type === 'reject' ? 'danger' : 'primary'"
|
|
561
|
-
:loading="action.submitting"
|
|
562
|
-
:disabled="action.type === 'transfer' && !action.targetUserId"
|
|
563
|
-
@click="confirmAction"
|
|
564
|
-
>
|
|
565
|
-
确认{{ actionTitle }}
|
|
566
|
-
</el-button>
|
|
567
|
-
</template>
|
|
568
|
-
</el-dialog>
|
|
569
|
-
|
|
570
|
-
<input
|
|
571
|
-
ref="instanceFileInput"
|
|
572
|
-
type="file"
|
|
573
|
-
accept="application/json,.json"
|
|
574
|
-
class="wb-hidden-input"
|
|
575
|
-
@change="handleInstanceImportFile"
|
|
576
|
-
/>
|
|
577
|
-
</div>
|
|
578
|
-
</template>
|
|
579
|
-
|
|
580
|
-
<script setup>
|
|
581
|
-
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, shallowRef, watch } from 'vue'
|
|
582
|
-
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
583
|
-
import {
|
|
584
|
-
DataAnalysis,
|
|
585
|
-
Delete,
|
|
586
|
-
Download,
|
|
587
|
-
Plus,
|
|
588
|
-
Setting,
|
|
589
|
-
Upload,
|
|
590
|
-
VideoPlay
|
|
591
|
-
} from '
|
|
592
|
-
import { FormViewer, enrichFormVariables } from 'gbformdesign'
|
|
593
|
-
import FlowProgressDiagram from './diagram/FlowProgressDiagram.vue'
|
|
594
|
-
import {
|
|
595
|
-
createMockRuntimeContext,
|
|
596
|
-
mockDepartments,
|
|
597
|
-
mockRoles,
|
|
598
|
-
mockUsers
|
|
599
|
-
} from './mock.js'
|
|
600
|
-
import { createFlowRuntime } from '../core/flow/runtime.js'
|
|
601
|
-
import { predictWorkflow } from '../core/flow/prediction.js'
|
|
602
|
-
import { findNodeById } from '../core/flow/node.js'
|
|
603
|
-
import { downloadJSON } from '../core/flow/index.js'
|
|
604
|
-
import { flowStorage } from '../storage.js'
|
|
605
|
-
import { formatDateTime, formatFieldValue } from '../utils/format.js'
|
|
606
|
-
import {
|
|
607
|
-
FlowNodeType,
|
|
608
|
-
RejectStrategyLabel,
|
|
609
|
-
SignModeLabel
|
|
610
|
-
} from '../core/flow/flowConstant.js'
|
|
611
|
-
|
|
612
|
-
defineOptions({ name: 'GbFlowTestPanel' })
|
|
613
|
-
|
|
614
|
-
const props = defineProps({
|
|
615
|
-
definition: { type: Object, default: null },
|
|
616
|
-
definitions: { type: Array, default: () => [] },
|
|
617
|
-
users: { type: Array, default: () => mockUsers },
|
|
618
|
-
departments: { type: Array, default: () => mockDepartments },
|
|
619
|
-
roles: { type: Array, default: () => mockRoles },
|
|
620
|
-
initiatorId: { type: [String, Number], default: null },
|
|
621
|
-
// 首次进入(本机尚无存档)时预置的实例,便于演示与联调直接看到列表
|
|
622
|
-
initialInstances: { type: Array, default: () => [] },
|
|
623
|
-
// 外层(如流程中心)自己渲染实例列表时置 false,避免出现两个列表
|
|
624
|
-
showInstanceList: { type: Boolean, default: true }
|
|
625
|
-
})
|
|
626
|
-
|
|
627
|
-
const emit = defineEmits(['manage-users', 'instances-change', 'operator-change'])
|
|
628
|
-
|
|
629
|
-
const STORAGE_KEY = 'gb-flowengine-workbench-v1'
|
|
630
|
-
const clone = (value) => JSON.parse(JSON.stringify(value))
|
|
631
|
-
const sameId = (left, right) =>
|
|
632
|
-
left !== undefined && right !== undefined && String(left) === String(right)
|
|
633
|
-
const nowIso = () => new Date().toISOString()
|
|
634
|
-
|
|
635
|
-
const STATUS_META = {
|
|
636
|
-
idle: { label: '未开始', type: 'info' },
|
|
637
|
-
running: { label: '运行中', type: 'warning' },
|
|
638
|
-
completed: { label: '已完成', type: 'success' },
|
|
639
|
-
rejected: { label: '已拒绝', type: 'danger' },
|
|
640
|
-
cancelled: { label: '已取消', type: 'info' },
|
|
641
|
-
revoked: { label: '已撤回', type: 'info' }
|
|
642
|
-
}
|
|
643
|
-
const FILTERS = [
|
|
644
|
-
{ value: 'all', label: '全部' },
|
|
645
|
-
{ value: 'running', label: '进行中' },
|
|
646
|
-
{ value: 'completed', label: '已完成' },
|
|
647
|
-
{ value: 'rejected', label: '已拒绝' },
|
|
648
|
-
{ value: 'revoked', label: '已撤回' }
|
|
649
|
-
]
|
|
650
|
-
const TIMELINE_EVENTS = new Set([
|
|
651
|
-
'start',
|
|
652
|
-
'approve',
|
|
653
|
-
'reject',
|
|
654
|
-
'transfer',
|
|
655
|
-
'cc',
|
|
656
|
-
'branch',
|
|
657
|
-
'split',
|
|
658
|
-
'join',
|
|
659
|
-
'autoApprove',
|
|
660
|
-
'return',
|
|
661
|
-
'resubmit',
|
|
662
|
-
'pass',
|
|
663
|
-
'rejectNode',
|
|
664
|
-
'rejectLimitReached',
|
|
665
|
-
'cancel',
|
|
666
|
-
'revoke',
|
|
667
|
-
'timeoutApprove',
|
|
668
|
-
'timeoutReject',
|
|
669
|
-
'finished'
|
|
670
|
-
])
|
|
671
|
-
|
|
672
|
-
const org = reactive({
|
|
673
|
-
users: clone(props.users),
|
|
674
|
-
departments: clone(props.departments),
|
|
675
|
-
roles: clone(props.roles)
|
|
676
|
-
})
|
|
677
|
-
|
|
678
|
-
const instances = ref([])
|
|
679
|
-
const activeId = ref(null)
|
|
680
|
-
|
|
681
|
-
// 外层流程中心需要渲染自己的实例列表,这里把实例变化同步出去
|
|
682
|
-
watch(instances, (value) => emit('instances-change', clone(value)), { deep: true, immediate: true })
|
|
683
|
-
const activeTab = ref('chart')
|
|
684
|
-
const statusFilter = ref('all')
|
|
685
|
-
const currentUserId = ref(props.initiatorId ?? props.users[0]?.id ?? null)
|
|
686
|
-
const initiatorId = ref(currentUserId.value)
|
|
687
|
-
const runtime = shallowRef(null)
|
|
688
|
-
const activeState = ref(null)
|
|
689
|
-
const autoRunning = ref(false)
|
|
690
|
-
const action = reactive({
|
|
691
|
-
visible: false,
|
|
692
|
-
type: 'approve',
|
|
693
|
-
task: null,
|
|
694
|
-
taskInstanceId: null,
|
|
695
|
-
comment: '',
|
|
696
|
-
targetUserId: null,
|
|
697
|
-
resubmitData: null,
|
|
698
|
-
submitting: false
|
|
699
|
-
})
|
|
700
|
-
const resubmitFormRef = ref(null)
|
|
701
|
-
const instanceFileInput = ref(null)
|
|
702
|
-
let deadlineTimer = null
|
|
703
|
-
|
|
704
|
-
const createVisible = ref(false)
|
|
705
|
-
const createTab = ref('form')
|
|
706
|
-
const createDefinitionId = ref(null)
|
|
707
|
-
const createInitiatorId = ref(currentUserId.value)
|
|
708
|
-
const createFormRef = ref(null)
|
|
709
|
-
const createCcSelections = ref({})
|
|
710
|
-
const createPrediction = ref(null)
|
|
711
|
-
const startingNew = ref(false)
|
|
712
|
-
const predicting = ref(false)
|
|
713
|
-
|
|
714
|
-
let storageReady = false
|
|
715
|
-
let persistTimer = null
|
|
716
|
-
|
|
717
|
-
const availableDefinitions = computed(() => {
|
|
718
|
-
const list = props.definitions?.length
|
|
719
|
-
? props.definitions
|
|
720
|
-
: props.definition
|
|
721
|
-
? [props.definition]
|
|
722
|
-
: []
|
|
723
|
-
return list.filter(
|
|
724
|
-
(item) => !item?.meta?.status || item.meta.status === 'published'
|
|
725
|
-
)
|
|
726
|
-
})
|
|
727
|
-
const createDefinition = computed(
|
|
728
|
-
() =>
|
|
729
|
-
availableDefinitions.value.find(
|
|
730
|
-
(item) => String(item.meta?.id) === String(createDefinitionId.value)
|
|
731
|
-
) ||
|
|
732
|
-
availableDefinitions.value[0] ||
|
|
733
|
-
null
|
|
734
|
-
)
|
|
735
|
-
|
|
736
|
-
const userIndex = computed(() => new Map(org.users.map((user) => [String(user.id), user])))
|
|
737
|
-
const deptIndex = computed(
|
|
738
|
-
() => new Map(org.departments.map((dept) => [String(dept.id), dept]))
|
|
739
|
-
)
|
|
740
|
-
const roleIndex = computed(
|
|
741
|
-
() => new Map(org.roles.map((role) => [String(role.id), role]))
|
|
742
|
-
)
|
|
743
|
-
const currentUser = computed(() => userIndex.value.get(String(currentUserId.value)) || null)
|
|
744
|
-
const activeInstance = computed(
|
|
745
|
-
() => instances.value.find((instance) => instance.id === activeId.value) || null
|
|
746
|
-
)
|
|
747
|
-
const activeStatusMeta = computed(
|
|
748
|
-
() => STATUS_META[activeState.value?.status] || STATUS_META.idle
|
|
749
|
-
)
|
|
750
|
-
const isActiveRunning = computed(() => activeState.value?.status === 'running')
|
|
751
|
-
const stateJSON = computed(() => JSON.stringify(activeState.value || {}, null, 2))
|
|
752
|
-
|
|
753
|
-
const filteredInstances = computed(() => {
|
|
754
|
-
if (statusFilter.value === 'all') return instances.value
|
|
755
|
-
return instances.value.filter((instance) => instance.state?.status === statusFilter.value)
|
|
756
|
-
})
|
|
757
|
-
|
|
758
|
-
const activePrediction = computed(() => {
|
|
759
|
-
const instance = activeInstance.value
|
|
760
|
-
if (!instance) return null
|
|
761
|
-
try {
|
|
762
|
-
return predictWorkflow({
|
|
763
|
-
definition: instance.definition,
|
|
764
|
-
data: instance.state?.variables || {},
|
|
765
|
-
context: contextForInstance(instance),
|
|
766
|
-
initiator: instance.state?.initiator || instance.initiator
|
|
767
|
-
})
|
|
768
|
-
} catch {
|
|
769
|
-
return null
|
|
770
|
-
}
|
|
771
|
-
})
|
|
772
|
-
|
|
773
|
-
const globalPendingItems = computed(() => {
|
|
774
|
-
const items = []
|
|
775
|
-
instances.value.forEach((instance) => {
|
|
776
|
-
pendingTasksFor(instance.state, currentUserId.value).forEach((task) => {
|
|
777
|
-
items.push({
|
|
778
|
-
instanceId: instance.id,
|
|
779
|
-
instanceName: instance.name,
|
|
780
|
-
task
|
|
781
|
-
})
|
|
782
|
-
})
|
|
783
|
-
})
|
|
784
|
-
return items.sort((left, right) =>
|
|
785
|
-
String(right.task.createdAt).localeCompare(String(left.task.createdAt))
|
|
786
|
-
)
|
|
787
|
-
})
|
|
788
|
-
|
|
789
|
-
const globalCcItems = computed(() => {
|
|
790
|
-
const items = []
|
|
791
|
-
instances.value.forEach((instance) => {
|
|
792
|
-
const state = instance.state
|
|
793
|
-
const currentCycle = state?.cycle || 1
|
|
794
|
-
const lastReturnAt = (state?.history || [])
|
|
795
|
-
.filter((event) => event.event === 'return')
|
|
796
|
-
.map((event) => event.at)
|
|
797
|
-
.sort()
|
|
798
|
-
.at(-1)
|
|
799
|
-
;(state?.ccRecords || []).forEach((record) => {
|
|
800
|
-
const inCycle = record.cycle
|
|
801
|
-
? Number(record.cycle) === currentCycle
|
|
802
|
-
: !lastReturnAt || String(record.createdAt || '') >= String(lastReturnAt)
|
|
803
|
-
if (
|
|
804
|
-
inCycle &&
|
|
805
|
-
(record.users || []).some((user) => sameId(user.id, currentUserId.value))
|
|
806
|
-
) {
|
|
807
|
-
items.push({ instanceId: instance.id, instanceName: instance.name, record })
|
|
808
|
-
}
|
|
809
|
-
})
|
|
810
|
-
})
|
|
811
|
-
return items.sort((left, right) =>
|
|
812
|
-
String(right.record.createdAt).localeCompare(String(left.record.createdAt))
|
|
813
|
-
)
|
|
814
|
-
})
|
|
815
|
-
|
|
816
|
-
const canRevokeActive = computed(
|
|
817
|
-
() =>
|
|
818
|
-
activeState.value?.status === 'running' &&
|
|
819
|
-
sameId(activeState.value?.initiator?.id, currentUserId.value)
|
|
820
|
-
)
|
|
821
|
-
|
|
822
|
-
const resubmitFormConfig = computed(
|
|
823
|
-
() => activeInstance.value?.definition?.form?.components || []
|
|
824
|
-
)
|
|
825
|
-
|
|
826
|
-
const emptyTaskText = computed(() => {
|
|
827
|
-
if (!currentUser.value) return '请选择当前操作人'
|
|
828
|
-
return '当前身份在所有流程里都没有待办'
|
|
829
|
-
})
|
|
830
|
-
|
|
831
|
-
const activeVariables = computed(() => {
|
|
832
|
-
const components = activeInstance.value?.definition?.form?.components || []
|
|
833
|
-
const variableMap = new Map(
|
|
834
|
-
enrichFormVariables(components).map((item) => [item.variableName, item])
|
|
835
|
-
)
|
|
836
|
-
const variables = activeState.value?.variables || {}
|
|
837
|
-
return Object.entries(variables)
|
|
838
|
-
.filter(([key]) => variableMap.size === 0 || variableMap.has(key))
|
|
839
|
-
.map(([key, value]) => ({
|
|
840
|
-
key,
|
|
841
|
-
label: variableMap.get(key)?.label || key,
|
|
842
|
-
value: formatFieldValue(value)
|
|
843
|
-
}))
|
|
844
|
-
})
|
|
845
|
-
|
|
846
|
-
const timeline = computed(() =>
|
|
847
|
-
[...(activeState.value?.history || [])]
|
|
848
|
-
.filter((event) => TIMELINE_EVENTS.has(event.event))
|
|
849
|
-
.slice(-100)
|
|
850
|
-
.reverse()
|
|
851
|
-
)
|
|
852
|
-
|
|
853
|
-
const transferCandidates = computed(() =>
|
|
854
|
-
org.users.filter(
|
|
855
|
-
(user) =>
|
|
856
|
-
!action.task?.approvers.some((approver) => sameId(approver.id, user.id)) &&
|
|
857
|
-
!sameId(user.id, currentUserId.value)
|
|
858
|
-
)
|
|
859
|
-
)
|
|
860
|
-
|
|
861
|
-
const actionTitle = computed(
|
|
862
|
-
() =>
|
|
863
|
-
({ approve: '同意', reject: '拒绝', transfer: '转交', resubmit: '重新提交' })[
|
|
864
|
-
action.type
|
|
865
|
-
] || '审批'
|
|
866
|
-
)
|
|
867
|
-
|
|
868
|
-
const actionRejectInfo = computed(() => {
|
|
869
|
-
if (action.type !== 'reject' || !action.task || !runtime.value) return null
|
|
870
|
-
try {
|
|
871
|
-
return runtime.value.getRejectInfo(action.task.nodeId)
|
|
872
|
-
} catch {
|
|
873
|
-
return null
|
|
874
|
-
}
|
|
875
|
-
})
|
|
876
|
-
|
|
877
|
-
const rejectImpactText = computed(() => {
|
|
878
|
-
const info = actionRejectInfo.value
|
|
879
|
-
if (!info) return '拒绝后将按节点配置处理。'
|
|
880
|
-
if (info.strategy === 'terminate') {
|
|
881
|
-
return '本次拒绝后流程直接结束,判定为不通过审批。'
|
|
882
|
-
}
|
|
883
|
-
if (info.unlimited) {
|
|
884
|
-
return '退回后流程进入下一轮重新审批;当前节点设置为不限退回次数。'
|
|
885
|
-
}
|
|
886
|
-
if (info.remaining <= 0) {
|
|
887
|
-
return `已退回 ${info.retriesUsed} 次,达到允许上限(${info.retryLimit} 次)。本次拒绝将直接终止流程,判定为不通过审批。`
|
|
888
|
-
}
|
|
889
|
-
return `已退回 ${info.retriesUsed} 次,允许 ${info.retryLimit} 次;本次退回后还可再退 ${info.remaining - 1} 次。超过上限后流程将自动不通过。`
|
|
890
|
-
})
|
|
891
|
-
|
|
892
|
-
function rejectPolicySummary(task) {
|
|
893
|
-
if (!task || !runtime.value) return ''
|
|
894
|
-
try {
|
|
895
|
-
const info = runtime.value.getRejectInfo(task.nodeId)
|
|
896
|
-
if (!info) return ''
|
|
897
|
-
if (info.strategy === 'terminate') return '拒绝即结束 · 不通过审批'
|
|
898
|
-
const target = RejectStrategyLabel[info.strategy] || '退回'
|
|
899
|
-
if (info.unlimited) return `${target} · 不限退回次数`
|
|
900
|
-
if (info.remaining <= 0) return `${target} · 已达退回上限,再拒绝将不通过`
|
|
901
|
-
return `${target} · 已退回 ${info.retriesUsed}/${info.retryLimit} 次`
|
|
902
|
-
} catch {
|
|
903
|
-
return ''
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
const createCcNodes = computed(() => {
|
|
908
|
-
const nodes = []
|
|
909
|
-
const visit = (node) => {
|
|
910
|
-
if (!node) return
|
|
911
|
-
if (node.type === FlowNodeType.CC && node.allowInitiatorAddUsers !== false) {
|
|
912
|
-
nodes.push({ nodeId: node.nodeId, nodeName: node.nodeName })
|
|
913
|
-
}
|
|
914
|
-
if (node.childNode) visit(node.childNode)
|
|
915
|
-
node.branchList?.forEach(visit)
|
|
916
|
-
}
|
|
917
|
-
visit(createDefinition.value?.workflow)
|
|
918
|
-
return nodes
|
|
919
|
-
})
|
|
920
|
-
|
|
921
|
-
function deptName(deptId) {
|
|
922
|
-
return deptIndex.value.get(String(deptId))?.name || '未分配部门'
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
function roleNamesOf(user) {
|
|
926
|
-
return (user.roleIds || [])
|
|
927
|
-
.map((roleId) => roleIndex.value.get(String(roleId))?.roleName)
|
|
928
|
-
.filter(Boolean)
|
|
929
|
-
.join(' / ')
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
function userById(userId) {
|
|
933
|
-
return userIndex.value.get(String(userId)) || null
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
function normalizeUser(user) {
|
|
937
|
-
return user
|
|
938
|
-
? {
|
|
939
|
-
id: user.id,
|
|
940
|
-
name: user.realName || user.name || String(user.id),
|
|
941
|
-
deptName: user.deptName || deptName(user.deptId) || ''
|
|
942
|
-
}
|
|
943
|
-
: null
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
function statusMetaOf(instance) {
|
|
947
|
-
return STATUS_META[instance.state?.status] || STATUS_META.idle
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
function filterCount(value) {
|
|
951
|
-
if (value === 'all') return instances.value.length
|
|
952
|
-
return instances.value.filter((instance) => instance.state?.status === value).length
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
function pendingTasksFor(state, userId) {
|
|
956
|
-
return (state?.tasks || []).filter(
|
|
957
|
-
(task) =>
|
|
958
|
-
task.status === 'pending' &&
|
|
959
|
-
task.approvers.some((approver) => sameId(approver.id, userId)) &&
|
|
960
|
-
!(task.approvedBy || []).some((approver) => sameId(approver.id, userId))
|
|
961
|
-
)
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
function pendingCountForInstance(instance) {
|
|
965
|
-
return pendingTasksFor(instance.state, currentUserId.value).length
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
function pendingCountForUser(userId) {
|
|
969
|
-
return instances.value.reduce(
|
|
970
|
-
(total, instance) => total + pendingTasksFor(instance.state, userId).length,
|
|
971
|
-
0
|
|
972
|
-
)
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
function instanceProgress(instance) {
|
|
976
|
-
const tasks = instance.state?.tasks || []
|
|
977
|
-
if (!tasks.length) return statusMetaOf(instance).label
|
|
978
|
-
const approved = tasks.filter((task) => task.status === 'approved').length
|
|
979
|
-
return `审批完成 ${approved}/${tasks.length}`
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
function nodeNameIn(instance, nodeId) {
|
|
983
|
-
return findNodeById(instance.definition.workflow, nodeId)?.nodeName || ''
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
function currentNodeText(instance) {
|
|
987
|
-
const state = instance.state
|
|
988
|
-
if (!state) return '未开始'
|
|
989
|
-
const pending = (state.tasks || []).filter((task) => task.status === 'pending')
|
|
990
|
-
const names = [
|
|
991
|
-
...new Set(pending.map((task) => nodeNameIn(instance, task.nodeId)).filter(Boolean))
|
|
992
|
-
]
|
|
993
|
-
if (names.length) return names.join('、')
|
|
994
|
-
if (state.status === 'running') return '处理中'
|
|
995
|
-
return STATUS_META[state.status]?.label || state.status
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
function extraCcUserObjects(selections) {
|
|
999
|
-
const result = {}
|
|
1000
|
-
Object.entries(selections || {}).forEach(([nodeId, ids]) => {
|
|
1001
|
-
const users = (ids || []).map((id) => userById(id)).filter(Boolean)
|
|
1002
|
-
if (users.length) result[nodeId] = users
|
|
1003
|
-
})
|
|
1004
|
-
return result
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
function contextForInstance(instance) {
|
|
1008
|
-
return createMockRuntimeContext({
|
|
1009
|
-
initiatorId: instance.state?.initiator?.id ?? instance.initiatorId,
|
|
1010
|
-
users: org.users,
|
|
1011
|
-
departments: org.departments,
|
|
1012
|
-
roles: org.roles,
|
|
1013
|
-
extraCcUsers: extraCcUserObjects(instance.extraCcUsers)
|
|
1014
|
-
})
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
function makeContext(initiator, extraSelections) {
|
|
1018
|
-
return createMockRuntimeContext({
|
|
1019
|
-
initiatorId: initiator.id,
|
|
1020
|
-
users: org.users,
|
|
1021
|
-
departments: org.departments,
|
|
1022
|
-
roles: org.roles,
|
|
1023
|
-
extraCcUsers: extraCcUserObjects(extraSelections)
|
|
1024
|
-
})
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
function activateInstance() {
|
|
1028
|
-
const instance = activeInstance.value
|
|
1029
|
-
if (!instance) {
|
|
1030
|
-
runtime.value = null
|
|
1031
|
-
activeState.value = null
|
|
1032
|
-
return
|
|
1033
|
-
}
|
|
1034
|
-
try {
|
|
1035
|
-
runtime.value = createFlowRuntime({
|
|
1036
|
-
workflow: instance.definition.workflow,
|
|
1037
|
-
state: instance.state,
|
|
1038
|
-
context: contextForInstance(instance)
|
|
1039
|
-
})
|
|
1040
|
-
// Catch up on deadlines missed while the tab was closed or another
|
|
1041
|
-
// instance was active.
|
|
1042
|
-
activeState.value = runtime.value.tick()
|
|
1043
|
-
instance.state = activeState.value
|
|
1044
|
-
} catch (error) {
|
|
1045
|
-
runtime.value = null
|
|
1046
|
-
activeState.value = instance.state
|
|
1047
|
-
ElMessage.error(`恢复流程实例失败:${error.message}`)
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
function selectInstance(instanceId) {
|
|
1052
|
-
if (activeId.value === instanceId) return
|
|
1053
|
-
activeId.value = instanceId
|
|
1054
|
-
activeTab.value = 'chart'
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
function selectInstanceById(instanceId) {
|
|
1058
|
-
if (!instances.value.some((item) => item.id === instanceId)) return false
|
|
1059
|
-
activeId.value = instanceId
|
|
1060
|
-
activeTab.value = 'chart'
|
|
1061
|
-
if (!runtime.value) activateInstance()
|
|
1062
|
-
return true
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
function syncActiveState(state) {
|
|
1066
|
-
if (!activeInstance.value || !state) return
|
|
1067
|
-
activeInstance.value.state = state
|
|
1068
|
-
activeInstance.value.updatedAt = nowIso()
|
|
1069
|
-
activeState.value = state
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
function snapshotPayload() {
|
|
1073
|
-
return {
|
|
1074
|
-
instances: instances.value,
|
|
1075
|
-
currentUserId: currentUserId.value,
|
|
1076
|
-
initiatorId: initiatorId.value,
|
|
1077
|
-
activeId: activeId.value
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
function persist() {
|
|
1082
|
-
if (!storageReady) return
|
|
1083
|
-
if (persistTimer) clearTimeout(persistTimer)
|
|
1084
|
-
persistTimer = setTimeout(() => {
|
|
1085
|
-
persistTimer = null
|
|
1086
|
-
flowStorage.setJSON(STORAGE_KEY, snapshotPayload()).catch(() => {
|
|
1087
|
-
// Keep the test session usable when storage is unavailable.
|
|
1088
|
-
})
|
|
1089
|
-
}, 120)
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
async function flushPersist() {
|
|
1093
|
-
if (!storageReady) return
|
|
1094
|
-
if (persistTimer) {
|
|
1095
|
-
clearTimeout(persistTimer)
|
|
1096
|
-
persistTimer = null
|
|
1097
|
-
}
|
|
1098
|
-
try {
|
|
1099
|
-
await flowStorage.setJSON(STORAGE_KEY, snapshotPayload())
|
|
1100
|
-
} catch {
|
|
1101
|
-
// ignore storage failures on teardown
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
async function load() {
|
|
1106
|
-
try {
|
|
1107
|
-
const data = await flowStorage.getJSON(STORAGE_KEY)
|
|
1108
|
-
if (data) {
|
|
1109
|
-
if (Array.isArray(data.instances)) {
|
|
1110
|
-
instances.value = data.instances.filter(
|
|
1111
|
-
(instance) =>
|
|
1112
|
-
instance?.id &&
|
|
1113
|
-
instance?.definition?.workflow &&
|
|
1114
|
-
instance?.state?.tasks
|
|
1115
|
-
)
|
|
1116
|
-
}
|
|
1117
|
-
if (data.currentUserId != null && userById(data.currentUserId)) {
|
|
1118
|
-
currentUserId.value = data.currentUserId
|
|
1119
|
-
} else if (org.users.length) {
|
|
1120
|
-
currentUserId.value = org.users[0].id
|
|
1121
|
-
}
|
|
1122
|
-
if (data.initiatorId != null && userById(data.initiatorId)) {
|
|
1123
|
-
initiatorId.value = data.initiatorId
|
|
1124
|
-
}
|
|
1125
|
-
const storedActive = data.activeId
|
|
1126
|
-
activeId.value =
|
|
1127
|
-
storedActive && instances.value.some((instance) => instance.id === storedActive)
|
|
1128
|
-
? storedActive
|
|
1129
|
-
: instances.value[0]?.id ?? null
|
|
1130
|
-
} else if (props.initialInstances.length) {
|
|
1131
|
-
instances.value = clone(props.initialInstances).filter(
|
|
1132
|
-
(instance) =>
|
|
1133
|
-
instance?.id &&
|
|
1134
|
-
instance?.definition?.workflow &&
|
|
1135
|
-
instance?.state?.tasks
|
|
1136
|
-
)
|
|
1137
|
-
activeId.value = instances.value[0]?.id ?? null
|
|
1138
|
-
if (org.users.length) currentUserId.value = org.users[0].id
|
|
1139
|
-
}
|
|
1140
|
-
} catch {
|
|
1141
|
-
// Ignore corrupt storage and start clean.
|
|
1142
|
-
}
|
|
1143
|
-
storageReady = true
|
|
1144
|
-
activateInstance()
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
function openCreate(definitionId = null) {
|
|
1148
|
-
if (!availableDefinitions.value.length) {
|
|
1149
|
-
ElMessage.error('还没有可用的流程定义,请先在流程设计中创建')
|
|
1150
|
-
return false
|
|
1151
|
-
}
|
|
1152
|
-
const preferred =
|
|
1153
|
-
(definitionId &&
|
|
1154
|
-
availableDefinitions.value.find(
|
|
1155
|
-
(item) => String(item.meta?.id) === String(definitionId)
|
|
1156
|
-
)) ||
|
|
1157
|
-
createDefinition.value ||
|
|
1158
|
-
availableDefinitions.value[0]
|
|
1159
|
-
if (!preferred?.workflow) {
|
|
1160
|
-
ElMessage.error('所选流程缺少流程定义')
|
|
1161
|
-
return false
|
|
1162
|
-
}
|
|
1163
|
-
createDefinitionId.value = preferred.meta?.id
|
|
1164
|
-
createTab.value = 'form'
|
|
1165
|
-
createInitiatorId.value = currentUser.value?.id ?? org.users[0]?.id ?? null
|
|
1166
|
-
const selections = {}
|
|
1167
|
-
createCcNodes.value.forEach((node) => {
|
|
1168
|
-
selections[node.nodeId] = []
|
|
1169
|
-
})
|
|
1170
|
-
createCcSelections.value = selections
|
|
1171
|
-
createPrediction.value = null
|
|
1172
|
-
createVisible.value = true
|
|
1173
|
-
return true
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
function handleCreateDefinitionChange() {
|
|
1177
|
-
createPrediction.value = null
|
|
1178
|
-
const selections = {}
|
|
1179
|
-
createCcNodes.value.forEach((node) => {
|
|
1180
|
-
selections[node.nodeId] = []
|
|
1181
|
-
})
|
|
1182
|
-
createCcSelections.value = selections
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
function readCreateFormData() {
|
|
1186
|
-
return createFormRef.value?.formData ? clone(createFormRef.value.formData) : {}
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
async function validateCreateForm() {
|
|
1190
|
-
const elForm = createFormRef.value?.formRef
|
|
1191
|
-
if (elForm && typeof elForm.validate === 'function') {
|
|
1192
|
-
await elForm.validate()
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
function buildCreatePrediction() {
|
|
1197
|
-
const initiator = userById(createInitiatorId.value) || org.users[0]
|
|
1198
|
-
if (!initiator) throw new Error('没有可用的用户')
|
|
1199
|
-
const context = makeContext(initiator, createCcSelections.value)
|
|
1200
|
-
return predictWorkflow({
|
|
1201
|
-
definition: createDefinition.value,
|
|
1202
|
-
data: readCreateFormData(),
|
|
1203
|
-
context,
|
|
1204
|
-
initiator
|
|
1205
|
-
})
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
function refreshCreatePrediction() {
|
|
1209
|
-
if (!createDefinition.value?.workflow) {
|
|
1210
|
-
ElMessage.error('所选流程缺少流程定义')
|
|
1211
|
-
return
|
|
1212
|
-
}
|
|
1213
|
-
predicting.value = true
|
|
1214
|
-
try {
|
|
1215
|
-
createPrediction.value = buildCreatePrediction()
|
|
1216
|
-
createTab.value = 'prediction'
|
|
1217
|
-
} catch (error) {
|
|
1218
|
-
ElMessage.error(`流程预测失败:${error.message}`)
|
|
1219
|
-
} finally {
|
|
1220
|
-
predicting.value = false
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
function previewCreate() {
|
|
1225
|
-
refreshCreatePrediction()
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
function nextInstanceNumber() {
|
|
1229
|
-
return (
|
|
1230
|
-
instances.value.reduce((max, instance) => {
|
|
1231
|
-
const match = String(instance.name || '').match(/#(\d+)$/)
|
|
1232
|
-
return Math.max(max, Number(match?.[1]) || 0)
|
|
1233
|
-
}, 0) + 1
|
|
1234
|
-
)
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
async function startNewTest() {
|
|
1238
|
-
if (startingNew.value) return
|
|
1239
|
-
if (!createDefinition.value?.workflow) {
|
|
1240
|
-
ElMessage.error('所选流程缺少流程定义')
|
|
1241
|
-
return
|
|
1242
|
-
}
|
|
1243
|
-
if (!org.users.length) {
|
|
1244
|
-
ElMessage.error('没有可用的用户')
|
|
1245
|
-
return
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
startingNew.value = true
|
|
1249
|
-
createTab.value = 'form'
|
|
1250
|
-
try {
|
|
1251
|
-
try {
|
|
1252
|
-
await validateCreateForm()
|
|
1253
|
-
} catch {
|
|
1254
|
-
ElMessage.warning('请先完善表单必填项再发起流程')
|
|
1255
|
-
return
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
const initiator = userById(createInitiatorId.value) || org.users[0]
|
|
1259
|
-
const data = readCreateFormData()
|
|
1260
|
-
const context = makeContext(initiator, createCcSelections.value)
|
|
1261
|
-
const selectedDefinition = clone(createDefinition.value)
|
|
1262
|
-
// Instances keep an immutable snapshot of the published content, not the
|
|
1263
|
-
// full revision history; otherwise every instance would duplicate it.
|
|
1264
|
-
if (selectedDefinition.meta) delete selectedDefinition.meta.revisions
|
|
1265
|
-
const newRuntime = createFlowRuntime({
|
|
1266
|
-
workflow: selectedDefinition.workflow,
|
|
1267
|
-
context
|
|
1268
|
-
})
|
|
1269
|
-
const state = newRuntime.start(data, initiator)
|
|
1270
|
-
const extraSelections = {}
|
|
1271
|
-
Object.entries(createCcSelections.value).forEach(([nodeId, ids]) => {
|
|
1272
|
-
if (ids?.length) extraSelections[nodeId] = [...ids]
|
|
1273
|
-
})
|
|
1274
|
-
|
|
1275
|
-
const baseName = selectedDefinition.meta?.name || '流程'
|
|
1276
|
-
const instance = {
|
|
1277
|
-
id: `test_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`,
|
|
1278
|
-
name: `${baseName} #${String(nextInstanceNumber()).padStart(2, '0')}`,
|
|
1279
|
-
definition: selectedDefinition,
|
|
1280
|
-
definitionVersion: selectedDefinition.meta?.version || 1,
|
|
1281
|
-
initiatorId: initiator.id,
|
|
1282
|
-
initiator: normalizeUser(initiator),
|
|
1283
|
-
extraCcUsers: extraSelections,
|
|
1284
|
-
createdAt: nowIso(),
|
|
1285
|
-
updatedAt: nowIso(),
|
|
1286
|
-
state
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
instances.value.unshift(instance)
|
|
1290
|
-
statusFilter.value = 'all'
|
|
1291
|
-
activeId.value = instance.id
|
|
1292
|
-
runtime.value = newRuntime
|
|
1293
|
-
activeState.value = state
|
|
1294
|
-
activeTab.value = 'chart'
|
|
1295
|
-
currentUserId.value = initiator.id
|
|
1296
|
-
initiatorId.value = initiator.id
|
|
1297
|
-
createVisible.value = false
|
|
1298
|
-
const warning = state.warnings?.[0]
|
|
1299
|
-
if (warning) {
|
|
1300
|
-
ElMessage.warning(warning.message)
|
|
1301
|
-
} else {
|
|
1302
|
-
ElMessage.success(`流程已由 ${initiator.realName} 发起`)
|
|
1303
|
-
}
|
|
1304
|
-
} catch (error) {
|
|
1305
|
-
ElMessage.error(`发起失败:${error.message}`)
|
|
1306
|
-
} finally {
|
|
1307
|
-
startingNew.value = false
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
function nodeOf(task) {
|
|
1312
|
-
const workflow = activeInstance.value?.definition?.workflow
|
|
1313
|
-
return task && workflow ? findNodeById(workflow, task.nodeId) : null
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
function signLabelOf(task) {
|
|
1317
|
-
return SignModeLabel[task.signMode] || task.signMode || '并签'
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
function hasApproved(task, approver) {
|
|
1321
|
-
return (task.approvedBy || []).some((item) => sameId(item.id, approver.id))
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
function lastComment(task) {
|
|
1325
|
-
const records = [...(task.records || [])].reverse()
|
|
1326
|
-
return records.find((record) => record.comment)?.comment || ''
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
function canTransfer(task) {
|
|
1330
|
-
return nodeOf(task)?.allowTransfer !== false
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
function rejectStrategyOf(task) {
|
|
1334
|
-
return RejectStrategyLabel[nodeOf(task)?.rejectStrategy] || '终止流程'
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
function openAction(task, type) {
|
|
1338
|
-
action.visible = true
|
|
1339
|
-
action.type = task?.kind === 'submit' ? 'resubmit' : type
|
|
1340
|
-
action.task = task
|
|
1341
|
-
action.taskInstanceId = activeId.value
|
|
1342
|
-
action.comment = ''
|
|
1343
|
-
action.targetUserId = null
|
|
1344
|
-
action.resubmitData = task?.kind === 'submit' ? clone(activeState.value?.variables || {}) : null
|
|
1345
|
-
action.submitting = false
|
|
1346
|
-
if (action.type === 'resubmit') {
|
|
1347
|
-
nextTick(() => prefillResubmitForm())
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
function prefillResubmitForm(attempt = 0) {
|
|
1352
|
-
if (action.type !== 'resubmit' || !action.visible) return
|
|
1353
|
-
const viewer = resubmitFormRef.value
|
|
1354
|
-
if (!viewer?.formData) {
|
|
1355
|
-
if (attempt < 8) setTimeout(() => prefillResubmitForm(attempt + 1), 50)
|
|
1356
|
-
return
|
|
1357
|
-
}
|
|
1358
|
-
if (!action.resubmitData) return
|
|
1359
|
-
Object.keys(viewer.formData).forEach((key) => delete viewer.formData[key])
|
|
1360
|
-
Object.assign(viewer.formData, clone(action.resubmitData))
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
function handleActionOpened() {
|
|
1364
|
-
prefillResubmitForm()
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
function openGlobalTask(item, type = 'approve') {
|
|
1368
|
-
if (activeId.value !== item.instanceId) {
|
|
1369
|
-
activeId.value = item.instanceId
|
|
1370
|
-
activateInstance()
|
|
1371
|
-
}
|
|
1372
|
-
const task = (activeState.value?.tasks || []).find(
|
|
1373
|
-
(entry) => entry.id === item.task.id && entry.status === 'pending'
|
|
1374
|
-
)
|
|
1375
|
-
if (!task) {
|
|
1376
|
-
ElMessage.warning('该任务已被处理,已刷新实例')
|
|
1377
|
-
return
|
|
1378
|
-
}
|
|
1379
|
-
openAction(task, type)
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
async function confirmAction() {
|
|
1383
|
-
if (!runtime.value || !action.task) return
|
|
1384
|
-
if (action.taskInstanceId && action.taskInstanceId !== activeId.value) {
|
|
1385
|
-
ElMessage.warning('实例已切换,请重新打开任务')
|
|
1386
|
-
action.visible = false
|
|
1387
|
-
return
|
|
1388
|
-
}
|
|
1389
|
-
if (action.type === 'transfer' && !action.targetUserId) {
|
|
1390
|
-
ElMessage.warning('请选择转交目标用户')
|
|
1391
|
-
return
|
|
1392
|
-
}
|
|
1393
|
-
action.submitting = true
|
|
1394
|
-
const rejectSnapshot = action.type === 'reject' ? actionRejectInfo.value : null
|
|
1395
|
-
try {
|
|
1396
|
-
const targetUser = userById(action.targetUserId)
|
|
1397
|
-
let state
|
|
1398
|
-
if (action.type === 'approve') {
|
|
1399
|
-
state = runtime.value.approve(action.task.id, {
|
|
1400
|
-
user: currentUser.value,
|
|
1401
|
-
comment: action.comment
|
|
1402
|
-
})
|
|
1403
|
-
} else if (action.type === 'reject') {
|
|
1404
|
-
state = runtime.value.reject(action.task.id, {
|
|
1405
|
-
user: currentUser.value,
|
|
1406
|
-
comment: action.comment
|
|
1407
|
-
})
|
|
1408
|
-
} else if (action.type === 'resubmit') {
|
|
1409
|
-
const viewer = resubmitFormRef.value
|
|
1410
|
-
if (viewer?.formRef?.validate) {
|
|
1411
|
-
try {
|
|
1412
|
-
await viewer.formRef.validate()
|
|
1413
|
-
} catch {
|
|
1414
|
-
ElMessage.warning('请先完善表单必填项再重新提交')
|
|
1415
|
-
return
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
const data = viewer?.formData ? clone(viewer.formData) : action.resubmitData
|
|
1419
|
-
state = runtime.value.resubmit(action.task.id, {
|
|
1420
|
-
user: currentUser.value,
|
|
1421
|
-
data,
|
|
1422
|
-
comment: action.comment
|
|
1423
|
-
})
|
|
1424
|
-
} else {
|
|
1425
|
-
state = runtime.value.transfer(action.task.id, {
|
|
1426
|
-
user: currentUser.value,
|
|
1427
|
-
toUser: targetUser,
|
|
1428
|
-
comment: action.comment
|
|
1429
|
-
})
|
|
1430
|
-
}
|
|
1431
|
-
syncActiveState(state)
|
|
1432
|
-
action.visible = false
|
|
1433
|
-
if (action.type === 'approve') {
|
|
1434
|
-
ElMessage.success(state.status === 'completed' ? '已同意,流程已完成' : '已同意')
|
|
1435
|
-
} else if (action.type === 'reject') {
|
|
1436
|
-
const hitRetryLimit =
|
|
1437
|
-
state.status === 'rejected' &&
|
|
1438
|
-
rejectSnapshot &&
|
|
1439
|
-
!rejectSnapshot.unlimited &&
|
|
1440
|
-
rejectSnapshot.retryLimit > 0 &&
|
|
1441
|
-
rejectSnapshot.retriesUsed >= rejectSnapshot.retryLimit
|
|
1442
|
-
ElMessage.warning(
|
|
1443
|
-
state.status === 'rejected'
|
|
1444
|
-
? hitRetryLimit
|
|
1445
|
-
? '已达到允许退回次数,流程不通过'
|
|
1446
|
-
: '已拒绝,流程已终止'
|
|
1447
|
-
: '已拒绝,流程已退回'
|
|
1448
|
-
)
|
|
1449
|
-
} else if (action.type === 'resubmit') {
|
|
1450
|
-
ElMessage.success('已重新提交,流程继续流转')
|
|
1451
|
-
} else {
|
|
1452
|
-
ElMessage.success(`已转交给 ${targetUser?.realName || '目标用户'}`)
|
|
1453
|
-
}
|
|
1454
|
-
} catch (error) {
|
|
1455
|
-
ElMessage.error(error.message)
|
|
1456
|
-
} finally {
|
|
1457
|
-
action.submitting = false
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
async function autoRun() {
|
|
1462
|
-
if (!runtime.value) return
|
|
1463
|
-
autoRunning.value = true
|
|
1464
|
-
try {
|
|
1465
|
-
let steps = 0
|
|
1466
|
-
while (steps < 200) {
|
|
1467
|
-
const state = runtime.value.getState()
|
|
1468
|
-
if (state.status !== 'running') break
|
|
1469
|
-
const task = state.tasks.find((item) => item.status === 'pending')
|
|
1470
|
-
if (!task) break
|
|
1471
|
-
const approver = task.approvers.find((item) => !hasApproved(task, item))
|
|
1472
|
-
if (!approver) break
|
|
1473
|
-
runtime.value.approve(task.id, { user: approver, comment: '测试模式自动推进' })
|
|
1474
|
-
steps += 1
|
|
1475
|
-
}
|
|
1476
|
-
syncActiveState(runtime.value.getState())
|
|
1477
|
-
if (steps >= 200) {
|
|
1478
|
-
ElMessage.warning('自动推进达到步数上限,请检查流程是否存在环')
|
|
1479
|
-
} else {
|
|
1480
|
-
ElMessage.success(`已自动推进 ${steps} 个审批任务`)
|
|
1481
|
-
}
|
|
1482
|
-
} catch (error) {
|
|
1483
|
-
ElMessage.error(`自动推进失败:${error.message}`)
|
|
1484
|
-
} finally {
|
|
1485
|
-
autoRunning.value = false
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
async function stopActive() {
|
|
1490
|
-
if (!runtime.value) return
|
|
1491
|
-
try {
|
|
1492
|
-
await ElMessageBox.confirm('确定终止当前流程吗?', '终止流程', {
|
|
1493
|
-
type: 'warning',
|
|
1494
|
-
confirmButtonText: '终止',
|
|
1495
|
-
cancelButtonText: '继续运行'
|
|
1496
|
-
})
|
|
1497
|
-
} catch {
|
|
1498
|
-
return
|
|
1499
|
-
}
|
|
1500
|
-
syncActiveState(runtime.value.cancel('测试模式手动终止'))
|
|
1501
|
-
ElMessage.info('流程已终止')
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
async function revokeActive() {
|
|
1505
|
-
if (!runtime.value || !canRevokeActive.value) return
|
|
1506
|
-
try {
|
|
1507
|
-
await ElMessageBox.confirm('撤回后流程将终止,确定继续吗?', '撤回流程', {
|
|
1508
|
-
type: 'warning',
|
|
1509
|
-
confirmButtonText: '撤回',
|
|
1510
|
-
cancelButtonText: '取消'
|
|
1511
|
-
})
|
|
1512
|
-
} catch {
|
|
1513
|
-
return
|
|
1514
|
-
}
|
|
1515
|
-
try {
|
|
1516
|
-
syncActiveState(
|
|
1517
|
-
runtime.value.revoke({ user: currentUser.value, reason: '发起人撤回' })
|
|
1518
|
-
)
|
|
1519
|
-
ElMessage.info('流程已撤回')
|
|
1520
|
-
} catch (error) {
|
|
1521
|
-
ElMessage.error(error.message)
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
function tickActiveRuntime() {
|
|
1526
|
-
if (!runtime.value) return
|
|
1527
|
-
try {
|
|
1528
|
-
const state = runtime.value.tick()
|
|
1529
|
-
if (JSON.stringify(state) !== JSON.stringify(activeState.value)) {
|
|
1530
|
-
syncActiveState(state)
|
|
1531
|
-
}
|
|
1532
|
-
} catch {
|
|
1533
|
-
// A broken instance should not stop the deadline sweep.
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
function tickAllInstances() {
|
|
1538
|
-
instances.value.forEach((instance) => {
|
|
1539
|
-
if (instance.id === activeId.value && runtime.value) {
|
|
1540
|
-
tickActiveRuntime()
|
|
1541
|
-
return
|
|
1542
|
-
}
|
|
1543
|
-
try {
|
|
1544
|
-
const scoped = createFlowRuntime({
|
|
1545
|
-
workflow: instance.definition.workflow,
|
|
1546
|
-
state: instance.state,
|
|
1547
|
-
context: contextForInstance(instance)
|
|
1548
|
-
})
|
|
1549
|
-
const state = scoped.tick()
|
|
1550
|
-
if (JSON.stringify(state) !== JSON.stringify(instance.state)) {
|
|
1551
|
-
instance.state = state
|
|
1552
|
-
instance.updatedAt = nowIso()
|
|
1553
|
-
}
|
|
1554
|
-
} catch {
|
|
1555
|
-
// One corrupt instance should not block the other deadlines.
|
|
1556
|
-
}
|
|
1557
|
-
})
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
function exportInstances() {
|
|
1561
|
-
if (!instances.value.length) {
|
|
1562
|
-
ElMessage.warning('还没有可导出的流程实例')
|
|
1563
|
-
return
|
|
1564
|
-
}
|
|
1565
|
-
downloadJSON(
|
|
1566
|
-
{
|
|
1567
|
-
kind: 'gbflow-instances',
|
|
1568
|
-
version: 1,
|
|
1569
|
-
exportedAt: nowIso(),
|
|
1570
|
-
instances: clone(instances.value)
|
|
1571
|
-
},
|
|
1572
|
-
`gbflow-instances-${Date.now()}.json`
|
|
1573
|
-
)
|
|
1574
|
-
ElMessage.success(`已导出 ${instances.value.length} 个流程实例`)
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
function triggerInstanceImport() {
|
|
1578
|
-
instanceFileInput.value?.click()
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
async function handleInstanceImportFile(event) {
|
|
1582
|
-
const file = event.target.files?.[0]
|
|
1583
|
-
event.target.value = ''
|
|
1584
|
-
if (!file) return
|
|
1585
|
-
try {
|
|
1586
|
-
const text = await file.text()
|
|
1587
|
-
const count = importInstances(text)
|
|
1588
|
-
if (count) ElMessage.success(`已导入 ${count} 个流程实例`)
|
|
1589
|
-
} catch (error) {
|
|
1590
|
-
ElMessage.error(`实例导入失败:${error.message || error}`)
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
function importInstances(input) {
|
|
1595
|
-
const payload = typeof input === 'string' ? JSON.parse(input) : input
|
|
1596
|
-
const list = Array.isArray(payload) ? payload : payload?.instances
|
|
1597
|
-
if (!Array.isArray(list)) throw new Error('未找到实例列表')
|
|
1598
|
-
const existing = new Set(instances.value.map((item) => String(item.id)))
|
|
1599
|
-
const imported = []
|
|
1600
|
-
list.forEach((item, index) => {
|
|
1601
|
-
if (!item?.definition?.workflow || !item?.state?.tasks) return
|
|
1602
|
-
const id = existing.has(String(item.id))
|
|
1603
|
-
? `imported_${Date.now()}_${index}`
|
|
1604
|
-
: item.id || `imported_${Date.now()}_${index}`
|
|
1605
|
-
existing.add(String(id))
|
|
1606
|
-
imported.push({
|
|
1607
|
-
...clone(item),
|
|
1608
|
-
id,
|
|
1609
|
-
createdAt: item.createdAt || nowIso(),
|
|
1610
|
-
updatedAt: nowIso()
|
|
1611
|
-
})
|
|
1612
|
-
})
|
|
1613
|
-
if (!imported.length) throw new Error('没有可用的流程实例')
|
|
1614
|
-
instances.value = [...imported, ...instances.value]
|
|
1615
|
-
statusFilter.value = 'all'
|
|
1616
|
-
activeId.value = imported[0].id
|
|
1617
|
-
currentUserId.value = imported[0].initiatorId ?? currentUserId.value
|
|
1618
|
-
activateInstance()
|
|
1619
|
-
persist()
|
|
1620
|
-
return imported.length
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
async function removeInstance(instance) {
|
|
1624
|
-
try {
|
|
1625
|
-
await ElMessageBox.confirm(`确定删除「${instance.name}」吗?`, '删除流程实例', {
|
|
1626
|
-
type: 'warning',
|
|
1627
|
-
confirmButtonText: '删除',
|
|
1628
|
-
cancelButtonText: '取消'
|
|
1629
|
-
})
|
|
1630
|
-
} catch {
|
|
1631
|
-
return
|
|
1632
|
-
}
|
|
1633
|
-
const index = instances.value.findIndex((item) => item.id === instance.id)
|
|
1634
|
-
if (index < 0) return
|
|
1635
|
-
const wasActive = instance.id === activeId.value
|
|
1636
|
-
instances.value.splice(index, 1)
|
|
1637
|
-
if (wasActive) {
|
|
1638
|
-
runtime.value = null
|
|
1639
|
-
activeState.value = null
|
|
1640
|
-
activeId.value = instances.value[index]?.id || instances.value[index - 1]?.id || null
|
|
1641
|
-
if (activeId.value) activateInstance()
|
|
1642
|
-
}
|
|
1643
|
-
ElMessage.success('流程实例已删除')
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
function nodeNameOf(nodeId) {
|
|
1647
|
-
const workflow = activeInstance.value?.definition?.workflow
|
|
1648
|
-
return (workflow && findNodeById(workflow, nodeId)?.nodeName) || ''
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
function eventTitle(event) {
|
|
1652
|
-
const node = event.nodeId ? nodeNameOf(event.nodeId) : ''
|
|
1653
|
-
switch (event.event) {
|
|
1654
|
-
case 'start':
|
|
1655
|
-
return `${event.initiator?.name || '发起人'} 发起了流程`
|
|
1656
|
-
case 'approve':
|
|
1657
|
-
return `${event.approver?.name || '审批人'} 同意 · ${node}`
|
|
1658
|
-
case 'reject':
|
|
1659
|
-
return `${event.approver?.name || '审批人'} 拒绝 · ${node}`
|
|
1660
|
-
case 'transfer':
|
|
1661
|
-
return `${event.approver?.name || '审批人'} 转交给 ${event.target?.name || '目标用户'} · ${node}`
|
|
1662
|
-
case 'cc':
|
|
1663
|
-
return `抄送 · ${node}`
|
|
1664
|
-
case 'branch': {
|
|
1665
|
-
const selected = event.branchId
|
|
1666
|
-
? nodeNameOf(event.branchId)
|
|
1667
|
-
: (event.branchIds || []).map(nodeNameOf).filter(Boolean).join('、')
|
|
1668
|
-
return `命中分支${selected ? `「${selected}」` : ''}`
|
|
1669
|
-
}
|
|
1670
|
-
case 'split':
|
|
1671
|
-
return `分支展开 · ${node}`
|
|
1672
|
-
case 'join':
|
|
1673
|
-
return `分支汇聚 · ${nodeNameOf(event.targetId) || node}`
|
|
1674
|
-
case 'autoApprove':
|
|
1675
|
-
return `未匹配到审批人,自动通过 · ${node}`
|
|
1676
|
-
case 'return':
|
|
1677
|
-
return `${event.approver?.name || '审批人'} 退回流程 → ${nodeNameOf(event.targetNodeId) || '发起人'}`
|
|
1678
|
-
case 'resubmit':
|
|
1679
|
-
return `${event.approver?.name || '发起人'} 修改表单后重新提交`
|
|
1680
|
-
case 'timeoutApprove':
|
|
1681
|
-
return `审批超时,系统自动通过 · ${node}`
|
|
1682
|
-
case 'timeoutReject':
|
|
1683
|
-
return `审批超时,系统自动拒绝 · ${node}`
|
|
1684
|
-
case 'revoke':
|
|
1685
|
-
return `${event.approver?.name || '发起人'} 撤回了流程${event.reason ? ` · ${event.reason}` : ''}`
|
|
1686
|
-
case 'pass':
|
|
1687
|
-
return `直接通过 · ${node}`
|
|
1688
|
-
case 'rejectNode':
|
|
1689
|
-
return `直接拒绝 · ${node}`
|
|
1690
|
-
case 'rejectLimitReached':
|
|
1691
|
-
return `达到最大退回次数(${event.retryLimit} 次),流程不通过 · ${node}`
|
|
1692
|
-
case 'cancel':
|
|
1693
|
-
return `流程已终止${event.reason ? ` · ${event.reason}` : ''}`
|
|
1694
|
-
case 'finished':
|
|
1695
|
-
return `流程结束 · ${STATUS_META[event.status]?.label || event.status}`
|
|
1696
|
-
default:
|
|
1697
|
-
return event.event
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
function eventMeta(event) {
|
|
1702
|
-
const parts = []
|
|
1703
|
-
if (event.event === 'cc' && event.users?.length) {
|
|
1704
|
-
parts.push(`抄送人:${event.users.map((user) => user.name).join('、')}`)
|
|
1705
|
-
}
|
|
1706
|
-
if (event.comment) parts.push(`意见:${event.comment}`)
|
|
1707
|
-
return parts.join(' · ')
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
function eventType(event) {
|
|
1711
|
-
return (
|
|
1712
|
-
{
|
|
1713
|
-
approve: 'success',
|
|
1714
|
-
transfer: 'primary',
|
|
1715
|
-
cc: 'warning',
|
|
1716
|
-
branch: 'primary',
|
|
1717
|
-
split: 'primary',
|
|
1718
|
-
join: 'primary',
|
|
1719
|
-
autoApprove: 'success',
|
|
1720
|
-
return: 'warning',
|
|
1721
|
-
reject: 'danger',
|
|
1722
|
-
rejectNode: 'danger',
|
|
1723
|
-
rejectLimitReached: 'danger',
|
|
1724
|
-
cancel: 'info',
|
|
1725
|
-
revoke: 'info',
|
|
1726
|
-
resubmit: 'primary',
|
|
1727
|
-
timeoutApprove: 'success',
|
|
1728
|
-
timeoutReject: 'danger',
|
|
1729
|
-
finished: 'success'
|
|
1730
|
-
}[event.event] || 'info'
|
|
1731
|
-
)
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
watch([instances, currentUserId, initiatorId, activeId], persist, { deep: true })
|
|
1735
|
-
watch(activeId, () => {
|
|
1736
|
-
if (storageReady) {
|
|
1737
|
-
activeTab.value = 'chart'
|
|
1738
|
-
activateInstance()
|
|
1739
|
-
}
|
|
1740
|
-
})
|
|
1741
|
-
watch(
|
|
1742
|
-
() => [props.users, props.departments, props.roles],
|
|
1743
|
-
() => {
|
|
1744
|
-
org.users = clone(props.users?.length ? props.users : mockUsers)
|
|
1745
|
-
org.departments = clone(props.departments?.length ? props.departments : mockDepartments)
|
|
1746
|
-
org.roles = clone(props.roles?.length ? props.roles : mockRoles)
|
|
1747
|
-
if (!userById(currentUserId.value)) {
|
|
1748
|
-
currentUserId.value = org.users[0]?.id ?? null
|
|
1749
|
-
}
|
|
1750
|
-
if (!userById(initiatorId.value)) {
|
|
1751
|
-
initiatorId.value = currentUserId.value
|
|
1752
|
-
}
|
|
1753
|
-
if (storageReady && activeId.value) {
|
|
1754
|
-
activateInstance()
|
|
1755
|
-
}
|
|
1756
|
-
},
|
|
1757
|
-
{ deep: true }
|
|
1758
|
-
)
|
|
1759
|
-
|
|
1760
|
-
defineExpose({
|
|
1761
|
-
openCreate,
|
|
1762
|
-
selectInstanceById,
|
|
1763
|
-
removeInstance,
|
|
1764
|
-
exportInstances,
|
|
1765
|
-
importInstances,
|
|
1766
|
-
activeId,
|
|
1767
|
-
currentUser
|
|
1768
|
-
})
|
|
1769
|
-
|
|
1770
|
-
watch(
|
|
1771
|
-
currentUser,
|
|
1772
|
-
(user) => emit('operator-change', user ? clone(user) : null),
|
|
1773
|
-
{ immediate: true }
|
|
1774
|
-
)
|
|
1775
|
-
|
|
1776
|
-
onMounted(() => {
|
|
1777
|
-
load().then(() => tickAllInstances())
|
|
1778
|
-
deadlineTimer = setInterval(tickAllInstances, 30000)
|
|
1779
|
-
})
|
|
1780
|
-
onBeforeUnmount(() => {
|
|
1781
|
-
if (deadlineTimer) clearInterval(deadlineTimer)
|
|
1782
|
-
flushPersist()
|
|
1783
|
-
})
|
|
1784
|
-
</script>
|
|
1785
|
-
|
|
1786
|
-
<style scoped lang="scss">
|
|
1787
|
-
.flow-workbench {
|
|
1788
|
-
height: 100%;
|
|
1789
|
-
min-height: 0;
|
|
1790
|
-
display: flex;
|
|
1791
|
-
gap: 12px;
|
|
1792
|
-
padding: 12px;
|
|
1793
|
-
background: #f3f5f9;
|
|
1794
|
-
box-sizing: border-box;
|
|
1795
|
-
overflow: hidden;
|
|
1796
|
-
color: #1f2937;
|
|
1797
|
-
font-size: 13px;
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
.wb-panel {
|
|
1801
|
-
display: flex;
|
|
1802
|
-
flex-direction: column;
|
|
1803
|
-
min-height: 0;
|
|
1804
|
-
background: #fff;
|
|
1805
|
-
border-radius: 10px;
|
|
1806
|
-
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
|
|
1807
|
-
overflow: hidden;
|
|
1808
|
-
|
|
1809
|
-
&__head {
|
|
1810
|
-
flex-shrink: 0;
|
|
1811
|
-
display: flex;
|
|
1812
|
-
align-items: flex-start;
|
|
1813
|
-
justify-content: space-between;
|
|
1814
|
-
gap: 10px;
|
|
1815
|
-
padding: 12px 14px;
|
|
1816
|
-
border-bottom: 1px solid #eef2f7;
|
|
1817
|
-
|
|
1818
|
-
h3 {
|
|
1819
|
-
margin: 0;
|
|
1820
|
-
font-size: 14px;
|
|
1821
|
-
font-weight: 600;
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
span {
|
|
1825
|
-
display: block;
|
|
1826
|
-
margin-top: 2px;
|
|
1827
|
-
font-size: 12px;
|
|
1828
|
-
color: #94a3b8;
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
&__foot {
|
|
1833
|
-
flex-shrink: 0;
|
|
1834
|
-
padding: 8px 14px;
|
|
1835
|
-
border-top: 1px solid #eef2f7;
|
|
1836
|
-
color: #94a3b8;
|
|
1837
|
-
font-size: 11px;
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
|
|
1841
|
-
.flow-workbench__sidebar {
|
|
1842
|
-
width: 260px;
|
|
1843
|
-
flex-shrink: 0;
|
|
1844
|
-
min-height: 0;
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
.wb-panel--list {
|
|
1848
|
-
height: 100%;
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
|
-
.wb-filters {
|
|
1852
|
-
flex-shrink: 0;
|
|
1853
|
-
display: grid;
|
|
1854
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1855
|
-
gap: 4px;
|
|
1856
|
-
padding: 8px 10px;
|
|
1857
|
-
border-bottom: 1px dashed #eef2f7;
|
|
1858
|
-
}
|
|
1859
|
-
|
|
1860
|
-
.wb-filter {
|
|
1861
|
-
display: inline-flex;
|
|
1862
|
-
align-items: center;
|
|
1863
|
-
justify-content: space-between;
|
|
1864
|
-
gap: 4px;
|
|
1865
|
-
padding: 3px 8px;
|
|
1866
|
-
border: 1px solid transparent;
|
|
1867
|
-
border-radius: 12px;
|
|
1868
|
-
background: #f1f5f9;
|
|
1869
|
-
color: #64748b;
|
|
1870
|
-
font-size: 11px;
|
|
1871
|
-
cursor: pointer;
|
|
1872
|
-
|
|
1873
|
-
span {
|
|
1874
|
-
color: #94a3b8;
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
&.is-active {
|
|
1878
|
-
background: #e8f2ff;
|
|
1879
|
-
border-color: #bfdbfe;
|
|
1880
|
-
color: #2563eb;
|
|
1881
|
-
|
|
1882
|
-
span {
|
|
1883
|
-
color: #2563eb;
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
.wb-instance-list {
|
|
1889
|
-
flex: 1;
|
|
1890
|
-
min-height: 0;
|
|
1891
|
-
overflow: auto;
|
|
1892
|
-
padding: 8px;
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
.wb-instance {
|
|
1896
|
-
position: relative;
|
|
1897
|
-
padding: 10px;
|
|
1898
|
-
margin-bottom: 8px;
|
|
1899
|
-
border: 1px solid #e2e8f0;
|
|
1900
|
-
border-radius: 8px;
|
|
1901
|
-
cursor: pointer;
|
|
1902
|
-
transition: all 0.15s;
|
|
1903
|
-
|
|
1904
|
-
&:hover {
|
|
1905
|
-
border-color: #bfdbfe;
|
|
1906
|
-
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
|
|
1907
|
-
|
|
1908
|
-
.wb-instance__delete {
|
|
1909
|
-
opacity: 1;
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
&.is-active {
|
|
1914
|
-
border-color: #3296fa;
|
|
1915
|
-
background: #f8fbff;
|
|
1916
|
-
box-shadow: inset 3px 0 0 #3296fa;
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
&__top {
|
|
1920
|
-
display: flex;
|
|
1921
|
-
align-items: center;
|
|
1922
|
-
justify-content: space-between;
|
|
1923
|
-
gap: 6px;
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
&__name {
|
|
1927
|
-
font-weight: 600;
|
|
1928
|
-
color: #1e293b;
|
|
1929
|
-
overflow: hidden;
|
|
1930
|
-
text-overflow: ellipsis;
|
|
1931
|
-
white-space: nowrap;
|
|
1932
|
-
}
|
|
1933
|
-
|
|
1934
|
-
&__meta {
|
|
1935
|
-
display: flex;
|
|
1936
|
-
justify-content: space-between;
|
|
1937
|
-
gap: 6px;
|
|
1938
|
-
margin-top: 5px;
|
|
1939
|
-
color: #94a3b8;
|
|
1940
|
-
font-size: 11px;
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1943
|
-
&__node {
|
|
1944
|
-
margin-top: 5px;
|
|
1945
|
-
color: #64748b;
|
|
1946
|
-
font-size: 12px;
|
|
1947
|
-
overflow: hidden;
|
|
1948
|
-
text-overflow: ellipsis;
|
|
1949
|
-
white-space: nowrap;
|
|
1950
|
-
}
|
|
1951
|
-
|
|
1952
|
-
&__foot {
|
|
1953
|
-
display: flex;
|
|
1954
|
-
align-items: center;
|
|
1955
|
-
justify-content: space-between;
|
|
1956
|
-
margin-top: 6px;
|
|
1957
|
-
font-size: 11px;
|
|
1958
|
-
color: #94a3b8;
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
&__pending {
|
|
1962
|
-
color: #d97706;
|
|
1963
|
-
font-weight: 600;
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
&__delete {
|
|
1967
|
-
opacity: 0;
|
|
1968
|
-
transition: opacity 0.15s;
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
.flow-workbench__main {
|
|
1973
|
-
flex: 1;
|
|
1974
|
-
min-width: 0;
|
|
1975
|
-
display: flex;
|
|
1976
|
-
min-height: 0;
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
|
-
.wb-panel--detail {
|
|
1980
|
-
flex: 1;
|
|
1981
|
-
min-width: 0;
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
.wb-panel--empty {
|
|
1985
|
-
flex: 1;
|
|
1986
|
-
align-items: center;
|
|
1987
|
-
justify-content: center;
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
.wb-detail {
|
|
1991
|
-
&__head {
|
|
1992
|
-
position: relative;
|
|
1993
|
-
flex-shrink: 0;
|
|
1994
|
-
padding: 12px 18px;
|
|
1995
|
-
border-bottom: 1px solid #eef2f7;
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
&__title {
|
|
1999
|
-
display: flex;
|
|
2000
|
-
align-items: center;
|
|
2001
|
-
gap: 8px;
|
|
2002
|
-
|
|
2003
|
-
h2 {
|
|
2004
|
-
margin: 0;
|
|
2005
|
-
font-size: 16px;
|
|
2006
|
-
font-weight: 600;
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
&__time {
|
|
2011
|
-
margin-left: 4px;
|
|
2012
|
-
color: #94a3b8;
|
|
2013
|
-
font-size: 12px;
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
&__meta {
|
|
2017
|
-
margin-top: 5px;
|
|
2018
|
-
color: #64748b;
|
|
2019
|
-
font-size: 12px;
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
&__actions {
|
|
2023
|
-
position: absolute;
|
|
2024
|
-
right: 18px;
|
|
2025
|
-
bottom: 12px;
|
|
2026
|
-
display: flex;
|
|
2027
|
-
gap: 8px;
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
&__tabs {
|
|
2031
|
-
flex: 1;
|
|
2032
|
-
min-height: 0;
|
|
2033
|
-
display: flex;
|
|
2034
|
-
flex-direction: column;
|
|
2035
|
-
|
|
2036
|
-
:deep(.el-tabs__header) {
|
|
2037
|
-
flex-shrink: 0;
|
|
2038
|
-
margin: 0;
|
|
2039
|
-
padding: 0 18px;
|
|
2040
|
-
}
|
|
2041
|
-
|
|
2042
|
-
:deep(.el-tabs__content) {
|
|
2043
|
-
flex: 1;
|
|
2044
|
-
min-height: 0;
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
:deep(.el-tab-pane) {
|
|
2048
|
-
height: 100%;
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
&__chart {
|
|
2053
|
-
height: 100%;
|
|
2054
|
-
min-height: 0;
|
|
2055
|
-
padding: 12px;
|
|
2056
|
-
box-sizing: border-box;
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
&__scroll {
|
|
2060
|
-
height: 100%;
|
|
2061
|
-
overflow: auto;
|
|
2062
|
-
padding: 16px 18px;
|
|
2063
|
-
box-sizing: border-box;
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
.wb-dot {
|
|
2068
|
-
margin: 0 6px;
|
|
2069
|
-
color: #cbd5e1;
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
.wb-info-bar {
|
|
2073
|
-
display: flex;
|
|
2074
|
-
align-items: center;
|
|
2075
|
-
gap: 8px;
|
|
2076
|
-
flex-wrap: wrap;
|
|
2077
|
-
padding: 10px 12px;
|
|
2078
|
-
margin-bottom: 12px;
|
|
2079
|
-
border-radius: 8px;
|
|
2080
|
-
background: #f8fafc;
|
|
2081
|
-
color: #64748b;
|
|
2082
|
-
|
|
2083
|
-
strong {
|
|
2084
|
-
color: #1e293b;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
&__time {
|
|
2088
|
-
margin-left: auto;
|
|
2089
|
-
color: #94a3b8;
|
|
2090
|
-
font-size: 12px;
|
|
2091
|
-
}
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
.wb-snapshot {
|
|
2095
|
-
margin-top: 12px;
|
|
2096
|
-
|
|
2097
|
-
:deep(.el-collapse-item__header) {
|
|
2098
|
-
font-size: 13px;
|
|
2099
|
-
color: #64748b;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
pre {
|
|
2103
|
-
margin: 0;
|
|
2104
|
-
max-height: 320px;
|
|
2105
|
-
overflow: auto;
|
|
2106
|
-
padding: 12px;
|
|
2107
|
-
border-radius: 6px;
|
|
2108
|
-
background: #0f172a;
|
|
2109
|
-
color: #e2e8f0;
|
|
2110
|
-
font-size: 12px;
|
|
2111
|
-
line-height: 1.6;
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
.wb-timeline {
|
|
2116
|
-
padding-left: 2px;
|
|
2117
|
-
|
|
2118
|
-
:deep(.el-timeline-item__timestamp) {
|
|
2119
|
-
font-size: 12px;
|
|
2120
|
-
color: #94a3b8;
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
.wb-event {
|
|
2125
|
-
color: #334155;
|
|
2126
|
-
|
|
2127
|
-
&__meta {
|
|
2128
|
-
margin-top: 2px;
|
|
2129
|
-
color: #94a3b8;
|
|
2130
|
-
font-size: 12px;
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
|
|
2134
|
-
.wb-trace-block {
|
|
2135
|
-
margin-top: 16px;
|
|
2136
|
-
|
|
2137
|
-
h4 {
|
|
2138
|
-
margin: 0 0 8px;
|
|
2139
|
-
font-size: 13px;
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
|
|
2143
|
-
.wb-alert {
|
|
2144
|
-
margin-bottom: 6px;
|
|
2145
|
-
}
|
|
2146
|
-
|
|
2147
|
-
.flow-workbench__rail {
|
|
2148
|
-
width: 330px;
|
|
2149
|
-
flex-shrink: 0;
|
|
2150
|
-
min-height: 0;
|
|
2151
|
-
display: flex;
|
|
2152
|
-
flex-direction: column;
|
|
2153
|
-
gap: 12px;
|
|
2154
|
-
overflow: auto;
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
.wb-panel--users,
|
|
2158
|
-
.wb-panel--tasks {
|
|
2159
|
-
flex-shrink: 0;
|
|
2160
|
-
}
|
|
2161
|
-
|
|
2162
|
-
.wb-user-list {
|
|
2163
|
-
padding: 8px;
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
|
-
.wb-user {
|
|
2167
|
-
width: 100%;
|
|
2168
|
-
display: flex;
|
|
2169
|
-
align-items: center;
|
|
2170
|
-
gap: 8px;
|
|
2171
|
-
padding: 7px 8px;
|
|
2172
|
-
border: 1px solid transparent;
|
|
2173
|
-
border-radius: 8px;
|
|
2174
|
-
background: transparent;
|
|
2175
|
-
cursor: pointer;
|
|
2176
|
-
text-align: left;
|
|
2177
|
-
|
|
2178
|
-
&:hover {
|
|
2179
|
-
background: #f8fafc;
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
&.is-active {
|
|
2183
|
-
background: #f0f7ff;
|
|
2184
|
-
border-color: #bfdbfe;
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
&__avatar {
|
|
2188
|
-
width: 28px;
|
|
2189
|
-
height: 28px;
|
|
2190
|
-
flex-shrink: 0;
|
|
2191
|
-
display: inline-flex;
|
|
2192
|
-
align-items: center;
|
|
2193
|
-
justify-content: center;
|
|
2194
|
-
border-radius: 50%;
|
|
2195
|
-
background: #e0edff;
|
|
2196
|
-
color: #2563eb;
|
|
2197
|
-
font-size: 12px;
|
|
2198
|
-
font-weight: 600;
|
|
2199
|
-
}
|
|
2200
|
-
|
|
2201
|
-
&__main {
|
|
2202
|
-
flex: 1;
|
|
2203
|
-
min-width: 0;
|
|
2204
|
-
display: flex;
|
|
2205
|
-
flex-direction: column;
|
|
2206
|
-
}
|
|
2207
|
-
|
|
2208
|
-
&__name {
|
|
2209
|
-
display: flex;
|
|
2210
|
-
align-items: center;
|
|
2211
|
-
gap: 6px;
|
|
2212
|
-
font-size: 12px;
|
|
2213
|
-
color: #1e293b;
|
|
2214
|
-
}
|
|
2215
|
-
|
|
2216
|
-
&__current {
|
|
2217
|
-
padding: 0 5px;
|
|
2218
|
-
border-radius: 8px;
|
|
2219
|
-
background: #3296fa;
|
|
2220
|
-
color: #fff;
|
|
2221
|
-
font-size: 10px;
|
|
2222
|
-
line-height: 16px;
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
&__meta {
|
|
2226
|
-
margin-top: 2px;
|
|
2227
|
-
color: #94a3b8;
|
|
2228
|
-
font-size: 11px;
|
|
2229
|
-
overflow: hidden;
|
|
2230
|
-
text-overflow: ellipsis;
|
|
2231
|
-
white-space: nowrap;
|
|
2232
|
-
}
|
|
2233
|
-
|
|
2234
|
-
&__badge {
|
|
2235
|
-
min-width: 18px;
|
|
2236
|
-
height: 18px;
|
|
2237
|
-
padding: 0 5px;
|
|
2238
|
-
border-radius: 9px;
|
|
2239
|
-
background: #f59e0b;
|
|
2240
|
-
color: #fff;
|
|
2241
|
-
font-size: 11px;
|
|
2242
|
-
line-height: 18px;
|
|
2243
|
-
text-align: center;
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
|
-
.wb-panel--tasks {
|
|
2248
|
-
flex: 1;
|
|
2249
|
-
min-height: 300px;
|
|
2250
|
-
overflow: auto;
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
.wb-instance-tools {
|
|
2254
|
-
display: flex;
|
|
2255
|
-
align-items: center;
|
|
2256
|
-
gap: 4px;
|
|
2257
|
-
}
|
|
2258
|
-
|
|
2259
|
-
.wb-task {
|
|
2260
|
-
margin: 0 12px 10px;
|
|
2261
|
-
padding: 10px;
|
|
2262
|
-
border: 1px solid #e2e8f0;
|
|
2263
|
-
border-radius: 8px;
|
|
2264
|
-
|
|
2265
|
-
&__head {
|
|
2266
|
-
display: flex;
|
|
2267
|
-
align-items: center;
|
|
2268
|
-
justify-content: space-between;
|
|
2269
|
-
gap: 6px;
|
|
2270
|
-
|
|
2271
|
-
strong {
|
|
2272
|
-
font-size: 13px;
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
|
-
&__progress {
|
|
2277
|
-
margin-top: 4px;
|
|
2278
|
-
color: #94a3b8;
|
|
2279
|
-
font-size: 11px;
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
&__approvers {
|
|
2283
|
-
display: flex;
|
|
2284
|
-
flex-wrap: wrap;
|
|
2285
|
-
gap: 4px;
|
|
2286
|
-
margin-top: 6px;
|
|
2287
|
-
}
|
|
2288
|
-
|
|
2289
|
-
&__instance {
|
|
2290
|
-
display: inline-flex;
|
|
2291
|
-
align-items: center;
|
|
2292
|
-
max-width: 100%;
|
|
2293
|
-
margin-top: 5px;
|
|
2294
|
-
padding: 0;
|
|
2295
|
-
border: none;
|
|
2296
|
-
background: transparent;
|
|
2297
|
-
color: #2563eb;
|
|
2298
|
-
font-size: 11px;
|
|
2299
|
-
cursor: pointer;
|
|
2300
|
-
overflow: hidden;
|
|
2301
|
-
text-overflow: ellipsis;
|
|
2302
|
-
white-space: nowrap;
|
|
2303
|
-
|
|
2304
|
-
&:hover {
|
|
2305
|
-
text-decoration: underline;
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
|
|
2309
|
-
&__deadline {
|
|
2310
|
-
margin-top: 5px;
|
|
2311
|
-
color: #b45309;
|
|
2312
|
-
font-size: 11px;
|
|
2313
|
-
}
|
|
2314
|
-
|
|
2315
|
-
&__comment {
|
|
2316
|
-
margin-top: 6px;
|
|
2317
|
-
padding: 4px 8px;
|
|
2318
|
-
border-radius: 4px;
|
|
2319
|
-
background: #f8fafc;
|
|
2320
|
-
color: #64748b;
|
|
2321
|
-
font-size: 12px;
|
|
2322
|
-
}
|
|
2323
|
-
|
|
2324
|
-
&__policy {
|
|
2325
|
-
margin-top: 5px;
|
|
2326
|
-
color: #b45309;
|
|
2327
|
-
font-size: 11px;
|
|
2328
|
-
}
|
|
2329
|
-
|
|
2330
|
-
&__actions {
|
|
2331
|
-
display: flex;
|
|
2332
|
-
gap: 6px;
|
|
2333
|
-
margin-top: 8px;
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
.wb-cc-list {
|
|
2338
|
-
padding: 0 12px 12px;
|
|
2339
|
-
|
|
2340
|
-
h4 {
|
|
2341
|
-
margin: 0 0 6px;
|
|
2342
|
-
font-size: 13px;
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2346
|
-
.wb-cc-row {
|
|
2347
|
-
display: flex;
|
|
2348
|
-
align-items: center;
|
|
2349
|
-
flex-wrap: wrap;
|
|
2350
|
-
gap: 6px;
|
|
2351
|
-
padding: 5px 0;
|
|
2352
|
-
border-bottom: 1px dashed #eef2f7;
|
|
2353
|
-
color: #64748b;
|
|
2354
|
-
font-size: 12px;
|
|
2355
|
-
|
|
2356
|
-
&:last-child {
|
|
2357
|
-
border-bottom: none;
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
|
|
2361
|
-
.wb-muted {
|
|
2362
|
-
color: #94a3b8;
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
|
-
.wb-resubmit {
|
|
2366
|
-
max-height: 60vh;
|
|
2367
|
-
overflow: auto;
|
|
2368
|
-
padding-right: 4px;
|
|
2369
|
-
|
|
2370
|
-
&__tip {
|
|
2371
|
-
margin-bottom: 10px;
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
.wb-hidden-input {
|
|
2376
|
-
display: none;
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
.wb-dialog-task {
|
|
2380
|
-
display: flex;
|
|
2381
|
-
align-items: center;
|
|
2382
|
-
flex-wrap: wrap;
|
|
2383
|
-
gap: 8px;
|
|
2384
|
-
margin-bottom: 14px;
|
|
2385
|
-
padding: 8px 12px;
|
|
2386
|
-
border-radius: 6px;
|
|
2387
|
-
background: #f8fafc;
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
.wb-create__tabs {
|
|
2391
|
-
:deep(.el-tabs__content) {
|
|
2392
|
-
height: 58vh;
|
|
2393
|
-
overflow: hidden;
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
|
-
.wb-create {
|
|
2398
|
-
display: flex;
|
|
2399
|
-
gap: 14px;
|
|
2400
|
-
height: 100%;
|
|
2401
|
-
|
|
2402
|
-
&__form {
|
|
2403
|
-
flex: 1;
|
|
2404
|
-
min-width: 0;
|
|
2405
|
-
overflow: auto;
|
|
2406
|
-
padding-right: 6px;
|
|
2407
|
-
|
|
2408
|
-
:deep(.form-view-container) {
|
|
2409
|
-
height: auto;
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2412
|
-
:deep(.form-view-content) {
|
|
2413
|
-
overflow: visible;
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
&__side {
|
|
2418
|
-
width: 280px;
|
|
2419
|
-
flex-shrink: 0;
|
|
2420
|
-
overflow: auto;
|
|
2421
|
-
padding: 12px;
|
|
2422
|
-
border-radius: 8px;
|
|
2423
|
-
background: #f8fafc;
|
|
2424
|
-
border: 1px solid #eef2f7;
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2427
|
-
&__field {
|
|
2428
|
-
display: flex;
|
|
2429
|
-
flex-direction: column;
|
|
2430
|
-
gap: 6px;
|
|
2431
|
-
margin-bottom: 14px;
|
|
2432
|
-
|
|
2433
|
-
label {
|
|
2434
|
-
font-size: 12px;
|
|
2435
|
-
color: #64748b;
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
&__cc {
|
|
2440
|
-
h4 {
|
|
2441
|
-
margin: 0 0 8px;
|
|
2442
|
-
font-size: 13px;
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
|
-
&__cc-row {
|
|
2447
|
-
display: flex;
|
|
2448
|
-
flex-direction: column;
|
|
2449
|
-
gap: 5px;
|
|
2450
|
-
margin-bottom: 10px;
|
|
2451
|
-
|
|
2452
|
-
> span {
|
|
2453
|
-
font-size: 12px;
|
|
2454
|
-
color: #64748b;
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
&__preview {
|
|
2459
|
-
height: 100%;
|
|
2460
|
-
display: flex;
|
|
2461
|
-
flex-direction: column;
|
|
2462
|
-
min-height: 0;
|
|
2463
|
-
}
|
|
2464
|
-
|
|
2465
|
-
&__preview-head {
|
|
2466
|
-
flex-shrink: 0;
|
|
2467
|
-
display: flex;
|
|
2468
|
-
align-items: center;
|
|
2469
|
-
justify-content: space-between;
|
|
2470
|
-
gap: 10px;
|
|
2471
|
-
margin-bottom: 8px;
|
|
2472
|
-
color: #94a3b8;
|
|
2473
|
-
font-size: 12px;
|
|
2474
|
-
}
|
|
2475
|
-
|
|
2476
|
-
&__preview-chart {
|
|
2477
|
-
flex: 1;
|
|
2478
|
-
min-height: 0;
|
|
2479
|
-
}
|
|
2480
|
-
|
|
2481
|
-
&__footer {
|
|
2482
|
-
display: flex;
|
|
2483
|
-
align-items: center;
|
|
2484
|
-
justify-content: flex-end;
|
|
2485
|
-
gap: 8px;
|
|
2486
|
-
|
|
2487
|
-
.wb-muted {
|
|
2488
|
-
margin-right: auto;
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
}
|
|
2492
|
-
|
|
2493
|
-
@media (max-width: 1280px) {
|
|
2494
|
-
.flow-workbench__sidebar {
|
|
2495
|
-
width: 230px;
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2498
|
-
.flow-workbench__rail {
|
|
2499
|
-
width: 300px;
|
|
2500
|
-
}
|
|
2501
|
-
}
|
|
2502
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flow-workbench">
|
|
3
|
+
<aside v-if="showInstanceList" class="flow-workbench__sidebar">
|
|
4
|
+
<div class="wb-panel wb-panel--list">
|
|
5
|
+
<div class="wb-panel__head">
|
|
6
|
+
<div>
|
|
7
|
+
<h3>流程实例</h3>
|
|
8
|
+
<span>{{ instances.length }} 个流程实例</span>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="wb-instance-tools">
|
|
11
|
+
<el-tooltip content="导出实例" placement="top">
|
|
12
|
+
<el-button link :icon="Download" @click="exportInstances" />
|
|
13
|
+
</el-tooltip>
|
|
14
|
+
<el-tooltip content="导入实例" placement="top">
|
|
15
|
+
<el-button link :icon="Upload" @click="triggerInstanceImport" />
|
|
16
|
+
</el-tooltip>
|
|
17
|
+
<el-button type="primary" size="small" :icon="Plus" @click="openCreate">
|
|
18
|
+
发起流程
|
|
19
|
+
</el-button>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div class="wb-filters">
|
|
24
|
+
<button
|
|
25
|
+
v-for="filter in FILTERS"
|
|
26
|
+
:key="filter.value"
|
|
27
|
+
type="button"
|
|
28
|
+
class="wb-filter"
|
|
29
|
+
:class="{ 'is-active': statusFilter === filter.value }"
|
|
30
|
+
@click="statusFilter = filter.value"
|
|
31
|
+
>
|
|
32
|
+
{{ filter.label }}
|
|
33
|
+
<span>{{ filterCount(filter.value) }}</span>
|
|
34
|
+
</button>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div class="wb-instance-list">
|
|
38
|
+
<div
|
|
39
|
+
v-for="instance in filteredInstances"
|
|
40
|
+
:key="instance.id"
|
|
41
|
+
class="wb-instance"
|
|
42
|
+
:class="{ 'is-active': instance.id === activeId }"
|
|
43
|
+
@click="selectInstance(instance.id)"
|
|
44
|
+
>
|
|
45
|
+
<div class="wb-instance__top">
|
|
46
|
+
<span class="wb-instance__name">{{ instance.name }}</span>
|
|
47
|
+
<el-tag size="small" :type="statusMetaOf(instance).type">
|
|
48
|
+
{{ statusMetaOf(instance).label }}
|
|
49
|
+
</el-tag>
|
|
50
|
+
</div>
|
|
51
|
+
<div class="wb-instance__meta">
|
|
52
|
+
<span>{{ instance.initiator?.name || '未知发起人' }}</span>
|
|
53
|
+
<span>{{ formatDateTime(instance.createdAt) }}</span>
|
|
54
|
+
</div>
|
|
55
|
+
<div class="wb-instance__node">当前节点:{{ currentNodeText(instance) }}</div>
|
|
56
|
+
<div class="wb-instance__foot">
|
|
57
|
+
<span v-if="pendingCountForInstance(instance)" class="wb-instance__pending">
|
|
58
|
+
我的待办 {{ pendingCountForInstance(instance) }}
|
|
59
|
+
</span>
|
|
60
|
+
<span v-else class="wb-instance__progress">{{ instanceProgress(instance) }}</span>
|
|
61
|
+
<el-button
|
|
62
|
+
link
|
|
63
|
+
type="danger"
|
|
64
|
+
:icon="Delete"
|
|
65
|
+
class="wb-instance__delete"
|
|
66
|
+
@click.stop="removeInstance(instance)"
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<el-empty
|
|
72
|
+
v-if="!filteredInstances.length"
|
|
73
|
+
:description="instances.length ? '当前筛选下没有实例' : '还没有流程实例,点击「发起流程」开始'"
|
|
74
|
+
:image-size="64"
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div class="wb-panel__foot">流程实例保存在本机浏览器</div>
|
|
79
|
+
</div>
|
|
80
|
+
</aside>
|
|
81
|
+
|
|
82
|
+
<main class="flow-workbench__main">
|
|
83
|
+
<div v-if="activeInstance" class="wb-panel wb-panel--detail">
|
|
84
|
+
<div class="wb-detail__head">
|
|
85
|
+
<div class="wb-detail__title">
|
|
86
|
+
<h2>{{ activeInstance.name }}</h2>
|
|
87
|
+
<el-tag :type="activeStatusMeta.type" size="small">
|
|
88
|
+
{{ activeStatusMeta.label }}
|
|
89
|
+
</el-tag>
|
|
90
|
+
<el-tag v-if="activeState?.cycle > 1" size="small" type="warning" effect="plain">
|
|
91
|
+
第 {{ activeState.cycle }} 轮
|
|
92
|
+
</el-tag>
|
|
93
|
+
<el-tag
|
|
94
|
+
v-if="activeInstance.definitionVersion"
|
|
95
|
+
size="small"
|
|
96
|
+
type="info"
|
|
97
|
+
effect="plain"
|
|
98
|
+
>
|
|
99
|
+
v{{ activeInstance.definitionVersion }}
|
|
100
|
+
</el-tag>
|
|
101
|
+
<span class="wb-detail__time">{{ formatDateTime(activeInstance.createdAt) }}</span>
|
|
102
|
+
</div>
|
|
103
|
+
<div class="wb-detail__meta">
|
|
104
|
+
发起人:{{ activeInstance.initiator?.name || '未知' }}
|
|
105
|
+
<template v-if="activeInstance.initiator?.deptName">
|
|
106
|
+
· {{ activeInstance.initiator.deptName }}
|
|
107
|
+
</template>
|
|
108
|
+
<span class="wb-dot">·</span>
|
|
109
|
+
{{ currentNodeText(activeInstance) }}
|
|
110
|
+
</div>
|
|
111
|
+
<div class="wb-detail__actions">
|
|
112
|
+
<el-button
|
|
113
|
+
v-if="isActiveRunning"
|
|
114
|
+
size="small"
|
|
115
|
+
:icon="VideoPlay"
|
|
116
|
+
:loading="autoRunning"
|
|
117
|
+
@click="autoRun"
|
|
118
|
+
>
|
|
119
|
+
自动推进
|
|
120
|
+
</el-button>
|
|
121
|
+
<el-button v-if="canRevokeActive" size="small" plain @click="revokeActive">
|
|
122
|
+
撤回
|
|
123
|
+
</el-button>
|
|
124
|
+
<el-button v-if="isActiveRunning" size="small" type="danger" plain @click="stopActive">
|
|
125
|
+
管理员终止
|
|
126
|
+
</el-button>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<el-tabs v-model="activeTab" class="wb-detail__tabs">
|
|
131
|
+
<el-tab-pane label="流程图" name="chart">
|
|
132
|
+
<div class="wb-detail__chart">
|
|
133
|
+
<FlowProgressDiagram
|
|
134
|
+
:workflow="activeInstance.definition.workflow"
|
|
135
|
+
:state="activeState"
|
|
136
|
+
:prediction="activePrediction"
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
139
|
+
</el-tab-pane>
|
|
140
|
+
|
|
141
|
+
<el-tab-pane label="表单" name="form">
|
|
142
|
+
<div class="wb-detail__scroll">
|
|
143
|
+
<div class="wb-info-bar">
|
|
144
|
+
<span>发起人</span>
|
|
145
|
+
<strong>{{ activeState?.initiator?.name || activeInstance.initiator?.name }}</strong>
|
|
146
|
+
<span class="wb-muted">{{ activeState?.initiator?.deptName || '' }}</span>
|
|
147
|
+
<span class="wb-info-bar__time">{{ formatDateTime(activeState?.startedAt) }}</span>
|
|
148
|
+
</div>
|
|
149
|
+
<el-descriptions v-if="activeVariables.length" :column="2" border size="small">
|
|
150
|
+
<el-descriptions-item
|
|
151
|
+
v-for="row in activeVariables"
|
|
152
|
+
:key="row.key"
|
|
153
|
+
:label="row.label"
|
|
154
|
+
>
|
|
155
|
+
{{ row.value }}
|
|
156
|
+
</el-descriptions-item>
|
|
157
|
+
</el-descriptions>
|
|
158
|
+
<el-empty v-else description="本流程未填写表单数据" :image-size="60" />
|
|
159
|
+
<el-collapse class="wb-snapshot">
|
|
160
|
+
<el-collapse-item title="表单变量 JSON" name="variables">
|
|
161
|
+
<pre>{{ JSON.stringify(activeState?.variables || {}, null, 2) }}</pre>
|
|
162
|
+
</el-collapse-item>
|
|
163
|
+
</el-collapse>
|
|
164
|
+
</div>
|
|
165
|
+
</el-tab-pane>
|
|
166
|
+
|
|
167
|
+
<el-tab-pane label="轨迹" name="trace">
|
|
168
|
+
<div class="wb-detail__scroll">
|
|
169
|
+
<el-timeline v-if="timeline.length" class="wb-timeline">
|
|
170
|
+
<el-timeline-item
|
|
171
|
+
v-for="event in timeline"
|
|
172
|
+
:key="event.id"
|
|
173
|
+
:timestamp="formatDateTime(event.at)"
|
|
174
|
+
:type="eventType(event)"
|
|
175
|
+
placement="top"
|
|
176
|
+
>
|
|
177
|
+
<div class="wb-event">
|
|
178
|
+
<el-tag
|
|
179
|
+
v-if="activeState?.cycle > 1 && event.cycle"
|
|
180
|
+
size="small"
|
|
181
|
+
type="info"
|
|
182
|
+
effect="plain"
|
|
183
|
+
>
|
|
184
|
+
第 {{ event.cycle }} 轮
|
|
185
|
+
</el-tag>
|
|
186
|
+
{{ eventTitle(event) }}
|
|
187
|
+
</div>
|
|
188
|
+
<div v-if="eventMeta(event)" class="wb-event__meta">{{ eventMeta(event) }}</div>
|
|
189
|
+
</el-timeline-item>
|
|
190
|
+
</el-timeline>
|
|
191
|
+
<el-empty v-else description="暂无流程记录" :image-size="60" />
|
|
192
|
+
|
|
193
|
+
<div v-if="activeState?.ccRecords?.length" class="wb-trace-block">
|
|
194
|
+
<h4>抄送记录</h4>
|
|
195
|
+
<div v-for="record in activeState.ccRecords" :key="record.id" class="wb-cc-row">
|
|
196
|
+
<span>{{ record.nodeName }}</span>
|
|
197
|
+
<el-tag
|
|
198
|
+
v-for="user in record.users"
|
|
199
|
+
:key="user.id"
|
|
200
|
+
size="small"
|
|
201
|
+
type="warning"
|
|
202
|
+
effect="plain"
|
|
203
|
+
>
|
|
204
|
+
{{ user.name }}
|
|
205
|
+
</el-tag>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<div v-if="activeState?.warnings?.length" class="wb-trace-block">
|
|
210
|
+
<h4>运行提醒</h4>
|
|
211
|
+
<el-alert
|
|
212
|
+
v-for="(warning, index) in activeState.warnings"
|
|
213
|
+
:key="`${warning.code}_${index}`"
|
|
214
|
+
:title="warning.message"
|
|
215
|
+
type="warning"
|
|
216
|
+
:closable="false"
|
|
217
|
+
show-icon
|
|
218
|
+
class="wb-alert"
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
<el-collapse class="wb-snapshot">
|
|
223
|
+
<el-collapse-item title="运行快照 JSON" name="state">
|
|
224
|
+
<pre>{{ stateJSON }}</pre>
|
|
225
|
+
</el-collapse-item>
|
|
226
|
+
</el-collapse>
|
|
227
|
+
</div>
|
|
228
|
+
</el-tab-pane>
|
|
229
|
+
</el-tabs>
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<div v-else class="wb-panel wb-panel--empty">
|
|
233
|
+
<el-empty description="选择左侧流程实例,或发起一个新的流程">
|
|
234
|
+
<el-button type="primary" :icon="Plus" @click="openCreate">发起流程</el-button>
|
|
235
|
+
</el-empty>
|
|
236
|
+
</div>
|
|
237
|
+
</main>
|
|
238
|
+
|
|
239
|
+
<aside class="flow-workbench__rail">
|
|
240
|
+
<div class="wb-panel wb-panel--users">
|
|
241
|
+
<div class="wb-panel__head">
|
|
242
|
+
<div>
|
|
243
|
+
<h3>用户</h3>
|
|
244
|
+
<span>点击切换当前操作人</span>
|
|
245
|
+
</div>
|
|
246
|
+
<el-button link type="primary" :icon="Setting" @click="emit('manage-users')">
|
|
247
|
+
用户管理
|
|
248
|
+
</el-button>
|
|
249
|
+
</div>
|
|
250
|
+
<div class="wb-user-list">
|
|
251
|
+
<button
|
|
252
|
+
v-for="user in org.users"
|
|
253
|
+
:key="user.id"
|
|
254
|
+
type="button"
|
|
255
|
+
class="wb-user"
|
|
256
|
+
:class="{ 'is-active': sameId(user.id, currentUserId) }"
|
|
257
|
+
@click="currentUserId = user.id"
|
|
258
|
+
>
|
|
259
|
+
<span class="wb-user__avatar">{{ (user.realName || '用').slice(0, 1) }}</span>
|
|
260
|
+
<span class="wb-user__main">
|
|
261
|
+
<span class="wb-user__name">
|
|
262
|
+
{{ user.realName }}
|
|
263
|
+
<span v-if="sameId(user.id, currentUserId)" class="wb-user__current">当前</span>
|
|
264
|
+
</span>
|
|
265
|
+
<span class="wb-user__meta">
|
|
266
|
+
{{ deptName(user.deptId) }} · {{ roleNamesOf(user) || user.title || '成员' }}
|
|
267
|
+
</span>
|
|
268
|
+
</span>
|
|
269
|
+
<span v-if="pendingCountForUser(user.id)" class="wb-user__badge">
|
|
270
|
+
{{ pendingCountForUser(user.id) }}
|
|
271
|
+
</span>
|
|
272
|
+
</button>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<div class="wb-panel wb-panel--tasks">
|
|
277
|
+
<div class="wb-panel__head">
|
|
278
|
+
<div>
|
|
279
|
+
<h3>我的待办</h3>
|
|
280
|
+
<span>{{ currentUser?.realName || '未选择' }} · {{ globalPendingItems.length }} 个</span>
|
|
281
|
+
</div>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
<el-empty
|
|
285
|
+
v-if="!globalPendingItems.length"
|
|
286
|
+
:description="emptyTaskText"
|
|
287
|
+
:image-size="56"
|
|
288
|
+
/>
|
|
289
|
+
<article
|
|
290
|
+
v-for="item in globalPendingItems"
|
|
291
|
+
:key="`${item.instanceId}_${item.task.id}`"
|
|
292
|
+
class="wb-task"
|
|
293
|
+
>
|
|
294
|
+
<div class="wb-task__head">
|
|
295
|
+
<strong>{{ item.task.nodeName }}</strong>
|
|
296
|
+
<el-tag
|
|
297
|
+
size="small"
|
|
298
|
+
:type="item.task.kind === 'submit' ? 'warning' : 'info'"
|
|
299
|
+
>
|
|
300
|
+
{{ item.task.kind === 'submit' ? '待重新提交' : signLabelOf(item.task) }}
|
|
301
|
+
</el-tag>
|
|
302
|
+
</div>
|
|
303
|
+
<button
|
|
304
|
+
type="button"
|
|
305
|
+
class="wb-task__instance"
|
|
306
|
+
@click="selectInstance(item.instanceId)"
|
|
307
|
+
>
|
|
308
|
+
{{ item.instanceName }}
|
|
309
|
+
</button>
|
|
310
|
+
<div v-if="item.task.kind !== 'submit'" class="wb-task__progress">
|
|
311
|
+
已同意 {{ item.task.approvedBy.length }} / {{ item.task.approvers.length }}
|
|
312
|
+
</div>
|
|
313
|
+
<div class="wb-task__approvers">
|
|
314
|
+
<el-tag
|
|
315
|
+
v-for="approver in item.task.approvers"
|
|
316
|
+
:key="approver.id"
|
|
317
|
+
size="small"
|
|
318
|
+
:type="hasApproved(item.task, approver) ? 'success' : 'primary'"
|
|
319
|
+
effect="plain"
|
|
320
|
+
>
|
|
321
|
+
{{ approver.name }}{{ hasApproved(item.task, approver) ? ' ✓' : '' }}
|
|
322
|
+
</el-tag>
|
|
323
|
+
</div>
|
|
324
|
+
<div v-if="item.task.dueAt" class="wb-task__deadline">
|
|
325
|
+
超时时间 {{ formatDateTime(item.task.dueAt) }} ·
|
|
326
|
+
{{ item.task.termMode === 1 ? '自动拒绝' : '自动通过' }}
|
|
327
|
+
</div>
|
|
328
|
+
<div v-if="lastComment(item.task)" class="wb-task__comment">
|
|
329
|
+
“{{ lastComment(item.task) }}”
|
|
330
|
+
</div>
|
|
331
|
+
<div
|
|
332
|
+
v-if="item.task.kind !== 'submit' && rejectPolicySummary(item.task)"
|
|
333
|
+
class="wb-task__policy"
|
|
334
|
+
>
|
|
335
|
+
{{ rejectPolicySummary(item.task) }}
|
|
336
|
+
</div>
|
|
337
|
+
<div class="wb-task__actions">
|
|
338
|
+
<template v-if="item.task.kind === 'submit'">
|
|
339
|
+
<el-button
|
|
340
|
+
type="primary"
|
|
341
|
+
size="small"
|
|
342
|
+
@click="openGlobalTask(item, 'resubmit')"
|
|
343
|
+
>
|
|
344
|
+
重新提交
|
|
345
|
+
</el-button>
|
|
346
|
+
</template>
|
|
347
|
+
<template v-else>
|
|
348
|
+
<el-button type="success" size="small" @click="openGlobalTask(item, 'approve')">
|
|
349
|
+
同意
|
|
350
|
+
</el-button>
|
|
351
|
+
<el-button type="danger" plain size="small" @click="openGlobalTask(item, 'reject')">
|
|
352
|
+
拒绝
|
|
353
|
+
</el-button>
|
|
354
|
+
<el-button
|
|
355
|
+
v-if="canTransfer(item.task)"
|
|
356
|
+
plain
|
|
357
|
+
size="small"
|
|
358
|
+
@click="openGlobalTask(item, 'transfer')"
|
|
359
|
+
>
|
|
360
|
+
转交
|
|
361
|
+
</el-button>
|
|
362
|
+
</template>
|
|
363
|
+
</div>
|
|
364
|
+
</article>
|
|
365
|
+
|
|
366
|
+
<div v-if="globalCcItems.length" class="wb-cc-list">
|
|
367
|
+
<h4>我的抄送</h4>
|
|
368
|
+
<div
|
|
369
|
+
v-for="item in globalCcItems"
|
|
370
|
+
:key="`${item.instanceId}_${item.record.id}`"
|
|
371
|
+
class="wb-cc-row"
|
|
372
|
+
>
|
|
373
|
+
<button
|
|
374
|
+
type="button"
|
|
375
|
+
class="wb-task__instance"
|
|
376
|
+
@click="selectInstance(item.instanceId)"
|
|
377
|
+
>
|
|
378
|
+
{{ item.instanceName }}
|
|
379
|
+
</button>
|
|
380
|
+
<span>{{ item.record.nodeName }}</span>
|
|
381
|
+
<el-tag
|
|
382
|
+
v-for="user in item.record.users"
|
|
383
|
+
:key="user.id"
|
|
384
|
+
size="small"
|
|
385
|
+
type="warning"
|
|
386
|
+
effect="plain"
|
|
387
|
+
>
|
|
388
|
+
{{ user.name }}
|
|
389
|
+
</el-tag>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
</aside>
|
|
394
|
+
|
|
395
|
+
<el-dialog
|
|
396
|
+
v-model="createVisible"
|
|
397
|
+
title="发起流程"
|
|
398
|
+
width="1120px"
|
|
399
|
+
append-to-body
|
|
400
|
+
destroy-on-close
|
|
401
|
+
class="wb-create-dialog"
|
|
402
|
+
>
|
|
403
|
+
<el-tabs v-model="createTab" class="wb-create__tabs">
|
|
404
|
+
<el-tab-pane label="填写表单" name="form">
|
|
405
|
+
<div class="wb-create">
|
|
406
|
+
<div class="wb-create__form">
|
|
407
|
+
<FormViewer
|
|
408
|
+
ref="createFormRef"
|
|
409
|
+
:form-config="createDefinition?.form?.components || []"
|
|
410
|
+
/>
|
|
411
|
+
</div>
|
|
412
|
+
<aside class="wb-create__side">
|
|
413
|
+
<div class="wb-create__field">
|
|
414
|
+
<label>流程定义</label>
|
|
415
|
+
<el-select
|
|
416
|
+
v-model="createDefinitionId"
|
|
417
|
+
filterable
|
|
418
|
+
@change="handleCreateDefinitionChange"
|
|
419
|
+
>
|
|
420
|
+
<el-option
|
|
421
|
+
v-for="item in availableDefinitions"
|
|
422
|
+
:key="item.meta?.id"
|
|
423
|
+
:label="item.meta?.name || '未命名流程'"
|
|
424
|
+
:value="item.meta?.id"
|
|
425
|
+
/>
|
|
426
|
+
</el-select>
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
<div class="wb-create__field">
|
|
430
|
+
<label>发起人</label>
|
|
431
|
+
<el-select v-model="createInitiatorId" filterable>
|
|
432
|
+
<el-option
|
|
433
|
+
v-for="user in org.users"
|
|
434
|
+
:key="user.id"
|
|
435
|
+
:label="`${user.realName} · ${deptName(user.deptId)}`"
|
|
436
|
+
:value="user.id"
|
|
437
|
+
/>
|
|
438
|
+
</el-select>
|
|
439
|
+
</div>
|
|
440
|
+
|
|
441
|
+
<div v-if="createCcNodes.length" class="wb-create__cc">
|
|
442
|
+
<h4>发起人自选抄送</h4>
|
|
443
|
+
<div v-for="node in createCcNodes" :key="node.nodeId" class="wb-create__cc-row">
|
|
444
|
+
<span>{{ node.nodeName }}</span>
|
|
445
|
+
<el-select
|
|
446
|
+
v-model="createCcSelections[node.nodeId]"
|
|
447
|
+
multiple
|
|
448
|
+
collapse-tags
|
|
449
|
+
collapse-tags-tooltip
|
|
450
|
+
clearable
|
|
451
|
+
placeholder="不额外抄送"
|
|
452
|
+
>
|
|
453
|
+
<el-option
|
|
454
|
+
v-for="user in org.users"
|
|
455
|
+
:key="user.id"
|
|
456
|
+
:label="`${user.realName} · ${deptName(user.deptId)}`"
|
|
457
|
+
:value="user.id"
|
|
458
|
+
/>
|
|
459
|
+
</el-select>
|
|
460
|
+
</div>
|
|
461
|
+
</div>
|
|
462
|
+
|
|
463
|
+
<el-alert
|
|
464
|
+
type="info"
|
|
465
|
+
:closable="false"
|
|
466
|
+
show-icon
|
|
467
|
+
title="发起后将在本机创建流程实例,可在左侧流程列表中处理待办。"
|
|
468
|
+
/>
|
|
469
|
+
</aside>
|
|
470
|
+
</div>
|
|
471
|
+
</el-tab-pane>
|
|
472
|
+
|
|
473
|
+
<el-tab-pane label="流程图预测" name="prediction">
|
|
474
|
+
<div class="wb-create__preview">
|
|
475
|
+
<div class="wb-create__preview-head">
|
|
476
|
+
<span>基于当前表单数据和测试组织预测,不会创建实例</span>
|
|
477
|
+
<el-button size="small" :icon="DataAnalysis" @click="refreshCreatePrediction">
|
|
478
|
+
刷新预测
|
|
479
|
+
</el-button>
|
|
480
|
+
</div>
|
|
481
|
+
<div v-if="createPrediction" class="wb-create__preview-chart">
|
|
482
|
+
<FlowProgressDiagram
|
|
483
|
+
:workflow="createDefinition?.workflow"
|
|
484
|
+
:prediction="createPrediction"
|
|
485
|
+
/>
|
|
486
|
+
</div>
|
|
487
|
+
<el-empty v-else description="点击「刷新预测」生成流程图" :image-size="60" />
|
|
488
|
+
</div>
|
|
489
|
+
</el-tab-pane>
|
|
490
|
+
</el-tabs>
|
|
491
|
+
|
|
492
|
+
<template #footer>
|
|
493
|
+
<div class="wb-create__footer">
|
|
494
|
+
<span class="wb-muted">审批人按用户与角色配置解析</span>
|
|
495
|
+
<el-button @click="createVisible = false">取消</el-button>
|
|
496
|
+
<el-button :icon="DataAnalysis" :loading="predicting" @click="previewCreate">
|
|
497
|
+
预测流程图
|
|
498
|
+
</el-button>
|
|
499
|
+
<el-button type="primary" :icon="VideoPlay" :loading="startingNew" @click="startNewTest">
|
|
500
|
+
发起流程
|
|
501
|
+
</el-button>
|
|
502
|
+
</div>
|
|
503
|
+
</template>
|
|
504
|
+
</el-dialog>
|
|
505
|
+
|
|
506
|
+
<el-dialog
|
|
507
|
+
v-model="action.visible"
|
|
508
|
+
:title="actionTitle"
|
|
509
|
+
:width="action.type === 'resubmit' ? '920px' : '480px'"
|
|
510
|
+
append-to-body
|
|
511
|
+
destroy-on-close
|
|
512
|
+
@opened="handleActionOpened"
|
|
513
|
+
>
|
|
514
|
+
<div v-if="action.task" class="wb-dialog-task">
|
|
515
|
+
<span>节点</span>
|
|
516
|
+
<strong>{{ action.task.nodeName }}</strong>
|
|
517
|
+
<span class="wb-muted">当前身份:{{ currentUser?.realName }}</span>
|
|
518
|
+
</div>
|
|
519
|
+
<div v-if="action.type === 'resubmit'" class="wb-resubmit">
|
|
520
|
+
<el-alert
|
|
521
|
+
type="warning"
|
|
522
|
+
:closable="false"
|
|
523
|
+
show-icon
|
|
524
|
+
title="流程已退回,请修改表单后重新提交"
|
|
525
|
+
class="wb-resubmit__tip"
|
|
526
|
+
/>
|
|
527
|
+
<FormViewer ref="resubmitFormRef" :form-config="resubmitFormConfig" />
|
|
528
|
+
</div>
|
|
529
|
+
<el-form v-else label-width="84px">
|
|
530
|
+
<el-form-item v-if="action.type === 'transfer'" label="转交给">
|
|
531
|
+
<el-select v-model="action.targetUserId" filterable placeholder="选择目标用户" style="width: 100%">
|
|
532
|
+
<el-option
|
|
533
|
+
v-for="user in transferCandidates"
|
|
534
|
+
:key="user.id"
|
|
535
|
+
:label="`${user.realName} · ${deptName(user.deptId)}`"
|
|
536
|
+
:value="user.id"
|
|
537
|
+
/>
|
|
538
|
+
</el-select>
|
|
539
|
+
</el-form-item>
|
|
540
|
+
<el-form-item label="审批意见">
|
|
541
|
+
<el-input
|
|
542
|
+
v-model="action.comment"
|
|
543
|
+
type="textarea"
|
|
544
|
+
:rows="3"
|
|
545
|
+
:placeholder="action.type === 'reject' ? '请输入拒绝原因(可选)' : '请输入意见(可选)'"
|
|
546
|
+
/>
|
|
547
|
+
</el-form-item>
|
|
548
|
+
</el-form>
|
|
549
|
+
<el-alert
|
|
550
|
+
v-if="action.type === 'reject'"
|
|
551
|
+
:type="actionRejectInfo?.wouldTerminate ? 'error' : 'warning'"
|
|
552
|
+
:closable="false"
|
|
553
|
+
show-icon
|
|
554
|
+
:title="`拒绝后处理:${actionRejectInfo?.strategy === 'terminate' ? '直接结束,不通过审批' : rejectStrategyOf(action.task)}`"
|
|
555
|
+
:description="rejectImpactText"
|
|
556
|
+
/>
|
|
557
|
+
<template #footer>
|
|
558
|
+
<el-button @click="action.visible = false">取消</el-button>
|
|
559
|
+
<el-button
|
|
560
|
+
:type="action.type === 'reject' ? 'danger' : 'primary'"
|
|
561
|
+
:loading="action.submitting"
|
|
562
|
+
:disabled="action.type === 'transfer' && !action.targetUserId"
|
|
563
|
+
@click="confirmAction"
|
|
564
|
+
>
|
|
565
|
+
确认{{ actionTitle }}
|
|
566
|
+
</el-button>
|
|
567
|
+
</template>
|
|
568
|
+
</el-dialog>
|
|
569
|
+
|
|
570
|
+
<input
|
|
571
|
+
ref="instanceFileInput"
|
|
572
|
+
type="file"
|
|
573
|
+
accept="application/json,.json"
|
|
574
|
+
class="wb-hidden-input"
|
|
575
|
+
@change="handleInstanceImportFile"
|
|
576
|
+
/>
|
|
577
|
+
</div>
|
|
578
|
+
</template>
|
|
579
|
+
|
|
580
|
+
<script setup>
|
|
581
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, shallowRef, watch } from 'vue'
|
|
582
|
+
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
583
|
+
import {
|
|
584
|
+
DataAnalysis,
|
|
585
|
+
Delete,
|
|
586
|
+
Download,
|
|
587
|
+
Plus,
|
|
588
|
+
Setting,
|
|
589
|
+
Upload,
|
|
590
|
+
VideoPlay
|
|
591
|
+
} from 'gbicons'
|
|
592
|
+
import { FormViewer, enrichFormVariables } from 'gbformdesign'
|
|
593
|
+
import FlowProgressDiagram from './diagram/FlowProgressDiagram.vue'
|
|
594
|
+
import {
|
|
595
|
+
createMockRuntimeContext,
|
|
596
|
+
mockDepartments,
|
|
597
|
+
mockRoles,
|
|
598
|
+
mockUsers
|
|
599
|
+
} from './mock.js'
|
|
600
|
+
import { createFlowRuntime } from '../core/flow/runtime.js'
|
|
601
|
+
import { predictWorkflow } from '../core/flow/prediction.js'
|
|
602
|
+
import { findNodeById } from '../core/flow/node.js'
|
|
603
|
+
import { downloadJSON } from '../core/flow/index.js'
|
|
604
|
+
import { flowStorage } from '../storage.js'
|
|
605
|
+
import { formatDateTime, formatFieldValue } from '../utils/format.js'
|
|
606
|
+
import {
|
|
607
|
+
FlowNodeType,
|
|
608
|
+
RejectStrategyLabel,
|
|
609
|
+
SignModeLabel
|
|
610
|
+
} from '../core/flow/flowConstant.js'
|
|
611
|
+
|
|
612
|
+
defineOptions({ name: 'GbFlowTestPanel' })
|
|
613
|
+
|
|
614
|
+
const props = defineProps({
|
|
615
|
+
definition: { type: Object, default: null },
|
|
616
|
+
definitions: { type: Array, default: () => [] },
|
|
617
|
+
users: { type: Array, default: () => mockUsers },
|
|
618
|
+
departments: { type: Array, default: () => mockDepartments },
|
|
619
|
+
roles: { type: Array, default: () => mockRoles },
|
|
620
|
+
initiatorId: { type: [String, Number], default: null },
|
|
621
|
+
// 首次进入(本机尚无存档)时预置的实例,便于演示与联调直接看到列表
|
|
622
|
+
initialInstances: { type: Array, default: () => [] },
|
|
623
|
+
// 外层(如流程中心)自己渲染实例列表时置 false,避免出现两个列表
|
|
624
|
+
showInstanceList: { type: Boolean, default: true }
|
|
625
|
+
})
|
|
626
|
+
|
|
627
|
+
const emit = defineEmits(['manage-users', 'instances-change', 'operator-change'])
|
|
628
|
+
|
|
629
|
+
const STORAGE_KEY = 'gb-flowengine-workbench-v1'
|
|
630
|
+
const clone = (value) => JSON.parse(JSON.stringify(value))
|
|
631
|
+
const sameId = (left, right) =>
|
|
632
|
+
left !== undefined && right !== undefined && String(left) === String(right)
|
|
633
|
+
const nowIso = () => new Date().toISOString()
|
|
634
|
+
|
|
635
|
+
const STATUS_META = {
|
|
636
|
+
idle: { label: '未开始', type: 'info' },
|
|
637
|
+
running: { label: '运行中', type: 'warning' },
|
|
638
|
+
completed: { label: '已完成', type: 'success' },
|
|
639
|
+
rejected: { label: '已拒绝', type: 'danger' },
|
|
640
|
+
cancelled: { label: '已取消', type: 'info' },
|
|
641
|
+
revoked: { label: '已撤回', type: 'info' }
|
|
642
|
+
}
|
|
643
|
+
const FILTERS = [
|
|
644
|
+
{ value: 'all', label: '全部' },
|
|
645
|
+
{ value: 'running', label: '进行中' },
|
|
646
|
+
{ value: 'completed', label: '已完成' },
|
|
647
|
+
{ value: 'rejected', label: '已拒绝' },
|
|
648
|
+
{ value: 'revoked', label: '已撤回' }
|
|
649
|
+
]
|
|
650
|
+
const TIMELINE_EVENTS = new Set([
|
|
651
|
+
'start',
|
|
652
|
+
'approve',
|
|
653
|
+
'reject',
|
|
654
|
+
'transfer',
|
|
655
|
+
'cc',
|
|
656
|
+
'branch',
|
|
657
|
+
'split',
|
|
658
|
+
'join',
|
|
659
|
+
'autoApprove',
|
|
660
|
+
'return',
|
|
661
|
+
'resubmit',
|
|
662
|
+
'pass',
|
|
663
|
+
'rejectNode',
|
|
664
|
+
'rejectLimitReached',
|
|
665
|
+
'cancel',
|
|
666
|
+
'revoke',
|
|
667
|
+
'timeoutApprove',
|
|
668
|
+
'timeoutReject',
|
|
669
|
+
'finished'
|
|
670
|
+
])
|
|
671
|
+
|
|
672
|
+
const org = reactive({
|
|
673
|
+
users: clone(props.users),
|
|
674
|
+
departments: clone(props.departments),
|
|
675
|
+
roles: clone(props.roles)
|
|
676
|
+
})
|
|
677
|
+
|
|
678
|
+
const instances = ref([])
|
|
679
|
+
const activeId = ref(null)
|
|
680
|
+
|
|
681
|
+
// 外层流程中心需要渲染自己的实例列表,这里把实例变化同步出去
|
|
682
|
+
watch(instances, (value) => emit('instances-change', clone(value)), { deep: true, immediate: true })
|
|
683
|
+
const activeTab = ref('chart')
|
|
684
|
+
const statusFilter = ref('all')
|
|
685
|
+
const currentUserId = ref(props.initiatorId ?? props.users[0]?.id ?? null)
|
|
686
|
+
const initiatorId = ref(currentUserId.value)
|
|
687
|
+
const runtime = shallowRef(null)
|
|
688
|
+
const activeState = ref(null)
|
|
689
|
+
const autoRunning = ref(false)
|
|
690
|
+
const action = reactive({
|
|
691
|
+
visible: false,
|
|
692
|
+
type: 'approve',
|
|
693
|
+
task: null,
|
|
694
|
+
taskInstanceId: null,
|
|
695
|
+
comment: '',
|
|
696
|
+
targetUserId: null,
|
|
697
|
+
resubmitData: null,
|
|
698
|
+
submitting: false
|
|
699
|
+
})
|
|
700
|
+
const resubmitFormRef = ref(null)
|
|
701
|
+
const instanceFileInput = ref(null)
|
|
702
|
+
let deadlineTimer = null
|
|
703
|
+
|
|
704
|
+
const createVisible = ref(false)
|
|
705
|
+
const createTab = ref('form')
|
|
706
|
+
const createDefinitionId = ref(null)
|
|
707
|
+
const createInitiatorId = ref(currentUserId.value)
|
|
708
|
+
const createFormRef = ref(null)
|
|
709
|
+
const createCcSelections = ref({})
|
|
710
|
+
const createPrediction = ref(null)
|
|
711
|
+
const startingNew = ref(false)
|
|
712
|
+
const predicting = ref(false)
|
|
713
|
+
|
|
714
|
+
let storageReady = false
|
|
715
|
+
let persistTimer = null
|
|
716
|
+
|
|
717
|
+
const availableDefinitions = computed(() => {
|
|
718
|
+
const list = props.definitions?.length
|
|
719
|
+
? props.definitions
|
|
720
|
+
: props.definition
|
|
721
|
+
? [props.definition]
|
|
722
|
+
: []
|
|
723
|
+
return list.filter(
|
|
724
|
+
(item) => !item?.meta?.status || item.meta.status === 'published'
|
|
725
|
+
)
|
|
726
|
+
})
|
|
727
|
+
const createDefinition = computed(
|
|
728
|
+
() =>
|
|
729
|
+
availableDefinitions.value.find(
|
|
730
|
+
(item) => String(item.meta?.id) === String(createDefinitionId.value)
|
|
731
|
+
) ||
|
|
732
|
+
availableDefinitions.value[0] ||
|
|
733
|
+
null
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
const userIndex = computed(() => new Map(org.users.map((user) => [String(user.id), user])))
|
|
737
|
+
const deptIndex = computed(
|
|
738
|
+
() => new Map(org.departments.map((dept) => [String(dept.id), dept]))
|
|
739
|
+
)
|
|
740
|
+
const roleIndex = computed(
|
|
741
|
+
() => new Map(org.roles.map((role) => [String(role.id), role]))
|
|
742
|
+
)
|
|
743
|
+
const currentUser = computed(() => userIndex.value.get(String(currentUserId.value)) || null)
|
|
744
|
+
const activeInstance = computed(
|
|
745
|
+
() => instances.value.find((instance) => instance.id === activeId.value) || null
|
|
746
|
+
)
|
|
747
|
+
const activeStatusMeta = computed(
|
|
748
|
+
() => STATUS_META[activeState.value?.status] || STATUS_META.idle
|
|
749
|
+
)
|
|
750
|
+
const isActiveRunning = computed(() => activeState.value?.status === 'running')
|
|
751
|
+
const stateJSON = computed(() => JSON.stringify(activeState.value || {}, null, 2))
|
|
752
|
+
|
|
753
|
+
const filteredInstances = computed(() => {
|
|
754
|
+
if (statusFilter.value === 'all') return instances.value
|
|
755
|
+
return instances.value.filter((instance) => instance.state?.status === statusFilter.value)
|
|
756
|
+
})
|
|
757
|
+
|
|
758
|
+
const activePrediction = computed(() => {
|
|
759
|
+
const instance = activeInstance.value
|
|
760
|
+
if (!instance) return null
|
|
761
|
+
try {
|
|
762
|
+
return predictWorkflow({
|
|
763
|
+
definition: instance.definition,
|
|
764
|
+
data: instance.state?.variables || {},
|
|
765
|
+
context: contextForInstance(instance),
|
|
766
|
+
initiator: instance.state?.initiator || instance.initiator
|
|
767
|
+
})
|
|
768
|
+
} catch {
|
|
769
|
+
return null
|
|
770
|
+
}
|
|
771
|
+
})
|
|
772
|
+
|
|
773
|
+
const globalPendingItems = computed(() => {
|
|
774
|
+
const items = []
|
|
775
|
+
instances.value.forEach((instance) => {
|
|
776
|
+
pendingTasksFor(instance.state, currentUserId.value).forEach((task) => {
|
|
777
|
+
items.push({
|
|
778
|
+
instanceId: instance.id,
|
|
779
|
+
instanceName: instance.name,
|
|
780
|
+
task
|
|
781
|
+
})
|
|
782
|
+
})
|
|
783
|
+
})
|
|
784
|
+
return items.sort((left, right) =>
|
|
785
|
+
String(right.task.createdAt).localeCompare(String(left.task.createdAt))
|
|
786
|
+
)
|
|
787
|
+
})
|
|
788
|
+
|
|
789
|
+
const globalCcItems = computed(() => {
|
|
790
|
+
const items = []
|
|
791
|
+
instances.value.forEach((instance) => {
|
|
792
|
+
const state = instance.state
|
|
793
|
+
const currentCycle = state?.cycle || 1
|
|
794
|
+
const lastReturnAt = (state?.history || [])
|
|
795
|
+
.filter((event) => event.event === 'return')
|
|
796
|
+
.map((event) => event.at)
|
|
797
|
+
.sort()
|
|
798
|
+
.at(-1)
|
|
799
|
+
;(state?.ccRecords || []).forEach((record) => {
|
|
800
|
+
const inCycle = record.cycle
|
|
801
|
+
? Number(record.cycle) === currentCycle
|
|
802
|
+
: !lastReturnAt || String(record.createdAt || '') >= String(lastReturnAt)
|
|
803
|
+
if (
|
|
804
|
+
inCycle &&
|
|
805
|
+
(record.users || []).some((user) => sameId(user.id, currentUserId.value))
|
|
806
|
+
) {
|
|
807
|
+
items.push({ instanceId: instance.id, instanceName: instance.name, record })
|
|
808
|
+
}
|
|
809
|
+
})
|
|
810
|
+
})
|
|
811
|
+
return items.sort((left, right) =>
|
|
812
|
+
String(right.record.createdAt).localeCompare(String(left.record.createdAt))
|
|
813
|
+
)
|
|
814
|
+
})
|
|
815
|
+
|
|
816
|
+
const canRevokeActive = computed(
|
|
817
|
+
() =>
|
|
818
|
+
activeState.value?.status === 'running' &&
|
|
819
|
+
sameId(activeState.value?.initiator?.id, currentUserId.value)
|
|
820
|
+
)
|
|
821
|
+
|
|
822
|
+
const resubmitFormConfig = computed(
|
|
823
|
+
() => activeInstance.value?.definition?.form?.components || []
|
|
824
|
+
)
|
|
825
|
+
|
|
826
|
+
const emptyTaskText = computed(() => {
|
|
827
|
+
if (!currentUser.value) return '请选择当前操作人'
|
|
828
|
+
return '当前身份在所有流程里都没有待办'
|
|
829
|
+
})
|
|
830
|
+
|
|
831
|
+
const activeVariables = computed(() => {
|
|
832
|
+
const components = activeInstance.value?.definition?.form?.components || []
|
|
833
|
+
const variableMap = new Map(
|
|
834
|
+
enrichFormVariables(components).map((item) => [item.variableName, item])
|
|
835
|
+
)
|
|
836
|
+
const variables = activeState.value?.variables || {}
|
|
837
|
+
return Object.entries(variables)
|
|
838
|
+
.filter(([key]) => variableMap.size === 0 || variableMap.has(key))
|
|
839
|
+
.map(([key, value]) => ({
|
|
840
|
+
key,
|
|
841
|
+
label: variableMap.get(key)?.label || key,
|
|
842
|
+
value: formatFieldValue(value)
|
|
843
|
+
}))
|
|
844
|
+
})
|
|
845
|
+
|
|
846
|
+
const timeline = computed(() =>
|
|
847
|
+
[...(activeState.value?.history || [])]
|
|
848
|
+
.filter((event) => TIMELINE_EVENTS.has(event.event))
|
|
849
|
+
.slice(-100)
|
|
850
|
+
.reverse()
|
|
851
|
+
)
|
|
852
|
+
|
|
853
|
+
const transferCandidates = computed(() =>
|
|
854
|
+
org.users.filter(
|
|
855
|
+
(user) =>
|
|
856
|
+
!action.task?.approvers.some((approver) => sameId(approver.id, user.id)) &&
|
|
857
|
+
!sameId(user.id, currentUserId.value)
|
|
858
|
+
)
|
|
859
|
+
)
|
|
860
|
+
|
|
861
|
+
const actionTitle = computed(
|
|
862
|
+
() =>
|
|
863
|
+
({ approve: '同意', reject: '拒绝', transfer: '转交', resubmit: '重新提交' })[
|
|
864
|
+
action.type
|
|
865
|
+
] || '审批'
|
|
866
|
+
)
|
|
867
|
+
|
|
868
|
+
const actionRejectInfo = computed(() => {
|
|
869
|
+
if (action.type !== 'reject' || !action.task || !runtime.value) return null
|
|
870
|
+
try {
|
|
871
|
+
return runtime.value.getRejectInfo(action.task.nodeId)
|
|
872
|
+
} catch {
|
|
873
|
+
return null
|
|
874
|
+
}
|
|
875
|
+
})
|
|
876
|
+
|
|
877
|
+
const rejectImpactText = computed(() => {
|
|
878
|
+
const info = actionRejectInfo.value
|
|
879
|
+
if (!info) return '拒绝后将按节点配置处理。'
|
|
880
|
+
if (info.strategy === 'terminate') {
|
|
881
|
+
return '本次拒绝后流程直接结束,判定为不通过审批。'
|
|
882
|
+
}
|
|
883
|
+
if (info.unlimited) {
|
|
884
|
+
return '退回后流程进入下一轮重新审批;当前节点设置为不限退回次数。'
|
|
885
|
+
}
|
|
886
|
+
if (info.remaining <= 0) {
|
|
887
|
+
return `已退回 ${info.retriesUsed} 次,达到允许上限(${info.retryLimit} 次)。本次拒绝将直接终止流程,判定为不通过审批。`
|
|
888
|
+
}
|
|
889
|
+
return `已退回 ${info.retriesUsed} 次,允许 ${info.retryLimit} 次;本次退回后还可再退 ${info.remaining - 1} 次。超过上限后流程将自动不通过。`
|
|
890
|
+
})
|
|
891
|
+
|
|
892
|
+
function rejectPolicySummary(task) {
|
|
893
|
+
if (!task || !runtime.value) return ''
|
|
894
|
+
try {
|
|
895
|
+
const info = runtime.value.getRejectInfo(task.nodeId)
|
|
896
|
+
if (!info) return ''
|
|
897
|
+
if (info.strategy === 'terminate') return '拒绝即结束 · 不通过审批'
|
|
898
|
+
const target = RejectStrategyLabel[info.strategy] || '退回'
|
|
899
|
+
if (info.unlimited) return `${target} · 不限退回次数`
|
|
900
|
+
if (info.remaining <= 0) return `${target} · 已达退回上限,再拒绝将不通过`
|
|
901
|
+
return `${target} · 已退回 ${info.retriesUsed}/${info.retryLimit} 次`
|
|
902
|
+
} catch {
|
|
903
|
+
return ''
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
const createCcNodes = computed(() => {
|
|
908
|
+
const nodes = []
|
|
909
|
+
const visit = (node) => {
|
|
910
|
+
if (!node) return
|
|
911
|
+
if (node.type === FlowNodeType.CC && node.allowInitiatorAddUsers !== false) {
|
|
912
|
+
nodes.push({ nodeId: node.nodeId, nodeName: node.nodeName })
|
|
913
|
+
}
|
|
914
|
+
if (node.childNode) visit(node.childNode)
|
|
915
|
+
node.branchList?.forEach(visit)
|
|
916
|
+
}
|
|
917
|
+
visit(createDefinition.value?.workflow)
|
|
918
|
+
return nodes
|
|
919
|
+
})
|
|
920
|
+
|
|
921
|
+
function deptName(deptId) {
|
|
922
|
+
return deptIndex.value.get(String(deptId))?.name || '未分配部门'
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
function roleNamesOf(user) {
|
|
926
|
+
return (user.roleIds || [])
|
|
927
|
+
.map((roleId) => roleIndex.value.get(String(roleId))?.roleName)
|
|
928
|
+
.filter(Boolean)
|
|
929
|
+
.join(' / ')
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
function userById(userId) {
|
|
933
|
+
return userIndex.value.get(String(userId)) || null
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function normalizeUser(user) {
|
|
937
|
+
return user
|
|
938
|
+
? {
|
|
939
|
+
id: user.id,
|
|
940
|
+
name: user.realName || user.name || String(user.id),
|
|
941
|
+
deptName: user.deptName || deptName(user.deptId) || ''
|
|
942
|
+
}
|
|
943
|
+
: null
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
function statusMetaOf(instance) {
|
|
947
|
+
return STATUS_META[instance.state?.status] || STATUS_META.idle
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
function filterCount(value) {
|
|
951
|
+
if (value === 'all') return instances.value.length
|
|
952
|
+
return instances.value.filter((instance) => instance.state?.status === value).length
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
function pendingTasksFor(state, userId) {
|
|
956
|
+
return (state?.tasks || []).filter(
|
|
957
|
+
(task) =>
|
|
958
|
+
task.status === 'pending' &&
|
|
959
|
+
task.approvers.some((approver) => sameId(approver.id, userId)) &&
|
|
960
|
+
!(task.approvedBy || []).some((approver) => sameId(approver.id, userId))
|
|
961
|
+
)
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
function pendingCountForInstance(instance) {
|
|
965
|
+
return pendingTasksFor(instance.state, currentUserId.value).length
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
function pendingCountForUser(userId) {
|
|
969
|
+
return instances.value.reduce(
|
|
970
|
+
(total, instance) => total + pendingTasksFor(instance.state, userId).length,
|
|
971
|
+
0
|
|
972
|
+
)
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
function instanceProgress(instance) {
|
|
976
|
+
const tasks = instance.state?.tasks || []
|
|
977
|
+
if (!tasks.length) return statusMetaOf(instance).label
|
|
978
|
+
const approved = tasks.filter((task) => task.status === 'approved').length
|
|
979
|
+
return `审批完成 ${approved}/${tasks.length}`
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
function nodeNameIn(instance, nodeId) {
|
|
983
|
+
return findNodeById(instance.definition.workflow, nodeId)?.nodeName || ''
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
function currentNodeText(instance) {
|
|
987
|
+
const state = instance.state
|
|
988
|
+
if (!state) return '未开始'
|
|
989
|
+
const pending = (state.tasks || []).filter((task) => task.status === 'pending')
|
|
990
|
+
const names = [
|
|
991
|
+
...new Set(pending.map((task) => nodeNameIn(instance, task.nodeId)).filter(Boolean))
|
|
992
|
+
]
|
|
993
|
+
if (names.length) return names.join('、')
|
|
994
|
+
if (state.status === 'running') return '处理中'
|
|
995
|
+
return STATUS_META[state.status]?.label || state.status
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function extraCcUserObjects(selections) {
|
|
999
|
+
const result = {}
|
|
1000
|
+
Object.entries(selections || {}).forEach(([nodeId, ids]) => {
|
|
1001
|
+
const users = (ids || []).map((id) => userById(id)).filter(Boolean)
|
|
1002
|
+
if (users.length) result[nodeId] = users
|
|
1003
|
+
})
|
|
1004
|
+
return result
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
function contextForInstance(instance) {
|
|
1008
|
+
return createMockRuntimeContext({
|
|
1009
|
+
initiatorId: instance.state?.initiator?.id ?? instance.initiatorId,
|
|
1010
|
+
users: org.users,
|
|
1011
|
+
departments: org.departments,
|
|
1012
|
+
roles: org.roles,
|
|
1013
|
+
extraCcUsers: extraCcUserObjects(instance.extraCcUsers)
|
|
1014
|
+
})
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function makeContext(initiator, extraSelections) {
|
|
1018
|
+
return createMockRuntimeContext({
|
|
1019
|
+
initiatorId: initiator.id,
|
|
1020
|
+
users: org.users,
|
|
1021
|
+
departments: org.departments,
|
|
1022
|
+
roles: org.roles,
|
|
1023
|
+
extraCcUsers: extraCcUserObjects(extraSelections)
|
|
1024
|
+
})
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
function activateInstance() {
|
|
1028
|
+
const instance = activeInstance.value
|
|
1029
|
+
if (!instance) {
|
|
1030
|
+
runtime.value = null
|
|
1031
|
+
activeState.value = null
|
|
1032
|
+
return
|
|
1033
|
+
}
|
|
1034
|
+
try {
|
|
1035
|
+
runtime.value = createFlowRuntime({
|
|
1036
|
+
workflow: instance.definition.workflow,
|
|
1037
|
+
state: instance.state,
|
|
1038
|
+
context: contextForInstance(instance)
|
|
1039
|
+
})
|
|
1040
|
+
// Catch up on deadlines missed while the tab was closed or another
|
|
1041
|
+
// instance was active.
|
|
1042
|
+
activeState.value = runtime.value.tick()
|
|
1043
|
+
instance.state = activeState.value
|
|
1044
|
+
} catch (error) {
|
|
1045
|
+
runtime.value = null
|
|
1046
|
+
activeState.value = instance.state
|
|
1047
|
+
ElMessage.error(`恢复流程实例失败:${error.message}`)
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
function selectInstance(instanceId) {
|
|
1052
|
+
if (activeId.value === instanceId) return
|
|
1053
|
+
activeId.value = instanceId
|
|
1054
|
+
activeTab.value = 'chart'
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function selectInstanceById(instanceId) {
|
|
1058
|
+
if (!instances.value.some((item) => item.id === instanceId)) return false
|
|
1059
|
+
activeId.value = instanceId
|
|
1060
|
+
activeTab.value = 'chart'
|
|
1061
|
+
if (!runtime.value) activateInstance()
|
|
1062
|
+
return true
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
function syncActiveState(state) {
|
|
1066
|
+
if (!activeInstance.value || !state) return
|
|
1067
|
+
activeInstance.value.state = state
|
|
1068
|
+
activeInstance.value.updatedAt = nowIso()
|
|
1069
|
+
activeState.value = state
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
function snapshotPayload() {
|
|
1073
|
+
return {
|
|
1074
|
+
instances: instances.value,
|
|
1075
|
+
currentUserId: currentUserId.value,
|
|
1076
|
+
initiatorId: initiatorId.value,
|
|
1077
|
+
activeId: activeId.value
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
function persist() {
|
|
1082
|
+
if (!storageReady) return
|
|
1083
|
+
if (persistTimer) clearTimeout(persistTimer)
|
|
1084
|
+
persistTimer = setTimeout(() => {
|
|
1085
|
+
persistTimer = null
|
|
1086
|
+
flowStorage.setJSON(STORAGE_KEY, snapshotPayload()).catch(() => {
|
|
1087
|
+
// Keep the test session usable when storage is unavailable.
|
|
1088
|
+
})
|
|
1089
|
+
}, 120)
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
async function flushPersist() {
|
|
1093
|
+
if (!storageReady) return
|
|
1094
|
+
if (persistTimer) {
|
|
1095
|
+
clearTimeout(persistTimer)
|
|
1096
|
+
persistTimer = null
|
|
1097
|
+
}
|
|
1098
|
+
try {
|
|
1099
|
+
await flowStorage.setJSON(STORAGE_KEY, snapshotPayload())
|
|
1100
|
+
} catch {
|
|
1101
|
+
// ignore storage failures on teardown
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
async function load() {
|
|
1106
|
+
try {
|
|
1107
|
+
const data = await flowStorage.getJSON(STORAGE_KEY)
|
|
1108
|
+
if (data) {
|
|
1109
|
+
if (Array.isArray(data.instances)) {
|
|
1110
|
+
instances.value = data.instances.filter(
|
|
1111
|
+
(instance) =>
|
|
1112
|
+
instance?.id &&
|
|
1113
|
+
instance?.definition?.workflow &&
|
|
1114
|
+
instance?.state?.tasks
|
|
1115
|
+
)
|
|
1116
|
+
}
|
|
1117
|
+
if (data.currentUserId != null && userById(data.currentUserId)) {
|
|
1118
|
+
currentUserId.value = data.currentUserId
|
|
1119
|
+
} else if (org.users.length) {
|
|
1120
|
+
currentUserId.value = org.users[0].id
|
|
1121
|
+
}
|
|
1122
|
+
if (data.initiatorId != null && userById(data.initiatorId)) {
|
|
1123
|
+
initiatorId.value = data.initiatorId
|
|
1124
|
+
}
|
|
1125
|
+
const storedActive = data.activeId
|
|
1126
|
+
activeId.value =
|
|
1127
|
+
storedActive && instances.value.some((instance) => instance.id === storedActive)
|
|
1128
|
+
? storedActive
|
|
1129
|
+
: instances.value[0]?.id ?? null
|
|
1130
|
+
} else if (props.initialInstances.length) {
|
|
1131
|
+
instances.value = clone(props.initialInstances).filter(
|
|
1132
|
+
(instance) =>
|
|
1133
|
+
instance?.id &&
|
|
1134
|
+
instance?.definition?.workflow &&
|
|
1135
|
+
instance?.state?.tasks
|
|
1136
|
+
)
|
|
1137
|
+
activeId.value = instances.value[0]?.id ?? null
|
|
1138
|
+
if (org.users.length) currentUserId.value = org.users[0].id
|
|
1139
|
+
}
|
|
1140
|
+
} catch {
|
|
1141
|
+
// Ignore corrupt storage and start clean.
|
|
1142
|
+
}
|
|
1143
|
+
storageReady = true
|
|
1144
|
+
activateInstance()
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
function openCreate(definitionId = null) {
|
|
1148
|
+
if (!availableDefinitions.value.length) {
|
|
1149
|
+
ElMessage.error('还没有可用的流程定义,请先在流程设计中创建')
|
|
1150
|
+
return false
|
|
1151
|
+
}
|
|
1152
|
+
const preferred =
|
|
1153
|
+
(definitionId &&
|
|
1154
|
+
availableDefinitions.value.find(
|
|
1155
|
+
(item) => String(item.meta?.id) === String(definitionId)
|
|
1156
|
+
)) ||
|
|
1157
|
+
createDefinition.value ||
|
|
1158
|
+
availableDefinitions.value[0]
|
|
1159
|
+
if (!preferred?.workflow) {
|
|
1160
|
+
ElMessage.error('所选流程缺少流程定义')
|
|
1161
|
+
return false
|
|
1162
|
+
}
|
|
1163
|
+
createDefinitionId.value = preferred.meta?.id
|
|
1164
|
+
createTab.value = 'form'
|
|
1165
|
+
createInitiatorId.value = currentUser.value?.id ?? org.users[0]?.id ?? null
|
|
1166
|
+
const selections = {}
|
|
1167
|
+
createCcNodes.value.forEach((node) => {
|
|
1168
|
+
selections[node.nodeId] = []
|
|
1169
|
+
})
|
|
1170
|
+
createCcSelections.value = selections
|
|
1171
|
+
createPrediction.value = null
|
|
1172
|
+
createVisible.value = true
|
|
1173
|
+
return true
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function handleCreateDefinitionChange() {
|
|
1177
|
+
createPrediction.value = null
|
|
1178
|
+
const selections = {}
|
|
1179
|
+
createCcNodes.value.forEach((node) => {
|
|
1180
|
+
selections[node.nodeId] = []
|
|
1181
|
+
})
|
|
1182
|
+
createCcSelections.value = selections
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function readCreateFormData() {
|
|
1186
|
+
return createFormRef.value?.formData ? clone(createFormRef.value.formData) : {}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
async function validateCreateForm() {
|
|
1190
|
+
const elForm = createFormRef.value?.formRef
|
|
1191
|
+
if (elForm && typeof elForm.validate === 'function') {
|
|
1192
|
+
await elForm.validate()
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
function buildCreatePrediction() {
|
|
1197
|
+
const initiator = userById(createInitiatorId.value) || org.users[0]
|
|
1198
|
+
if (!initiator) throw new Error('没有可用的用户')
|
|
1199
|
+
const context = makeContext(initiator, createCcSelections.value)
|
|
1200
|
+
return predictWorkflow({
|
|
1201
|
+
definition: createDefinition.value,
|
|
1202
|
+
data: readCreateFormData(),
|
|
1203
|
+
context,
|
|
1204
|
+
initiator
|
|
1205
|
+
})
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
function refreshCreatePrediction() {
|
|
1209
|
+
if (!createDefinition.value?.workflow) {
|
|
1210
|
+
ElMessage.error('所选流程缺少流程定义')
|
|
1211
|
+
return
|
|
1212
|
+
}
|
|
1213
|
+
predicting.value = true
|
|
1214
|
+
try {
|
|
1215
|
+
createPrediction.value = buildCreatePrediction()
|
|
1216
|
+
createTab.value = 'prediction'
|
|
1217
|
+
} catch (error) {
|
|
1218
|
+
ElMessage.error(`流程预测失败:${error.message}`)
|
|
1219
|
+
} finally {
|
|
1220
|
+
predicting.value = false
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
function previewCreate() {
|
|
1225
|
+
refreshCreatePrediction()
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
function nextInstanceNumber() {
|
|
1229
|
+
return (
|
|
1230
|
+
instances.value.reduce((max, instance) => {
|
|
1231
|
+
const match = String(instance.name || '').match(/#(\d+)$/)
|
|
1232
|
+
return Math.max(max, Number(match?.[1]) || 0)
|
|
1233
|
+
}, 0) + 1
|
|
1234
|
+
)
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
async function startNewTest() {
|
|
1238
|
+
if (startingNew.value) return
|
|
1239
|
+
if (!createDefinition.value?.workflow) {
|
|
1240
|
+
ElMessage.error('所选流程缺少流程定义')
|
|
1241
|
+
return
|
|
1242
|
+
}
|
|
1243
|
+
if (!org.users.length) {
|
|
1244
|
+
ElMessage.error('没有可用的用户')
|
|
1245
|
+
return
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
startingNew.value = true
|
|
1249
|
+
createTab.value = 'form'
|
|
1250
|
+
try {
|
|
1251
|
+
try {
|
|
1252
|
+
await validateCreateForm()
|
|
1253
|
+
} catch {
|
|
1254
|
+
ElMessage.warning('请先完善表单必填项再发起流程')
|
|
1255
|
+
return
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
const initiator = userById(createInitiatorId.value) || org.users[0]
|
|
1259
|
+
const data = readCreateFormData()
|
|
1260
|
+
const context = makeContext(initiator, createCcSelections.value)
|
|
1261
|
+
const selectedDefinition = clone(createDefinition.value)
|
|
1262
|
+
// Instances keep an immutable snapshot of the published content, not the
|
|
1263
|
+
// full revision history; otherwise every instance would duplicate it.
|
|
1264
|
+
if (selectedDefinition.meta) delete selectedDefinition.meta.revisions
|
|
1265
|
+
const newRuntime = createFlowRuntime({
|
|
1266
|
+
workflow: selectedDefinition.workflow,
|
|
1267
|
+
context
|
|
1268
|
+
})
|
|
1269
|
+
const state = newRuntime.start(data, initiator)
|
|
1270
|
+
const extraSelections = {}
|
|
1271
|
+
Object.entries(createCcSelections.value).forEach(([nodeId, ids]) => {
|
|
1272
|
+
if (ids?.length) extraSelections[nodeId] = [...ids]
|
|
1273
|
+
})
|
|
1274
|
+
|
|
1275
|
+
const baseName = selectedDefinition.meta?.name || '流程'
|
|
1276
|
+
const instance = {
|
|
1277
|
+
id: `test_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`,
|
|
1278
|
+
name: `${baseName} #${String(nextInstanceNumber()).padStart(2, '0')}`,
|
|
1279
|
+
definition: selectedDefinition,
|
|
1280
|
+
definitionVersion: selectedDefinition.meta?.version || 1,
|
|
1281
|
+
initiatorId: initiator.id,
|
|
1282
|
+
initiator: normalizeUser(initiator),
|
|
1283
|
+
extraCcUsers: extraSelections,
|
|
1284
|
+
createdAt: nowIso(),
|
|
1285
|
+
updatedAt: nowIso(),
|
|
1286
|
+
state
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
instances.value.unshift(instance)
|
|
1290
|
+
statusFilter.value = 'all'
|
|
1291
|
+
activeId.value = instance.id
|
|
1292
|
+
runtime.value = newRuntime
|
|
1293
|
+
activeState.value = state
|
|
1294
|
+
activeTab.value = 'chart'
|
|
1295
|
+
currentUserId.value = initiator.id
|
|
1296
|
+
initiatorId.value = initiator.id
|
|
1297
|
+
createVisible.value = false
|
|
1298
|
+
const warning = state.warnings?.[0]
|
|
1299
|
+
if (warning) {
|
|
1300
|
+
ElMessage.warning(warning.message)
|
|
1301
|
+
} else {
|
|
1302
|
+
ElMessage.success(`流程已由 ${initiator.realName} 发起`)
|
|
1303
|
+
}
|
|
1304
|
+
} catch (error) {
|
|
1305
|
+
ElMessage.error(`发起失败:${error.message}`)
|
|
1306
|
+
} finally {
|
|
1307
|
+
startingNew.value = false
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
function nodeOf(task) {
|
|
1312
|
+
const workflow = activeInstance.value?.definition?.workflow
|
|
1313
|
+
return task && workflow ? findNodeById(workflow, task.nodeId) : null
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function signLabelOf(task) {
|
|
1317
|
+
return SignModeLabel[task.signMode] || task.signMode || '并签'
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
function hasApproved(task, approver) {
|
|
1321
|
+
return (task.approvedBy || []).some((item) => sameId(item.id, approver.id))
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
function lastComment(task) {
|
|
1325
|
+
const records = [...(task.records || [])].reverse()
|
|
1326
|
+
return records.find((record) => record.comment)?.comment || ''
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
function canTransfer(task) {
|
|
1330
|
+
return nodeOf(task)?.allowTransfer !== false
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
function rejectStrategyOf(task) {
|
|
1334
|
+
return RejectStrategyLabel[nodeOf(task)?.rejectStrategy] || '终止流程'
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
function openAction(task, type) {
|
|
1338
|
+
action.visible = true
|
|
1339
|
+
action.type = task?.kind === 'submit' ? 'resubmit' : type
|
|
1340
|
+
action.task = task
|
|
1341
|
+
action.taskInstanceId = activeId.value
|
|
1342
|
+
action.comment = ''
|
|
1343
|
+
action.targetUserId = null
|
|
1344
|
+
action.resubmitData = task?.kind === 'submit' ? clone(activeState.value?.variables || {}) : null
|
|
1345
|
+
action.submitting = false
|
|
1346
|
+
if (action.type === 'resubmit') {
|
|
1347
|
+
nextTick(() => prefillResubmitForm())
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
function prefillResubmitForm(attempt = 0) {
|
|
1352
|
+
if (action.type !== 'resubmit' || !action.visible) return
|
|
1353
|
+
const viewer = resubmitFormRef.value
|
|
1354
|
+
if (!viewer?.formData) {
|
|
1355
|
+
if (attempt < 8) setTimeout(() => prefillResubmitForm(attempt + 1), 50)
|
|
1356
|
+
return
|
|
1357
|
+
}
|
|
1358
|
+
if (!action.resubmitData) return
|
|
1359
|
+
Object.keys(viewer.formData).forEach((key) => delete viewer.formData[key])
|
|
1360
|
+
Object.assign(viewer.formData, clone(action.resubmitData))
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
function handleActionOpened() {
|
|
1364
|
+
prefillResubmitForm()
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
function openGlobalTask(item, type = 'approve') {
|
|
1368
|
+
if (activeId.value !== item.instanceId) {
|
|
1369
|
+
activeId.value = item.instanceId
|
|
1370
|
+
activateInstance()
|
|
1371
|
+
}
|
|
1372
|
+
const task = (activeState.value?.tasks || []).find(
|
|
1373
|
+
(entry) => entry.id === item.task.id && entry.status === 'pending'
|
|
1374
|
+
)
|
|
1375
|
+
if (!task) {
|
|
1376
|
+
ElMessage.warning('该任务已被处理,已刷新实例')
|
|
1377
|
+
return
|
|
1378
|
+
}
|
|
1379
|
+
openAction(task, type)
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
async function confirmAction() {
|
|
1383
|
+
if (!runtime.value || !action.task) return
|
|
1384
|
+
if (action.taskInstanceId && action.taskInstanceId !== activeId.value) {
|
|
1385
|
+
ElMessage.warning('实例已切换,请重新打开任务')
|
|
1386
|
+
action.visible = false
|
|
1387
|
+
return
|
|
1388
|
+
}
|
|
1389
|
+
if (action.type === 'transfer' && !action.targetUserId) {
|
|
1390
|
+
ElMessage.warning('请选择转交目标用户')
|
|
1391
|
+
return
|
|
1392
|
+
}
|
|
1393
|
+
action.submitting = true
|
|
1394
|
+
const rejectSnapshot = action.type === 'reject' ? actionRejectInfo.value : null
|
|
1395
|
+
try {
|
|
1396
|
+
const targetUser = userById(action.targetUserId)
|
|
1397
|
+
let state
|
|
1398
|
+
if (action.type === 'approve') {
|
|
1399
|
+
state = runtime.value.approve(action.task.id, {
|
|
1400
|
+
user: currentUser.value,
|
|
1401
|
+
comment: action.comment
|
|
1402
|
+
})
|
|
1403
|
+
} else if (action.type === 'reject') {
|
|
1404
|
+
state = runtime.value.reject(action.task.id, {
|
|
1405
|
+
user: currentUser.value,
|
|
1406
|
+
comment: action.comment
|
|
1407
|
+
})
|
|
1408
|
+
} else if (action.type === 'resubmit') {
|
|
1409
|
+
const viewer = resubmitFormRef.value
|
|
1410
|
+
if (viewer?.formRef?.validate) {
|
|
1411
|
+
try {
|
|
1412
|
+
await viewer.formRef.validate()
|
|
1413
|
+
} catch {
|
|
1414
|
+
ElMessage.warning('请先完善表单必填项再重新提交')
|
|
1415
|
+
return
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
const data = viewer?.formData ? clone(viewer.formData) : action.resubmitData
|
|
1419
|
+
state = runtime.value.resubmit(action.task.id, {
|
|
1420
|
+
user: currentUser.value,
|
|
1421
|
+
data,
|
|
1422
|
+
comment: action.comment
|
|
1423
|
+
})
|
|
1424
|
+
} else {
|
|
1425
|
+
state = runtime.value.transfer(action.task.id, {
|
|
1426
|
+
user: currentUser.value,
|
|
1427
|
+
toUser: targetUser,
|
|
1428
|
+
comment: action.comment
|
|
1429
|
+
})
|
|
1430
|
+
}
|
|
1431
|
+
syncActiveState(state)
|
|
1432
|
+
action.visible = false
|
|
1433
|
+
if (action.type === 'approve') {
|
|
1434
|
+
ElMessage.success(state.status === 'completed' ? '已同意,流程已完成' : '已同意')
|
|
1435
|
+
} else if (action.type === 'reject') {
|
|
1436
|
+
const hitRetryLimit =
|
|
1437
|
+
state.status === 'rejected' &&
|
|
1438
|
+
rejectSnapshot &&
|
|
1439
|
+
!rejectSnapshot.unlimited &&
|
|
1440
|
+
rejectSnapshot.retryLimit > 0 &&
|
|
1441
|
+
rejectSnapshot.retriesUsed >= rejectSnapshot.retryLimit
|
|
1442
|
+
ElMessage.warning(
|
|
1443
|
+
state.status === 'rejected'
|
|
1444
|
+
? hitRetryLimit
|
|
1445
|
+
? '已达到允许退回次数,流程不通过'
|
|
1446
|
+
: '已拒绝,流程已终止'
|
|
1447
|
+
: '已拒绝,流程已退回'
|
|
1448
|
+
)
|
|
1449
|
+
} else if (action.type === 'resubmit') {
|
|
1450
|
+
ElMessage.success('已重新提交,流程继续流转')
|
|
1451
|
+
} else {
|
|
1452
|
+
ElMessage.success(`已转交给 ${targetUser?.realName || '目标用户'}`)
|
|
1453
|
+
}
|
|
1454
|
+
} catch (error) {
|
|
1455
|
+
ElMessage.error(error.message)
|
|
1456
|
+
} finally {
|
|
1457
|
+
action.submitting = false
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
async function autoRun() {
|
|
1462
|
+
if (!runtime.value) return
|
|
1463
|
+
autoRunning.value = true
|
|
1464
|
+
try {
|
|
1465
|
+
let steps = 0
|
|
1466
|
+
while (steps < 200) {
|
|
1467
|
+
const state = runtime.value.getState()
|
|
1468
|
+
if (state.status !== 'running') break
|
|
1469
|
+
const task = state.tasks.find((item) => item.status === 'pending')
|
|
1470
|
+
if (!task) break
|
|
1471
|
+
const approver = task.approvers.find((item) => !hasApproved(task, item))
|
|
1472
|
+
if (!approver) break
|
|
1473
|
+
runtime.value.approve(task.id, { user: approver, comment: '测试模式自动推进' })
|
|
1474
|
+
steps += 1
|
|
1475
|
+
}
|
|
1476
|
+
syncActiveState(runtime.value.getState())
|
|
1477
|
+
if (steps >= 200) {
|
|
1478
|
+
ElMessage.warning('自动推进达到步数上限,请检查流程是否存在环')
|
|
1479
|
+
} else {
|
|
1480
|
+
ElMessage.success(`已自动推进 ${steps} 个审批任务`)
|
|
1481
|
+
}
|
|
1482
|
+
} catch (error) {
|
|
1483
|
+
ElMessage.error(`自动推进失败:${error.message}`)
|
|
1484
|
+
} finally {
|
|
1485
|
+
autoRunning.value = false
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
async function stopActive() {
|
|
1490
|
+
if (!runtime.value) return
|
|
1491
|
+
try {
|
|
1492
|
+
await ElMessageBox.confirm('确定终止当前流程吗?', '终止流程', {
|
|
1493
|
+
type: 'warning',
|
|
1494
|
+
confirmButtonText: '终止',
|
|
1495
|
+
cancelButtonText: '继续运行'
|
|
1496
|
+
})
|
|
1497
|
+
} catch {
|
|
1498
|
+
return
|
|
1499
|
+
}
|
|
1500
|
+
syncActiveState(runtime.value.cancel('测试模式手动终止'))
|
|
1501
|
+
ElMessage.info('流程已终止')
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
async function revokeActive() {
|
|
1505
|
+
if (!runtime.value || !canRevokeActive.value) return
|
|
1506
|
+
try {
|
|
1507
|
+
await ElMessageBox.confirm('撤回后流程将终止,确定继续吗?', '撤回流程', {
|
|
1508
|
+
type: 'warning',
|
|
1509
|
+
confirmButtonText: '撤回',
|
|
1510
|
+
cancelButtonText: '取消'
|
|
1511
|
+
})
|
|
1512
|
+
} catch {
|
|
1513
|
+
return
|
|
1514
|
+
}
|
|
1515
|
+
try {
|
|
1516
|
+
syncActiveState(
|
|
1517
|
+
runtime.value.revoke({ user: currentUser.value, reason: '发起人撤回' })
|
|
1518
|
+
)
|
|
1519
|
+
ElMessage.info('流程已撤回')
|
|
1520
|
+
} catch (error) {
|
|
1521
|
+
ElMessage.error(error.message)
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
function tickActiveRuntime() {
|
|
1526
|
+
if (!runtime.value) return
|
|
1527
|
+
try {
|
|
1528
|
+
const state = runtime.value.tick()
|
|
1529
|
+
if (JSON.stringify(state) !== JSON.stringify(activeState.value)) {
|
|
1530
|
+
syncActiveState(state)
|
|
1531
|
+
}
|
|
1532
|
+
} catch {
|
|
1533
|
+
// A broken instance should not stop the deadline sweep.
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
function tickAllInstances() {
|
|
1538
|
+
instances.value.forEach((instance) => {
|
|
1539
|
+
if (instance.id === activeId.value && runtime.value) {
|
|
1540
|
+
tickActiveRuntime()
|
|
1541
|
+
return
|
|
1542
|
+
}
|
|
1543
|
+
try {
|
|
1544
|
+
const scoped = createFlowRuntime({
|
|
1545
|
+
workflow: instance.definition.workflow,
|
|
1546
|
+
state: instance.state,
|
|
1547
|
+
context: contextForInstance(instance)
|
|
1548
|
+
})
|
|
1549
|
+
const state = scoped.tick()
|
|
1550
|
+
if (JSON.stringify(state) !== JSON.stringify(instance.state)) {
|
|
1551
|
+
instance.state = state
|
|
1552
|
+
instance.updatedAt = nowIso()
|
|
1553
|
+
}
|
|
1554
|
+
} catch {
|
|
1555
|
+
// One corrupt instance should not block the other deadlines.
|
|
1556
|
+
}
|
|
1557
|
+
})
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
function exportInstances() {
|
|
1561
|
+
if (!instances.value.length) {
|
|
1562
|
+
ElMessage.warning('还没有可导出的流程实例')
|
|
1563
|
+
return
|
|
1564
|
+
}
|
|
1565
|
+
downloadJSON(
|
|
1566
|
+
{
|
|
1567
|
+
kind: 'gbflow-instances',
|
|
1568
|
+
version: 1,
|
|
1569
|
+
exportedAt: nowIso(),
|
|
1570
|
+
instances: clone(instances.value)
|
|
1571
|
+
},
|
|
1572
|
+
`gbflow-instances-${Date.now()}.json`
|
|
1573
|
+
)
|
|
1574
|
+
ElMessage.success(`已导出 ${instances.value.length} 个流程实例`)
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
function triggerInstanceImport() {
|
|
1578
|
+
instanceFileInput.value?.click()
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
async function handleInstanceImportFile(event) {
|
|
1582
|
+
const file = event.target.files?.[0]
|
|
1583
|
+
event.target.value = ''
|
|
1584
|
+
if (!file) return
|
|
1585
|
+
try {
|
|
1586
|
+
const text = await file.text()
|
|
1587
|
+
const count = importInstances(text)
|
|
1588
|
+
if (count) ElMessage.success(`已导入 ${count} 个流程实例`)
|
|
1589
|
+
} catch (error) {
|
|
1590
|
+
ElMessage.error(`实例导入失败:${error.message || error}`)
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
function importInstances(input) {
|
|
1595
|
+
const payload = typeof input === 'string' ? JSON.parse(input) : input
|
|
1596
|
+
const list = Array.isArray(payload) ? payload : payload?.instances
|
|
1597
|
+
if (!Array.isArray(list)) throw new Error('未找到实例列表')
|
|
1598
|
+
const existing = new Set(instances.value.map((item) => String(item.id)))
|
|
1599
|
+
const imported = []
|
|
1600
|
+
list.forEach((item, index) => {
|
|
1601
|
+
if (!item?.definition?.workflow || !item?.state?.tasks) return
|
|
1602
|
+
const id = existing.has(String(item.id))
|
|
1603
|
+
? `imported_${Date.now()}_${index}`
|
|
1604
|
+
: item.id || `imported_${Date.now()}_${index}`
|
|
1605
|
+
existing.add(String(id))
|
|
1606
|
+
imported.push({
|
|
1607
|
+
...clone(item),
|
|
1608
|
+
id,
|
|
1609
|
+
createdAt: item.createdAt || nowIso(),
|
|
1610
|
+
updatedAt: nowIso()
|
|
1611
|
+
})
|
|
1612
|
+
})
|
|
1613
|
+
if (!imported.length) throw new Error('没有可用的流程实例')
|
|
1614
|
+
instances.value = [...imported, ...instances.value]
|
|
1615
|
+
statusFilter.value = 'all'
|
|
1616
|
+
activeId.value = imported[0].id
|
|
1617
|
+
currentUserId.value = imported[0].initiatorId ?? currentUserId.value
|
|
1618
|
+
activateInstance()
|
|
1619
|
+
persist()
|
|
1620
|
+
return imported.length
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
async function removeInstance(instance) {
|
|
1624
|
+
try {
|
|
1625
|
+
await ElMessageBox.confirm(`确定删除「${instance.name}」吗?`, '删除流程实例', {
|
|
1626
|
+
type: 'warning',
|
|
1627
|
+
confirmButtonText: '删除',
|
|
1628
|
+
cancelButtonText: '取消'
|
|
1629
|
+
})
|
|
1630
|
+
} catch {
|
|
1631
|
+
return
|
|
1632
|
+
}
|
|
1633
|
+
const index = instances.value.findIndex((item) => item.id === instance.id)
|
|
1634
|
+
if (index < 0) return
|
|
1635
|
+
const wasActive = instance.id === activeId.value
|
|
1636
|
+
instances.value.splice(index, 1)
|
|
1637
|
+
if (wasActive) {
|
|
1638
|
+
runtime.value = null
|
|
1639
|
+
activeState.value = null
|
|
1640
|
+
activeId.value = instances.value[index]?.id || instances.value[index - 1]?.id || null
|
|
1641
|
+
if (activeId.value) activateInstance()
|
|
1642
|
+
}
|
|
1643
|
+
ElMessage.success('流程实例已删除')
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
function nodeNameOf(nodeId) {
|
|
1647
|
+
const workflow = activeInstance.value?.definition?.workflow
|
|
1648
|
+
return (workflow && findNodeById(workflow, nodeId)?.nodeName) || ''
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
function eventTitle(event) {
|
|
1652
|
+
const node = event.nodeId ? nodeNameOf(event.nodeId) : ''
|
|
1653
|
+
switch (event.event) {
|
|
1654
|
+
case 'start':
|
|
1655
|
+
return `${event.initiator?.name || '发起人'} 发起了流程`
|
|
1656
|
+
case 'approve':
|
|
1657
|
+
return `${event.approver?.name || '审批人'} 同意 · ${node}`
|
|
1658
|
+
case 'reject':
|
|
1659
|
+
return `${event.approver?.name || '审批人'} 拒绝 · ${node}`
|
|
1660
|
+
case 'transfer':
|
|
1661
|
+
return `${event.approver?.name || '审批人'} 转交给 ${event.target?.name || '目标用户'} · ${node}`
|
|
1662
|
+
case 'cc':
|
|
1663
|
+
return `抄送 · ${node}`
|
|
1664
|
+
case 'branch': {
|
|
1665
|
+
const selected = event.branchId
|
|
1666
|
+
? nodeNameOf(event.branchId)
|
|
1667
|
+
: (event.branchIds || []).map(nodeNameOf).filter(Boolean).join('、')
|
|
1668
|
+
return `命中分支${selected ? `「${selected}」` : ''}`
|
|
1669
|
+
}
|
|
1670
|
+
case 'split':
|
|
1671
|
+
return `分支展开 · ${node}`
|
|
1672
|
+
case 'join':
|
|
1673
|
+
return `分支汇聚 · ${nodeNameOf(event.targetId) || node}`
|
|
1674
|
+
case 'autoApprove':
|
|
1675
|
+
return `未匹配到审批人,自动通过 · ${node}`
|
|
1676
|
+
case 'return':
|
|
1677
|
+
return `${event.approver?.name || '审批人'} 退回流程 → ${nodeNameOf(event.targetNodeId) || '发起人'}`
|
|
1678
|
+
case 'resubmit':
|
|
1679
|
+
return `${event.approver?.name || '发起人'} 修改表单后重新提交`
|
|
1680
|
+
case 'timeoutApprove':
|
|
1681
|
+
return `审批超时,系统自动通过 · ${node}`
|
|
1682
|
+
case 'timeoutReject':
|
|
1683
|
+
return `审批超时,系统自动拒绝 · ${node}`
|
|
1684
|
+
case 'revoke':
|
|
1685
|
+
return `${event.approver?.name || '发起人'} 撤回了流程${event.reason ? ` · ${event.reason}` : ''}`
|
|
1686
|
+
case 'pass':
|
|
1687
|
+
return `直接通过 · ${node}`
|
|
1688
|
+
case 'rejectNode':
|
|
1689
|
+
return `直接拒绝 · ${node}`
|
|
1690
|
+
case 'rejectLimitReached':
|
|
1691
|
+
return `达到最大退回次数(${event.retryLimit} 次),流程不通过 · ${node}`
|
|
1692
|
+
case 'cancel':
|
|
1693
|
+
return `流程已终止${event.reason ? ` · ${event.reason}` : ''}`
|
|
1694
|
+
case 'finished':
|
|
1695
|
+
return `流程结束 · ${STATUS_META[event.status]?.label || event.status}`
|
|
1696
|
+
default:
|
|
1697
|
+
return event.event
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
function eventMeta(event) {
|
|
1702
|
+
const parts = []
|
|
1703
|
+
if (event.event === 'cc' && event.users?.length) {
|
|
1704
|
+
parts.push(`抄送人:${event.users.map((user) => user.name).join('、')}`)
|
|
1705
|
+
}
|
|
1706
|
+
if (event.comment) parts.push(`意见:${event.comment}`)
|
|
1707
|
+
return parts.join(' · ')
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
function eventType(event) {
|
|
1711
|
+
return (
|
|
1712
|
+
{
|
|
1713
|
+
approve: 'success',
|
|
1714
|
+
transfer: 'primary',
|
|
1715
|
+
cc: 'warning',
|
|
1716
|
+
branch: 'primary',
|
|
1717
|
+
split: 'primary',
|
|
1718
|
+
join: 'primary',
|
|
1719
|
+
autoApprove: 'success',
|
|
1720
|
+
return: 'warning',
|
|
1721
|
+
reject: 'danger',
|
|
1722
|
+
rejectNode: 'danger',
|
|
1723
|
+
rejectLimitReached: 'danger',
|
|
1724
|
+
cancel: 'info',
|
|
1725
|
+
revoke: 'info',
|
|
1726
|
+
resubmit: 'primary',
|
|
1727
|
+
timeoutApprove: 'success',
|
|
1728
|
+
timeoutReject: 'danger',
|
|
1729
|
+
finished: 'success'
|
|
1730
|
+
}[event.event] || 'info'
|
|
1731
|
+
)
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
watch([instances, currentUserId, initiatorId, activeId], persist, { deep: true })
|
|
1735
|
+
watch(activeId, () => {
|
|
1736
|
+
if (storageReady) {
|
|
1737
|
+
activeTab.value = 'chart'
|
|
1738
|
+
activateInstance()
|
|
1739
|
+
}
|
|
1740
|
+
})
|
|
1741
|
+
watch(
|
|
1742
|
+
() => [props.users, props.departments, props.roles],
|
|
1743
|
+
() => {
|
|
1744
|
+
org.users = clone(props.users?.length ? props.users : mockUsers)
|
|
1745
|
+
org.departments = clone(props.departments?.length ? props.departments : mockDepartments)
|
|
1746
|
+
org.roles = clone(props.roles?.length ? props.roles : mockRoles)
|
|
1747
|
+
if (!userById(currentUserId.value)) {
|
|
1748
|
+
currentUserId.value = org.users[0]?.id ?? null
|
|
1749
|
+
}
|
|
1750
|
+
if (!userById(initiatorId.value)) {
|
|
1751
|
+
initiatorId.value = currentUserId.value
|
|
1752
|
+
}
|
|
1753
|
+
if (storageReady && activeId.value) {
|
|
1754
|
+
activateInstance()
|
|
1755
|
+
}
|
|
1756
|
+
},
|
|
1757
|
+
{ deep: true }
|
|
1758
|
+
)
|
|
1759
|
+
|
|
1760
|
+
defineExpose({
|
|
1761
|
+
openCreate,
|
|
1762
|
+
selectInstanceById,
|
|
1763
|
+
removeInstance,
|
|
1764
|
+
exportInstances,
|
|
1765
|
+
importInstances,
|
|
1766
|
+
activeId,
|
|
1767
|
+
currentUser
|
|
1768
|
+
})
|
|
1769
|
+
|
|
1770
|
+
watch(
|
|
1771
|
+
currentUser,
|
|
1772
|
+
(user) => emit('operator-change', user ? clone(user) : null),
|
|
1773
|
+
{ immediate: true }
|
|
1774
|
+
)
|
|
1775
|
+
|
|
1776
|
+
onMounted(() => {
|
|
1777
|
+
load().then(() => tickAllInstances())
|
|
1778
|
+
deadlineTimer = setInterval(tickAllInstances, 30000)
|
|
1779
|
+
})
|
|
1780
|
+
onBeforeUnmount(() => {
|
|
1781
|
+
if (deadlineTimer) clearInterval(deadlineTimer)
|
|
1782
|
+
flushPersist()
|
|
1783
|
+
})
|
|
1784
|
+
</script>
|
|
1785
|
+
|
|
1786
|
+
<style scoped lang="scss">
|
|
1787
|
+
.flow-workbench {
|
|
1788
|
+
height: 100%;
|
|
1789
|
+
min-height: 0;
|
|
1790
|
+
display: flex;
|
|
1791
|
+
gap: 12px;
|
|
1792
|
+
padding: 12px;
|
|
1793
|
+
background: #f3f5f9;
|
|
1794
|
+
box-sizing: border-box;
|
|
1795
|
+
overflow: hidden;
|
|
1796
|
+
color: #1f2937;
|
|
1797
|
+
font-size: 13px;
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
.wb-panel {
|
|
1801
|
+
display: flex;
|
|
1802
|
+
flex-direction: column;
|
|
1803
|
+
min-height: 0;
|
|
1804
|
+
background: #fff;
|
|
1805
|
+
border-radius: 10px;
|
|
1806
|
+
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
|
|
1807
|
+
overflow: hidden;
|
|
1808
|
+
|
|
1809
|
+
&__head {
|
|
1810
|
+
flex-shrink: 0;
|
|
1811
|
+
display: flex;
|
|
1812
|
+
align-items: flex-start;
|
|
1813
|
+
justify-content: space-between;
|
|
1814
|
+
gap: 10px;
|
|
1815
|
+
padding: 12px 14px;
|
|
1816
|
+
border-bottom: 1px solid #eef2f7;
|
|
1817
|
+
|
|
1818
|
+
h3 {
|
|
1819
|
+
margin: 0;
|
|
1820
|
+
font-size: 14px;
|
|
1821
|
+
font-weight: 600;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
span {
|
|
1825
|
+
display: block;
|
|
1826
|
+
margin-top: 2px;
|
|
1827
|
+
font-size: 12px;
|
|
1828
|
+
color: #94a3b8;
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
&__foot {
|
|
1833
|
+
flex-shrink: 0;
|
|
1834
|
+
padding: 8px 14px;
|
|
1835
|
+
border-top: 1px solid #eef2f7;
|
|
1836
|
+
color: #94a3b8;
|
|
1837
|
+
font-size: 11px;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
.flow-workbench__sidebar {
|
|
1842
|
+
width: 260px;
|
|
1843
|
+
flex-shrink: 0;
|
|
1844
|
+
min-height: 0;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
.wb-panel--list {
|
|
1848
|
+
height: 100%;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
.wb-filters {
|
|
1852
|
+
flex-shrink: 0;
|
|
1853
|
+
display: grid;
|
|
1854
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1855
|
+
gap: 4px;
|
|
1856
|
+
padding: 8px 10px;
|
|
1857
|
+
border-bottom: 1px dashed #eef2f7;
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
.wb-filter {
|
|
1861
|
+
display: inline-flex;
|
|
1862
|
+
align-items: center;
|
|
1863
|
+
justify-content: space-between;
|
|
1864
|
+
gap: 4px;
|
|
1865
|
+
padding: 3px 8px;
|
|
1866
|
+
border: 1px solid transparent;
|
|
1867
|
+
border-radius: 12px;
|
|
1868
|
+
background: #f1f5f9;
|
|
1869
|
+
color: #64748b;
|
|
1870
|
+
font-size: 11px;
|
|
1871
|
+
cursor: pointer;
|
|
1872
|
+
|
|
1873
|
+
span {
|
|
1874
|
+
color: #94a3b8;
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
&.is-active {
|
|
1878
|
+
background: #e8f2ff;
|
|
1879
|
+
border-color: #bfdbfe;
|
|
1880
|
+
color: #2563eb;
|
|
1881
|
+
|
|
1882
|
+
span {
|
|
1883
|
+
color: #2563eb;
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
.wb-instance-list {
|
|
1889
|
+
flex: 1;
|
|
1890
|
+
min-height: 0;
|
|
1891
|
+
overflow: auto;
|
|
1892
|
+
padding: 8px;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
.wb-instance {
|
|
1896
|
+
position: relative;
|
|
1897
|
+
padding: 10px;
|
|
1898
|
+
margin-bottom: 8px;
|
|
1899
|
+
border: 1px solid #e2e8f0;
|
|
1900
|
+
border-radius: 8px;
|
|
1901
|
+
cursor: pointer;
|
|
1902
|
+
transition: all 0.15s;
|
|
1903
|
+
|
|
1904
|
+
&:hover {
|
|
1905
|
+
border-color: #bfdbfe;
|
|
1906
|
+
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
|
|
1907
|
+
|
|
1908
|
+
.wb-instance__delete {
|
|
1909
|
+
opacity: 1;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
&.is-active {
|
|
1914
|
+
border-color: #3296fa;
|
|
1915
|
+
background: #f8fbff;
|
|
1916
|
+
box-shadow: inset 3px 0 0 #3296fa;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
&__top {
|
|
1920
|
+
display: flex;
|
|
1921
|
+
align-items: center;
|
|
1922
|
+
justify-content: space-between;
|
|
1923
|
+
gap: 6px;
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
&__name {
|
|
1927
|
+
font-weight: 600;
|
|
1928
|
+
color: #1e293b;
|
|
1929
|
+
overflow: hidden;
|
|
1930
|
+
text-overflow: ellipsis;
|
|
1931
|
+
white-space: nowrap;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
&__meta {
|
|
1935
|
+
display: flex;
|
|
1936
|
+
justify-content: space-between;
|
|
1937
|
+
gap: 6px;
|
|
1938
|
+
margin-top: 5px;
|
|
1939
|
+
color: #94a3b8;
|
|
1940
|
+
font-size: 11px;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
&__node {
|
|
1944
|
+
margin-top: 5px;
|
|
1945
|
+
color: #64748b;
|
|
1946
|
+
font-size: 12px;
|
|
1947
|
+
overflow: hidden;
|
|
1948
|
+
text-overflow: ellipsis;
|
|
1949
|
+
white-space: nowrap;
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
&__foot {
|
|
1953
|
+
display: flex;
|
|
1954
|
+
align-items: center;
|
|
1955
|
+
justify-content: space-between;
|
|
1956
|
+
margin-top: 6px;
|
|
1957
|
+
font-size: 11px;
|
|
1958
|
+
color: #94a3b8;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
&__pending {
|
|
1962
|
+
color: #d97706;
|
|
1963
|
+
font-weight: 600;
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
&__delete {
|
|
1967
|
+
opacity: 0;
|
|
1968
|
+
transition: opacity 0.15s;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
.flow-workbench__main {
|
|
1973
|
+
flex: 1;
|
|
1974
|
+
min-width: 0;
|
|
1975
|
+
display: flex;
|
|
1976
|
+
min-height: 0;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
.wb-panel--detail {
|
|
1980
|
+
flex: 1;
|
|
1981
|
+
min-width: 0;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
.wb-panel--empty {
|
|
1985
|
+
flex: 1;
|
|
1986
|
+
align-items: center;
|
|
1987
|
+
justify-content: center;
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
.wb-detail {
|
|
1991
|
+
&__head {
|
|
1992
|
+
position: relative;
|
|
1993
|
+
flex-shrink: 0;
|
|
1994
|
+
padding: 12px 18px;
|
|
1995
|
+
border-bottom: 1px solid #eef2f7;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
&__title {
|
|
1999
|
+
display: flex;
|
|
2000
|
+
align-items: center;
|
|
2001
|
+
gap: 8px;
|
|
2002
|
+
|
|
2003
|
+
h2 {
|
|
2004
|
+
margin: 0;
|
|
2005
|
+
font-size: 16px;
|
|
2006
|
+
font-weight: 600;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
&__time {
|
|
2011
|
+
margin-left: 4px;
|
|
2012
|
+
color: #94a3b8;
|
|
2013
|
+
font-size: 12px;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
&__meta {
|
|
2017
|
+
margin-top: 5px;
|
|
2018
|
+
color: #64748b;
|
|
2019
|
+
font-size: 12px;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
&__actions {
|
|
2023
|
+
position: absolute;
|
|
2024
|
+
right: 18px;
|
|
2025
|
+
bottom: 12px;
|
|
2026
|
+
display: flex;
|
|
2027
|
+
gap: 8px;
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
&__tabs {
|
|
2031
|
+
flex: 1;
|
|
2032
|
+
min-height: 0;
|
|
2033
|
+
display: flex;
|
|
2034
|
+
flex-direction: column;
|
|
2035
|
+
|
|
2036
|
+
:deep(.el-tabs__header) {
|
|
2037
|
+
flex-shrink: 0;
|
|
2038
|
+
margin: 0;
|
|
2039
|
+
padding: 0 18px;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
:deep(.el-tabs__content) {
|
|
2043
|
+
flex: 1;
|
|
2044
|
+
min-height: 0;
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
:deep(.el-tab-pane) {
|
|
2048
|
+
height: 100%;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
&__chart {
|
|
2053
|
+
height: 100%;
|
|
2054
|
+
min-height: 0;
|
|
2055
|
+
padding: 12px;
|
|
2056
|
+
box-sizing: border-box;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
&__scroll {
|
|
2060
|
+
height: 100%;
|
|
2061
|
+
overflow: auto;
|
|
2062
|
+
padding: 16px 18px;
|
|
2063
|
+
box-sizing: border-box;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
.wb-dot {
|
|
2068
|
+
margin: 0 6px;
|
|
2069
|
+
color: #cbd5e1;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
.wb-info-bar {
|
|
2073
|
+
display: flex;
|
|
2074
|
+
align-items: center;
|
|
2075
|
+
gap: 8px;
|
|
2076
|
+
flex-wrap: wrap;
|
|
2077
|
+
padding: 10px 12px;
|
|
2078
|
+
margin-bottom: 12px;
|
|
2079
|
+
border-radius: 8px;
|
|
2080
|
+
background: #f8fafc;
|
|
2081
|
+
color: #64748b;
|
|
2082
|
+
|
|
2083
|
+
strong {
|
|
2084
|
+
color: #1e293b;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
&__time {
|
|
2088
|
+
margin-left: auto;
|
|
2089
|
+
color: #94a3b8;
|
|
2090
|
+
font-size: 12px;
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
.wb-snapshot {
|
|
2095
|
+
margin-top: 12px;
|
|
2096
|
+
|
|
2097
|
+
:deep(.el-collapse-item__header) {
|
|
2098
|
+
font-size: 13px;
|
|
2099
|
+
color: #64748b;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
pre {
|
|
2103
|
+
margin: 0;
|
|
2104
|
+
max-height: 320px;
|
|
2105
|
+
overflow: auto;
|
|
2106
|
+
padding: 12px;
|
|
2107
|
+
border-radius: 6px;
|
|
2108
|
+
background: #0f172a;
|
|
2109
|
+
color: #e2e8f0;
|
|
2110
|
+
font-size: 12px;
|
|
2111
|
+
line-height: 1.6;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
.wb-timeline {
|
|
2116
|
+
padding-left: 2px;
|
|
2117
|
+
|
|
2118
|
+
:deep(.el-timeline-item__timestamp) {
|
|
2119
|
+
font-size: 12px;
|
|
2120
|
+
color: #94a3b8;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
.wb-event {
|
|
2125
|
+
color: #334155;
|
|
2126
|
+
|
|
2127
|
+
&__meta {
|
|
2128
|
+
margin-top: 2px;
|
|
2129
|
+
color: #94a3b8;
|
|
2130
|
+
font-size: 12px;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
.wb-trace-block {
|
|
2135
|
+
margin-top: 16px;
|
|
2136
|
+
|
|
2137
|
+
h4 {
|
|
2138
|
+
margin: 0 0 8px;
|
|
2139
|
+
font-size: 13px;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
.wb-alert {
|
|
2144
|
+
margin-bottom: 6px;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
.flow-workbench__rail {
|
|
2148
|
+
width: 330px;
|
|
2149
|
+
flex-shrink: 0;
|
|
2150
|
+
min-height: 0;
|
|
2151
|
+
display: flex;
|
|
2152
|
+
flex-direction: column;
|
|
2153
|
+
gap: 12px;
|
|
2154
|
+
overflow: auto;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
.wb-panel--users,
|
|
2158
|
+
.wb-panel--tasks {
|
|
2159
|
+
flex-shrink: 0;
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
.wb-user-list {
|
|
2163
|
+
padding: 8px;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
.wb-user {
|
|
2167
|
+
width: 100%;
|
|
2168
|
+
display: flex;
|
|
2169
|
+
align-items: center;
|
|
2170
|
+
gap: 8px;
|
|
2171
|
+
padding: 7px 8px;
|
|
2172
|
+
border: 1px solid transparent;
|
|
2173
|
+
border-radius: 8px;
|
|
2174
|
+
background: transparent;
|
|
2175
|
+
cursor: pointer;
|
|
2176
|
+
text-align: left;
|
|
2177
|
+
|
|
2178
|
+
&:hover {
|
|
2179
|
+
background: #f8fafc;
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
&.is-active {
|
|
2183
|
+
background: #f0f7ff;
|
|
2184
|
+
border-color: #bfdbfe;
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
&__avatar {
|
|
2188
|
+
width: 28px;
|
|
2189
|
+
height: 28px;
|
|
2190
|
+
flex-shrink: 0;
|
|
2191
|
+
display: inline-flex;
|
|
2192
|
+
align-items: center;
|
|
2193
|
+
justify-content: center;
|
|
2194
|
+
border-radius: 50%;
|
|
2195
|
+
background: #e0edff;
|
|
2196
|
+
color: #2563eb;
|
|
2197
|
+
font-size: 12px;
|
|
2198
|
+
font-weight: 600;
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
&__main {
|
|
2202
|
+
flex: 1;
|
|
2203
|
+
min-width: 0;
|
|
2204
|
+
display: flex;
|
|
2205
|
+
flex-direction: column;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
&__name {
|
|
2209
|
+
display: flex;
|
|
2210
|
+
align-items: center;
|
|
2211
|
+
gap: 6px;
|
|
2212
|
+
font-size: 12px;
|
|
2213
|
+
color: #1e293b;
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
&__current {
|
|
2217
|
+
padding: 0 5px;
|
|
2218
|
+
border-radius: 8px;
|
|
2219
|
+
background: #3296fa;
|
|
2220
|
+
color: #fff;
|
|
2221
|
+
font-size: 10px;
|
|
2222
|
+
line-height: 16px;
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
&__meta {
|
|
2226
|
+
margin-top: 2px;
|
|
2227
|
+
color: #94a3b8;
|
|
2228
|
+
font-size: 11px;
|
|
2229
|
+
overflow: hidden;
|
|
2230
|
+
text-overflow: ellipsis;
|
|
2231
|
+
white-space: nowrap;
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
&__badge {
|
|
2235
|
+
min-width: 18px;
|
|
2236
|
+
height: 18px;
|
|
2237
|
+
padding: 0 5px;
|
|
2238
|
+
border-radius: 9px;
|
|
2239
|
+
background: #f59e0b;
|
|
2240
|
+
color: #fff;
|
|
2241
|
+
font-size: 11px;
|
|
2242
|
+
line-height: 18px;
|
|
2243
|
+
text-align: center;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
.wb-panel--tasks {
|
|
2248
|
+
flex: 1;
|
|
2249
|
+
min-height: 300px;
|
|
2250
|
+
overflow: auto;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
.wb-instance-tools {
|
|
2254
|
+
display: flex;
|
|
2255
|
+
align-items: center;
|
|
2256
|
+
gap: 4px;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
.wb-task {
|
|
2260
|
+
margin: 0 12px 10px;
|
|
2261
|
+
padding: 10px;
|
|
2262
|
+
border: 1px solid #e2e8f0;
|
|
2263
|
+
border-radius: 8px;
|
|
2264
|
+
|
|
2265
|
+
&__head {
|
|
2266
|
+
display: flex;
|
|
2267
|
+
align-items: center;
|
|
2268
|
+
justify-content: space-between;
|
|
2269
|
+
gap: 6px;
|
|
2270
|
+
|
|
2271
|
+
strong {
|
|
2272
|
+
font-size: 13px;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
&__progress {
|
|
2277
|
+
margin-top: 4px;
|
|
2278
|
+
color: #94a3b8;
|
|
2279
|
+
font-size: 11px;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
&__approvers {
|
|
2283
|
+
display: flex;
|
|
2284
|
+
flex-wrap: wrap;
|
|
2285
|
+
gap: 4px;
|
|
2286
|
+
margin-top: 6px;
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
&__instance {
|
|
2290
|
+
display: inline-flex;
|
|
2291
|
+
align-items: center;
|
|
2292
|
+
max-width: 100%;
|
|
2293
|
+
margin-top: 5px;
|
|
2294
|
+
padding: 0;
|
|
2295
|
+
border: none;
|
|
2296
|
+
background: transparent;
|
|
2297
|
+
color: #2563eb;
|
|
2298
|
+
font-size: 11px;
|
|
2299
|
+
cursor: pointer;
|
|
2300
|
+
overflow: hidden;
|
|
2301
|
+
text-overflow: ellipsis;
|
|
2302
|
+
white-space: nowrap;
|
|
2303
|
+
|
|
2304
|
+
&:hover {
|
|
2305
|
+
text-decoration: underline;
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
&__deadline {
|
|
2310
|
+
margin-top: 5px;
|
|
2311
|
+
color: #b45309;
|
|
2312
|
+
font-size: 11px;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
&__comment {
|
|
2316
|
+
margin-top: 6px;
|
|
2317
|
+
padding: 4px 8px;
|
|
2318
|
+
border-radius: 4px;
|
|
2319
|
+
background: #f8fafc;
|
|
2320
|
+
color: #64748b;
|
|
2321
|
+
font-size: 12px;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
&__policy {
|
|
2325
|
+
margin-top: 5px;
|
|
2326
|
+
color: #b45309;
|
|
2327
|
+
font-size: 11px;
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
&__actions {
|
|
2331
|
+
display: flex;
|
|
2332
|
+
gap: 6px;
|
|
2333
|
+
margin-top: 8px;
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
.wb-cc-list {
|
|
2338
|
+
padding: 0 12px 12px;
|
|
2339
|
+
|
|
2340
|
+
h4 {
|
|
2341
|
+
margin: 0 0 6px;
|
|
2342
|
+
font-size: 13px;
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
.wb-cc-row {
|
|
2347
|
+
display: flex;
|
|
2348
|
+
align-items: center;
|
|
2349
|
+
flex-wrap: wrap;
|
|
2350
|
+
gap: 6px;
|
|
2351
|
+
padding: 5px 0;
|
|
2352
|
+
border-bottom: 1px dashed #eef2f7;
|
|
2353
|
+
color: #64748b;
|
|
2354
|
+
font-size: 12px;
|
|
2355
|
+
|
|
2356
|
+
&:last-child {
|
|
2357
|
+
border-bottom: none;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
.wb-muted {
|
|
2362
|
+
color: #94a3b8;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
.wb-resubmit {
|
|
2366
|
+
max-height: 60vh;
|
|
2367
|
+
overflow: auto;
|
|
2368
|
+
padding-right: 4px;
|
|
2369
|
+
|
|
2370
|
+
&__tip {
|
|
2371
|
+
margin-bottom: 10px;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
.wb-hidden-input {
|
|
2376
|
+
display: none;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
.wb-dialog-task {
|
|
2380
|
+
display: flex;
|
|
2381
|
+
align-items: center;
|
|
2382
|
+
flex-wrap: wrap;
|
|
2383
|
+
gap: 8px;
|
|
2384
|
+
margin-bottom: 14px;
|
|
2385
|
+
padding: 8px 12px;
|
|
2386
|
+
border-radius: 6px;
|
|
2387
|
+
background: #f8fafc;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
.wb-create__tabs {
|
|
2391
|
+
:deep(.el-tabs__content) {
|
|
2392
|
+
height: 58vh;
|
|
2393
|
+
overflow: hidden;
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
.wb-create {
|
|
2398
|
+
display: flex;
|
|
2399
|
+
gap: 14px;
|
|
2400
|
+
height: 100%;
|
|
2401
|
+
|
|
2402
|
+
&__form {
|
|
2403
|
+
flex: 1;
|
|
2404
|
+
min-width: 0;
|
|
2405
|
+
overflow: auto;
|
|
2406
|
+
padding-right: 6px;
|
|
2407
|
+
|
|
2408
|
+
:deep(.form-view-container) {
|
|
2409
|
+
height: auto;
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
:deep(.form-view-content) {
|
|
2413
|
+
overflow: visible;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
&__side {
|
|
2418
|
+
width: 280px;
|
|
2419
|
+
flex-shrink: 0;
|
|
2420
|
+
overflow: auto;
|
|
2421
|
+
padding: 12px;
|
|
2422
|
+
border-radius: 8px;
|
|
2423
|
+
background: #f8fafc;
|
|
2424
|
+
border: 1px solid #eef2f7;
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
&__field {
|
|
2428
|
+
display: flex;
|
|
2429
|
+
flex-direction: column;
|
|
2430
|
+
gap: 6px;
|
|
2431
|
+
margin-bottom: 14px;
|
|
2432
|
+
|
|
2433
|
+
label {
|
|
2434
|
+
font-size: 12px;
|
|
2435
|
+
color: #64748b;
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
&__cc {
|
|
2440
|
+
h4 {
|
|
2441
|
+
margin: 0 0 8px;
|
|
2442
|
+
font-size: 13px;
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
&__cc-row {
|
|
2447
|
+
display: flex;
|
|
2448
|
+
flex-direction: column;
|
|
2449
|
+
gap: 5px;
|
|
2450
|
+
margin-bottom: 10px;
|
|
2451
|
+
|
|
2452
|
+
> span {
|
|
2453
|
+
font-size: 12px;
|
|
2454
|
+
color: #64748b;
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
&__preview {
|
|
2459
|
+
height: 100%;
|
|
2460
|
+
display: flex;
|
|
2461
|
+
flex-direction: column;
|
|
2462
|
+
min-height: 0;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
&__preview-head {
|
|
2466
|
+
flex-shrink: 0;
|
|
2467
|
+
display: flex;
|
|
2468
|
+
align-items: center;
|
|
2469
|
+
justify-content: space-between;
|
|
2470
|
+
gap: 10px;
|
|
2471
|
+
margin-bottom: 8px;
|
|
2472
|
+
color: #94a3b8;
|
|
2473
|
+
font-size: 12px;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
&__preview-chart {
|
|
2477
|
+
flex: 1;
|
|
2478
|
+
min-height: 0;
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
&__footer {
|
|
2482
|
+
display: flex;
|
|
2483
|
+
align-items: center;
|
|
2484
|
+
justify-content: flex-end;
|
|
2485
|
+
gap: 8px;
|
|
2486
|
+
|
|
2487
|
+
.wb-muted {
|
|
2488
|
+
margin-right: auto;
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
@media (max-width: 1280px) {
|
|
2494
|
+
.flow-workbench__sidebar {
|
|
2495
|
+
width: 230px;
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
.flow-workbench__rail {
|
|
2499
|
+
width: 300px;
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
</style>
|