gbflowengine 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +270 -2
  3. package/dist/gbflowengine.css +1 -0
  4. package/dist/gbflowengine.js +19682 -0
  5. package/dist/gbflowengine.js.map +1 -0
  6. package/dist/gbflowengine.umd.cjs +5 -0
  7. package/dist/gbflowengine.umd.cjs.map +1 -0
  8. package/package.json +83 -4
  9. package/src/center/DefinitionInspect.vue +291 -0
  10. package/src/center/FlowCenter.vue +33 -0
  11. package/src/center/index.js +29 -0
  12. package/src/center/storage.js +748 -0
  13. package/src/core/flow/condition.js +160 -0
  14. package/src/core/flow/customNode.js +385 -0
  15. package/src/core/flow/defaults.js +124 -0
  16. package/src/core/flow/flowConstant.js +265 -0
  17. package/src/core/flow/flowNodeUtils.js +30 -0
  18. package/src/core/flow/index.js +47 -0
  19. package/src/core/flow/node.js +44 -0
  20. package/src/core/flow/nodeFactory.js +58 -0
  21. package/src/core/flow/prediction.js +325 -0
  22. package/src/core/flow/runtime/auto.js +83 -0
  23. package/src/core/flow/runtime/decide.js +329 -0
  24. package/src/core/flow/runtime/event.js +28 -0
  25. package/src/core/flow/runtime/execute.js +357 -0
  26. package/src/core/flow/runtime/helpers.js +52 -0
  27. package/src/core/flow/runtime/query.js +146 -0
  28. package/src/core/flow/runtime/reject.js +137 -0
  29. package/src/core/flow/runtime/token.js +269 -0
  30. package/src/core/flow/runtime.js +129 -0
  31. package/src/core/flow/schema.js +864 -0
  32. package/src/definition/FlowDefinitionDesigner.vue +338 -0
  33. package/src/definition/index.js +9 -0
  34. package/src/index.js +39 -0
  35. package/src/storage.js +200 -0
  36. package/src/testing/FlowTestPanel.vue +2502 -0
  37. package/src/testing/UserConfigDrawer.vue +376 -0
  38. package/src/testing/diagram/FlowProgressDiagram.vue +318 -0
  39. package/src/testing/diagramModel.js +517 -0
  40. package/src/testing/index.js +23 -0
  41. package/src/testing/mock.js +246 -0
  42. package/src/testing/oaExecutors.js +51 -0
  43. package/src/testing/oaSeed.js +467 -0
  44. package/src/testing/sample.js +412 -0
  45. package/src/testing/seed.js +122 -0
  46. package/src/utils/format.js +27 -0
  47. package/src/visual/FlowCanvas.vue +441 -0
  48. package/src/visual/NodeProgressDetail.vue +43 -0
  49. package/src/visual/NodeStatusBadge.vue +17 -0
  50. package/src/visual/NodeWrap.vue +47 -0
  51. package/src/visual/ScWorkflow.vue +50 -0
  52. package/src/visual/SelectDialog.vue +460 -0
  53. package/src/visual/conditionHelpers.js +117 -0
  54. package/src/visual/index.js +6 -0
  55. package/src/visual/nodes/AddNode.vue +223 -0
  56. package/src/visual/nodes/ApproverNode.vue +348 -0
  57. package/src/visual/nodes/BranchNode.vue +442 -0
  58. package/src/visual/nodes/CustomNode.vue +339 -0
  59. package/src/visual/nodes/EndNode.vue +22 -0
  60. package/src/visual/nodes/PassNode.vue +101 -0
  61. package/src/visual/nodes/PromoterNode.vue +135 -0
  62. package/src/visual/nodes/RejectNode.vue +101 -0
  63. package/src/visual/nodes/SendNode.vue +152 -0
  64. package/src/visual/styles.scss +879 -0
  65. package/src/visual/useScNodeStatus.js +18 -0
  66. package/src/workbench/OaWorkbench.vue +1341 -0
  67. package/src/workbench/components/ApprovalWorkspace.vue +2090 -0
  68. package/src/workbench/components/CategoryIcon.vue +74 -0
  69. package/src/workbench/components/NotificationIcon.vue +73 -0
  70. package/src/workbench/components/ProcessSteps.vue +557 -0
  71. package/src/workbench/components/ResubmitDialog.vue +227 -0
  72. package/src/workbench/components/SidebarNav.vue +138 -0
  73. package/src/workbench/components/StartFlowDialog.vue +1058 -0
  74. package/src/workbench/components/UserAvatar.vue +68 -0
  75. package/src/workbench/custom-tasks.js +130 -0
  76. package/src/workbench/model.js +1080 -0
  77. package/src/workbench/pages/DesignPage.vue +798 -0
  78. package/src/workbench/pages/HomePage.vue +1050 -0
  79. package/src/workbench/pages/MonitorPage.vue +1029 -0
  80. package/src/workbench/pages/NotificationsPage.vue +554 -0
  81. package/src/workbench/pages/RequestsPage.vue +644 -0
  82. package/src/workbench/pages/TaskCenterPage.vue +1155 -0
  83. package/src/workbench/pages/TemplatesPage.vue +680 -0
  84. package/src/workbench/persistence.js +89 -0
  85. package/src/workbench/shared.js +18 -0
  86. package/src/workbench/styles.scss +555 -0
  87. package/src/workbench/useWorkbench.js +955 -0
  88. package/types/center.d.ts +5 -0
  89. package/types/core.d.ts +479 -0
  90. package/types/definition.d.ts +4 -0
  91. package/types/index.d.ts +34 -0
  92. package/types/testing.d.ts +20 -0
  93. package/types/visual.d.ts +20 -0
@@ -0,0 +1,554 @@
1
+ <template>
2
+ <div class="oa-page oa-notifications">
3
+ <header class="oa-page-head">
4
+ <div class="oa-page-head__main">
5
+ <p class="oa-eyebrow">消息与提醒</p>
6
+ <h1 class="oa-title">通知中心</h1>
7
+ <p class="oa-subtitle">待办到达、超时、催办、抄送与流程结果统一汇总,避免重复打扰。</p>
8
+ </div>
9
+ <div class="oa-actions">
10
+ <el-button v-if="oa.unreadNotifications.value.length" :icon="CircleCheck" plain @click="markAllRead">
11
+ 全部标为已读
12
+ </el-button>
13
+ </div>
14
+ </header>
15
+
16
+ <section class="oa-notifications__stats">
17
+ <div class="oa-notification-stat">
18
+ <span>未读</span>
19
+ <strong class="oa-num">{{ oa.unreadNotifications.value.length }}</strong>
20
+ </div>
21
+ <div class="oa-notification-stat">
22
+ <span>超时 / 催办</span>
23
+ <strong class="oa-num">{{ urgentCount }}</strong>
24
+ </div>
25
+ <div class="oa-notification-stat">
26
+ <span>今日到达</span>
27
+ <strong class="oa-num">{{ todayCount }}</strong>
28
+ </div>
29
+ <div class="oa-notification-channels">
30
+ <span><el-icon><Monitor /></el-icon>站内</span>
31
+ <span><el-icon><Message /></el-icon>邮件</span>
32
+ <span><el-icon><Phone /></el-icon>移动端推送</span>
33
+ </div>
34
+ </section>
35
+
36
+ <div class="oa-notifications__layout">
37
+ <section class="oa-card oa-notification-list">
38
+ <div class="oa-notification-list__tabs">
39
+ <button
40
+ v-for="filter in filters"
41
+ :key="filter.value"
42
+ type="button"
43
+ :class="{ 'is-active': activeFilter === filter.value }"
44
+ @click="activeFilter = filter.value"
45
+ >
46
+ {{ filter.label }}
47
+ <span>{{ filter.count }}</span>
48
+ </button>
49
+ </div>
50
+
51
+ <div v-if="groupedNotifications.length" class="oa-notification-list__body">
52
+ <div v-for="group in groupedNotifications" :key="group.key" class="oa-notification-group">
53
+ <div class="oa-notification-group__label">{{ group.label }}</div>
54
+ <button
55
+ v-for="notification in group.items"
56
+ :key="notification.id"
57
+ type="button"
58
+ class="oa-notification"
59
+ :class="{ 'is-unread': !notification.read }"
60
+ @click="openNotification(notification)"
61
+ >
62
+ <NotificationIcon :type="notification.type" :size="30" />
63
+ <span class="oa-notification__body">
64
+ <span class="oa-notification__title">
65
+ <strong>{{ notification.title }}</strong>
66
+ <span class="oa-chip">{{ NOTIFICATION_META[notification.type].label }}</span>
67
+ </span>
68
+ <span class="oa-notification__description">{{ notification.description }}</span>
69
+ <span class="oa-notification__meta">
70
+ {{ notification.instance?.definition?.meta?.name }}
71
+ <i></i>
72
+ {{ notification.instance?.state?.initiator?.name || '系统' }}
73
+ <i></i>
74
+ {{ formatRelativeTime(notification.at, oa.now.value) }}
75
+ </span>
76
+ </span>
77
+ <span class="oa-notification__action">
78
+ {{ notification.action === 'task' ? '去处理' : '查看' }}
79
+ <el-icon><ArrowRight /></el-icon>
80
+ </span>
81
+ </button>
82
+ </div>
83
+ </div>
84
+
85
+ <div v-else class="oa-empty oa-notification-list__empty">
86
+ <span class="oa-empty__icon"><el-icon><Bell /></el-icon></span>
87
+ <strong>暂时没有通知</strong>
88
+ <p>{{ emptyDescription }}</p>
89
+ </div>
90
+ </section>
91
+
92
+ <aside class="oa-notifications__side">
93
+ <section class="oa-card oa-notification-policy">
94
+ <div class="oa-section-head">
95
+ <h3 class="oa-section-head__title">通知策略</h3>
96
+ </div>
97
+ <div class="oa-notification-policy__row">
98
+ <el-icon><Tickets /></el-icon>
99
+ <div>
100
+ <strong>只有需要你行动的事项</strong>
101
+ <p>待办与退回修改进入即时通知;普通抄送按日汇总。</p>
102
+ </div>
103
+ </div>
104
+ <div class="oa-notification-policy__row">
105
+ <el-icon><WarningFilled /></el-icon>
106
+ <div>
107
+ <strong>超时与催办优先</strong>
108
+ <p>超时任务会提升到通知列表顶部,同一任务不会重复轰炸。</p>
109
+ </div>
110
+ </div>
111
+ <div class="oa-notification-policy__row">
112
+ <el-icon><Timer /></el-icon>
113
+ <div>
114
+ <strong>免打扰时段</strong>
115
+ <p>移动端推送默认 22:00–08:00 静默,站内消息保持可查。</p>
116
+ </div>
117
+ </div>
118
+ </section>
119
+
120
+ <section class="oa-card oa-notification-summary">
121
+ <div class="oa-section-head">
122
+ <h3 class="oa-section-head__title">快捷入口</h3>
123
+ </div>
124
+ <button type="button" @click="oa.navigate('tasks')">
125
+ <span><el-icon><Tickets /></el-icon>进入待办中心</span>
126
+ <el-icon><ArrowRight /></el-icon>
127
+ </button>
128
+ <button type="button" @click="oa.navigate('requests', { scope: 'mine' })">
129
+ <span><el-icon><Document /></el-icon>查看我的申请</span>
130
+ <el-icon><ArrowRight /></el-icon>
131
+ </button>
132
+ </section>
133
+ </aside>
134
+ </div>
135
+ </div>
136
+ </template>
137
+
138
+ <script setup>
139
+ import { computed, inject, ref } from 'vue'
140
+ import {
141
+ ArrowRight,
142
+ Bell,
143
+ CircleCheck,
144
+ Document,
145
+ Message,
146
+ Monitor,
147
+ Phone,
148
+ Tickets,
149
+ Timer,
150
+ WarningFilled
151
+ } from 'gbicons'
152
+ import NotificationIcon from '../components/NotificationIcon.vue'
153
+ import {
154
+ NOTIFICATION_META,
155
+ formatRelativeTime
156
+ } from '../model.js'
157
+
158
+ defineOptions({ name: 'OaNotificationsPage' })
159
+
160
+ const oa = inject('oaStore')
161
+ const activeFilter = ref('all')
162
+
163
+ const filters = computed(() => {
164
+ const list = oa.notifications.value
165
+ return [
166
+ { value: 'all', label: '全部', count: list.length },
167
+ { value: 'unread', label: '未读', count: list.filter((item) => !item.read).length },
168
+ { value: 'todo', label: '待办', count: list.filter((item) => item.type === 'todo').length },
169
+ {
170
+ value: 'urgent',
171
+ label: '超时催办',
172
+ count: list.filter((item) => ['overdue', 'urge'].includes(item.type)).length
173
+ },
174
+ { value: 'cc', label: '抄送', count: list.filter((item) => item.type === 'cc').length },
175
+ { value: 'result', label: '结果', count: list.filter((item) => item.type === 'result').length }
176
+ ]
177
+ })
178
+
179
+ const filtered = computed(() => {
180
+ const list = oa.notifications.value
181
+ if (activeFilter.value === 'all') return list
182
+ if (activeFilter.value === 'unread') return list.filter((item) => !item.read)
183
+ if (activeFilter.value === 'urgent') {
184
+ return list.filter((item) => ['overdue', 'urge'].includes(item.type))
185
+ }
186
+ return list.filter((item) => item.type === activeFilter.value)
187
+ })
188
+
189
+ const groupedNotifications = computed(() => {
190
+ const groups = new Map()
191
+ const now = new Date(oa.now.value)
192
+ const today = now.toDateString()
193
+ const yesterday = new Date(oa.now.value - 24 * 3600 * 1000).toDateString()
194
+ const items = [...filtered.value].sort((left, right) =>
195
+ String(right.at).localeCompare(String(left.at))
196
+ )
197
+ items.forEach((notification) => {
198
+ const date = new Date(notification.at)
199
+ const key = date.toDateString()
200
+ const label =
201
+ key === today ? '今天' : key === yesterday ? '昨天' : formatDateLabel(date)
202
+ if (!groups.has(key)) {
203
+ groups.set(key, { key, label, items: [] })
204
+ }
205
+ groups.get(key).items.push(notification)
206
+ })
207
+ return [...groups.values()]
208
+ })
209
+
210
+ const urgentCount = computed(
211
+ () => oa.notifications.value.filter((item) => ['overdue', 'urge'].includes(item.type)).length
212
+ )
213
+ const todayCount = computed(() => {
214
+ const today = new Date(oa.now.value).toDateString()
215
+ return oa.notifications.value.filter(
216
+ (item) => new Date(item.at).toDateString() === today
217
+ ).length
218
+ })
219
+ const emptyDescription = computed(() =>
220
+ activeFilter.value === 'all'
221
+ ? '新的待办、抄送和流程结果会出现在这里。'
222
+ : '当前筛选下没有通知,切换其他分类查看。'
223
+ )
224
+
225
+ function formatDateLabel(date) {
226
+ return `${date.getMonth() + 1} 月 ${date.getDate()} 日`
227
+ }
228
+
229
+ function markAllRead() {
230
+ oa.markAllNotificationsRead()
231
+ }
232
+
233
+ function openNotification(notification) {
234
+ oa.markNotificationRead(notification.id)
235
+ if (notification.action === 'task' && notification.task) {
236
+ oa.navigate('tasks', {
237
+ instanceId: notification.instance.id,
238
+ taskId: notification.task.id
239
+ })
240
+ return
241
+ }
242
+ oa.openInstanceDetail(notification.instance.id)
243
+ }
244
+ </script>
245
+
246
+ <style scoped lang="scss">
247
+ .oa-notifications {
248
+ max-width: 1380px;
249
+ margin: 0 auto;
250
+ width: 100%;
251
+ }
252
+
253
+ .oa-notifications__stats {
254
+ display: flex;
255
+ align-items: center;
256
+ gap: 24px;
257
+ padding: 12px 16px;
258
+ border: 1px solid var(--oa-line);
259
+ border-radius: var(--oa-radius);
260
+ background: #fff;
261
+ box-shadow: var(--oa-shadow);
262
+ }
263
+
264
+ .oa-notification-stat {
265
+ display: flex;
266
+ flex-direction: column;
267
+
268
+ span {
269
+ color: var(--oa-faint);
270
+ font-size: 10px;
271
+ }
272
+
273
+ strong {
274
+ color: var(--oa-ink);
275
+ font-size: 20px;
276
+ font-weight: 650;
277
+ letter-spacing: -0.02em;
278
+ line-height: 1.3;
279
+ }
280
+ }
281
+
282
+ .oa-notification-channels {
283
+ display: flex;
284
+ align-items: center;
285
+ gap: 6px;
286
+ margin-left: auto;
287
+
288
+ span {
289
+ display: inline-flex;
290
+ align-items: center;
291
+ gap: 4px;
292
+ padding: 3px 8px;
293
+ border-radius: 4px;
294
+ background: #f4f7fb;
295
+ color: var(--oa-muted);
296
+ font-size: 10px;
297
+ }
298
+ }
299
+
300
+ .oa-notifications__layout {
301
+ display: grid;
302
+ grid-template-columns: minmax(0, 1fr) 300px;
303
+ gap: 14px;
304
+ align-items: start;
305
+ }
306
+
307
+ .oa-notification-list {
308
+ overflow: hidden;
309
+ }
310
+
311
+ .oa-notification-list__tabs {
312
+ display: flex;
313
+ flex-wrap: wrap;
314
+ gap: 3px;
315
+ padding: 10px 14px;
316
+ border-bottom: 1px solid var(--oa-line);
317
+
318
+ button {
319
+ display: inline-flex;
320
+ align-items: center;
321
+ gap: 4px;
322
+ padding: 4px 9px;
323
+ border: none;
324
+ border-radius: 5px;
325
+ background: transparent;
326
+ color: var(--oa-muted);
327
+ font-size: 11px;
328
+ cursor: pointer;
329
+
330
+ span {
331
+ color: var(--oa-faint);
332
+ font-size: 9.5px;
333
+ }
334
+
335
+ &.is-active {
336
+ background: var(--oa-ink);
337
+ color: #fff;
338
+
339
+ span {
340
+ color: rgba(255, 255, 255, 0.65);
341
+ }
342
+ }
343
+ }
344
+ }
345
+
346
+ .oa-notification-list__body {
347
+ padding: 4px 8px 12px;
348
+ }
349
+
350
+ .oa-notification-group__label {
351
+ padding: 12px 10px 5px;
352
+ color: var(--oa-faint);
353
+ font-size: 10px;
354
+ font-weight: 600;
355
+ letter-spacing: 0.04em;
356
+ }
357
+
358
+ .oa-notification {
359
+ display: flex;
360
+ align-items: flex-start;
361
+ gap: 10px;
362
+ width: 100%;
363
+ padding: 11px 10px;
364
+ border: none;
365
+ border-radius: 7px;
366
+ background: transparent;
367
+ text-align: left;
368
+ cursor: pointer;
369
+ transition: background 0.15s ease;
370
+
371
+ &:hover {
372
+ background: #f8faff;
373
+
374
+ .oa-notification__action {
375
+ color: var(--oa-primary);
376
+ opacity: 1;
377
+ }
378
+ }
379
+
380
+ &.is-unread {
381
+ background: #fbfcff;
382
+
383
+ .oa-notification__title strong::after {
384
+ content: '';
385
+ display: inline-block;
386
+ width: 5px;
387
+ height: 5px;
388
+ margin-left: 5px;
389
+ border-radius: 50%;
390
+ background: var(--oa-primary);
391
+ vertical-align: 2px;
392
+ }
393
+ }
394
+
395
+ & + & {
396
+ border-top: 1px solid #f2f5f9;
397
+ border-top-left-radius: 0;
398
+ border-top-right-radius: 0;
399
+ }
400
+ }
401
+
402
+ .oa-notification__body {
403
+ display: flex;
404
+ flex-direction: column;
405
+ flex: 1;
406
+ min-width: 0;
407
+ }
408
+
409
+ .oa-notification__title {
410
+ display: flex;
411
+ align-items: center;
412
+ gap: 6px;
413
+
414
+ strong {
415
+ color: var(--oa-ink);
416
+ font-size: 12px;
417
+ font-weight: 600;
418
+ }
419
+ }
420
+
421
+ .oa-notification__description {
422
+ margin-top: 2px;
423
+ color: var(--oa-muted);
424
+ font-size: 11px;
425
+ line-height: 1.6;
426
+ }
427
+
428
+ .oa-notification__meta {
429
+ display: flex;
430
+ align-items: center;
431
+ gap: 5px;
432
+ margin-top: 3px;
433
+ color: var(--oa-faint);
434
+ font-size: 9.5px;
435
+
436
+ i {
437
+ width: 2px;
438
+ height: 2px;
439
+ border-radius: 50%;
440
+ background: #c5cedd;
441
+ }
442
+ }
443
+
444
+ .oa-notification__action {
445
+ display: inline-flex;
446
+ align-items: center;
447
+ gap: 2px;
448
+ flex-shrink: 0;
449
+ padding-top: 2px;
450
+ color: #a5b0c0;
451
+ font-size: 10px;
452
+ opacity: 0.8;
453
+ }
454
+
455
+ .oa-notification-list__empty {
456
+ padding: 64px 24px;
457
+ }
458
+
459
+ .oa-notifications__side {
460
+ display: flex;
461
+ flex-direction: column;
462
+ gap: 12px;
463
+ }
464
+
465
+ .oa-notification-policy {
466
+ padding-bottom: 8px;
467
+ }
468
+
469
+ .oa-notification-policy__row {
470
+ display: flex;
471
+ align-items: flex-start;
472
+ gap: 9px;
473
+ padding: 9px 16px;
474
+
475
+ > .el-icon {
476
+ margin-top: 2px;
477
+ flex-shrink: 0;
478
+ color: var(--oa-faint);
479
+ }
480
+
481
+ strong {
482
+ color: var(--oa-ink);
483
+ font-size: 11px;
484
+ font-weight: 600;
485
+ }
486
+
487
+ p {
488
+ margin: 2px 0 0;
489
+ color: var(--oa-faint);
490
+ font-size: 10px;
491
+ line-height: 1.65;
492
+ }
493
+ }
494
+
495
+ .oa-notification-summary {
496
+ padding-bottom: 6px;
497
+
498
+ button {
499
+ display: flex;
500
+ align-items: center;
501
+ justify-content: space-between;
502
+ width: calc(100% - 20px);
503
+ margin: 0 10px;
504
+ padding: 8px 6px;
505
+ border: none;
506
+ border-radius: 5px;
507
+ background: transparent;
508
+ color: var(--oa-muted);
509
+ font-size: 11px;
510
+ cursor: pointer;
511
+
512
+ > span {
513
+ display: inline-flex;
514
+ align-items: center;
515
+ gap: 6px;
516
+ }
517
+
518
+ &:hover {
519
+ background: #f8faff;
520
+ color: var(--oa-primary);
521
+ }
522
+ }
523
+ }
524
+
525
+ @media (max-width: 960px) {
526
+ .oa-notifications__stats {
527
+ gap: 16px;
528
+ flex-wrap: wrap;
529
+ }
530
+
531
+ .oa-notification-channels {
532
+ width: 100%;
533
+ margin-left: 0;
534
+ padding-top: 6px;
535
+ border-top: 1px dashed var(--oa-line);
536
+ }
537
+
538
+ .oa-notifications__layout {
539
+ grid-template-columns: minmax(0, 1fr);
540
+ }
541
+
542
+ .oa-notifications__side {
543
+ order: 2;
544
+ }
545
+
546
+ .oa-notification__action {
547
+ display: none;
548
+ }
549
+
550
+ .oa-notification {
551
+ min-height: 58px;
552
+ }
553
+ }
554
+ </style>