gbflowengine 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +271 -271
  2. package/dist/gbflowengine.css +1 -1
  3. package/dist/gbflowengine.js +8232 -6913
  4. package/dist/gbflowengine.js.map +1 -1
  5. package/dist/gbflowengine.umd.cjs +2 -2
  6. package/dist/gbflowengine.umd.cjs.map +1 -1
  7. package/package.json +85 -84
  8. package/src/center/DefinitionInspect.vue +291 -291
  9. package/src/center/FlowCenter.vue +33 -33
  10. package/src/center/index.js +29 -29
  11. package/src/center/storage.js +748 -748
  12. package/src/core/flow/condition.js +160 -160
  13. package/src/core/flow/customNode.js +385 -385
  14. package/src/core/flow/defaults.js +124 -124
  15. package/src/core/flow/flowConstant.js +265 -265
  16. package/src/core/flow/flowNodeUtils.js +29 -29
  17. package/src/core/flow/index.js +47 -47
  18. package/src/core/flow/node.js +44 -44
  19. package/src/core/flow/nodeFactory.js +58 -58
  20. package/src/core/flow/prediction.js +325 -325
  21. package/src/core/flow/schema.js +864 -864
  22. package/src/definition/FlowDefinitionDesigner.vue +338 -338
  23. package/src/definition/index.js +9 -9
  24. package/src/index.js +39 -39
  25. package/src/storage.js +200 -200
  26. package/src/testing/FlowTestPanel.vue +2502 -2502
  27. package/src/testing/UserConfigDrawer.vue +376 -376
  28. package/src/testing/diagram/FlowProgressDiagram.vue +318 -318
  29. package/src/testing/diagramModel.js +517 -517
  30. package/src/testing/index.js +23 -23
  31. package/src/testing/mock.js +246 -246
  32. package/src/testing/oaExecutors.js +51 -51
  33. package/src/testing/oaSeed.js +467 -467
  34. package/src/testing/sample.js +412 -412
  35. package/src/testing/seed.js +122 -122
  36. package/src/utils/format.js +27 -27
  37. package/src/visual/FlowCanvas.vue +440 -440
  38. package/src/visual/NodeProgressDetail.vue +43 -43
  39. package/src/visual/NodeStatusBadge.vue +17 -17
  40. package/src/visual/NodeWrap.vue +46 -46
  41. package/src/visual/ScWorkflow.vue +49 -49
  42. package/src/visual/SelectDialog.vue +459 -459
  43. package/src/visual/conditionHelpers.js +116 -116
  44. package/src/visual/index.js +6 -6
  45. package/src/visual/nodes/AddNode.vue +222 -222
  46. package/src/visual/nodes/ApproverNode.vue +347 -347
  47. package/src/visual/nodes/BranchNode.vue +441 -441
  48. package/src/visual/nodes/CustomNode.vue +339 -339
  49. package/src/visual/nodes/EndNode.vue +21 -21
  50. package/src/visual/nodes/PassNode.vue +100 -100
  51. package/src/visual/nodes/PromoterNode.vue +134 -134
  52. package/src/visual/nodes/RejectNode.vue +100 -100
  53. package/src/visual/nodes/SendNode.vue +151 -151
  54. package/src/visual/styles.scss +879 -879
  55. package/src/visual/useScNodeStatus.js +18 -18
  56. package/src/workbench/OaWorkbench.vue +1341 -1341
  57. package/src/workbench/components/ApprovalWorkspace.vue +2090 -2090
  58. package/src/workbench/components/CategoryIcon.vue +74 -74
  59. package/src/workbench/components/NotificationIcon.vue +73 -73
  60. package/src/workbench/components/ProcessSteps.vue +557 -557
  61. package/src/workbench/components/ResubmitDialog.vue +227 -227
  62. package/src/workbench/components/SidebarNav.vue +138 -138
  63. package/src/workbench/components/StartFlowDialog.vue +1058 -1058
  64. package/src/workbench/components/UserAvatar.vue +68 -68
  65. package/src/workbench/model.js +1080 -1080
  66. package/src/workbench/pages/DesignPage.vue +798 -798
  67. package/src/workbench/pages/HomePage.vue +1050 -1050
  68. package/src/workbench/pages/MonitorPage.vue +1029 -1029
  69. package/src/workbench/pages/NotificationsPage.vue +554 -554
  70. package/src/workbench/pages/RequestsPage.vue +644 -644
  71. package/src/workbench/pages/TaskCenterPage.vue +1155 -1155
  72. package/src/workbench/pages/TemplatesPage.vue +680 -680
  73. package/src/workbench/styles.scss +555 -555
  74. package/types/center.d.ts +5 -5
  75. package/types/core.d.ts +479 -479
  76. package/types/definition.d.ts +4 -4
  77. package/types/index.d.ts +34 -34
  78. package/types/testing.d.ts +20 -20
  79. package/types/visual.d.ts +20 -20
@@ -1,557 +1,557 @@
1
- <template>
2
- <div class="oa-steps" :class="{ 'oa-steps--compact': compact }">
3
- <article
4
- v-for="(step, index) in steps"
5
- :key="step.key || index"
6
- class="oa-step"
7
- :class="[`is-${step.status}`, `is-kind-${step.kind}`]"
8
- >
9
- <div class="oa-step__rail">
10
- <span class="oa-step__dot">
11
- <el-icon>
12
- <component :is="iconOf(step)" />
13
- </el-icon>
14
- </span>
15
- <span v-if="index < steps.length - 1" class="oa-step__line"></span>
16
- </div>
17
-
18
- <div class="oa-step__body">
19
- <header class="oa-step__head">
20
- <div class="oa-step__title-wrap">
21
- <h4>{{ step.title }}</h4>
22
- <p v-if="step.subtitle">{{ step.subtitle }}</p>
23
- </div>
24
- <div class="oa-step__head-right">
25
- <span v-if="step.status === 'current'" class="oa-step__now">当前</span>
26
- <span v-else-if="step.status === 'upcoming'" class="oa-step__upcoming">待执行</span>
27
- <time v-if="step.at && !compact" class="oa-step__time oa-num">
28
- {{ formatDateTime(step.at) }}
29
- </time>
30
- </div>
31
- </header>
32
-
33
- <div
34
- v-if="!compact && step.records && step.records.length"
35
- class="oa-step__records"
36
- >
37
- <div
38
- v-for="(record, recordIndex) in step.records"
39
- :key="`${step.key}_record_${recordIndex}`"
40
- class="oa-step__record"
41
- :class="{ 'is-system': record.system }"
42
- >
43
- <span class="oa-step__record-actor">{{ record.actorName }}</span>
44
- <span class="oa-step__record-action" :class="actionTone(record.action)">
45
- {{ record.actionLabel }}
46
- <template v-if="record.targetName">给 {{ record.targetName }}</template>
47
- </span>
48
- <time class="oa-step__record-time oa-num">{{ formatDateTime(record.at, { short: true }) }}</time>
49
- <p v-if="record.comment" class="oa-step__comment">{{ record.comment }}</p>
50
- </div>
51
- </div>
52
-
53
- <div
54
- v-else-if="!compact && step.actors && step.actors.length"
55
- class="oa-step__actors"
56
- >
57
- <span
58
- v-for="actor in step.actors"
59
- :key="`${step.key}_${actor.name}`"
60
- class="oa-step__actor"
61
- :class="{ 'is-done': actor.done }"
62
- >
63
- <i></i>{{ actor.name }}
64
- <em v-if="actor.addedBy">加签 · {{ actor.addedBy }}</em>
65
- </span>
66
- <span v-if="step.progress && step.progress.total > 1" class="oa-step__progress oa-num">
67
- {{ step.task?.signMode === 'or'
68
- ? (step.progress.approved ? `已同意 ${step.progress.approved}/${step.progress.total}` : '或签 · 任意一人')
69
- : `${step.progress.approved}/${step.progress.total} 已同意` }}
70
- </span>
71
- </div>
72
-
73
- <div v-if="!compact" class="oa-step__flags">
74
- <span v-if="step.overdue" class="oa-chip oa-chip--danger">
75
- <el-icon><WarningFilled /></el-icon>
76
- 已等待 {{ formatElapsed(step.createdAt, now) }}
77
- </span>
78
- <span v-else-if="step.status === 'current' && step.waitHours" class="oa-chip oa-chip--warning">
79
- 已等待 {{ formatElapsed(step.createdAt, now) }}
80
- </span>
81
- <span v-if="step.kind === 'cc' && step.status === 'done'" class="oa-chip">已送达</span>
82
- <button
83
- v-if="step.kind === 'custom' && step.task?.result !== undefined"
84
- type="button"
85
- class="oa-link oa-step__result-toggle"
86
- @click="toggleResult(step.key)"
87
- >
88
- {{ isResultOpen(step.key) ? '收起执行结果' : '查看执行结果' }}
89
- </button>
90
- </div>
91
- <pre
92
- v-if="!compact && step.kind === 'custom' && step.task?.result !== undefined && isResultOpen(step.key)"
93
- class="oa-step__result"
94
- >{{ formatResult(step.task.result) }}</pre>
95
- </div>
96
- </article>
97
- </div>
98
- </template>
99
-
100
- <script setup>
101
- import {
102
- ChatDotRound,
103
- CircleCheckFilled,
104
- CircleCloseFilled,
105
- Clock,
106
- SetUp,
107
- Finished,
108
- UserFilled,
109
- VideoPlay,
110
- WarningFilled
111
- } from '@element-plus/icons-vue'
112
- import { ref } from 'vue'
113
- import { formatDateTime } from '../../utils/format.js'
114
- import { formatElapsed } from '../model.js'
115
-
116
- defineOptions({ name: 'OaProcessSteps' })
117
-
118
- defineProps({
119
- steps: { type: Array, default: () => [] },
120
- compact: { type: Boolean, default: false },
121
- now: { type: Number, default: Date.now }
122
- })
123
-
124
- const expandedResults = ref([])
125
-
126
- function isResultOpen(key) {
127
- return expandedResults.value.includes(key)
128
- }
129
-
130
- function toggleResult(key) {
131
- expandedResults.value = isResultOpen(key)
132
- ? expandedResults.value.filter((item) => item !== key)
133
- : [...expandedResults.value, key]
134
- }
135
-
136
- function formatResult(result) {
137
- if (typeof result === 'string') return result.slice(0, 4000)
138
- try {
139
- return JSON.stringify(result, null, 2).slice(0, 4000)
140
- } catch {
141
- return String(result)
142
- }
143
- }
144
-
145
- const iconOf = (step) => {
146
- if (step.status === 'failed') return CircleCloseFilled
147
- if (step.status === 'rejected') return CircleCloseFilled
148
- if (step.status === 'cancelled') return CircleCloseFilled
149
- if (step.kind === 'start') return VideoPlay
150
- if (step.kind === 'cc') return ChatDotRound
151
- if (step.kind === 'custom') return SetUp
152
- if (step.kind === 'end') return step.status === 'done' ? Finished : CircleCheckFilled
153
- if (step.status === 'upcoming') return Clock
154
- if (step.status === 'current') return Clock
155
- return UserFilled
156
- }
157
-
158
- const actionTone = (action) => {
159
- if (action === 'approve' || action === 'execute') return 'is-success'
160
- if (action === 'reject' || action === 'executeFailed') return 'is-danger'
161
- if (action === 'transfer' || action === 'addSign') return 'is-info'
162
- return ''
163
- }
164
- </script>
165
-
166
- <style scoped lang="scss">
167
- .oa-steps {
168
- display: flex;
169
- flex-direction: column;
170
- min-width: 0;
171
- }
172
-
173
- .oa-step {
174
- display: grid;
175
- grid-template-columns: 26px minmax(0, 1fr);
176
- gap: 10px;
177
- min-width: 0;
178
-
179
- &__rail {
180
- display: flex;
181
- flex-direction: column;
182
- align-items: center;
183
- padding-top: 1px;
184
- }
185
-
186
- &__dot {
187
- position: relative;
188
- z-index: 1;
189
- display: grid;
190
- place-items: center;
191
- width: 24px;
192
- height: 24px;
193
- border: 1px solid var(--oa-line-strong);
194
- border-radius: 50%;
195
- background: #fff;
196
- color: var(--oa-faint);
197
- font-size: 11px;
198
- }
199
-
200
- &__line {
201
- flex: 1;
202
- width: 1px;
203
- margin: 3px 0;
204
- background: var(--oa-line);
205
- }
206
-
207
- &__body {
208
- min-width: 0;
209
- padding-bottom: 22px;
210
- }
211
-
212
- &__head {
213
- display: flex;
214
- align-items: flex-start;
215
- justify-content: space-between;
216
- gap: 10px;
217
- min-height: 24px;
218
-
219
- h4 {
220
- margin: 2px 0 0;
221
- color: var(--oa-ink);
222
- font-size: 13px;
223
- font-weight: 600;
224
- line-height: 1.5;
225
- }
226
-
227
- p {
228
- margin: 3px 0 0;
229
- color: var(--oa-faint);
230
- font-size: 11.5px;
231
- line-height: 1.5;
232
- }
233
- }
234
-
235
- &__title-wrap {
236
- min-width: 0;
237
- }
238
-
239
- &__head-right {
240
- display: flex;
241
- align-items: center;
242
- gap: 6px;
243
- flex-shrink: 0;
244
- padding-top: 1px;
245
- }
246
-
247
- &__time {
248
- color: var(--oa-faint);
249
- font-size: 11px;
250
- }
251
-
252
- &__now {
253
- padding: 0 7px;
254
- border-radius: 4px;
255
- background: var(--oa-primary);
256
- color: #fff;
257
- font-size: 10px;
258
- font-weight: 600;
259
- line-height: 18px;
260
- }
261
-
262
- &__upcoming {
263
- color: var(--oa-faint);
264
- font-size: 10px;
265
- }
266
-
267
- &__records {
268
- display: flex;
269
- flex-direction: column;
270
- gap: 6px;
271
- margin-top: 8px;
272
- }
273
-
274
- &__record {
275
- display: flex;
276
- flex-wrap: wrap;
277
- align-items: center;
278
- gap: 6px;
279
- padding: 7px 9px;
280
- border-radius: 6px;
281
- background: var(--oa-surface-soft);
282
- font-size: 11.5px;
283
-
284
- &.is-system {
285
- color: var(--oa-muted);
286
- background: #f0f4fa;
287
- }
288
- }
289
-
290
- &__record-actor {
291
- color: var(--oa-ink);
292
- font-weight: 600;
293
- }
294
-
295
- &__record-action {
296
- padding: 0 5px;
297
- border-radius: 3px;
298
- background: #edf1f7;
299
- color: var(--oa-muted);
300
- font-size: 10.5px;
301
-
302
- &.is-success {
303
- background: var(--oa-success-soft);
304
- color: var(--oa-success);
305
- }
306
-
307
- &.is-danger {
308
- background: var(--oa-danger-soft);
309
- color: var(--oa-danger);
310
- }
311
-
312
- &.is-info {
313
- background: var(--oa-primary-soft);
314
- color: var(--oa-primary);
315
- }
316
- }
317
-
318
- &__record-time {
319
- margin-left: auto;
320
- color: var(--oa-faint);
321
- font-size: 10.5px;
322
- }
323
-
324
- &__comment {
325
- flex: 0 0 100%;
326
- margin: 1px 0 0;
327
- color: var(--oa-muted);
328
- font-size: 11.5px;
329
- line-height: 1.6;
330
- word-break: break-word;
331
- }
332
-
333
- &__actors {
334
- display: flex;
335
- flex-wrap: wrap;
336
- align-items: center;
337
- gap: 6px;
338
- margin-top: 8px;
339
- }
340
-
341
- &__actor {
342
- display: inline-flex;
343
- align-items: center;
344
- gap: 5px;
345
- padding: 2px 7px;
346
- border-radius: 4px;
347
- background: #f1f4f9;
348
- color: var(--oa-muted);
349
- font-size: 11px;
350
-
351
- i {
352
- width: 5px;
353
- height: 5px;
354
- border-radius: 50%;
355
- background: #b6c0cf;
356
- }
357
-
358
- &.is-done {
359
- background: var(--oa-success-soft);
360
- color: var(--oa-success);
361
-
362
- i {
363
- background: var(--oa-success);
364
- }
365
- }
366
-
367
- em {
368
- color: var(--oa-faint);
369
- font-size: 10px;
370
- font-style: normal;
371
- }
372
- }
373
-
374
- &__progress {
375
- margin-left: auto;
376
- color: var(--oa-faint);
377
- font-size: 10.5px;
378
- }
379
-
380
- &__flags {
381
- display: flex;
382
- flex-wrap: wrap;
383
- gap: 5px;
384
- margin-top: 7px;
385
-
386
- &:empty {
387
- display: none;
388
- }
389
- }
390
-
391
- &.is-current {
392
- .oa-step__dot {
393
- border-color: var(--oa-primary);
394
- background: var(--oa-primary);
395
- color: #fff;
396
- box-shadow: 0 0 0 4px rgba(36, 86, 214, 0.11);
397
- }
398
-
399
- h4 {
400
- color: var(--oa-primary-dark);
401
- }
402
-
403
- .oa-step__body {
404
- position: relative;
405
-
406
- &::before {
407
- content: '';
408
- position: absolute;
409
- inset: 30px 0 10px -12px;
410
- border-radius: 8px;
411
- background: linear-gradient(90deg, rgba(36, 86, 214, 0.04), transparent 70%);
412
- pointer-events: none;
413
- }
414
- }
415
- }
416
-
417
- &.is-done {
418
- .oa-step__dot {
419
- border-color: #bfe1d0;
420
- background: var(--oa-success-soft);
421
- color: var(--oa-success);
422
- }
423
-
424
- .oa-step__line {
425
- background: #cfe5da;
426
- }
427
- }
428
-
429
- &.is-rejected,
430
- &.is-failed {
431
- .oa-step__dot {
432
- border-color: #f0cbc7;
433
- background: var(--oa-danger-soft);
434
- color: var(--oa-danger);
435
- }
436
-
437
- h4 {
438
- color: var(--oa-danger);
439
- }
440
- }
441
-
442
- &.is-cancelled {
443
- .oa-step__dot {
444
- border-color: var(--oa-line);
445
- background: #f2f4f8;
446
- color: var(--oa-faint);
447
- }
448
-
449
- h4,
450
- .oa-step__title-wrap p {
451
- color: var(--oa-faint);
452
- }
453
- }
454
-
455
- &.is-upcoming {
456
- .oa-step__dot {
457
- border-style: dashed;
458
- color: #a3aec0;
459
- background: #fbfcfe;
460
- }
461
-
462
- h4 {
463
- color: #8b97a9;
464
- font-weight: 500;
465
- }
466
-
467
- .oa-step__body {
468
- padding-bottom: 16px;
469
- }
470
- }
471
-
472
- &.is-kind-cc.is-done {
473
- .oa-step__dot {
474
- border-color: #d8e2f8;
475
- background: var(--oa-primary-soft);
476
- color: var(--oa-primary);
477
- }
478
- }
479
-
480
- &.is-kind-custom.is-done {
481
- .oa-step__dot {
482
- border-color: #ddd6fe;
483
- background: #f4f1ff;
484
- color: #6f5cf1;
485
- }
486
- }
487
-
488
- &.is-kind-custom.is-current {
489
- .oa-step__dot {
490
- border-color: #6f5cf1;
491
- background: #6f5cf1;
492
- color: #fff;
493
- box-shadow: 0 0 0 4px rgba(111, 92, 241, 0.12);
494
- }
495
- }
496
-
497
- &.is-kind-end {
498
- .oa-step__body {
499
- padding-bottom: 0;
500
- }
501
- }
502
-
503
- &:last-child &__line {
504
- display: none;
505
- }
506
- }
507
-
508
- .oa-steps--compact {
509
- .oa-step {
510
- grid-template-columns: 20px minmax(0, 1fr);
511
- gap: 8px;
512
- }
513
-
514
- .oa-step__dot {
515
- width: 18px;
516
- height: 18px;
517
- font-size: 9px;
518
- }
519
-
520
- .oa-step__body {
521
- padding-bottom: 12px;
522
- }
523
-
524
- .oa-step__head {
525
- min-height: 18px;
526
-
527
- h4 {
528
- margin-top: 0;
529
- font-size: 12px;
530
- }
531
-
532
- p {
533
- font-size: 11px;
534
- }
535
- }
536
- }
537
-
538
- .oa-step__result-toggle {
539
- margin-left: auto;
540
- font-size: 10.5px;
541
- }
542
-
543
- .oa-step__result {
544
- max-height: 180px;
545
- overflow: auto;
546
- margin: 7px 0 0;
547
- padding: 9px 10px;
548
- border-radius: 6px;
549
- background: #f7f9fc;
550
- color: #475569;
551
- font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
552
- font-size: 10.5px;
553
- line-height: 1.6;
554
- white-space: pre-wrap;
555
- word-break: break-all;
556
- }
557
- </style>
1
+ <template>
2
+ <div class="oa-steps" :class="{ 'oa-steps--compact': compact }">
3
+ <article
4
+ v-for="(step, index) in steps"
5
+ :key="step.key || index"
6
+ class="oa-step"
7
+ :class="[`is-${step.status}`, `is-kind-${step.kind}`]"
8
+ >
9
+ <div class="oa-step__rail">
10
+ <span class="oa-step__dot">
11
+ <el-icon>
12
+ <component :is="iconOf(step)" />
13
+ </el-icon>
14
+ </span>
15
+ <span v-if="index < steps.length - 1" class="oa-step__line"></span>
16
+ </div>
17
+
18
+ <div class="oa-step__body">
19
+ <header class="oa-step__head">
20
+ <div class="oa-step__title-wrap">
21
+ <h4>{{ step.title }}</h4>
22
+ <p v-if="step.subtitle">{{ step.subtitle }}</p>
23
+ </div>
24
+ <div class="oa-step__head-right">
25
+ <span v-if="step.status === 'current'" class="oa-step__now">当前</span>
26
+ <span v-else-if="step.status === 'upcoming'" class="oa-step__upcoming">待执行</span>
27
+ <time v-if="step.at && !compact" class="oa-step__time oa-num">
28
+ {{ formatDateTime(step.at) }}
29
+ </time>
30
+ </div>
31
+ </header>
32
+
33
+ <div
34
+ v-if="!compact && step.records && step.records.length"
35
+ class="oa-step__records"
36
+ >
37
+ <div
38
+ v-for="(record, recordIndex) in step.records"
39
+ :key="`${step.key}_record_${recordIndex}`"
40
+ class="oa-step__record"
41
+ :class="{ 'is-system': record.system }"
42
+ >
43
+ <span class="oa-step__record-actor">{{ record.actorName }}</span>
44
+ <span class="oa-step__record-action" :class="actionTone(record.action)">
45
+ {{ record.actionLabel }}
46
+ <template v-if="record.targetName">给 {{ record.targetName }}</template>
47
+ </span>
48
+ <time class="oa-step__record-time oa-num">{{ formatDateTime(record.at, { short: true }) }}</time>
49
+ <p v-if="record.comment" class="oa-step__comment">{{ record.comment }}</p>
50
+ </div>
51
+ </div>
52
+
53
+ <div
54
+ v-else-if="!compact && step.actors && step.actors.length"
55
+ class="oa-step__actors"
56
+ >
57
+ <span
58
+ v-for="actor in step.actors"
59
+ :key="`${step.key}_${actor.name}`"
60
+ class="oa-step__actor"
61
+ :class="{ 'is-done': actor.done }"
62
+ >
63
+ <i></i>{{ actor.name }}
64
+ <em v-if="actor.addedBy">加签 · {{ actor.addedBy }}</em>
65
+ </span>
66
+ <span v-if="step.progress && step.progress.total > 1" class="oa-step__progress oa-num">
67
+ {{ step.task?.signMode === 'or'
68
+ ? (step.progress.approved ? `已同意 ${step.progress.approved}/${step.progress.total}` : '或签 · 任意一人')
69
+ : `${step.progress.approved}/${step.progress.total} 已同意` }}
70
+ </span>
71
+ </div>
72
+
73
+ <div v-if="!compact" class="oa-step__flags">
74
+ <span v-if="step.overdue" class="oa-chip oa-chip--danger">
75
+ <el-icon><WarningFilled /></el-icon>
76
+ 已等待 {{ formatElapsed(step.createdAt, now) }}
77
+ </span>
78
+ <span v-else-if="step.status === 'current' && step.waitHours" class="oa-chip oa-chip--warning">
79
+ 已等待 {{ formatElapsed(step.createdAt, now) }}
80
+ </span>
81
+ <span v-if="step.kind === 'cc' && step.status === 'done'" class="oa-chip">已送达</span>
82
+ <button
83
+ v-if="step.kind === 'custom' && step.task?.result !== undefined"
84
+ type="button"
85
+ class="oa-link oa-step__result-toggle"
86
+ @click="toggleResult(step.key)"
87
+ >
88
+ {{ isResultOpen(step.key) ? '收起执行结果' : '查看执行结果' }}
89
+ </button>
90
+ </div>
91
+ <pre
92
+ v-if="!compact && step.kind === 'custom' && step.task?.result !== undefined && isResultOpen(step.key)"
93
+ class="oa-step__result"
94
+ >{{ formatResult(step.task.result) }}</pre>
95
+ </div>
96
+ </article>
97
+ </div>
98
+ </template>
99
+
100
+ <script setup>
101
+ import {
102
+ ChatDotRound,
103
+ CircleCheckFilled,
104
+ CircleCloseFilled,
105
+ Clock,
106
+ SetUp,
107
+ Finished,
108
+ UserFilled,
109
+ VideoPlay,
110
+ WarningFilled
111
+ } from 'gbicons'
112
+ import { ref } from 'vue'
113
+ import { formatDateTime } from '../../utils/format.js'
114
+ import { formatElapsed } from '../model.js'
115
+
116
+ defineOptions({ name: 'OaProcessSteps' })
117
+
118
+ defineProps({
119
+ steps: { type: Array, default: () => [] },
120
+ compact: { type: Boolean, default: false },
121
+ now: { type: Number, default: Date.now }
122
+ })
123
+
124
+ const expandedResults = ref([])
125
+
126
+ function isResultOpen(key) {
127
+ return expandedResults.value.includes(key)
128
+ }
129
+
130
+ function toggleResult(key) {
131
+ expandedResults.value = isResultOpen(key)
132
+ ? expandedResults.value.filter((item) => item !== key)
133
+ : [...expandedResults.value, key]
134
+ }
135
+
136
+ function formatResult(result) {
137
+ if (typeof result === 'string') return result.slice(0, 4000)
138
+ try {
139
+ return JSON.stringify(result, null, 2).slice(0, 4000)
140
+ } catch {
141
+ return String(result)
142
+ }
143
+ }
144
+
145
+ const iconOf = (step) => {
146
+ if (step.status === 'failed') return CircleCloseFilled
147
+ if (step.status === 'rejected') return CircleCloseFilled
148
+ if (step.status === 'cancelled') return CircleCloseFilled
149
+ if (step.kind === 'start') return VideoPlay
150
+ if (step.kind === 'cc') return ChatDotRound
151
+ if (step.kind === 'custom') return SetUp
152
+ if (step.kind === 'end') return step.status === 'done' ? Finished : CircleCheckFilled
153
+ if (step.status === 'upcoming') return Clock
154
+ if (step.status === 'current') return Clock
155
+ return UserFilled
156
+ }
157
+
158
+ const actionTone = (action) => {
159
+ if (action === 'approve' || action === 'execute') return 'is-success'
160
+ if (action === 'reject' || action === 'executeFailed') return 'is-danger'
161
+ if (action === 'transfer' || action === 'addSign') return 'is-info'
162
+ return ''
163
+ }
164
+ </script>
165
+
166
+ <style scoped lang="scss">
167
+ .oa-steps {
168
+ display: flex;
169
+ flex-direction: column;
170
+ min-width: 0;
171
+ }
172
+
173
+ .oa-step {
174
+ display: grid;
175
+ grid-template-columns: 26px minmax(0, 1fr);
176
+ gap: 10px;
177
+ min-width: 0;
178
+
179
+ &__rail {
180
+ display: flex;
181
+ flex-direction: column;
182
+ align-items: center;
183
+ padding-top: 1px;
184
+ }
185
+
186
+ &__dot {
187
+ position: relative;
188
+ z-index: 1;
189
+ display: grid;
190
+ place-items: center;
191
+ width: 24px;
192
+ height: 24px;
193
+ border: 1px solid var(--oa-line-strong);
194
+ border-radius: 50%;
195
+ background: #fff;
196
+ color: var(--oa-faint);
197
+ font-size: 11px;
198
+ }
199
+
200
+ &__line {
201
+ flex: 1;
202
+ width: 1px;
203
+ margin: 3px 0;
204
+ background: var(--oa-line);
205
+ }
206
+
207
+ &__body {
208
+ min-width: 0;
209
+ padding-bottom: 22px;
210
+ }
211
+
212
+ &__head {
213
+ display: flex;
214
+ align-items: flex-start;
215
+ justify-content: space-between;
216
+ gap: 10px;
217
+ min-height: 24px;
218
+
219
+ h4 {
220
+ margin: 2px 0 0;
221
+ color: var(--oa-ink);
222
+ font-size: 13px;
223
+ font-weight: 600;
224
+ line-height: 1.5;
225
+ }
226
+
227
+ p {
228
+ margin: 3px 0 0;
229
+ color: var(--oa-faint);
230
+ font-size: 11.5px;
231
+ line-height: 1.5;
232
+ }
233
+ }
234
+
235
+ &__title-wrap {
236
+ min-width: 0;
237
+ }
238
+
239
+ &__head-right {
240
+ display: flex;
241
+ align-items: center;
242
+ gap: 6px;
243
+ flex-shrink: 0;
244
+ padding-top: 1px;
245
+ }
246
+
247
+ &__time {
248
+ color: var(--oa-faint);
249
+ font-size: 11px;
250
+ }
251
+
252
+ &__now {
253
+ padding: 0 7px;
254
+ border-radius: 4px;
255
+ background: var(--oa-primary);
256
+ color: #fff;
257
+ font-size: 10px;
258
+ font-weight: 600;
259
+ line-height: 18px;
260
+ }
261
+
262
+ &__upcoming {
263
+ color: var(--oa-faint);
264
+ font-size: 10px;
265
+ }
266
+
267
+ &__records {
268
+ display: flex;
269
+ flex-direction: column;
270
+ gap: 6px;
271
+ margin-top: 8px;
272
+ }
273
+
274
+ &__record {
275
+ display: flex;
276
+ flex-wrap: wrap;
277
+ align-items: center;
278
+ gap: 6px;
279
+ padding: 7px 9px;
280
+ border-radius: 6px;
281
+ background: var(--oa-surface-soft);
282
+ font-size: 11.5px;
283
+
284
+ &.is-system {
285
+ color: var(--oa-muted);
286
+ background: #f0f4fa;
287
+ }
288
+ }
289
+
290
+ &__record-actor {
291
+ color: var(--oa-ink);
292
+ font-weight: 600;
293
+ }
294
+
295
+ &__record-action {
296
+ padding: 0 5px;
297
+ border-radius: 3px;
298
+ background: #edf1f7;
299
+ color: var(--oa-muted);
300
+ font-size: 10.5px;
301
+
302
+ &.is-success {
303
+ background: var(--oa-success-soft);
304
+ color: var(--oa-success);
305
+ }
306
+
307
+ &.is-danger {
308
+ background: var(--oa-danger-soft);
309
+ color: var(--oa-danger);
310
+ }
311
+
312
+ &.is-info {
313
+ background: var(--oa-primary-soft);
314
+ color: var(--oa-primary);
315
+ }
316
+ }
317
+
318
+ &__record-time {
319
+ margin-left: auto;
320
+ color: var(--oa-faint);
321
+ font-size: 10.5px;
322
+ }
323
+
324
+ &__comment {
325
+ flex: 0 0 100%;
326
+ margin: 1px 0 0;
327
+ color: var(--oa-muted);
328
+ font-size: 11.5px;
329
+ line-height: 1.6;
330
+ word-break: break-word;
331
+ }
332
+
333
+ &__actors {
334
+ display: flex;
335
+ flex-wrap: wrap;
336
+ align-items: center;
337
+ gap: 6px;
338
+ margin-top: 8px;
339
+ }
340
+
341
+ &__actor {
342
+ display: inline-flex;
343
+ align-items: center;
344
+ gap: 5px;
345
+ padding: 2px 7px;
346
+ border-radius: 4px;
347
+ background: #f1f4f9;
348
+ color: var(--oa-muted);
349
+ font-size: 11px;
350
+
351
+ i {
352
+ width: 5px;
353
+ height: 5px;
354
+ border-radius: 50%;
355
+ background: #b6c0cf;
356
+ }
357
+
358
+ &.is-done {
359
+ background: var(--oa-success-soft);
360
+ color: var(--oa-success);
361
+
362
+ i {
363
+ background: var(--oa-success);
364
+ }
365
+ }
366
+
367
+ em {
368
+ color: var(--oa-faint);
369
+ font-size: 10px;
370
+ font-style: normal;
371
+ }
372
+ }
373
+
374
+ &__progress {
375
+ margin-left: auto;
376
+ color: var(--oa-faint);
377
+ font-size: 10.5px;
378
+ }
379
+
380
+ &__flags {
381
+ display: flex;
382
+ flex-wrap: wrap;
383
+ gap: 5px;
384
+ margin-top: 7px;
385
+
386
+ &:empty {
387
+ display: none;
388
+ }
389
+ }
390
+
391
+ &.is-current {
392
+ .oa-step__dot {
393
+ border-color: var(--oa-primary);
394
+ background: var(--oa-primary);
395
+ color: #fff;
396
+ box-shadow: 0 0 0 4px rgba(36, 86, 214, 0.11);
397
+ }
398
+
399
+ h4 {
400
+ color: var(--oa-primary-dark);
401
+ }
402
+
403
+ .oa-step__body {
404
+ position: relative;
405
+
406
+ &::before {
407
+ content: '';
408
+ position: absolute;
409
+ inset: 30px 0 10px -12px;
410
+ border-radius: 8px;
411
+ background: linear-gradient(90deg, rgba(36, 86, 214, 0.04), transparent 70%);
412
+ pointer-events: none;
413
+ }
414
+ }
415
+ }
416
+
417
+ &.is-done {
418
+ .oa-step__dot {
419
+ border-color: #bfe1d0;
420
+ background: var(--oa-success-soft);
421
+ color: var(--oa-success);
422
+ }
423
+
424
+ .oa-step__line {
425
+ background: #cfe5da;
426
+ }
427
+ }
428
+
429
+ &.is-rejected,
430
+ &.is-failed {
431
+ .oa-step__dot {
432
+ border-color: #f0cbc7;
433
+ background: var(--oa-danger-soft);
434
+ color: var(--oa-danger);
435
+ }
436
+
437
+ h4 {
438
+ color: var(--oa-danger);
439
+ }
440
+ }
441
+
442
+ &.is-cancelled {
443
+ .oa-step__dot {
444
+ border-color: var(--oa-line);
445
+ background: #f2f4f8;
446
+ color: var(--oa-faint);
447
+ }
448
+
449
+ h4,
450
+ .oa-step__title-wrap p {
451
+ color: var(--oa-faint);
452
+ }
453
+ }
454
+
455
+ &.is-upcoming {
456
+ .oa-step__dot {
457
+ border-style: dashed;
458
+ color: #a3aec0;
459
+ background: #fbfcfe;
460
+ }
461
+
462
+ h4 {
463
+ color: #8b97a9;
464
+ font-weight: 500;
465
+ }
466
+
467
+ .oa-step__body {
468
+ padding-bottom: 16px;
469
+ }
470
+ }
471
+
472
+ &.is-kind-cc.is-done {
473
+ .oa-step__dot {
474
+ border-color: #d8e2f8;
475
+ background: var(--oa-primary-soft);
476
+ color: var(--oa-primary);
477
+ }
478
+ }
479
+
480
+ &.is-kind-custom.is-done {
481
+ .oa-step__dot {
482
+ border-color: #ddd6fe;
483
+ background: #f4f1ff;
484
+ color: #6f5cf1;
485
+ }
486
+ }
487
+
488
+ &.is-kind-custom.is-current {
489
+ .oa-step__dot {
490
+ border-color: #6f5cf1;
491
+ background: #6f5cf1;
492
+ color: #fff;
493
+ box-shadow: 0 0 0 4px rgba(111, 92, 241, 0.12);
494
+ }
495
+ }
496
+
497
+ &.is-kind-end {
498
+ .oa-step__body {
499
+ padding-bottom: 0;
500
+ }
501
+ }
502
+
503
+ &:last-child &__line {
504
+ display: none;
505
+ }
506
+ }
507
+
508
+ .oa-steps--compact {
509
+ .oa-step {
510
+ grid-template-columns: 20px minmax(0, 1fr);
511
+ gap: 8px;
512
+ }
513
+
514
+ .oa-step__dot {
515
+ width: 18px;
516
+ height: 18px;
517
+ font-size: 9px;
518
+ }
519
+
520
+ .oa-step__body {
521
+ padding-bottom: 12px;
522
+ }
523
+
524
+ .oa-step__head {
525
+ min-height: 18px;
526
+
527
+ h4 {
528
+ margin-top: 0;
529
+ font-size: 12px;
530
+ }
531
+
532
+ p {
533
+ font-size: 11px;
534
+ }
535
+ }
536
+ }
537
+
538
+ .oa-step__result-toggle {
539
+ margin-left: auto;
540
+ font-size: 10.5px;
541
+ }
542
+
543
+ .oa-step__result {
544
+ max-height: 180px;
545
+ overflow: auto;
546
+ margin: 7px 0 0;
547
+ padding: 9px 10px;
548
+ border-radius: 6px;
549
+ background: #f7f9fc;
550
+ color: #475569;
551
+ font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
552
+ font-size: 10.5px;
553
+ line-height: 1.6;
554
+ white-space: pre-wrap;
555
+ word-break: break-all;
556
+ }
557
+ </style>