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,680 +1,680 @@
1
- <template>
2
- <div class="oa-page oa-templates">
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.isAdmin.value" :icon="EditPen" plain @click="oa.navigate('design')">
11
- 管理流程
12
- </el-button>
13
- <el-button :icon="Clock" :type="showRecent ? 'primary' : 'default'" plain @click="toggleRecent">
14
- {{ showRecent ? '查看全部模板' : '最近使用' }}
15
- </el-button>
16
- </div>
17
- </header>
18
-
19
- <section class="oa-template-guide">
20
- <div class="oa-template-guide__lead">
21
- <span class="oa-template-guide__kicker">3 步发起</span>
22
- <strong>模板直达,少填少跳转</strong>
23
- <p>选择模板后,在同一个申请页完成填写、路径预览与提交。</p>
24
- </div>
25
- <div class="oa-template-guide__steps">
26
- <div><span>01</span><strong>选择模板</strong><small>按业务分类或搜索</small></div>
27
- <i><el-icon><ArrowRight /></el-icon></i>
28
- <div><span>02</span><strong>填写申请</strong><small>自动保存与规则校验</small></div>
29
- <i><el-icon><ArrowRight /></el-icon></i>
30
- <div><span>03</span><strong>确认提交</strong><small>预览审批人与预计时长</small></div>
31
- </div>
32
- </section>
33
-
34
- <section class="oa-templates__toolbar">
35
- <div class="oa-templates__categories">
36
- <button
37
- v-for="category in categories"
38
- :key="category.value"
39
- type="button"
40
- class="oa-category"
41
- :class="{ 'is-active': activeCategory === category.value }"
42
- @click="activeCategory = category.value; showRecent = false"
43
- >
44
- {{ category.label }}
45
- <span>{{ category.count }}</span>
46
- </button>
47
- </div>
48
- <div class="oa-templates__tools">
49
- <el-input
50
- v-model="keyword"
51
- :prefix-icon="Search"
52
- placeholder="搜索模板名称或适用场景"
53
- clearable
54
- size="small"
55
- class="oa-templates__search"
56
- />
57
- <button
58
- type="button"
59
- class="oa-favorite-filter"
60
- :class="{ 'is-active': favoriteOnly }"
61
- @click="toggleFavoriteFilter"
62
- >
63
- <el-icon><StarFilled /></el-icon>
64
- 我的收藏
65
- <span>{{ oa.favoriteIds.value.length }}</span>
66
- </button>
67
- </div>
68
- </section>
69
-
70
- <div v-if="recentTemplates.length" class="oa-templates__recent">
71
- <span class="oa-templates__recent-label">最近使用</span>
72
- <button
73
- v-for="template in recentTemplates"
74
- :key="template.id"
75
- type="button"
76
- class="oa-recent-chip"
77
- @click="oa.openStartDialog(template.id)"
78
- >
79
- <CategoryIcon :category="template.business.category" :size="20" />
80
- {{ template.name }}
81
- </button>
82
- </div>
83
-
84
- <section v-if="visibleTemplates.length" class="oa-template-grid">
85
- <article
86
- v-for="template in visibleTemplates"
87
- :key="template.id"
88
- class="oa-template-card oa-card"
89
- @click="start(template)"
90
- >
91
- <div class="oa-template-card__top">
92
- <CategoryIcon :category="template.business.category" :size="40" />
93
- <div class="oa-template-card__title">
94
- <div class="oa-template-card__name-row">
95
- <h3>{{ template.name }}</h3>
96
- <span class="oa-template-card__version">v{{ template.version }}</span>
97
- </div>
98
- <p>{{ template.business.scenario }}</p>
99
- </div>
100
- <button
101
- type="button"
102
- class="oa-template-card__star"
103
- :class="{ 'is-active': isFavorite(template.id) }"
104
- :aria-label="isFavorite(template.id) ? '取消收藏' : '收藏模板'"
105
- @click.stop="oa.toggleFavorite(template.id)"
106
- >
107
- <el-icon><StarFilled /></el-icon>
108
- </button>
109
- </div>
110
-
111
- <p class="oa-template-card__description">{{ template.description }}</p>
112
-
113
- <div class="oa-template-card__meta">
114
- <span class="oa-chip">{{ template.business.category }}</span>
115
- <span><el-icon><Clock /></el-icon>{{ template.slaLabel }}</span>
116
- <span><el-icon><Share /></el-icon>{{ template.approvalCount }} 个审批节点</span>
117
- <span v-if="template.customCount">
118
- <el-icon><SetUp /></el-icon>{{ template.customCount }} 个自定义节点
119
- </span>
120
- </div>
121
-
122
- <div v-if="template.business.materials.length" class="oa-template-card__materials">
123
- <span class="oa-template-card__materials-label">所需材料</span>
124
- <span
125
- v-for="material in template.business.materials.slice(0, 3)"
126
- :key="material"
127
- class="oa-chip"
128
- >
129
- {{ material }}
130
- </span>
131
- </div>
132
-
133
- <footer class="oa-template-card__foot">
134
- <span>{{ template.business.owner }} · 近期使用 {{ template.business.popularity }} 次</span>
135
- <el-button type="primary" size="small" plain @click.stop="start(template)">
136
- 发起申请
137
- </el-button>
138
- </footer>
139
- </article>
140
- </section>
141
-
142
- <div v-else class="oa-card">
143
- <div class="oa-empty oa-templates__empty">
144
- <span class="oa-empty__icon"><el-icon><Grid /></el-icon></span>
145
- <strong>{{ emptyTitle }}</strong>
146
- <p>{{ emptyDescription }}</p>
147
- <el-button v-if="oa.isAdmin.value" type="primary" plain size="small" @click="oa.navigate('design')">
148
- 去流程设计
149
- </el-button>
150
- </div>
151
- </div>
152
- </div>
153
- </template>
154
-
155
- <script setup>
156
- import { computed, inject, ref } from 'vue'
157
- import {
158
- ArrowRight,
159
- Clock,
160
- EditPen,
161
- Grid,
162
- Search,
163
- SetUp,
164
- Share,
165
- StarFilled
166
- } from '@element-plus/icons-vue'
167
- import CategoryIcon from '../components/CategoryIcon.vue'
168
- import { buildTemplateCards } from '../model.js'
169
-
170
- defineOptions({ name: 'OaTemplatesPage' })
171
-
172
- const oa = inject('oaStore')
173
-
174
- const keyword = ref('')
175
- const activeCategory = ref('all')
176
- const favoriteOnly = ref(false)
177
- const showRecent = ref(false)
178
-
179
- const allTemplates = computed(() =>
180
- buildTemplateCards(oa.publishedDefinitions.value)
181
- )
182
-
183
- const categories = computed(() => {
184
- const map = new Map()
185
- allTemplates.value.forEach((template) => {
186
- const category = template.business.category || '通用'
187
- map.set(category, (map.get(category) || 0) + 1)
188
- })
189
- return [
190
- { value: 'all', label: '全部', count: allTemplates.value.length },
191
- ...[...map.entries()].map(([value, count]) => ({ value, label: value, count }))
192
- ]
193
- })
194
-
195
- const recentTemplates = computed(() => {
196
- const ids = new Set()
197
- oa.myInstances.value.forEach((instance) => {
198
- const id = instance.definition?.meta?.id
199
- if (id) ids.add(String(id))
200
- })
201
- return allTemplates.value.filter((template) => ids.has(String(template.id))).slice(0, 4)
202
- })
203
-
204
- const visibleTemplates = computed(() => {
205
- const text = keyword.value.trim().toLowerCase()
206
- let list = allTemplates.value
207
- if (showRecent.value) {
208
- const recentIds = new Set(recentTemplates.value.map((template) => template.id))
209
- list = list.filter((template) => recentIds.has(template.id))
210
- }
211
- if (activeCategory.value !== 'all') {
212
- list = list.filter((template) => template.business.category === activeCategory.value)
213
- }
214
- if (favoriteOnly.value) {
215
- list = list.filter((template) => isFavorite(template.id))
216
- }
217
- if (text) {
218
- list = list.filter((template) =>
219
- [
220
- template.name,
221
- template.description,
222
- template.business.scenario,
223
- template.business.category,
224
- template.business.owner
225
- ]
226
- .filter(Boolean)
227
- .some((field) => String(field).toLowerCase().includes(text))
228
- )
229
- }
230
- return list
231
- })
232
-
233
- const emptyTitle = computed(() => {
234
- if (keyword.value.trim() || favoriteOnly.value || showRecent.value) return '没有匹配的模板'
235
- if (activeCategory.value !== 'all') return '该分类下暂无可用模板'
236
- return '暂无可发起的流程模板'
237
- })
238
-
239
- const emptyDescription = computed(() => {
240
- if (keyword.value.trim() || favoriteOnly.value) {
241
- return '尝试更换关键词、分类,或取消收藏筛选。'
242
- }
243
- if (showRecent.value) return '你还没有使用过流程模板,先浏览全部模板发起一次申请。'
244
- return '流程管理员发布流程后,模板会自动出现在这里。'
245
- })
246
-
247
- function isFavorite(id) {
248
- return oa.favoriteIds.value.map(String).includes(String(id))
249
- }
250
-
251
- function toggleFavoriteFilter() {
252
- favoriteOnly.value = !favoriteOnly.value
253
- if (favoriteOnly.value) showRecent.value = false
254
- }
255
-
256
- function toggleRecent() {
257
- showRecent.value = !showRecent.value
258
- if (showRecent.value) favoriteOnly.value = false
259
- }
260
-
261
- function start(template) {
262
- oa.openStartDialog(template.id)
263
- }
264
- </script>
265
-
266
- <style scoped lang="scss">
267
- .oa-templates {
268
- max-width: 1440px;
269
- margin: 0 auto;
270
- width: 100%;
271
- }
272
-
273
- .oa-template-guide {
274
- display: flex;
275
- align-items: center;
276
- justify-content: space-between;
277
- gap: 24px;
278
- padding: 18px 22px;
279
- border: 1px solid #dbe4f5;
280
- border-radius: var(--oa-radius);
281
- background:
282
- radial-gradient(circle at 85% -20%, rgba(36, 86, 214, 0.1), transparent 45%),
283
- linear-gradient(110deg, #f8faff, #fff);
284
- box-shadow: var(--oa-shadow);
285
- flex-wrap: wrap;
286
- }
287
-
288
- .oa-template-guide__lead {
289
- min-width: 270px;
290
-
291
- strong {
292
- display: block;
293
- margin-top: 4px;
294
- color: var(--oa-ink-strong);
295
- font-size: 18px;
296
- font-weight: 650;
297
- letter-spacing: -0.02em;
298
- }
299
-
300
- p {
301
- margin: 4px 0 0;
302
- color: var(--oa-muted);
303
- font-size: 11.5px;
304
- }
305
- }
306
-
307
- .oa-template-guide__kicker {
308
- display: inline-block;
309
- padding: 1px 7px;
310
- border-radius: 4px;
311
- background: var(--oa-primary-soft);
312
- color: var(--oa-primary);
313
- font-size: 10px;
314
- font-weight: 600;
315
- }
316
-
317
- .oa-template-guide__steps {
318
- display: flex;
319
- align-items: center;
320
- gap: 14px;
321
-
322
- > div {
323
- display: grid;
324
- grid-template-columns: auto 1fr;
325
- column-gap: 8px;
326
- align-items: center;
327
-
328
- > span {
329
- grid-row: span 2;
330
- display: grid;
331
- place-items: center;
332
- width: 30px;
333
- height: 30px;
334
- border: 1px solid #d2def4;
335
- border-radius: 50%;
336
- background: #fff;
337
- color: var(--oa-primary);
338
- font-size: 10px;
339
- font-weight: 700;
340
- font-variant-numeric: tabular-nums;
341
- }
342
-
343
- strong {
344
- color: var(--oa-ink);
345
- font-size: 11.5px;
346
- font-weight: 600;
347
- }
348
-
349
- small {
350
- color: var(--oa-faint);
351
- font-size: 10px;
352
- }
353
- }
354
-
355
- > i {
356
- color: #b7c6de;
357
- font-size: 12px;
358
- font-style: normal;
359
- }
360
- }
361
-
362
- .oa-templates__toolbar {
363
- display: flex;
364
- align-items: center;
365
- justify-content: space-between;
366
- gap: 14px;
367
- flex-wrap: wrap;
368
- }
369
-
370
- .oa-templates__categories {
371
- display: flex;
372
- flex-wrap: wrap;
373
- gap: 4px;
374
- }
375
-
376
- .oa-category {
377
- display: inline-flex;
378
- align-items: center;
379
- gap: 5px;
380
- min-height: 30px;
381
- padding: 3px 10px;
382
- border: 1px solid transparent;
383
- border-radius: 6px;
384
- background: transparent;
385
- color: var(--oa-muted);
386
- font-size: 11.5px;
387
- cursor: pointer;
388
-
389
- span {
390
- color: var(--oa-faint);
391
- font-size: 9.5px;
392
- }
393
-
394
- &:hover {
395
- background: #f6f8fc;
396
- }
397
-
398
- &.is-active {
399
- border-color: var(--oa-line);
400
- background: #fff;
401
- color: var(--oa-ink);
402
- font-weight: 600;
403
- box-shadow: var(--oa-shadow);
404
- }
405
- }
406
-
407
- .oa-templates__tools {
408
- display: flex;
409
- gap: 7px;
410
- }
411
-
412
- .oa-templates__search {
413
- width: 250px;
414
- }
415
-
416
- .oa-favorite-filter {
417
- display: inline-flex;
418
- align-items: center;
419
- gap: 5px;
420
- padding: 3px 9px;
421
- border: 1px solid var(--oa-line);
422
- border-radius: 6px;
423
- background: #fff;
424
- color: var(--oa-muted);
425
- font-size: 11px;
426
- cursor: pointer;
427
-
428
- .el-icon {
429
- color: #e2b23e;
430
- }
431
-
432
- span {
433
- color: var(--oa-faint);
434
- font-size: 9.5px;
435
- }
436
-
437
- &.is-active {
438
- border-color: #eddaa6;
439
- background: #fffaed;
440
- color: #8c6717;
441
- }
442
- }
443
-
444
- .oa-templates__recent {
445
- display: flex;
446
- align-items: center;
447
- flex-wrap: wrap;
448
- gap: 6px;
449
- }
450
-
451
- .oa-templates__recent-label {
452
- margin-right: 2px;
453
- color: var(--oa-faint);
454
- font-size: 10.5px;
455
- }
456
-
457
- .oa-recent-chip {
458
- display: inline-flex;
459
- align-items: center;
460
- gap: 6px;
461
- padding: 3px 9px 3px 4px;
462
- border: 1px solid var(--oa-line);
463
- border-radius: 18px;
464
- background: #fff;
465
- color: var(--oa-muted);
466
- font-size: 10.5px;
467
- cursor: pointer;
468
- transition: border-color 0.15s ease, color 0.15s ease;
469
-
470
- &:hover {
471
- border-color: #c7d5f1;
472
- color: var(--oa-primary);
473
- }
474
- }
475
-
476
- .oa-template-grid {
477
- display: grid;
478
- grid-template-columns: repeat(3, minmax(0, 1fr));
479
- gap: 14px;
480
- }
481
-
482
- .oa-template-card {
483
- display: flex;
484
- flex-direction: column;
485
- min-width: 0;
486
- padding: 17px 18px 14px;
487
- cursor: pointer;
488
- transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
489
-
490
- &:hover {
491
- border-color: #c7d7f3;
492
- box-shadow: 0 10px 30px rgba(15, 31, 55, 0.07);
493
- transform: translateY(-2px);
494
- }
495
- }
496
-
497
- .oa-template-card__top {
498
- display: flex;
499
- align-items: flex-start;
500
- gap: 11px;
501
- }
502
-
503
- .oa-template-card__title {
504
- flex: 1;
505
- min-width: 0;
506
-
507
- p {
508
- margin: 3px 0 0;
509
- color: var(--oa-faint);
510
- font-size: 10.5px;
511
- line-height: 1.6;
512
- }
513
- }
514
-
515
- .oa-template-card__name-row {
516
- display: flex;
517
- align-items: center;
518
- gap: 6px;
519
-
520
- h3 {
521
- margin: 0;
522
- overflow: hidden;
523
- color: var(--oa-ink);
524
- font-size: 14px;
525
- font-weight: 650;
526
- letter-spacing: -0.01em;
527
- text-overflow: ellipsis;
528
- white-space: nowrap;
529
- }
530
- }
531
-
532
- .oa-template-card__version {
533
- flex-shrink: 0;
534
- padding: 0 4px;
535
- border-radius: 3px;
536
- background: #f1f4f9;
537
- color: var(--oa-faint);
538
- font-size: 9px;
539
- line-height: 16px;
540
- }
541
-
542
- .oa-template-card__star {
543
- display: grid;
544
- place-items: center;
545
- width: 28px;
546
- height: 28px;
547
- flex-shrink: 0;
548
- border: 1px solid transparent;
549
- border-radius: 6px;
550
- background: transparent;
551
- color: #ccd4e0;
552
- font-size: 15px;
553
- cursor: pointer;
554
-
555
- &:hover {
556
- background: #fffaed;
557
- color: #d7a92d;
558
- }
559
-
560
- &.is-active {
561
- color: #d7a92d;
562
- }
563
- }
564
-
565
- .oa-template-card__description {
566
- display: -webkit-box;
567
- overflow: hidden;
568
- margin: 12px 0 0;
569
- color: var(--oa-muted);
570
- font-size: 11.5px;
571
- line-height: 1.7;
572
- -webkit-box-orient: vertical;
573
- -webkit-line-clamp: 2;
574
- }
575
-
576
- .oa-template-card__meta {
577
- display: flex;
578
- align-items: center;
579
- flex-wrap: wrap;
580
- gap: 8px;
581
- margin-top: 12px;
582
- color: var(--oa-faint);
583
- font-size: 10.5px;
584
-
585
- > span:not(.oa-chip) {
586
- display: inline-flex;
587
- align-items: center;
588
- gap: 3px;
589
- }
590
- }
591
-
592
- .oa-template-card__materials {
593
- display: flex;
594
- align-items: center;
595
- flex-wrap: wrap;
596
- gap: 4px;
597
- margin-top: 10px;
598
- padding-top: 10px;
599
- border-top: 1px dashed var(--oa-line);
600
- }
601
-
602
- .oa-template-card__materials-label {
603
- margin-right: 2px;
604
- color: var(--oa-faint);
605
- font-size: 10px;
606
- }
607
-
608
- .oa-template-card__foot {
609
- display: flex;
610
- align-items: center;
611
- justify-content: space-between;
612
- gap: 10px;
613
- margin-top: auto;
614
- padding-top: 14px;
615
- color: var(--oa-faint);
616
- font-size: 10px;
617
- }
618
-
619
- .oa-templates__empty {
620
- padding: 72px 24px;
621
- }
622
-
623
- @media (max-width: 1200px) {
624
- .oa-template-grid {
625
- grid-template-columns: repeat(2, minmax(0, 1fr));
626
- }
627
-
628
- .oa-template-guide__steps {
629
- gap: 9px;
630
- }
631
- }
632
-
633
- @media (max-width: 960px) {
634
- .oa-template-guide {
635
- padding: 14px 16px;
636
- }
637
-
638
- .oa-template-guide__steps {
639
- display: none;
640
- }
641
-
642
- .oa-templates__categories {
643
- flex-wrap: nowrap;
644
- overflow-x: auto;
645
- width: 100%;
646
- padding-bottom: 2px;
647
-
648
- .oa-category {
649
- flex-shrink: 0;
650
- }
651
- }
652
-
653
- .oa-templates__toolbar {
654
- gap: 8px;
655
- }
656
-
657
- .oa-templates__tools {
658
- width: 100%;
659
-
660
- .oa-templates__search {
661
- flex: 1;
662
- width: auto;
663
- }
664
- }
665
-
666
- .oa-template-grid {
667
- grid-template-columns: minmax(0, 1fr);
668
- }
669
-
670
- .oa-template-card {
671
- padding: 15px;
672
- }
673
-
674
- .oa-template-card__foot {
675
- .el-button {
676
- min-height: 44px;
677
- }
678
- }
679
- }
680
- </style>
1
+ <template>
2
+ <div class="oa-page oa-templates">
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.isAdmin.value" :icon="EditPen" plain @click="oa.navigate('design')">
11
+ 管理流程
12
+ </el-button>
13
+ <el-button :icon="Clock" :type="showRecent ? 'primary' : 'default'" plain @click="toggleRecent">
14
+ {{ showRecent ? '查看全部模板' : '最近使用' }}
15
+ </el-button>
16
+ </div>
17
+ </header>
18
+
19
+ <section class="oa-template-guide">
20
+ <div class="oa-template-guide__lead">
21
+ <span class="oa-template-guide__kicker">3 步发起</span>
22
+ <strong>模板直达,少填少跳转</strong>
23
+ <p>选择模板后,在同一个申请页完成填写、路径预览与提交。</p>
24
+ </div>
25
+ <div class="oa-template-guide__steps">
26
+ <div><span>01</span><strong>选择模板</strong><small>按业务分类或搜索</small></div>
27
+ <i><el-icon><ArrowRight /></el-icon></i>
28
+ <div><span>02</span><strong>填写申请</strong><small>自动保存与规则校验</small></div>
29
+ <i><el-icon><ArrowRight /></el-icon></i>
30
+ <div><span>03</span><strong>确认提交</strong><small>预览审批人与预计时长</small></div>
31
+ </div>
32
+ </section>
33
+
34
+ <section class="oa-templates__toolbar">
35
+ <div class="oa-templates__categories">
36
+ <button
37
+ v-for="category in categories"
38
+ :key="category.value"
39
+ type="button"
40
+ class="oa-category"
41
+ :class="{ 'is-active': activeCategory === category.value }"
42
+ @click="activeCategory = category.value; showRecent = false"
43
+ >
44
+ {{ category.label }}
45
+ <span>{{ category.count }}</span>
46
+ </button>
47
+ </div>
48
+ <div class="oa-templates__tools">
49
+ <el-input
50
+ v-model="keyword"
51
+ :prefix-icon="Search"
52
+ placeholder="搜索模板名称或适用场景"
53
+ clearable
54
+ size="small"
55
+ class="oa-templates__search"
56
+ />
57
+ <button
58
+ type="button"
59
+ class="oa-favorite-filter"
60
+ :class="{ 'is-active': favoriteOnly }"
61
+ @click="toggleFavoriteFilter"
62
+ >
63
+ <el-icon><StarFilled /></el-icon>
64
+ 我的收藏
65
+ <span>{{ oa.favoriteIds.value.length }}</span>
66
+ </button>
67
+ </div>
68
+ </section>
69
+
70
+ <div v-if="recentTemplates.length" class="oa-templates__recent">
71
+ <span class="oa-templates__recent-label">最近使用</span>
72
+ <button
73
+ v-for="template in recentTemplates"
74
+ :key="template.id"
75
+ type="button"
76
+ class="oa-recent-chip"
77
+ @click="oa.openStartDialog(template.id)"
78
+ >
79
+ <CategoryIcon :category="template.business.category" :size="20" />
80
+ {{ template.name }}
81
+ </button>
82
+ </div>
83
+
84
+ <section v-if="visibleTemplates.length" class="oa-template-grid">
85
+ <article
86
+ v-for="template in visibleTemplates"
87
+ :key="template.id"
88
+ class="oa-template-card oa-card"
89
+ @click="start(template)"
90
+ >
91
+ <div class="oa-template-card__top">
92
+ <CategoryIcon :category="template.business.category" :size="40" />
93
+ <div class="oa-template-card__title">
94
+ <div class="oa-template-card__name-row">
95
+ <h3>{{ template.name }}</h3>
96
+ <span class="oa-template-card__version">v{{ template.version }}</span>
97
+ </div>
98
+ <p>{{ template.business.scenario }}</p>
99
+ </div>
100
+ <button
101
+ type="button"
102
+ class="oa-template-card__star"
103
+ :class="{ 'is-active': isFavorite(template.id) }"
104
+ :aria-label="isFavorite(template.id) ? '取消收藏' : '收藏模板'"
105
+ @click.stop="oa.toggleFavorite(template.id)"
106
+ >
107
+ <el-icon><StarFilled /></el-icon>
108
+ </button>
109
+ </div>
110
+
111
+ <p class="oa-template-card__description">{{ template.description }}</p>
112
+
113
+ <div class="oa-template-card__meta">
114
+ <span class="oa-chip">{{ template.business.category }}</span>
115
+ <span><el-icon><Clock /></el-icon>{{ template.slaLabel }}</span>
116
+ <span><el-icon><Share /></el-icon>{{ template.approvalCount }} 个审批节点</span>
117
+ <span v-if="template.customCount">
118
+ <el-icon><SetUp /></el-icon>{{ template.customCount }} 个自定义节点
119
+ </span>
120
+ </div>
121
+
122
+ <div v-if="template.business.materials.length" class="oa-template-card__materials">
123
+ <span class="oa-template-card__materials-label">所需材料</span>
124
+ <span
125
+ v-for="material in template.business.materials.slice(0, 3)"
126
+ :key="material"
127
+ class="oa-chip"
128
+ >
129
+ {{ material }}
130
+ </span>
131
+ </div>
132
+
133
+ <footer class="oa-template-card__foot">
134
+ <span>{{ template.business.owner }} · 近期使用 {{ template.business.popularity }} 次</span>
135
+ <el-button type="primary" size="small" plain @click.stop="start(template)">
136
+ 发起申请
137
+ </el-button>
138
+ </footer>
139
+ </article>
140
+ </section>
141
+
142
+ <div v-else class="oa-card">
143
+ <div class="oa-empty oa-templates__empty">
144
+ <span class="oa-empty__icon"><el-icon><Grid /></el-icon></span>
145
+ <strong>{{ emptyTitle }}</strong>
146
+ <p>{{ emptyDescription }}</p>
147
+ <el-button v-if="oa.isAdmin.value" type="primary" plain size="small" @click="oa.navigate('design')">
148
+ 去流程设计
149
+ </el-button>
150
+ </div>
151
+ </div>
152
+ </div>
153
+ </template>
154
+
155
+ <script setup>
156
+ import { computed, inject, ref } from 'vue'
157
+ import {
158
+ ArrowRight,
159
+ Clock,
160
+ EditPen,
161
+ Grid,
162
+ Search,
163
+ SetUp,
164
+ Share,
165
+ StarFilled
166
+ } from 'gbicons'
167
+ import CategoryIcon from '../components/CategoryIcon.vue'
168
+ import { buildTemplateCards } from '../model.js'
169
+
170
+ defineOptions({ name: 'OaTemplatesPage' })
171
+
172
+ const oa = inject('oaStore')
173
+
174
+ const keyword = ref('')
175
+ const activeCategory = ref('all')
176
+ const favoriteOnly = ref(false)
177
+ const showRecent = ref(false)
178
+
179
+ const allTemplates = computed(() =>
180
+ buildTemplateCards(oa.publishedDefinitions.value)
181
+ )
182
+
183
+ const categories = computed(() => {
184
+ const map = new Map()
185
+ allTemplates.value.forEach((template) => {
186
+ const category = template.business.category || '通用'
187
+ map.set(category, (map.get(category) || 0) + 1)
188
+ })
189
+ return [
190
+ { value: 'all', label: '全部', count: allTemplates.value.length },
191
+ ...[...map.entries()].map(([value, count]) => ({ value, label: value, count }))
192
+ ]
193
+ })
194
+
195
+ const recentTemplates = computed(() => {
196
+ const ids = new Set()
197
+ oa.myInstances.value.forEach((instance) => {
198
+ const id = instance.definition?.meta?.id
199
+ if (id) ids.add(String(id))
200
+ })
201
+ return allTemplates.value.filter((template) => ids.has(String(template.id))).slice(0, 4)
202
+ })
203
+
204
+ const visibleTemplates = computed(() => {
205
+ const text = keyword.value.trim().toLowerCase()
206
+ let list = allTemplates.value
207
+ if (showRecent.value) {
208
+ const recentIds = new Set(recentTemplates.value.map((template) => template.id))
209
+ list = list.filter((template) => recentIds.has(template.id))
210
+ }
211
+ if (activeCategory.value !== 'all') {
212
+ list = list.filter((template) => template.business.category === activeCategory.value)
213
+ }
214
+ if (favoriteOnly.value) {
215
+ list = list.filter((template) => isFavorite(template.id))
216
+ }
217
+ if (text) {
218
+ list = list.filter((template) =>
219
+ [
220
+ template.name,
221
+ template.description,
222
+ template.business.scenario,
223
+ template.business.category,
224
+ template.business.owner
225
+ ]
226
+ .filter(Boolean)
227
+ .some((field) => String(field).toLowerCase().includes(text))
228
+ )
229
+ }
230
+ return list
231
+ })
232
+
233
+ const emptyTitle = computed(() => {
234
+ if (keyword.value.trim() || favoriteOnly.value || showRecent.value) return '没有匹配的模板'
235
+ if (activeCategory.value !== 'all') return '该分类下暂无可用模板'
236
+ return '暂无可发起的流程模板'
237
+ })
238
+
239
+ const emptyDescription = computed(() => {
240
+ if (keyword.value.trim() || favoriteOnly.value) {
241
+ return '尝试更换关键词、分类,或取消收藏筛选。'
242
+ }
243
+ if (showRecent.value) return '你还没有使用过流程模板,先浏览全部模板发起一次申请。'
244
+ return '流程管理员发布流程后,模板会自动出现在这里。'
245
+ })
246
+
247
+ function isFavorite(id) {
248
+ return oa.favoriteIds.value.map(String).includes(String(id))
249
+ }
250
+
251
+ function toggleFavoriteFilter() {
252
+ favoriteOnly.value = !favoriteOnly.value
253
+ if (favoriteOnly.value) showRecent.value = false
254
+ }
255
+
256
+ function toggleRecent() {
257
+ showRecent.value = !showRecent.value
258
+ if (showRecent.value) favoriteOnly.value = false
259
+ }
260
+
261
+ function start(template) {
262
+ oa.openStartDialog(template.id)
263
+ }
264
+ </script>
265
+
266
+ <style scoped lang="scss">
267
+ .oa-templates {
268
+ max-width: 1440px;
269
+ margin: 0 auto;
270
+ width: 100%;
271
+ }
272
+
273
+ .oa-template-guide {
274
+ display: flex;
275
+ align-items: center;
276
+ justify-content: space-between;
277
+ gap: 24px;
278
+ padding: 18px 22px;
279
+ border: 1px solid #dbe4f5;
280
+ border-radius: var(--oa-radius);
281
+ background:
282
+ radial-gradient(circle at 85% -20%, rgba(36, 86, 214, 0.1), transparent 45%),
283
+ linear-gradient(110deg, #f8faff, #fff);
284
+ box-shadow: var(--oa-shadow);
285
+ flex-wrap: wrap;
286
+ }
287
+
288
+ .oa-template-guide__lead {
289
+ min-width: 270px;
290
+
291
+ strong {
292
+ display: block;
293
+ margin-top: 4px;
294
+ color: var(--oa-ink-strong);
295
+ font-size: 18px;
296
+ font-weight: 650;
297
+ letter-spacing: -0.02em;
298
+ }
299
+
300
+ p {
301
+ margin: 4px 0 0;
302
+ color: var(--oa-muted);
303
+ font-size: 11.5px;
304
+ }
305
+ }
306
+
307
+ .oa-template-guide__kicker {
308
+ display: inline-block;
309
+ padding: 1px 7px;
310
+ border-radius: 4px;
311
+ background: var(--oa-primary-soft);
312
+ color: var(--oa-primary);
313
+ font-size: 10px;
314
+ font-weight: 600;
315
+ }
316
+
317
+ .oa-template-guide__steps {
318
+ display: flex;
319
+ align-items: center;
320
+ gap: 14px;
321
+
322
+ > div {
323
+ display: grid;
324
+ grid-template-columns: auto 1fr;
325
+ column-gap: 8px;
326
+ align-items: center;
327
+
328
+ > span {
329
+ grid-row: span 2;
330
+ display: grid;
331
+ place-items: center;
332
+ width: 30px;
333
+ height: 30px;
334
+ border: 1px solid #d2def4;
335
+ border-radius: 50%;
336
+ background: #fff;
337
+ color: var(--oa-primary);
338
+ font-size: 10px;
339
+ font-weight: 700;
340
+ font-variant-numeric: tabular-nums;
341
+ }
342
+
343
+ strong {
344
+ color: var(--oa-ink);
345
+ font-size: 11.5px;
346
+ font-weight: 600;
347
+ }
348
+
349
+ small {
350
+ color: var(--oa-faint);
351
+ font-size: 10px;
352
+ }
353
+ }
354
+
355
+ > i {
356
+ color: #b7c6de;
357
+ font-size: 12px;
358
+ font-style: normal;
359
+ }
360
+ }
361
+
362
+ .oa-templates__toolbar {
363
+ display: flex;
364
+ align-items: center;
365
+ justify-content: space-between;
366
+ gap: 14px;
367
+ flex-wrap: wrap;
368
+ }
369
+
370
+ .oa-templates__categories {
371
+ display: flex;
372
+ flex-wrap: wrap;
373
+ gap: 4px;
374
+ }
375
+
376
+ .oa-category {
377
+ display: inline-flex;
378
+ align-items: center;
379
+ gap: 5px;
380
+ min-height: 30px;
381
+ padding: 3px 10px;
382
+ border: 1px solid transparent;
383
+ border-radius: 6px;
384
+ background: transparent;
385
+ color: var(--oa-muted);
386
+ font-size: 11.5px;
387
+ cursor: pointer;
388
+
389
+ span {
390
+ color: var(--oa-faint);
391
+ font-size: 9.5px;
392
+ }
393
+
394
+ &:hover {
395
+ background: #f6f8fc;
396
+ }
397
+
398
+ &.is-active {
399
+ border-color: var(--oa-line);
400
+ background: #fff;
401
+ color: var(--oa-ink);
402
+ font-weight: 600;
403
+ box-shadow: var(--oa-shadow);
404
+ }
405
+ }
406
+
407
+ .oa-templates__tools {
408
+ display: flex;
409
+ gap: 7px;
410
+ }
411
+
412
+ .oa-templates__search {
413
+ width: 250px;
414
+ }
415
+
416
+ .oa-favorite-filter {
417
+ display: inline-flex;
418
+ align-items: center;
419
+ gap: 5px;
420
+ padding: 3px 9px;
421
+ border: 1px solid var(--oa-line);
422
+ border-radius: 6px;
423
+ background: #fff;
424
+ color: var(--oa-muted);
425
+ font-size: 11px;
426
+ cursor: pointer;
427
+
428
+ .el-icon {
429
+ color: #e2b23e;
430
+ }
431
+
432
+ span {
433
+ color: var(--oa-faint);
434
+ font-size: 9.5px;
435
+ }
436
+
437
+ &.is-active {
438
+ border-color: #eddaa6;
439
+ background: #fffaed;
440
+ color: #8c6717;
441
+ }
442
+ }
443
+
444
+ .oa-templates__recent {
445
+ display: flex;
446
+ align-items: center;
447
+ flex-wrap: wrap;
448
+ gap: 6px;
449
+ }
450
+
451
+ .oa-templates__recent-label {
452
+ margin-right: 2px;
453
+ color: var(--oa-faint);
454
+ font-size: 10.5px;
455
+ }
456
+
457
+ .oa-recent-chip {
458
+ display: inline-flex;
459
+ align-items: center;
460
+ gap: 6px;
461
+ padding: 3px 9px 3px 4px;
462
+ border: 1px solid var(--oa-line);
463
+ border-radius: 18px;
464
+ background: #fff;
465
+ color: var(--oa-muted);
466
+ font-size: 10.5px;
467
+ cursor: pointer;
468
+ transition: border-color 0.15s ease, color 0.15s ease;
469
+
470
+ &:hover {
471
+ border-color: #c7d5f1;
472
+ color: var(--oa-primary);
473
+ }
474
+ }
475
+
476
+ .oa-template-grid {
477
+ display: grid;
478
+ grid-template-columns: repeat(3, minmax(0, 1fr));
479
+ gap: 14px;
480
+ }
481
+
482
+ .oa-template-card {
483
+ display: flex;
484
+ flex-direction: column;
485
+ min-width: 0;
486
+ padding: 17px 18px 14px;
487
+ cursor: pointer;
488
+ transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
489
+
490
+ &:hover {
491
+ border-color: #c7d7f3;
492
+ box-shadow: 0 10px 30px rgba(15, 31, 55, 0.07);
493
+ transform: translateY(-2px);
494
+ }
495
+ }
496
+
497
+ .oa-template-card__top {
498
+ display: flex;
499
+ align-items: flex-start;
500
+ gap: 11px;
501
+ }
502
+
503
+ .oa-template-card__title {
504
+ flex: 1;
505
+ min-width: 0;
506
+
507
+ p {
508
+ margin: 3px 0 0;
509
+ color: var(--oa-faint);
510
+ font-size: 10.5px;
511
+ line-height: 1.6;
512
+ }
513
+ }
514
+
515
+ .oa-template-card__name-row {
516
+ display: flex;
517
+ align-items: center;
518
+ gap: 6px;
519
+
520
+ h3 {
521
+ margin: 0;
522
+ overflow: hidden;
523
+ color: var(--oa-ink);
524
+ font-size: 14px;
525
+ font-weight: 650;
526
+ letter-spacing: -0.01em;
527
+ text-overflow: ellipsis;
528
+ white-space: nowrap;
529
+ }
530
+ }
531
+
532
+ .oa-template-card__version {
533
+ flex-shrink: 0;
534
+ padding: 0 4px;
535
+ border-radius: 3px;
536
+ background: #f1f4f9;
537
+ color: var(--oa-faint);
538
+ font-size: 9px;
539
+ line-height: 16px;
540
+ }
541
+
542
+ .oa-template-card__star {
543
+ display: grid;
544
+ place-items: center;
545
+ width: 28px;
546
+ height: 28px;
547
+ flex-shrink: 0;
548
+ border: 1px solid transparent;
549
+ border-radius: 6px;
550
+ background: transparent;
551
+ color: #ccd4e0;
552
+ font-size: 15px;
553
+ cursor: pointer;
554
+
555
+ &:hover {
556
+ background: #fffaed;
557
+ color: #d7a92d;
558
+ }
559
+
560
+ &.is-active {
561
+ color: #d7a92d;
562
+ }
563
+ }
564
+
565
+ .oa-template-card__description {
566
+ display: -webkit-box;
567
+ overflow: hidden;
568
+ margin: 12px 0 0;
569
+ color: var(--oa-muted);
570
+ font-size: 11.5px;
571
+ line-height: 1.7;
572
+ -webkit-box-orient: vertical;
573
+ -webkit-line-clamp: 2;
574
+ }
575
+
576
+ .oa-template-card__meta {
577
+ display: flex;
578
+ align-items: center;
579
+ flex-wrap: wrap;
580
+ gap: 8px;
581
+ margin-top: 12px;
582
+ color: var(--oa-faint);
583
+ font-size: 10.5px;
584
+
585
+ > span:not(.oa-chip) {
586
+ display: inline-flex;
587
+ align-items: center;
588
+ gap: 3px;
589
+ }
590
+ }
591
+
592
+ .oa-template-card__materials {
593
+ display: flex;
594
+ align-items: center;
595
+ flex-wrap: wrap;
596
+ gap: 4px;
597
+ margin-top: 10px;
598
+ padding-top: 10px;
599
+ border-top: 1px dashed var(--oa-line);
600
+ }
601
+
602
+ .oa-template-card__materials-label {
603
+ margin-right: 2px;
604
+ color: var(--oa-faint);
605
+ font-size: 10px;
606
+ }
607
+
608
+ .oa-template-card__foot {
609
+ display: flex;
610
+ align-items: center;
611
+ justify-content: space-between;
612
+ gap: 10px;
613
+ margin-top: auto;
614
+ padding-top: 14px;
615
+ color: var(--oa-faint);
616
+ font-size: 10px;
617
+ }
618
+
619
+ .oa-templates__empty {
620
+ padding: 72px 24px;
621
+ }
622
+
623
+ @media (max-width: 1200px) {
624
+ .oa-template-grid {
625
+ grid-template-columns: repeat(2, minmax(0, 1fr));
626
+ }
627
+
628
+ .oa-template-guide__steps {
629
+ gap: 9px;
630
+ }
631
+ }
632
+
633
+ @media (max-width: 960px) {
634
+ .oa-template-guide {
635
+ padding: 14px 16px;
636
+ }
637
+
638
+ .oa-template-guide__steps {
639
+ display: none;
640
+ }
641
+
642
+ .oa-templates__categories {
643
+ flex-wrap: nowrap;
644
+ overflow-x: auto;
645
+ width: 100%;
646
+ padding-bottom: 2px;
647
+
648
+ .oa-category {
649
+ flex-shrink: 0;
650
+ }
651
+ }
652
+
653
+ .oa-templates__toolbar {
654
+ gap: 8px;
655
+ }
656
+
657
+ .oa-templates__tools {
658
+ width: 100%;
659
+
660
+ .oa-templates__search {
661
+ flex: 1;
662
+ width: auto;
663
+ }
664
+ }
665
+
666
+ .oa-template-grid {
667
+ grid-template-columns: minmax(0, 1fr);
668
+ }
669
+
670
+ .oa-template-card {
671
+ padding: 15px;
672
+ }
673
+
674
+ .oa-template-card__foot {
675
+ .el-button {
676
+ min-height: 44px;
677
+ }
678
+ }
679
+ }
680
+ </style>