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,644 +1,644 @@
1
- <template>
2
- <div class="oa-page oa-requests">
3
- <header class="oa-page-head">
4
- <div class="oa-page-head__main">
5
- <p class="oa-eyebrow">申请台账</p>
6
- <h1 class="oa-title">{{ pageMeta.title }}</h1>
7
- <p class="oa-subtitle">{{ pageMeta.description }}</p>
8
- </div>
9
- <div class="oa-actions">
10
- <el-button :icon="Plus" type="primary" @click="oa.navigate('templates')">发起申请</el-button>
11
- </div>
12
- </header>
13
-
14
- <div class="oa-requests__scope">
15
- <button
16
- v-for="scope in scopes"
17
- :key="scope.value"
18
- type="button"
19
- class="oa-requests__scope-item"
20
- :class="{ 'is-active': oa.requestScope.value === scope.value }"
21
- @click="switchScope(scope.value)"
22
- >
23
- <el-icon><component :is="scope.icon" /></el-icon>
24
- <span>{{ scope.label }}</span>
25
- <em>{{ scope.count }}</em>
26
- </button>
27
- </div>
28
-
29
- <section class="oa-card oa-requests__card">
30
- <div class="oa-requests__toolbar">
31
- <div class="oa-requests__status-tabs">
32
- <button
33
- v-for="status in statusOptions"
34
- :key="status.value"
35
- type="button"
36
- :class="{ 'is-active': statusFilter === status.value }"
37
- @click="statusFilter = status.value"
38
- >
39
- {{ status.label }}
40
- <span>{{ status.count }}</span>
41
- </button>
42
- </div>
43
- <div class="oa-requests__toolbar-right">
44
- <el-input
45
- v-model="keyword"
46
- :prefix-icon="Search"
47
- placeholder="搜索事项、单号、发起人"
48
- clearable
49
- size="small"
50
- class="oa-requests__search"
51
- />
52
- <el-select v-model="timeRange" size="small" class="oa-requests__time">
53
- <el-option label="全部时间" value="all" />
54
- <el-option label="近 7 天" value="7" />
55
- <el-option label="近 30 天" value="30" />
56
- </el-select>
57
- </div>
58
- </div>
59
-
60
- <div v-if="visibleItems.length" class="oa-requests__table-wrap oa-desktop-only">
61
- <table class="oa-table">
62
- <thead>
63
- <tr>
64
- <th>事项</th>
65
- <th>流程类型</th>
66
- <th>{{ tableNodeLabel }}</th>
67
- <th>发起人</th>
68
- <th>{{ tableTimeLabel }}</th>
69
- <th>状态</th>
70
- <th>操作</th>
71
- </tr>
72
- </thead>
73
- <tbody>
74
- <tr v-for="item in visibleItems" :key="item.id" @click="open(item)">
75
- <td>
76
- <span class="oa-table__primary">{{ instanceTitle(item.instance) }}</span>
77
- <span class="oa-table__code">{{ item.code }}</span>
78
- </td>
79
- <td>{{ item.instance.definition?.meta?.name }}</td>
80
- <td>
81
- <template v-if="oa.requestScope.value === 'done'">
82
- <span class="oa-chip">{{ item.nodeName }}</span>
83
- </template>
84
- <template v-else-if="oa.requestScope.value === 'cc'">
85
- <span class="oa-chip">{{ item.nodeName }}</span>
86
- </template>
87
- <template v-else>
88
- <span class="oa-request-node">{{ currentNodeLabel(item.instance) }}</span>
89
- </template>
90
- </td>
91
- <td>
92
- <span class="oa-request-initiator">
93
- {{ item.initiatorName || item.instance.initiator?.name || '—' }}
94
- </span>
95
- </td>
96
- <td class="oa-num">{{ formatDateTime(timeOf(item)) }}</td>
97
- <td>
98
- <template v-if="oa.requestScope.value === 'done'">
99
- <span class="oa-chip" :class="doneTone(item.action)">{{ item.actionLabel }}</span>
100
- </template>
101
- <span v-else class="oa-status" :class="`oa-status--${statusMeta(item.instance.state?.status).tone}`">
102
- {{ statusMeta(item.instance.state?.status).label }}
103
- </span>
104
- </td>
105
- <td>
106
- <button type="button" class="oa-link" @click.stop="open(item)">查看详情</button>
107
- </td>
108
- </tr>
109
- </tbody>
110
- </table>
111
- </div>
112
-
113
- <div v-if="visibleItems.length" class="oa-request-cards">
114
- <div
115
- v-for="item in visibleItems"
116
- :key="item.id"
117
- class="oa-request-card"
118
- role="button"
119
- tabindex="0"
120
- @click="open(item)"
121
- @keydown.enter="open(item)"
122
- @keydown.space.prevent="open(item)"
123
- >
124
- <div class="oa-request-card__top">
125
- <strong>{{ instanceTitle(item.instance) }}</strong>
126
- <span v-if="oa.requestScope.value === 'done'" class="oa-chip" :class="doneTone(item.action)">
127
- {{ item.actionLabel }}
128
- </span>
129
- <span v-else class="oa-status" :class="`oa-status--${statusMeta(item.instance.state?.status).tone}`">
130
- {{ statusMeta(item.instance.state?.status).label }}
131
- </span>
132
- </div>
133
- <div class="oa-request-card__meta">
134
- {{ item.code }} · {{ item.instance.definition?.meta?.name }}
135
- </div>
136
- <div class="oa-request-card__foot">
137
- <span>{{ oa.requestScope.value === 'done' ? `处理节点:${item.nodeName}` : currentNodeLabel(item.instance) }}</span>
138
- <time>{{ formatDateTime(timeOf(item)) }}</time>
139
- </div>
140
- </div>
141
- </div>
142
-
143
- <div v-if="!visibleItems.length" class="oa-empty oa-requests__empty">
144
- <span class="oa-empty__icon"><el-icon><component :is="pageMeta.icon" /></el-icon></span>
145
- <strong>{{ emptyTitle }}</strong>
146
- <p>{{ emptyDescription }}</p>
147
- <el-button v-if="oa.requestScope.value === 'mine'" type="primary" plain size="small" @click="oa.navigate('templates')">
148
- 去发起申请
149
- </el-button>
150
- </div>
151
-
152
- <footer v-if="visibleItems.length" class="oa-requests__foot">
153
- 共 {{ visibleItems.length }} 条记录
154
- <span class="oa-requests__foot-hint">按最近更新时间排序</span>
155
- </footer>
156
- </section>
157
- </div>
158
- </template>
159
-
160
- <script setup>
161
- import { computed, inject, ref, watch } from 'vue'
162
- import {
163
- ChatDotRound,
164
- CircleCheck,
165
- Document,
166
- Plus,
167
- Search
168
- } from '@element-plus/icons-vue'
169
- import { formatDateTime } from '../../utils/format.js'
170
- import {
171
- instanceTitle,
172
- statusMeta
173
- } from '../model.js'
174
-
175
- defineOptions({ name: 'OaRequestsPage' })
176
-
177
- const oa = inject('oaStore')
178
-
179
- const keyword = ref('')
180
- const statusFilter = ref('all')
181
- const timeRange = ref('all')
182
-
183
- const scopes = computed(() => [
184
- {
185
- value: 'mine',
186
- label: '我的申请',
187
- icon: Document,
188
- count: oa.myInstances.value.length
189
- },
190
- {
191
- value: 'cc',
192
- label: '抄送我的',
193
- icon: ChatDotRound,
194
- count: oa.ccItems.value.length
195
- },
196
- {
197
- value: 'done',
198
- label: '已办事项',
199
- icon: CircleCheck,
200
- count: oa.doneItems.value.length
201
- }
202
- ])
203
-
204
- const pageMeta = computed(() => {
205
- if (oa.requestScope.value === 'cc') {
206
- return {
207
- title: '抄送我的',
208
- description: '知会、归档与需要你关注的流程事项,不占用审批待办。',
209
- icon: ChatDotRound
210
- }
211
- }
212
- if (oa.requestScope.value === 'done') {
213
- return {
214
- title: '已办事项',
215
- description: '你处理过的审批动作与意见,均可在流程轨迹中追溯。',
216
- icon: CircleCheck
217
- }
218
- }
219
- return {
220
- title: '我的申请',
221
- description: '查看自己发起的流程、当前节点与完整审批结果。',
222
- icon: Document
223
- }
224
- })
225
-
226
- const scopeItems = computed(() => {
227
- if (oa.requestScope.value === 'cc') return oa.ccItems.value
228
- if (oa.requestScope.value === 'done') return oa.doneItems.value
229
- return oa.myInstances.value.map((instance) => ({
230
- id: instance.id,
231
- instance,
232
- code: instance.code || '',
233
- at: instance.updatedAt,
234
- initiatorName: instance.initiator?.name || ''
235
- }))
236
- })
237
-
238
- const statusOptions = computed(() => {
239
- if (oa.requestScope.value === 'done') {
240
- const actions = new Map()
241
- scopeItems.value.forEach((item) => {
242
- actions.set(item.action, (actions.get(item.action) || 0) + 1)
243
- })
244
- return [
245
- { value: 'all', label: '全部', count: scopeItems.value.length },
246
- ...[...actions.entries()].map(([value, count]) => ({
247
- value,
248
- label: actionLabel(value),
249
- count
250
- }))
251
- ]
252
- }
253
- return [
254
- { value: 'all', label: '全部', count: scopeItems.value.length },
255
- { value: 'running', label: '审批中', count: countStatus('running') },
256
- { value: 'completed', label: '已通过', count: countStatus('completed') },
257
- { value: 'rejected', label: '已驳回', count: countStatus('rejected') },
258
- { value: 'revoked', label: '已撤回', count: countStatus('revoked') },
259
- { value: 'cancelled', label: '已终止', count: countStatus('cancelled') }
260
- ]
261
- })
262
-
263
- const visibleItems = computed(() => {
264
- const text = keyword.value.trim().toLowerCase()
265
- const now = oa.now.value
266
- return scopeItems.value
267
- .filter((item) => {
268
- const instance = item.instance
269
- if (oa.requestScope.value === 'done') {
270
- if (statusFilter.value !== 'all' && item.action !== statusFilter.value) return false
271
- } else if (
272
- statusFilter.value !== 'all' &&
273
- instance.state?.status !== statusFilter.value
274
- ) {
275
- return false
276
- }
277
- if (timeRange.value !== 'all') {
278
- const days = Number(timeRange.value)
279
- const time = new Date(timeOf(item)).getTime()
280
- if (!Number.isFinite(time) || now - time > days * 24 * 3600 * 1000) return false
281
- }
282
- if (!text) return true
283
- return [
284
- instanceTitle(instance),
285
- item.code,
286
- item.initiatorName,
287
- instance.initiator?.name,
288
- instance.definition?.meta?.name,
289
- item.nodeName,
290
- item.comment
291
- ]
292
- .filter(Boolean)
293
- .some((field) => String(field).toLowerCase().includes(text))
294
- })
295
- .sort((left, right) => String(timeOf(right)).localeCompare(String(timeOf(left))))
296
- })
297
-
298
- const tableNodeLabel = computed(() =>
299
- oa.requestScope.value === 'done' ? '处理节点' : oa.requestScope.value === 'cc' ? '抄送节点' : '当前节点'
300
- )
301
- const tableTimeLabel = computed(() =>
302
- oa.requestScope.value === 'done' ? '处理时间' : oa.requestScope.value === 'cc' ? '抄送时间' : '最近更新'
303
- )
304
-
305
- const emptyTitle = computed(() => {
306
- if (keyword.value.trim() || statusFilter.value !== 'all' || timeRange.value !== 'all') {
307
- return '没有匹配的记录'
308
- }
309
- if (oa.requestScope.value === 'cc') return '暂时没有抄送事项'
310
- if (oa.requestScope.value === 'done') return '还没有已办记录'
311
- return '还没有发起过流程'
312
- })
313
-
314
- const emptyDescription = computed(() => {
315
- if (keyword.value.trim() || statusFilter.value !== 'all') {
316
- return '尝试调整搜索关键词或状态筛选。'
317
- }
318
- if (oa.requestScope.value === 'cc') {
319
- return '流程到达抄送节点时,相关事项会出现在这里。'
320
- }
321
- if (oa.requestScope.value === 'done') {
322
- return '完成审批、退回、转办或加签后,处理记录会归档到这里。'
323
- }
324
- return '从模板中心选择流程,填写申请后即可在这里追踪进度。'
325
- })
326
-
327
- function countStatus(status) {
328
- return scopeItems.value.filter((item) => item.instance?.state?.status === status).length
329
- }
330
-
331
- function actionLabel(action) {
332
- return (
333
- {
334
- approve: '同意',
335
- reject: '退回',
336
- transfer: '转办',
337
- addSign: '加签',
338
- resubmit: '重新提交'
339
- }[action] || action
340
- )
341
- }
342
-
343
- function doneTone(action) {
344
- if (action === 'approve' || action === 'resubmit') return 'oa-chip--success'
345
- if (action === 'reject') return 'oa-chip--warning'
346
- if (action === 'transfer' || action === 'addSign') return 'oa-chip--primary'
347
- return ''
348
- }
349
-
350
- function timeOf(item) {
351
- if (oa.requestScope.value === 'done') return item.at
352
- if (oa.requestScope.value === 'cc') return item.at
353
- return item.instance.updatedAt
354
- }
355
-
356
- function currentNodeLabel(instance) {
357
- const task = (instance.state?.tasks || []).find((item) => item.status === 'pending')
358
- return task ? `当前:${task.nodeName}` : statusMeta(instance.state?.status).label
359
- }
360
-
361
- function switchScope(scope) {
362
- oa.navigate('requests', { scope })
363
- }
364
-
365
- function open(item) {
366
- oa.openInstanceDetail(item.instance.id)
367
- }
368
-
369
- watch(
370
- () => oa.requestScope.value,
371
- () => {
372
- statusFilter.value = 'all'
373
- keyword.value = ''
374
- timeRange.value = 'all'
375
- }
376
- )
377
- </script>
378
-
379
- <style scoped lang="scss">
380
- .oa-requests {
381
- max-width: 1440px;
382
- margin: 0 auto;
383
- width: 100%;
384
- }
385
-
386
- .oa-requests__scope {
387
- display: flex;
388
- gap: 8px;
389
- flex-wrap: wrap;
390
- }
391
-
392
- .oa-requests__scope-item {
393
- display: inline-flex;
394
- align-items: center;
395
- gap: 7px;
396
- min-height: 36px;
397
- padding: 5px 12px;
398
- border: 1px solid var(--oa-line);
399
- border-radius: 8px;
400
- background: #fff;
401
- color: var(--oa-muted);
402
- font-size: 12px;
403
- cursor: pointer;
404
- box-shadow: var(--oa-shadow);
405
- transition: border-color 0.15s ease, color 0.15s ease;
406
-
407
- em {
408
- display: inline-grid;
409
- place-items: center;
410
- min-width: 18px;
411
- height: 18px;
412
- padding: 0 5px;
413
- border-radius: 9px;
414
- background: #f0f3f8;
415
- color: var(--oa-faint);
416
- font-size: 10px;
417
- font-style: normal;
418
- }
419
-
420
- &:hover {
421
- border-color: #c9d7f4;
422
- color: var(--oa-primary);
423
- }
424
-
425
- &.is-active {
426
- border-color: #c3d4f7;
427
- background: var(--oa-primary-soft);
428
- color: var(--oa-primary);
429
- font-weight: 600;
430
-
431
- em {
432
- background: #fff;
433
- color: var(--oa-primary);
434
- }
435
- }
436
- }
437
-
438
- .oa-requests__card {
439
- overflow: hidden;
440
- }
441
-
442
- .oa-requests__toolbar {
443
- display: flex;
444
- align-items: center;
445
- justify-content: space-between;
446
- gap: 14px;
447
- flex-wrap: wrap;
448
- padding: 12px 16px;
449
- border-bottom: 1px solid var(--oa-line);
450
- }
451
-
452
- .oa-requests__status-tabs {
453
- display: flex;
454
- flex-wrap: wrap;
455
- gap: 4px;
456
-
457
- button {
458
- display: inline-flex;
459
- align-items: center;
460
- gap: 4px;
461
- padding: 4px 9px;
462
- border: none;
463
- border-radius: 5px;
464
- background: transparent;
465
- color: var(--oa-muted);
466
- font-size: 11.5px;
467
- cursor: pointer;
468
-
469
- span {
470
- color: var(--oa-faint);
471
- font-size: 9.5px;
472
- }
473
-
474
- &:hover {
475
- background: #f5f7fb;
476
- }
477
-
478
- &.is-active {
479
- background: var(--oa-ink);
480
- color: #fff;
481
-
482
- span {
483
- color: rgba(255, 255, 255, 0.65);
484
- }
485
- }
486
- }
487
- }
488
-
489
- .oa-requests__toolbar-right {
490
- display: flex;
491
- gap: 7px;
492
- }
493
-
494
- .oa-requests__search {
495
- width: 240px;
496
- }
497
-
498
- .oa-requests__time {
499
- width: 104px;
500
- }
501
-
502
- .oa-requests__table-wrap {
503
- overflow-x: auto;
504
- }
505
-
506
- .oa-table td {
507
- cursor: pointer;
508
- }
509
-
510
- .oa-request-node {
511
- display: inline-block;
512
- max-width: 190px;
513
- overflow: hidden;
514
- text-overflow: ellipsis;
515
- white-space: nowrap;
516
- }
517
-
518
- .oa-request-initiator {
519
- color: var(--oa-muted);
520
- }
521
-
522
- .oa-requests__foot {
523
- display: flex;
524
- align-items: center;
525
- gap: 10px;
526
- padding: 10px 16px;
527
- border-top: 1px solid var(--oa-line);
528
- color: var(--oa-faint);
529
- font-size: 10.5px;
530
- }
531
-
532
- .oa-requests__foot-hint {
533
- margin-left: auto;
534
- }
535
-
536
- .oa-requests__empty {
537
- padding: 70px 24px;
538
- }
539
-
540
- .oa-request-cards {
541
- display: none;
542
- flex-direction: column;
543
- padding: 8px;
544
- }
545
-
546
- .oa-request-card {
547
- display: block;
548
- width: 100%;
549
- padding: 12px 10px;
550
- border: none;
551
- border-bottom: 1px solid #f0f3f8;
552
- background: transparent;
553
- color: inherit;
554
- font: inherit;
555
- text-align: left;
556
- cursor: pointer;
557
-
558
- &:last-child {
559
- border-bottom: none;
560
- }
561
-
562
- &__top {
563
- display: flex;
564
- align-items: flex-start;
565
- gap: 7px;
566
-
567
- strong {
568
- flex: 1;
569
- color: var(--oa-ink);
570
- font-size: 13px;
571
- font-weight: 600;
572
- line-height: 1.5;
573
- }
574
- }
575
-
576
- &__meta {
577
- margin-top: 4px;
578
- color: var(--oa-faint);
579
- font-size: 10.5px;
580
- }
581
-
582
- &__foot {
583
- display: flex;
584
- align-items: center;
585
- justify-content: space-between;
586
- gap: 12px;
587
- margin-top: 6px;
588
- color: var(--oa-muted);
589
- font-size: 10.5px;
590
-
591
- time {
592
- flex-shrink: 0;
593
- color: var(--oa-faint);
594
- }
595
- }
596
- }
597
-
598
- @media (max-width: 960px) {
599
- .oa-requests__scope {
600
- display: grid;
601
- grid-template-columns: repeat(3, minmax(0, 1fr));
602
- gap: 6px;
603
- }
604
-
605
- .oa-requests__scope-item {
606
- justify-content: center;
607
- padding: 7px 6px;
608
- font-size: 11px;
609
-
610
- em {
611
- display: none;
612
- }
613
- }
614
-
615
- .oa-requests__toolbar {
616
- align-items: stretch;
617
- gap: 8px;
618
- padding: 10px 12px;
619
- }
620
-
621
- .oa-requests__status-tabs {
622
- flex-wrap: nowrap;
623
- overflow-x: auto;
624
- padding-bottom: 2px;
625
-
626
- button {
627
- flex-shrink: 0;
628
- }
629
- }
630
-
631
- .oa-requests__toolbar-right {
632
- width: 100%;
633
-
634
- .oa-requests__search {
635
- flex: 1;
636
- width: auto;
637
- }
638
- }
639
-
640
- .oa-request-cards {
641
- display: flex;
642
- }
643
- }
644
- </style>
1
+ <template>
2
+ <div class="oa-page oa-requests">
3
+ <header class="oa-page-head">
4
+ <div class="oa-page-head__main">
5
+ <p class="oa-eyebrow">申请台账</p>
6
+ <h1 class="oa-title">{{ pageMeta.title }}</h1>
7
+ <p class="oa-subtitle">{{ pageMeta.description }}</p>
8
+ </div>
9
+ <div class="oa-actions">
10
+ <el-button :icon="Plus" type="primary" @click="oa.navigate('templates')">发起申请</el-button>
11
+ </div>
12
+ </header>
13
+
14
+ <div class="oa-requests__scope">
15
+ <button
16
+ v-for="scope in scopes"
17
+ :key="scope.value"
18
+ type="button"
19
+ class="oa-requests__scope-item"
20
+ :class="{ 'is-active': oa.requestScope.value === scope.value }"
21
+ @click="switchScope(scope.value)"
22
+ >
23
+ <el-icon><component :is="scope.icon" /></el-icon>
24
+ <span>{{ scope.label }}</span>
25
+ <em>{{ scope.count }}</em>
26
+ </button>
27
+ </div>
28
+
29
+ <section class="oa-card oa-requests__card">
30
+ <div class="oa-requests__toolbar">
31
+ <div class="oa-requests__status-tabs">
32
+ <button
33
+ v-for="status in statusOptions"
34
+ :key="status.value"
35
+ type="button"
36
+ :class="{ 'is-active': statusFilter === status.value }"
37
+ @click="statusFilter = status.value"
38
+ >
39
+ {{ status.label }}
40
+ <span>{{ status.count }}</span>
41
+ </button>
42
+ </div>
43
+ <div class="oa-requests__toolbar-right">
44
+ <el-input
45
+ v-model="keyword"
46
+ :prefix-icon="Search"
47
+ placeholder="搜索事项、单号、发起人"
48
+ clearable
49
+ size="small"
50
+ class="oa-requests__search"
51
+ />
52
+ <el-select v-model="timeRange" size="small" class="oa-requests__time">
53
+ <el-option label="全部时间" value="all" />
54
+ <el-option label="近 7 天" value="7" />
55
+ <el-option label="近 30 天" value="30" />
56
+ </el-select>
57
+ </div>
58
+ </div>
59
+
60
+ <div v-if="visibleItems.length" class="oa-requests__table-wrap oa-desktop-only">
61
+ <table class="oa-table">
62
+ <thead>
63
+ <tr>
64
+ <th>事项</th>
65
+ <th>流程类型</th>
66
+ <th>{{ tableNodeLabel }}</th>
67
+ <th>发起人</th>
68
+ <th>{{ tableTimeLabel }}</th>
69
+ <th>状态</th>
70
+ <th>操作</th>
71
+ </tr>
72
+ </thead>
73
+ <tbody>
74
+ <tr v-for="item in visibleItems" :key="item.id" @click="open(item)">
75
+ <td>
76
+ <span class="oa-table__primary">{{ instanceTitle(item.instance) }}</span>
77
+ <span class="oa-table__code">{{ item.code }}</span>
78
+ </td>
79
+ <td>{{ item.instance.definition?.meta?.name }}</td>
80
+ <td>
81
+ <template v-if="oa.requestScope.value === 'done'">
82
+ <span class="oa-chip">{{ item.nodeName }}</span>
83
+ </template>
84
+ <template v-else-if="oa.requestScope.value === 'cc'">
85
+ <span class="oa-chip">{{ item.nodeName }}</span>
86
+ </template>
87
+ <template v-else>
88
+ <span class="oa-request-node">{{ currentNodeLabel(item.instance) }}</span>
89
+ </template>
90
+ </td>
91
+ <td>
92
+ <span class="oa-request-initiator">
93
+ {{ item.initiatorName || item.instance.initiator?.name || '—' }}
94
+ </span>
95
+ </td>
96
+ <td class="oa-num">{{ formatDateTime(timeOf(item)) }}</td>
97
+ <td>
98
+ <template v-if="oa.requestScope.value === 'done'">
99
+ <span class="oa-chip" :class="doneTone(item.action)">{{ item.actionLabel }}</span>
100
+ </template>
101
+ <span v-else class="oa-status" :class="`oa-status--${statusMeta(item.instance.state?.status).tone}`">
102
+ {{ statusMeta(item.instance.state?.status).label }}
103
+ </span>
104
+ </td>
105
+ <td>
106
+ <button type="button" class="oa-link" @click.stop="open(item)">查看详情</button>
107
+ </td>
108
+ </tr>
109
+ </tbody>
110
+ </table>
111
+ </div>
112
+
113
+ <div v-if="visibleItems.length" class="oa-request-cards">
114
+ <div
115
+ v-for="item in visibleItems"
116
+ :key="item.id"
117
+ class="oa-request-card"
118
+ role="button"
119
+ tabindex="0"
120
+ @click="open(item)"
121
+ @keydown.enter="open(item)"
122
+ @keydown.space.prevent="open(item)"
123
+ >
124
+ <div class="oa-request-card__top">
125
+ <strong>{{ instanceTitle(item.instance) }}</strong>
126
+ <span v-if="oa.requestScope.value === 'done'" class="oa-chip" :class="doneTone(item.action)">
127
+ {{ item.actionLabel }}
128
+ </span>
129
+ <span v-else class="oa-status" :class="`oa-status--${statusMeta(item.instance.state?.status).tone}`">
130
+ {{ statusMeta(item.instance.state?.status).label }}
131
+ </span>
132
+ </div>
133
+ <div class="oa-request-card__meta">
134
+ {{ item.code }} · {{ item.instance.definition?.meta?.name }}
135
+ </div>
136
+ <div class="oa-request-card__foot">
137
+ <span>{{ oa.requestScope.value === 'done' ? `处理节点:${item.nodeName}` : currentNodeLabel(item.instance) }}</span>
138
+ <time>{{ formatDateTime(timeOf(item)) }}</time>
139
+ </div>
140
+ </div>
141
+ </div>
142
+
143
+ <div v-if="!visibleItems.length" class="oa-empty oa-requests__empty">
144
+ <span class="oa-empty__icon"><el-icon><component :is="pageMeta.icon" /></el-icon></span>
145
+ <strong>{{ emptyTitle }}</strong>
146
+ <p>{{ emptyDescription }}</p>
147
+ <el-button v-if="oa.requestScope.value === 'mine'" type="primary" plain size="small" @click="oa.navigate('templates')">
148
+ 去发起申请
149
+ </el-button>
150
+ </div>
151
+
152
+ <footer v-if="visibleItems.length" class="oa-requests__foot">
153
+ 共 {{ visibleItems.length }} 条记录
154
+ <span class="oa-requests__foot-hint">按最近更新时间排序</span>
155
+ </footer>
156
+ </section>
157
+ </div>
158
+ </template>
159
+
160
+ <script setup>
161
+ import { computed, inject, ref, watch } from 'vue'
162
+ import {
163
+ ChatDotRound,
164
+ CircleCheck,
165
+ Document,
166
+ Plus,
167
+ Search
168
+ } from 'gbicons'
169
+ import { formatDateTime } from '../../utils/format.js'
170
+ import {
171
+ instanceTitle,
172
+ statusMeta
173
+ } from '../model.js'
174
+
175
+ defineOptions({ name: 'OaRequestsPage' })
176
+
177
+ const oa = inject('oaStore')
178
+
179
+ const keyword = ref('')
180
+ const statusFilter = ref('all')
181
+ const timeRange = ref('all')
182
+
183
+ const scopes = computed(() => [
184
+ {
185
+ value: 'mine',
186
+ label: '我的申请',
187
+ icon: Document,
188
+ count: oa.myInstances.value.length
189
+ },
190
+ {
191
+ value: 'cc',
192
+ label: '抄送我的',
193
+ icon: ChatDotRound,
194
+ count: oa.ccItems.value.length
195
+ },
196
+ {
197
+ value: 'done',
198
+ label: '已办事项',
199
+ icon: CircleCheck,
200
+ count: oa.doneItems.value.length
201
+ }
202
+ ])
203
+
204
+ const pageMeta = computed(() => {
205
+ if (oa.requestScope.value === 'cc') {
206
+ return {
207
+ title: '抄送我的',
208
+ description: '知会、归档与需要你关注的流程事项,不占用审批待办。',
209
+ icon: ChatDotRound
210
+ }
211
+ }
212
+ if (oa.requestScope.value === 'done') {
213
+ return {
214
+ title: '已办事项',
215
+ description: '你处理过的审批动作与意见,均可在流程轨迹中追溯。',
216
+ icon: CircleCheck
217
+ }
218
+ }
219
+ return {
220
+ title: '我的申请',
221
+ description: '查看自己发起的流程、当前节点与完整审批结果。',
222
+ icon: Document
223
+ }
224
+ })
225
+
226
+ const scopeItems = computed(() => {
227
+ if (oa.requestScope.value === 'cc') return oa.ccItems.value
228
+ if (oa.requestScope.value === 'done') return oa.doneItems.value
229
+ return oa.myInstances.value.map((instance) => ({
230
+ id: instance.id,
231
+ instance,
232
+ code: instance.code || '',
233
+ at: instance.updatedAt,
234
+ initiatorName: instance.initiator?.name || ''
235
+ }))
236
+ })
237
+
238
+ const statusOptions = computed(() => {
239
+ if (oa.requestScope.value === 'done') {
240
+ const actions = new Map()
241
+ scopeItems.value.forEach((item) => {
242
+ actions.set(item.action, (actions.get(item.action) || 0) + 1)
243
+ })
244
+ return [
245
+ { value: 'all', label: '全部', count: scopeItems.value.length },
246
+ ...[...actions.entries()].map(([value, count]) => ({
247
+ value,
248
+ label: actionLabel(value),
249
+ count
250
+ }))
251
+ ]
252
+ }
253
+ return [
254
+ { value: 'all', label: '全部', count: scopeItems.value.length },
255
+ { value: 'running', label: '审批中', count: countStatus('running') },
256
+ { value: 'completed', label: '已通过', count: countStatus('completed') },
257
+ { value: 'rejected', label: '已驳回', count: countStatus('rejected') },
258
+ { value: 'revoked', label: '已撤回', count: countStatus('revoked') },
259
+ { value: 'cancelled', label: '已终止', count: countStatus('cancelled') }
260
+ ]
261
+ })
262
+
263
+ const visibleItems = computed(() => {
264
+ const text = keyword.value.trim().toLowerCase()
265
+ const now = oa.now.value
266
+ return scopeItems.value
267
+ .filter((item) => {
268
+ const instance = item.instance
269
+ if (oa.requestScope.value === 'done') {
270
+ if (statusFilter.value !== 'all' && item.action !== statusFilter.value) return false
271
+ } else if (
272
+ statusFilter.value !== 'all' &&
273
+ instance.state?.status !== statusFilter.value
274
+ ) {
275
+ return false
276
+ }
277
+ if (timeRange.value !== 'all') {
278
+ const days = Number(timeRange.value)
279
+ const time = new Date(timeOf(item)).getTime()
280
+ if (!Number.isFinite(time) || now - time > days * 24 * 3600 * 1000) return false
281
+ }
282
+ if (!text) return true
283
+ return [
284
+ instanceTitle(instance),
285
+ item.code,
286
+ item.initiatorName,
287
+ instance.initiator?.name,
288
+ instance.definition?.meta?.name,
289
+ item.nodeName,
290
+ item.comment
291
+ ]
292
+ .filter(Boolean)
293
+ .some((field) => String(field).toLowerCase().includes(text))
294
+ })
295
+ .sort((left, right) => String(timeOf(right)).localeCompare(String(timeOf(left))))
296
+ })
297
+
298
+ const tableNodeLabel = computed(() =>
299
+ oa.requestScope.value === 'done' ? '处理节点' : oa.requestScope.value === 'cc' ? '抄送节点' : '当前节点'
300
+ )
301
+ const tableTimeLabel = computed(() =>
302
+ oa.requestScope.value === 'done' ? '处理时间' : oa.requestScope.value === 'cc' ? '抄送时间' : '最近更新'
303
+ )
304
+
305
+ const emptyTitle = computed(() => {
306
+ if (keyword.value.trim() || statusFilter.value !== 'all' || timeRange.value !== 'all') {
307
+ return '没有匹配的记录'
308
+ }
309
+ if (oa.requestScope.value === 'cc') return '暂时没有抄送事项'
310
+ if (oa.requestScope.value === 'done') return '还没有已办记录'
311
+ return '还没有发起过流程'
312
+ })
313
+
314
+ const emptyDescription = computed(() => {
315
+ if (keyword.value.trim() || statusFilter.value !== 'all') {
316
+ return '尝试调整搜索关键词或状态筛选。'
317
+ }
318
+ if (oa.requestScope.value === 'cc') {
319
+ return '流程到达抄送节点时,相关事项会出现在这里。'
320
+ }
321
+ if (oa.requestScope.value === 'done') {
322
+ return '完成审批、退回、转办或加签后,处理记录会归档到这里。'
323
+ }
324
+ return '从模板中心选择流程,填写申请后即可在这里追踪进度。'
325
+ })
326
+
327
+ function countStatus(status) {
328
+ return scopeItems.value.filter((item) => item.instance?.state?.status === status).length
329
+ }
330
+
331
+ function actionLabel(action) {
332
+ return (
333
+ {
334
+ approve: '同意',
335
+ reject: '退回',
336
+ transfer: '转办',
337
+ addSign: '加签',
338
+ resubmit: '重新提交'
339
+ }[action] || action
340
+ )
341
+ }
342
+
343
+ function doneTone(action) {
344
+ if (action === 'approve' || action === 'resubmit') return 'oa-chip--success'
345
+ if (action === 'reject') return 'oa-chip--warning'
346
+ if (action === 'transfer' || action === 'addSign') return 'oa-chip--primary'
347
+ return ''
348
+ }
349
+
350
+ function timeOf(item) {
351
+ if (oa.requestScope.value === 'done') return item.at
352
+ if (oa.requestScope.value === 'cc') return item.at
353
+ return item.instance.updatedAt
354
+ }
355
+
356
+ function currentNodeLabel(instance) {
357
+ const task = (instance.state?.tasks || []).find((item) => item.status === 'pending')
358
+ return task ? `当前:${task.nodeName}` : statusMeta(instance.state?.status).label
359
+ }
360
+
361
+ function switchScope(scope) {
362
+ oa.navigate('requests', { scope })
363
+ }
364
+
365
+ function open(item) {
366
+ oa.openInstanceDetail(item.instance.id)
367
+ }
368
+
369
+ watch(
370
+ () => oa.requestScope.value,
371
+ () => {
372
+ statusFilter.value = 'all'
373
+ keyword.value = ''
374
+ timeRange.value = 'all'
375
+ }
376
+ )
377
+ </script>
378
+
379
+ <style scoped lang="scss">
380
+ .oa-requests {
381
+ max-width: 1440px;
382
+ margin: 0 auto;
383
+ width: 100%;
384
+ }
385
+
386
+ .oa-requests__scope {
387
+ display: flex;
388
+ gap: 8px;
389
+ flex-wrap: wrap;
390
+ }
391
+
392
+ .oa-requests__scope-item {
393
+ display: inline-flex;
394
+ align-items: center;
395
+ gap: 7px;
396
+ min-height: 36px;
397
+ padding: 5px 12px;
398
+ border: 1px solid var(--oa-line);
399
+ border-radius: 8px;
400
+ background: #fff;
401
+ color: var(--oa-muted);
402
+ font-size: 12px;
403
+ cursor: pointer;
404
+ box-shadow: var(--oa-shadow);
405
+ transition: border-color 0.15s ease, color 0.15s ease;
406
+
407
+ em {
408
+ display: inline-grid;
409
+ place-items: center;
410
+ min-width: 18px;
411
+ height: 18px;
412
+ padding: 0 5px;
413
+ border-radius: 9px;
414
+ background: #f0f3f8;
415
+ color: var(--oa-faint);
416
+ font-size: 10px;
417
+ font-style: normal;
418
+ }
419
+
420
+ &:hover {
421
+ border-color: #c9d7f4;
422
+ color: var(--oa-primary);
423
+ }
424
+
425
+ &.is-active {
426
+ border-color: #c3d4f7;
427
+ background: var(--oa-primary-soft);
428
+ color: var(--oa-primary);
429
+ font-weight: 600;
430
+
431
+ em {
432
+ background: #fff;
433
+ color: var(--oa-primary);
434
+ }
435
+ }
436
+ }
437
+
438
+ .oa-requests__card {
439
+ overflow: hidden;
440
+ }
441
+
442
+ .oa-requests__toolbar {
443
+ display: flex;
444
+ align-items: center;
445
+ justify-content: space-between;
446
+ gap: 14px;
447
+ flex-wrap: wrap;
448
+ padding: 12px 16px;
449
+ border-bottom: 1px solid var(--oa-line);
450
+ }
451
+
452
+ .oa-requests__status-tabs {
453
+ display: flex;
454
+ flex-wrap: wrap;
455
+ gap: 4px;
456
+
457
+ button {
458
+ display: inline-flex;
459
+ align-items: center;
460
+ gap: 4px;
461
+ padding: 4px 9px;
462
+ border: none;
463
+ border-radius: 5px;
464
+ background: transparent;
465
+ color: var(--oa-muted);
466
+ font-size: 11.5px;
467
+ cursor: pointer;
468
+
469
+ span {
470
+ color: var(--oa-faint);
471
+ font-size: 9.5px;
472
+ }
473
+
474
+ &:hover {
475
+ background: #f5f7fb;
476
+ }
477
+
478
+ &.is-active {
479
+ background: var(--oa-ink);
480
+ color: #fff;
481
+
482
+ span {
483
+ color: rgba(255, 255, 255, 0.65);
484
+ }
485
+ }
486
+ }
487
+ }
488
+
489
+ .oa-requests__toolbar-right {
490
+ display: flex;
491
+ gap: 7px;
492
+ }
493
+
494
+ .oa-requests__search {
495
+ width: 240px;
496
+ }
497
+
498
+ .oa-requests__time {
499
+ width: 104px;
500
+ }
501
+
502
+ .oa-requests__table-wrap {
503
+ overflow-x: auto;
504
+ }
505
+
506
+ .oa-table td {
507
+ cursor: pointer;
508
+ }
509
+
510
+ .oa-request-node {
511
+ display: inline-block;
512
+ max-width: 190px;
513
+ overflow: hidden;
514
+ text-overflow: ellipsis;
515
+ white-space: nowrap;
516
+ }
517
+
518
+ .oa-request-initiator {
519
+ color: var(--oa-muted);
520
+ }
521
+
522
+ .oa-requests__foot {
523
+ display: flex;
524
+ align-items: center;
525
+ gap: 10px;
526
+ padding: 10px 16px;
527
+ border-top: 1px solid var(--oa-line);
528
+ color: var(--oa-faint);
529
+ font-size: 10.5px;
530
+ }
531
+
532
+ .oa-requests__foot-hint {
533
+ margin-left: auto;
534
+ }
535
+
536
+ .oa-requests__empty {
537
+ padding: 70px 24px;
538
+ }
539
+
540
+ .oa-request-cards {
541
+ display: none;
542
+ flex-direction: column;
543
+ padding: 8px;
544
+ }
545
+
546
+ .oa-request-card {
547
+ display: block;
548
+ width: 100%;
549
+ padding: 12px 10px;
550
+ border: none;
551
+ border-bottom: 1px solid #f0f3f8;
552
+ background: transparent;
553
+ color: inherit;
554
+ font: inherit;
555
+ text-align: left;
556
+ cursor: pointer;
557
+
558
+ &:last-child {
559
+ border-bottom: none;
560
+ }
561
+
562
+ &__top {
563
+ display: flex;
564
+ align-items: flex-start;
565
+ gap: 7px;
566
+
567
+ strong {
568
+ flex: 1;
569
+ color: var(--oa-ink);
570
+ font-size: 13px;
571
+ font-weight: 600;
572
+ line-height: 1.5;
573
+ }
574
+ }
575
+
576
+ &__meta {
577
+ margin-top: 4px;
578
+ color: var(--oa-faint);
579
+ font-size: 10.5px;
580
+ }
581
+
582
+ &__foot {
583
+ display: flex;
584
+ align-items: center;
585
+ justify-content: space-between;
586
+ gap: 12px;
587
+ margin-top: 6px;
588
+ color: var(--oa-muted);
589
+ font-size: 10.5px;
590
+
591
+ time {
592
+ flex-shrink: 0;
593
+ color: var(--oa-faint);
594
+ }
595
+ }
596
+ }
597
+
598
+ @media (max-width: 960px) {
599
+ .oa-requests__scope {
600
+ display: grid;
601
+ grid-template-columns: repeat(3, minmax(0, 1fr));
602
+ gap: 6px;
603
+ }
604
+
605
+ .oa-requests__scope-item {
606
+ justify-content: center;
607
+ padding: 7px 6px;
608
+ font-size: 11px;
609
+
610
+ em {
611
+ display: none;
612
+ }
613
+ }
614
+
615
+ .oa-requests__toolbar {
616
+ align-items: stretch;
617
+ gap: 8px;
618
+ padding: 10px 12px;
619
+ }
620
+
621
+ .oa-requests__status-tabs {
622
+ flex-wrap: nowrap;
623
+ overflow-x: auto;
624
+ padding-bottom: 2px;
625
+
626
+ button {
627
+ flex-shrink: 0;
628
+ }
629
+ }
630
+
631
+ .oa-requests__toolbar-right {
632
+ width: 100%;
633
+
634
+ .oa-requests__search {
635
+ flex: 1;
636
+ width: auto;
637
+ }
638
+ }
639
+
640
+ .oa-request-cards {
641
+ display: flex;
642
+ }
643
+ }
644
+ </style>