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,1050 +1,1050 @@
1
- <template>
2
- <div class="oa-page oa-home">
3
- <header class="oa-home__hero">
4
- <div>
5
- <p class="oa-eyebrow">
6
- {{ dateLabel }}
7
- <span class="oa-home__role">{{ oa.currentUserRoleNames.value.join(' / ') || '成员' }}</span>
8
- </p>
9
- <h1 class="oa-title">{{ greeting }},{{ oa.currentUserName.value }}</h1>
10
- <p class="oa-subtitle">
11
- {{ oa.currentUserDept.value }}
12
- <template v-if="oa.approveItems.value.length">
13
- · 有 <strong>{{ oa.approveItems.value.length }}</strong> 项审批待你处理
14
- </template>
15
- </p>
16
- </div>
17
- <div class="oa-home__hero-actions">
18
- <el-button :icon="Plus" type="primary" @click="oa.navigate('templates')">发起申请</el-button>
19
- <el-button :icon="Tickets" @click="oa.navigate('tasks')">进入待办中心</el-button>
20
- </div>
21
- </header>
22
-
23
- <button
24
- v-if="overdueItem"
25
- type="button"
26
- class="oa-home__alert"
27
- @click="oa.openTask(overdueItem)"
28
- >
29
- <el-icon><WarningFilled /></el-icon>
30
- <span>
31
- <strong>「{{ overdueItem.title }}」已超时</strong>
32
- 当前节点「{{ overdueItem.nodeName }}」已等待 {{ formatElapsed(overdueItem.arrivedAt, oa.now.value) }},请优先处理
33
- </span>
34
- <em>立即处理<el-icon><ArrowRight /></el-icon></em>
35
- </button>
36
-
37
- <section class="oa-home__stats">
38
- <button type="button" class="oa-stat" @click="oa.navigate('tasks')">
39
- <span class="oa-stat__icon is-blue"><el-icon><Tickets /></el-icon></span>
40
- <span class="oa-stat__body">
41
- <small>待我审批</small>
42
- <strong class="oa-num">{{ oa.approveItems.value.length }}</strong>
43
- <em v-if="overdueCount">其中 {{ overdueCount }} 项超时</em>
44
- <em v-else>全部在 SLA 内</em>
45
- </span>
46
- </button>
47
- <button type="button" class="oa-stat" @click="oa.navigate('tasks', { taskTab: 'submit' })">
48
- <span class="oa-stat__icon is-amber"><el-icon><EditPen /></el-icon></span>
49
- <span class="oa-stat__body">
50
- <small>待我提交</small>
51
- <strong class="oa-num">{{ oa.submitItems.value.length }}</strong>
52
- <em>{{ oa.submitItems.value.length ? '退回修改后需重新提交' : '暂无退回申请' }}</em>
53
- </span>
54
- </button>
55
- <button type="button" class="oa-stat" @click="oa.navigate('requests', { scope: 'mine' })">
56
- <span class="oa-stat__icon is-green"><el-icon><Document /></el-icon></span>
57
- <span class="oa-stat__body">
58
- <small>我发起的</small>
59
- <strong class="oa-num">{{ oa.myInstances.value.length }}</strong>
60
- <em>{{ runningMine.length }} 个正在审批</em>
61
- </span>
62
- </button>
63
- <button type="button" class="oa-stat" @click="oa.navigate('requests', { scope: 'cc' })">
64
- <span class="oa-stat__icon is-violet"><el-icon><ChatDotRound /></el-icon></span>
65
- <span class="oa-stat__body">
66
- <small>抄送我的</small>
67
- <strong class="oa-num">{{ oa.ccItems.value.length }}</strong>
68
- <em>知会与归档事项</em>
69
- </span>
70
- </button>
71
- </section>
72
-
73
- <div class="oa-home__grid">
74
- <div class="oa-home__main">
75
- <section class="oa-card oa-todo-card">
76
- <div class="oa-section-head">
77
- <h2 class="oa-section-head__title">
78
- 待我处理
79
- <small>{{ activeTodoTab === 'approve' ? '按超时与优先级排序' : '退回修改后需重新提交' }}</small>
80
- </h2>
81
- <div class="oa-todo-card__tools">
82
- <div class="oa-segment">
83
- <button
84
- type="button"
85
- :class="{ 'is-active': activeTodoTab === 'approve' }"
86
- @click="activeTodoTab = 'approve'"
87
- >
88
- 审批 {{ oa.approveItems.value.length }}
89
- </button>
90
- <button
91
- type="button"
92
- :class="{ 'is-active': activeTodoTab === 'submit' }"
93
- @click="activeTodoTab = 'submit'"
94
- >
95
- 提交 {{ oa.submitItems.value.length }}
96
- </button>
97
- </div>
98
- <el-button link type="primary" @click="oa.navigate('tasks')">
99
- 全部<el-icon class="el-icon--right"><ArrowRight /></el-icon>
100
- </el-button>
101
- </div>
102
- </div>
103
-
104
- <div v-if="visibleTodos.length" class="oa-todo-list">
105
- <button
106
- v-for="item in visibleTodos"
107
- :key="item.id"
108
- type="button"
109
- class="oa-todo"
110
- @click="oa.openTask(item)"
111
- >
112
- <span class="oa-todo__mark" :class="`is-${item.priorityMeta.tone}`"></span>
113
- <span class="oa-todo__main">
114
- <span class="oa-todo__title-row">
115
- <strong>{{ item.title }}</strong>
116
- <span class="oa-chip" :class="item.kind === 'submit' ? 'oa-chip--warning' : ''">
117
- {{ item.kind === 'submit' ? '待重新提交' : item.nodeName }}
118
- </span>
119
- <span v-if="item.overdue" class="oa-chip oa-chip--danger">已超时</span>
120
- <span v-else-if="item.priority !== 'normal'" class="oa-chip" :class="`oa-chip--${item.priorityMeta.tone}`">
121
- {{ item.priorityMeta.label }}
122
- </span>
123
- </span>
124
- <span class="oa-todo__meta">
125
- {{ item.initiatorName }} · {{ item.initiatorDept }}
126
- <i></i>
127
- {{ item.code }}
128
- <i></i>
129
- {{ formatRelativeTime(item.arrivedAt, oa.now.value) }}到达
130
- </span>
131
- </span>
132
- <span v-if="item.amount" class="oa-todo__amount oa-num">{{ formatMoney(item.amount) }}</span>
133
- <span class="oa-todo__cta">去处理<el-icon><ArrowRight /></el-icon></span>
134
- </button>
135
- </div>
136
- <div v-else class="oa-empty">
137
- <span class="oa-empty__icon"><el-icon><CircleCheck /></el-icon></span>
138
- <strong>当前没有需要处理的事项</strong>
139
- <p>新的待办到达后会出现在这里,也会通过通知中心提醒你。</p>
140
- </div>
141
- </section>
142
-
143
- <section class="oa-card oa-mine-card">
144
- <div class="oa-section-head">
145
- <h2 class="oa-section-head__title">
146
- 我发起的流程
147
- <small>进行中 {{ runningMine.length }} 个</small>
148
- </h2>
149
- <el-button link type="primary" @click="oa.navigate('requests', { scope: 'mine' })">
150
- 全部申请<el-icon class="el-icon--right"><ArrowRight /></el-icon>
151
- </el-button>
152
- </div>
153
-
154
- <div v-if="recentMine.length" class="oa-mine-list">
155
- <button
156
- v-for="instance in recentMine"
157
- :key="instance.id"
158
- type="button"
159
- class="oa-mine"
160
- @click="oa.openInstanceDetail(instance.id)"
161
- >
162
- <span class="oa-mine__info">
163
- <span class="oa-mine__title">
164
- <strong>{{ instanceTitle(instance) }}</strong>
165
- <span class="oa-status" :class="`oa-status--${statusMeta(instance.state.status).tone}`">
166
- {{ statusMeta(instance.state.status).label }}
167
- </span>
168
- </span>
169
- <span class="oa-mine__meta">
170
- {{ instance.code || instanceCode(instance) }}
171
- <i></i>
172
- {{ progressText(instance) }}
173
- <i></i>
174
- {{ formatRelativeTime(instance.updatedAt, oa.now.value) }}更新
175
- </span>
176
- <span class="oa-progress oa-mine__progress">
177
- <span :style="{ width: `${progressOf(instance)}%` }"></span>
178
- </span>
179
- </span>
180
- <span class="oa-mine__side">
181
- <span class="oa-num">{{ progressOf(instance) }}%</span>
182
- <small>流程进度</small>
183
- </span>
184
- </button>
185
- </div>
186
- <div v-else class="oa-empty">
187
- <span class="oa-empty__icon"><el-icon><Document /></el-icon></span>
188
- <strong>还没有发起过流程</strong>
189
- <p>从模板中心选择常用流程,填写申请后即可发起。</p>
190
- <el-button type="primary" plain size="small" @click="oa.navigate('templates')">去模板中心</el-button>
191
- </div>
192
- </section>
193
- </div>
194
-
195
- <aside class="oa-home__side">
196
- <section class="oa-card oa-quick-card">
197
- <div class="oa-section-head">
198
- <h2 class="oa-section-head__title">常用流程</h2>
199
- <el-button link type="primary" @click="oa.navigate('templates')">全部</el-button>
200
- </div>
201
- <div class="oa-quick-list">
202
- <button
203
- v-for="template in quickTemplates"
204
- :key="template.id"
205
- type="button"
206
- class="oa-quick"
207
- @click="oa.openStartDialog(template.id)"
208
- >
209
- <CategoryIcon :category="template.business.category" :size="32" />
210
- <span class="oa-quick__body">
211
- <strong>{{ template.name }}</strong>
212
- <small>{{ template.business.scenario }}</small>
213
- </span>
214
- <span class="oa-quick__sla">{{ template.slaLabel }}</span>
215
- <el-icon class="oa-quick__plus"><CirclePlus /></el-icon>
216
- </button>
217
- <div v-if="!quickTemplates.length" class="oa-empty oa-empty--sm">
218
- <strong>暂无可用模板</strong>
219
- <p>请先在流程设计中发布流程。</p>
220
- </div>
221
- </div>
222
- </section>
223
-
224
- <section class="oa-card oa-activity-card">
225
- <div class="oa-section-head">
226
- <h2 class="oa-section-head__title">
227
- 流程动态
228
- <small v-if="oa.unreadNotifications.value.length">{{ oa.unreadNotifications.value.length }} 条未读</small>
229
- </h2>
230
- <el-button link type="primary" @click="oa.navigate('notifications')">全部</el-button>
231
- </div>
232
- <div v-if="recentNotifications.length" class="oa-activity">
233
- <button
234
- v-for="notification in recentNotifications"
235
- :key="notification.id"
236
- type="button"
237
- class="oa-activity__item"
238
- :class="{ 'is-unread': !notification.read }"
239
- @click="openNotification(notification)"
240
- >
241
- <NotificationIcon :type="notification.type" :size="22" />
242
- <span class="oa-activity__body">
243
- <strong>{{ notification.title }}</strong>
244
- <small>{{ notification.description }}</small>
245
- </span>
246
- <time>{{ formatRelativeTime(notification.at, oa.now.value) }}</time>
247
- </button>
248
- </div>
249
- <div v-else class="oa-empty oa-empty--sm">
250
- <span class="oa-empty__icon"><el-icon><Bell /></el-icon></span>
251
- <strong>暂无新动态</strong>
252
- <p>待办、抄送和流程结果会汇总在这里。</p>
253
- </div>
254
- </section>
255
-
256
- <section class="oa-home__note">
257
- <el-icon><CircleCheck /></el-icon>
258
- <div>
259
- <strong>数据自动保存</strong>
260
- <p>演示数据保存在本机浏览器;所有审批动作都会写入流程轨迹与审计日志。</p>
261
- </div>
262
- </section>
263
- </aside>
264
- </div>
265
- </div>
266
- </template>
267
-
268
- <script setup>
269
- import { computed, inject, ref } from 'vue'
270
- import {
271
- ArrowRight,
272
- Bell,
273
- ChatDotRound,
274
- CircleCheck,
275
- CirclePlus,
276
- Document,
277
- EditPen,
278
- Plus,
279
- Tickets,
280
- WarningFilled
281
- } from '@element-plus/icons-vue'
282
- import CategoryIcon from '../components/CategoryIcon.vue'
283
- import NotificationIcon from '../components/NotificationIcon.vue'
284
- import {
285
- buildTemplateCards,
286
- formatElapsed,
287
- formatMoney,
288
- formatRelativeTime,
289
- instanceCode,
290
- instanceTitle,
291
- statusMeta
292
- } from '../model.js'
293
-
294
- defineOptions({ name: 'OaHomePage' })
295
-
296
- const oa = inject('oaStore')
297
- const activeTodoTab = ref('approve')
298
-
299
- const nowDate = computed(() => new Date(oa.now.value))
300
- const dateLabel = computed(() =>
301
- nowDate.value.toLocaleDateString('zh-CN', {
302
- year: 'numeric',
303
- month: 'long',
304
- day: 'numeric',
305
- weekday: 'long'
306
- })
307
- )
308
- const greeting = computed(() => {
309
- const hour = nowDate.value.getHours()
310
- if (hour < 6) return '夜深了'
311
- if (hour < 12) return '早上好'
312
- if (hour < 14) return '中午好'
313
- if (hour < 18) return '下午好'
314
- return '晚上好'
315
- })
316
-
317
- const overdueItem = computed(() => oa.approveItems.value.find((item) => item.overdue) || null)
318
- const overdueCount = computed(
319
- () => oa.approveItems.value.filter((item) => item.overdue).length
320
- )
321
- const visibleTodos = computed(() =>
322
- (activeTodoTab.value === 'approve' ? oa.approveItems.value : oa.submitItems.value).slice(0, 5)
323
- )
324
- const runningMine = computed(
325
- () => oa.myInstances.value.filter((instance) => instance.state?.status === 'running')
326
- )
327
- const recentMine = computed(() =>
328
- [...oa.myInstances.value]
329
- .sort((left, right) => String(right.updatedAt).localeCompare(String(left.updatedAt)))
330
- .slice(0, 4)
331
- )
332
- const quickTemplates = computed(() =>
333
- buildTemplateCards(oa.publishedDefinitions.value).slice(0, 4)
334
- )
335
- const recentNotifications = computed(() => oa.notifications.value.slice(0, 5))
336
-
337
- function progressText(instance) {
338
- const task = (instance.state?.tasks || []).find((item) => item.status === 'pending')
339
- if (task) return `当前节点:${task.nodeName}`
340
- return `状态:${statusMeta(instance.state?.status).label}`
341
- }
342
-
343
- function progressOf(instance) {
344
- const tasks = instance.state?.tasks || []
345
- if (!tasks.length) return 0
346
- const completed = tasks.filter((task) =>
347
- ['approved', 'completed', 'rejected', 'failed', 'cancelled'].includes(task.status)
348
- ).length
349
- if (['completed', 'rejected', 'revoked', 'cancelled'].includes(instance.state?.status)) {
350
- return 100
351
- }
352
- return Math.max(6, Math.round((completed / tasks.length) * 100))
353
- }
354
-
355
- function openNotification(notification) {
356
- oa.markNotificationRead(notification.id)
357
- if (notification.action === 'task' && notification.task) {
358
- oa.navigate('tasks', {
359
- instanceId: notification.instance.id,
360
- taskId: notification.task.id
361
- })
362
- return
363
- }
364
- oa.openInstanceDetail(notification.instance.id)
365
- }
366
- </script>
367
-
368
- <style scoped lang="scss">
369
- .oa-home {
370
- max-width: 1500px;
371
- margin: 0 auto;
372
- width: 100%;
373
- }
374
-
375
- .oa-home__hero {
376
- display: flex;
377
- align-items: flex-start;
378
- justify-content: space-between;
379
- gap: 20px;
380
- flex-wrap: wrap;
381
- padding: 2px 0 4px;
382
-
383
- .oa-subtitle strong {
384
- color: var(--oa-primary);
385
- font-weight: 650;
386
- }
387
- }
388
-
389
- .oa-home__role {
390
- padding: 1px 7px;
391
- border-radius: 4px;
392
- background: var(--oa-primary-soft);
393
- color: var(--oa-primary);
394
- font-size: 10px;
395
- font-weight: 600;
396
- letter-spacing: 0;
397
- text-transform: none;
398
- }
399
-
400
- .oa-home__hero-actions {
401
- display: flex;
402
- gap: 8px;
403
- padding-top: 18px;
404
- }
405
-
406
- .oa-home__alert {
407
- display: flex;
408
- align-items: center;
409
- gap: 12px;
410
- width: 100%;
411
- padding: 12px 16px;
412
- border: 1px solid #f1d7b1;
413
- border-radius: var(--oa-radius);
414
- background: linear-gradient(90deg, #fff8eb, #fffdf9);
415
- color: #7e5310;
416
- text-align: left;
417
- cursor: pointer;
418
- transition: border-color 0.15s ease, box-shadow 0.15s ease;
419
-
420
- &:hover {
421
- border-color: #e6bf87;
422
- box-shadow: 0 4px 14px rgba(170, 106, 18, 0.08);
423
- }
424
-
425
- > .el-icon {
426
- flex-shrink: 0;
427
- color: #c07b1b;
428
- font-size: 17px;
429
- }
430
-
431
- span {
432
- flex: 1;
433
- min-width: 0;
434
- font-size: 12px;
435
- line-height: 1.6;
436
- }
437
-
438
- strong {
439
- margin-right: 6px;
440
- color: #8d5b11;
441
- font-weight: 650;
442
- }
443
-
444
- em {
445
- display: inline-flex;
446
- align-items: center;
447
- gap: 3px;
448
- flex-shrink: 0;
449
- color: #a46712;
450
- font-size: 12px;
451
- font-style: normal;
452
- font-weight: 600;
453
- }
454
- }
455
-
456
- .oa-home__stats {
457
- display: grid;
458
- grid-template-columns: repeat(4, minmax(0, 1fr));
459
- gap: 12px;
460
- }
461
-
462
- .oa-stat {
463
- display: flex;
464
- align-items: flex-start;
465
- gap: 12px;
466
- padding: 16px;
467
- border: 1px solid var(--oa-line);
468
- border-radius: var(--oa-radius);
469
- background: var(--oa-surface);
470
- box-shadow: var(--oa-shadow);
471
- text-align: left;
472
- cursor: pointer;
473
- transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
474
-
475
- &:hover {
476
- border-color: #c9d7f4;
477
- box-shadow: 0 8px 24px rgba(15, 31, 55, 0.07);
478
- transform: translateY(-1px);
479
- }
480
- }
481
-
482
- .oa-stat__icon {
483
- display: grid;
484
- place-items: center;
485
- width: 36px;
486
- height: 36px;
487
- flex-shrink: 0;
488
- border-radius: 9px;
489
- font-size: 16px;
490
-
491
- &.is-blue {
492
- background: #edf2ff;
493
- color: #2456d6;
494
- }
495
-
496
- &.is-amber {
497
- background: #fff4e2;
498
- color: #a86a16;
499
- }
500
-
501
- &.is-green {
502
- background: #e9f7f0;
503
- color: #0d8057;
504
- }
505
-
506
- &.is-violet {
507
- background: #f0edfb;
508
- color: #5c4bb0;
509
- }
510
- }
511
-
512
- .oa-stat__body {
513
- display: flex;
514
- flex-direction: column;
515
- min-width: 0;
516
-
517
- small {
518
- color: var(--oa-muted);
519
- font-size: 12px;
520
- }
521
-
522
- strong {
523
- margin-top: 1px;
524
- color: var(--oa-ink-strong);
525
- font-size: 26px;
526
- font-weight: 650;
527
- letter-spacing: -0.03em;
528
- line-height: 1.25;
529
- }
530
-
531
- em {
532
- margin-top: 2px;
533
- color: var(--oa-faint);
534
- font-size: 10.5px;
535
- font-style: normal;
536
- overflow: hidden;
537
- text-overflow: ellipsis;
538
- white-space: nowrap;
539
- }
540
- }
541
-
542
- .oa-home__grid {
543
- display: grid;
544
- grid-template-columns: minmax(0, 1fr) 360px;
545
- gap: 16px;
546
- align-items: start;
547
- }
548
-
549
- .oa-home__main,
550
- .oa-home__side {
551
- display: flex;
552
- flex-direction: column;
553
- gap: 16px;
554
- min-width: 0;
555
- }
556
-
557
- .oa-todo-card__tools {
558
- display: flex;
559
- align-items: center;
560
- gap: 10px;
561
- }
562
-
563
- .oa-segment {
564
- display: inline-flex;
565
- gap: 2px;
566
- padding: 2px;
567
- border-radius: 7px;
568
- background: #f1f4f9;
569
-
570
- button {
571
- padding: 3px 10px;
572
- border: none;
573
- border-radius: 5px;
574
- background: transparent;
575
- color: var(--oa-muted);
576
- font-size: 11.5px;
577
- cursor: pointer;
578
- transition: background 0.15s ease, color 0.15s ease;
579
-
580
- &:hover {
581
- color: var(--oa-ink);
582
- }
583
-
584
- &.is-active {
585
- background: #fff;
586
- color: var(--oa-ink);
587
- font-weight: 600;
588
- box-shadow: 0 1px 3px rgba(15, 31, 55, 0.08);
589
- }
590
- }
591
- }
592
-
593
- .oa-todo-list {
594
- padding: 0 8px 8px;
595
- }
596
-
597
- .oa-todo {
598
- position: relative;
599
- display: flex;
600
- align-items: center;
601
- gap: 12px;
602
- width: 100%;
603
- padding: 12px 12px 12px 14px;
604
- border: 1px solid transparent;
605
- border-radius: 8px;
606
- background: transparent;
607
- text-align: left;
608
- cursor: pointer;
609
- transition: background 0.15s ease, border-color 0.15s ease;
610
-
611
- &:hover {
612
- border-color: #e2e9f5;
613
- background: #f8faff;
614
-
615
- .oa-todo__cta {
616
- color: var(--oa-primary);
617
- opacity: 1;
618
- }
619
- }
620
-
621
- & + & {
622
- border-top: 1px solid #f0f3f8;
623
- border-top-left-radius: 0;
624
- border-top-right-radius: 0;
625
- }
626
- }
627
-
628
- .oa-todo__mark {
629
- width: 3px;
630
- height: 30px;
631
- flex-shrink: 0;
632
- border-radius: 3px;
633
- background: #d8dfeb;
634
-
635
- &.is-danger {
636
- background: #d05248;
637
- }
638
-
639
- &.is-warning {
640
- background: #d59a3b;
641
- }
642
- }
643
-
644
- .oa-todo__main {
645
- display: flex;
646
- flex-direction: column;
647
- min-width: 0;
648
- flex: 1;
649
- }
650
-
651
- .oa-todo__title-row {
652
- display: flex;
653
- align-items: center;
654
- gap: 6px;
655
- min-width: 0;
656
-
657
- strong {
658
- overflow: hidden;
659
- color: var(--oa-ink);
660
- font-size: 13px;
661
- font-weight: 600;
662
- text-overflow: ellipsis;
663
- white-space: nowrap;
664
- }
665
- }
666
-
667
- .oa-todo__meta {
668
- display: flex;
669
- align-items: center;
670
- gap: 6px;
671
- margin-top: 3px;
672
- color: var(--oa-faint);
673
- font-size: 11px;
674
- overflow: hidden;
675
- white-space: nowrap;
676
-
677
- i {
678
- width: 2px;
679
- height: 2px;
680
- border-radius: 50%;
681
- background: #c5cedd;
682
- }
683
- }
684
-
685
- .oa-todo__amount {
686
- flex-shrink: 0;
687
- color: var(--oa-ink-strong);
688
- font-size: 13px;
689
- font-weight: 650;
690
- }
691
-
692
- .oa-todo__cta {
693
- display: inline-flex;
694
- align-items: center;
695
- gap: 2px;
696
- flex-shrink: 0;
697
- color: #9aa6b8;
698
- font-size: 11px;
699
- font-weight: 600;
700
- opacity: 0.8;
701
- transition: color 0.15s ease, opacity 0.15s ease;
702
- }
703
-
704
- .oa-mine-list {
705
- padding: 0 8px 8px;
706
- }
707
-
708
- .oa-mine {
709
- display: flex;
710
- align-items: center;
711
- gap: 16px;
712
- width: 100%;
713
- padding: 12px 12px;
714
- border: none;
715
- border-radius: 8px;
716
- background: transparent;
717
- text-align: left;
718
- cursor: pointer;
719
-
720
- &:hover {
721
- background: #f8faff;
722
- }
723
-
724
- & + & {
725
- border-top: 1px solid #f0f3f8;
726
- }
727
- }
728
-
729
- .oa-mine__info {
730
- flex: 1;
731
- min-width: 0;
732
- }
733
-
734
- .oa-mine__title {
735
- display: flex;
736
- align-items: center;
737
- gap: 7px;
738
-
739
- strong {
740
- overflow: hidden;
741
- color: var(--oa-ink);
742
- font-size: 12.5px;
743
- font-weight: 600;
744
- text-overflow: ellipsis;
745
- white-space: nowrap;
746
- }
747
- }
748
-
749
- .oa-mine__meta {
750
- display: flex;
751
- align-items: center;
752
- gap: 6px;
753
- margin-top: 3px;
754
- color: var(--oa-faint);
755
- font-size: 11px;
756
- overflow: hidden;
757
- white-space: nowrap;
758
-
759
- i {
760
- width: 2px;
761
- height: 2px;
762
- border-radius: 50%;
763
- background: #c5cedd;
764
- }
765
- }
766
-
767
- .oa-mine__progress {
768
- display: block;
769
- max-width: 320px;
770
- margin-top: 8px;
771
- }
772
-
773
- .oa-mine__side {
774
- flex-shrink: 0;
775
- text-align: right;
776
-
777
- span {
778
- display: block;
779
- color: var(--oa-ink);
780
- font-size: 15px;
781
- font-weight: 650;
782
- }
783
-
784
- small {
785
- color: var(--oa-faint);
786
- font-size: 10px;
787
- }
788
- }
789
-
790
- .oa-quick-list {
791
- padding: 0 8px 8px;
792
- }
793
-
794
- .oa-quick {
795
- display: flex;
796
- align-items: center;
797
- gap: 10px;
798
- width: 100%;
799
- padding: 9px 10px;
800
- border: none;
801
- border-radius: 8px;
802
- background: transparent;
803
- text-align: left;
804
- cursor: pointer;
805
-
806
- &:hover {
807
- background: #f8faff;
808
-
809
- .oa-quick__plus {
810
- color: var(--oa-primary);
811
- opacity: 1;
812
- }
813
- }
814
- }
815
-
816
- .oa-quick__body {
817
- flex: 1;
818
- min-width: 0;
819
- display: flex;
820
- flex-direction: column;
821
-
822
- strong {
823
- color: var(--oa-ink);
824
- font-size: 12.5px;
825
- font-weight: 600;
826
- }
827
-
828
- small {
829
- overflow: hidden;
830
- color: var(--oa-faint);
831
- font-size: 10.5px;
832
- text-overflow: ellipsis;
833
- white-space: nowrap;
834
- }
835
- }
836
-
837
- .oa-quick__sla {
838
- flex-shrink: 0;
839
- color: var(--oa-faint);
840
- font-size: 10.5px;
841
- }
842
-
843
- .oa-quick__plus {
844
- flex-shrink: 0;
845
- color: #b3bdcd;
846
- font-size: 15px;
847
- opacity: 0.72;
848
- }
849
-
850
- .oa-activity {
851
- padding: 0 8px 8px;
852
- }
853
-
854
- .oa-activity__item {
855
- display: flex;
856
- align-items: flex-start;
857
- gap: 9px;
858
- width: 100%;
859
- padding: 8px 10px;
860
- border: none;
861
- border-radius: 7px;
862
- background: transparent;
863
- text-align: left;
864
- cursor: pointer;
865
-
866
- &:hover {
867
- background: #f8faff;
868
- }
869
-
870
- > time {
871
- flex-shrink: 0;
872
- padding-top: 1px;
873
- color: var(--oa-faint);
874
- font-size: 10px;
875
- }
876
- }
877
-
878
- .oa-activity__body {
879
- display: flex;
880
- flex-direction: column;
881
- flex: 1;
882
- min-width: 0;
883
-
884
- strong {
885
- overflow: hidden;
886
- color: var(--oa-ink);
887
- font-size: 11.5px;
888
- font-weight: 600;
889
- text-overflow: ellipsis;
890
- white-space: nowrap;
891
- }
892
-
893
- small {
894
- display: -webkit-box;
895
- overflow: hidden;
896
- margin-top: 1px;
897
- color: var(--oa-faint);
898
- font-size: 10.5px;
899
- line-height: 1.5;
900
- -webkit-box-orient: vertical;
901
- -webkit-line-clamp: 2;
902
- }
903
- }
904
-
905
- .oa-activity__item.is-unread .oa-activity__body strong::after {
906
- content: '';
907
- display: inline-block;
908
- width: 5px;
909
- height: 5px;
910
- margin-left: 5px;
911
- border-radius: 50%;
912
- background: var(--oa-primary);
913
- vertical-align: 2px;
914
- }
915
-
916
- .oa-home__note {
917
- display: flex;
918
- gap: 10px;
919
- padding: 4px 6px;
920
- color: var(--oa-faint);
921
-
922
- > .el-icon {
923
- margin-top: 2px;
924
- color: #89a39a;
925
- }
926
-
927
- strong {
928
- display: block;
929
- color: var(--oa-muted);
930
- font-size: 11.5px;
931
- font-weight: 600;
932
- }
933
-
934
- p {
935
- margin: 2px 0 0;
936
- font-size: 10.5px;
937
- line-height: 1.7;
938
- }
939
- }
940
-
941
- .oa-empty--sm {
942
- padding: 26px 18px;
943
- }
944
-
945
- @media (max-width: 1200px) {
946
- .oa-home__stats {
947
- grid-template-columns: repeat(2, minmax(0, 1fr));
948
- }
949
-
950
- .oa-home__grid {
951
- grid-template-columns: minmax(0, 1fr) 320px;
952
- }
953
- }
954
-
955
- @media (max-width: 960px) {
956
- .oa-home__hero-actions {
957
- width: 100%;
958
- padding-top: 0;
959
- }
960
-
961
- .oa-home__stats {
962
- grid-template-columns: repeat(2, minmax(0, 1fr));
963
- gap: 8px;
964
- }
965
-
966
- .oa-stat {
967
- padding: 13px;
968
- }
969
-
970
- .oa-stat__body strong {
971
- font-size: 22px;
972
- }
973
-
974
- .oa-home__grid {
975
- grid-template-columns: minmax(0, 1fr);
976
- }
977
-
978
- .oa-home__side {
979
- gap: 12px;
980
- }
981
-
982
- .oa-todo__amount,
983
- .oa-todo__cta {
984
- display: none;
985
- }
986
-
987
- .oa-home__alert em {
988
- display: none;
989
- }
990
- }
991
-
992
- @media (max-width: 560px) {
993
- .oa-home__stats {
994
- gap: 8px;
995
- }
996
-
997
- .oa-stat {
998
- gap: 9px;
999
- padding: 12px;
1000
-
1001
- &__icon {
1002
- width: 30px;
1003
- height: 30px;
1004
- font-size: 14px;
1005
- }
1006
-
1007
- &__body {
1008
- strong {
1009
- font-size: 20px;
1010
- }
1011
-
1012
- em {
1013
- max-width: 118px;
1014
- }
1015
- }
1016
- }
1017
-
1018
- .oa-todo-card .oa-section-head,
1019
- .oa-mine-card .oa-section-head {
1020
- flex-wrap: wrap;
1021
- gap: 6px;
1022
- }
1023
-
1024
- .oa-todo-card .oa-section-head__title,
1025
- .oa-mine-card .oa-section-head__title {
1026
- width: 100%;
1027
- }
1028
-
1029
- .oa-todo-card .oa-section-head__title small {
1030
- display: none;
1031
- }
1032
-
1033
- .oa-todo-card__tools {
1034
- width: 100%;
1035
- justify-content: space-between;
1036
- }
1037
-
1038
- .oa-todo__title-row {
1039
- flex-wrap: wrap;
1040
- }
1041
-
1042
- .oa-mine__side {
1043
- display: none;
1044
- }
1045
-
1046
- .oa-home__hero-actions .el-button {
1047
- flex: 1;
1048
- }
1049
- }
1050
- </style>
1
+ <template>
2
+ <div class="oa-page oa-home">
3
+ <header class="oa-home__hero">
4
+ <div>
5
+ <p class="oa-eyebrow">
6
+ {{ dateLabel }}
7
+ <span class="oa-home__role">{{ oa.currentUserRoleNames.value.join(' / ') || '成员' }}</span>
8
+ </p>
9
+ <h1 class="oa-title">{{ greeting }},{{ oa.currentUserName.value }}</h1>
10
+ <p class="oa-subtitle">
11
+ {{ oa.currentUserDept.value }}
12
+ <template v-if="oa.approveItems.value.length">
13
+ · 有 <strong>{{ oa.approveItems.value.length }}</strong> 项审批待你处理
14
+ </template>
15
+ </p>
16
+ </div>
17
+ <div class="oa-home__hero-actions">
18
+ <el-button :icon="Plus" type="primary" @click="oa.navigate('templates')">发起申请</el-button>
19
+ <el-button :icon="Tickets" @click="oa.navigate('tasks')">进入待办中心</el-button>
20
+ </div>
21
+ </header>
22
+
23
+ <button
24
+ v-if="overdueItem"
25
+ type="button"
26
+ class="oa-home__alert"
27
+ @click="oa.openTask(overdueItem)"
28
+ >
29
+ <el-icon><WarningFilled /></el-icon>
30
+ <span>
31
+ <strong>「{{ overdueItem.title }}」已超时</strong>
32
+ 当前节点「{{ overdueItem.nodeName }}」已等待 {{ formatElapsed(overdueItem.arrivedAt, oa.now.value) }},请优先处理
33
+ </span>
34
+ <em>立即处理<el-icon><ArrowRight /></el-icon></em>
35
+ </button>
36
+
37
+ <section class="oa-home__stats">
38
+ <button type="button" class="oa-stat" @click="oa.navigate('tasks')">
39
+ <span class="oa-stat__icon is-blue"><el-icon><Tickets /></el-icon></span>
40
+ <span class="oa-stat__body">
41
+ <small>待我审批</small>
42
+ <strong class="oa-num">{{ oa.approveItems.value.length }}</strong>
43
+ <em v-if="overdueCount">其中 {{ overdueCount }} 项超时</em>
44
+ <em v-else>全部在 SLA 内</em>
45
+ </span>
46
+ </button>
47
+ <button type="button" class="oa-stat" @click="oa.navigate('tasks', { taskTab: 'submit' })">
48
+ <span class="oa-stat__icon is-amber"><el-icon><EditPen /></el-icon></span>
49
+ <span class="oa-stat__body">
50
+ <small>待我提交</small>
51
+ <strong class="oa-num">{{ oa.submitItems.value.length }}</strong>
52
+ <em>{{ oa.submitItems.value.length ? '退回修改后需重新提交' : '暂无退回申请' }}</em>
53
+ </span>
54
+ </button>
55
+ <button type="button" class="oa-stat" @click="oa.navigate('requests', { scope: 'mine' })">
56
+ <span class="oa-stat__icon is-green"><el-icon><Document /></el-icon></span>
57
+ <span class="oa-stat__body">
58
+ <small>我发起的</small>
59
+ <strong class="oa-num">{{ oa.myInstances.value.length }}</strong>
60
+ <em>{{ runningMine.length }} 个正在审批</em>
61
+ </span>
62
+ </button>
63
+ <button type="button" class="oa-stat" @click="oa.navigate('requests', { scope: 'cc' })">
64
+ <span class="oa-stat__icon is-violet"><el-icon><ChatDotRound /></el-icon></span>
65
+ <span class="oa-stat__body">
66
+ <small>抄送我的</small>
67
+ <strong class="oa-num">{{ oa.ccItems.value.length }}</strong>
68
+ <em>知会与归档事项</em>
69
+ </span>
70
+ </button>
71
+ </section>
72
+
73
+ <div class="oa-home__grid">
74
+ <div class="oa-home__main">
75
+ <section class="oa-card oa-todo-card">
76
+ <div class="oa-section-head">
77
+ <h2 class="oa-section-head__title">
78
+ 待我处理
79
+ <small>{{ activeTodoTab === 'approve' ? '按超时与优先级排序' : '退回修改后需重新提交' }}</small>
80
+ </h2>
81
+ <div class="oa-todo-card__tools">
82
+ <div class="oa-segment">
83
+ <button
84
+ type="button"
85
+ :class="{ 'is-active': activeTodoTab === 'approve' }"
86
+ @click="activeTodoTab = 'approve'"
87
+ >
88
+ 审批 {{ oa.approveItems.value.length }}
89
+ </button>
90
+ <button
91
+ type="button"
92
+ :class="{ 'is-active': activeTodoTab === 'submit' }"
93
+ @click="activeTodoTab = 'submit'"
94
+ >
95
+ 提交 {{ oa.submitItems.value.length }}
96
+ </button>
97
+ </div>
98
+ <el-button link type="primary" @click="oa.navigate('tasks')">
99
+ 全部<el-icon class="el-icon--right"><ArrowRight /></el-icon>
100
+ </el-button>
101
+ </div>
102
+ </div>
103
+
104
+ <div v-if="visibleTodos.length" class="oa-todo-list">
105
+ <button
106
+ v-for="item in visibleTodos"
107
+ :key="item.id"
108
+ type="button"
109
+ class="oa-todo"
110
+ @click="oa.openTask(item)"
111
+ >
112
+ <span class="oa-todo__mark" :class="`is-${item.priorityMeta.tone}`"></span>
113
+ <span class="oa-todo__main">
114
+ <span class="oa-todo__title-row">
115
+ <strong>{{ item.title }}</strong>
116
+ <span class="oa-chip" :class="item.kind === 'submit' ? 'oa-chip--warning' : ''">
117
+ {{ item.kind === 'submit' ? '待重新提交' : item.nodeName }}
118
+ </span>
119
+ <span v-if="item.overdue" class="oa-chip oa-chip--danger">已超时</span>
120
+ <span v-else-if="item.priority !== 'normal'" class="oa-chip" :class="`oa-chip--${item.priorityMeta.tone}`">
121
+ {{ item.priorityMeta.label }}
122
+ </span>
123
+ </span>
124
+ <span class="oa-todo__meta">
125
+ {{ item.initiatorName }} · {{ item.initiatorDept }}
126
+ <i></i>
127
+ {{ item.code }}
128
+ <i></i>
129
+ {{ formatRelativeTime(item.arrivedAt, oa.now.value) }}到达
130
+ </span>
131
+ </span>
132
+ <span v-if="item.amount" class="oa-todo__amount oa-num">{{ formatMoney(item.amount) }}</span>
133
+ <span class="oa-todo__cta">去处理<el-icon><ArrowRight /></el-icon></span>
134
+ </button>
135
+ </div>
136
+ <div v-else class="oa-empty">
137
+ <span class="oa-empty__icon"><el-icon><CircleCheck /></el-icon></span>
138
+ <strong>当前没有需要处理的事项</strong>
139
+ <p>新的待办到达后会出现在这里,也会通过通知中心提醒你。</p>
140
+ </div>
141
+ </section>
142
+
143
+ <section class="oa-card oa-mine-card">
144
+ <div class="oa-section-head">
145
+ <h2 class="oa-section-head__title">
146
+ 我发起的流程
147
+ <small>进行中 {{ runningMine.length }} 个</small>
148
+ </h2>
149
+ <el-button link type="primary" @click="oa.navigate('requests', { scope: 'mine' })">
150
+ 全部申请<el-icon class="el-icon--right"><ArrowRight /></el-icon>
151
+ </el-button>
152
+ </div>
153
+
154
+ <div v-if="recentMine.length" class="oa-mine-list">
155
+ <button
156
+ v-for="instance in recentMine"
157
+ :key="instance.id"
158
+ type="button"
159
+ class="oa-mine"
160
+ @click="oa.openInstanceDetail(instance.id)"
161
+ >
162
+ <span class="oa-mine__info">
163
+ <span class="oa-mine__title">
164
+ <strong>{{ instanceTitle(instance) }}</strong>
165
+ <span class="oa-status" :class="`oa-status--${statusMeta(instance.state.status).tone}`">
166
+ {{ statusMeta(instance.state.status).label }}
167
+ </span>
168
+ </span>
169
+ <span class="oa-mine__meta">
170
+ {{ instance.code || instanceCode(instance) }}
171
+ <i></i>
172
+ {{ progressText(instance) }}
173
+ <i></i>
174
+ {{ formatRelativeTime(instance.updatedAt, oa.now.value) }}更新
175
+ </span>
176
+ <span class="oa-progress oa-mine__progress">
177
+ <span :style="{ width: `${progressOf(instance)}%` }"></span>
178
+ </span>
179
+ </span>
180
+ <span class="oa-mine__side">
181
+ <span class="oa-num">{{ progressOf(instance) }}%</span>
182
+ <small>流程进度</small>
183
+ </span>
184
+ </button>
185
+ </div>
186
+ <div v-else class="oa-empty">
187
+ <span class="oa-empty__icon"><el-icon><Document /></el-icon></span>
188
+ <strong>还没有发起过流程</strong>
189
+ <p>从模板中心选择常用流程,填写申请后即可发起。</p>
190
+ <el-button type="primary" plain size="small" @click="oa.navigate('templates')">去模板中心</el-button>
191
+ </div>
192
+ </section>
193
+ </div>
194
+
195
+ <aside class="oa-home__side">
196
+ <section class="oa-card oa-quick-card">
197
+ <div class="oa-section-head">
198
+ <h2 class="oa-section-head__title">常用流程</h2>
199
+ <el-button link type="primary" @click="oa.navigate('templates')">全部</el-button>
200
+ </div>
201
+ <div class="oa-quick-list">
202
+ <button
203
+ v-for="template in quickTemplates"
204
+ :key="template.id"
205
+ type="button"
206
+ class="oa-quick"
207
+ @click="oa.openStartDialog(template.id)"
208
+ >
209
+ <CategoryIcon :category="template.business.category" :size="32" />
210
+ <span class="oa-quick__body">
211
+ <strong>{{ template.name }}</strong>
212
+ <small>{{ template.business.scenario }}</small>
213
+ </span>
214
+ <span class="oa-quick__sla">{{ template.slaLabel }}</span>
215
+ <el-icon class="oa-quick__plus"><CirclePlus /></el-icon>
216
+ </button>
217
+ <div v-if="!quickTemplates.length" class="oa-empty oa-empty--sm">
218
+ <strong>暂无可用模板</strong>
219
+ <p>请先在流程设计中发布流程。</p>
220
+ </div>
221
+ </div>
222
+ </section>
223
+
224
+ <section class="oa-card oa-activity-card">
225
+ <div class="oa-section-head">
226
+ <h2 class="oa-section-head__title">
227
+ 流程动态
228
+ <small v-if="oa.unreadNotifications.value.length">{{ oa.unreadNotifications.value.length }} 条未读</small>
229
+ </h2>
230
+ <el-button link type="primary" @click="oa.navigate('notifications')">全部</el-button>
231
+ </div>
232
+ <div v-if="recentNotifications.length" class="oa-activity">
233
+ <button
234
+ v-for="notification in recentNotifications"
235
+ :key="notification.id"
236
+ type="button"
237
+ class="oa-activity__item"
238
+ :class="{ 'is-unread': !notification.read }"
239
+ @click="openNotification(notification)"
240
+ >
241
+ <NotificationIcon :type="notification.type" :size="22" />
242
+ <span class="oa-activity__body">
243
+ <strong>{{ notification.title }}</strong>
244
+ <small>{{ notification.description }}</small>
245
+ </span>
246
+ <time>{{ formatRelativeTime(notification.at, oa.now.value) }}</time>
247
+ </button>
248
+ </div>
249
+ <div v-else class="oa-empty oa-empty--sm">
250
+ <span class="oa-empty__icon"><el-icon><Bell /></el-icon></span>
251
+ <strong>暂无新动态</strong>
252
+ <p>待办、抄送和流程结果会汇总在这里。</p>
253
+ </div>
254
+ </section>
255
+
256
+ <section class="oa-home__note">
257
+ <el-icon><CircleCheck /></el-icon>
258
+ <div>
259
+ <strong>数据自动保存</strong>
260
+ <p>演示数据保存在本机浏览器;所有审批动作都会写入流程轨迹与审计日志。</p>
261
+ </div>
262
+ </section>
263
+ </aside>
264
+ </div>
265
+ </div>
266
+ </template>
267
+
268
+ <script setup>
269
+ import { computed, inject, ref } from 'vue'
270
+ import {
271
+ ArrowRight,
272
+ Bell,
273
+ ChatDotRound,
274
+ CircleCheck,
275
+ CirclePlus,
276
+ Document,
277
+ EditPen,
278
+ Plus,
279
+ Tickets,
280
+ WarningFilled
281
+ } from 'gbicons'
282
+ import CategoryIcon from '../components/CategoryIcon.vue'
283
+ import NotificationIcon from '../components/NotificationIcon.vue'
284
+ import {
285
+ buildTemplateCards,
286
+ formatElapsed,
287
+ formatMoney,
288
+ formatRelativeTime,
289
+ instanceCode,
290
+ instanceTitle,
291
+ statusMeta
292
+ } from '../model.js'
293
+
294
+ defineOptions({ name: 'OaHomePage' })
295
+
296
+ const oa = inject('oaStore')
297
+ const activeTodoTab = ref('approve')
298
+
299
+ const nowDate = computed(() => new Date(oa.now.value))
300
+ const dateLabel = computed(() =>
301
+ nowDate.value.toLocaleDateString('zh-CN', {
302
+ year: 'numeric',
303
+ month: 'long',
304
+ day: 'numeric',
305
+ weekday: 'long'
306
+ })
307
+ )
308
+ const greeting = computed(() => {
309
+ const hour = nowDate.value.getHours()
310
+ if (hour < 6) return '夜深了'
311
+ if (hour < 12) return '早上好'
312
+ if (hour < 14) return '中午好'
313
+ if (hour < 18) return '下午好'
314
+ return '晚上好'
315
+ })
316
+
317
+ const overdueItem = computed(() => oa.approveItems.value.find((item) => item.overdue) || null)
318
+ const overdueCount = computed(
319
+ () => oa.approveItems.value.filter((item) => item.overdue).length
320
+ )
321
+ const visibleTodos = computed(() =>
322
+ (activeTodoTab.value === 'approve' ? oa.approveItems.value : oa.submitItems.value).slice(0, 5)
323
+ )
324
+ const runningMine = computed(
325
+ () => oa.myInstances.value.filter((instance) => instance.state?.status === 'running')
326
+ )
327
+ const recentMine = computed(() =>
328
+ [...oa.myInstances.value]
329
+ .sort((left, right) => String(right.updatedAt).localeCompare(String(left.updatedAt)))
330
+ .slice(0, 4)
331
+ )
332
+ const quickTemplates = computed(() =>
333
+ buildTemplateCards(oa.publishedDefinitions.value).slice(0, 4)
334
+ )
335
+ const recentNotifications = computed(() => oa.notifications.value.slice(0, 5))
336
+
337
+ function progressText(instance) {
338
+ const task = (instance.state?.tasks || []).find((item) => item.status === 'pending')
339
+ if (task) return `当前节点:${task.nodeName}`
340
+ return `状态:${statusMeta(instance.state?.status).label}`
341
+ }
342
+
343
+ function progressOf(instance) {
344
+ const tasks = instance.state?.tasks || []
345
+ if (!tasks.length) return 0
346
+ const completed = tasks.filter((task) =>
347
+ ['approved', 'completed', 'rejected', 'failed', 'cancelled'].includes(task.status)
348
+ ).length
349
+ if (['completed', 'rejected', 'revoked', 'cancelled'].includes(instance.state?.status)) {
350
+ return 100
351
+ }
352
+ return Math.max(6, Math.round((completed / tasks.length) * 100))
353
+ }
354
+
355
+ function openNotification(notification) {
356
+ oa.markNotificationRead(notification.id)
357
+ if (notification.action === 'task' && notification.task) {
358
+ oa.navigate('tasks', {
359
+ instanceId: notification.instance.id,
360
+ taskId: notification.task.id
361
+ })
362
+ return
363
+ }
364
+ oa.openInstanceDetail(notification.instance.id)
365
+ }
366
+ </script>
367
+
368
+ <style scoped lang="scss">
369
+ .oa-home {
370
+ max-width: 1500px;
371
+ margin: 0 auto;
372
+ width: 100%;
373
+ }
374
+
375
+ .oa-home__hero {
376
+ display: flex;
377
+ align-items: flex-start;
378
+ justify-content: space-between;
379
+ gap: 20px;
380
+ flex-wrap: wrap;
381
+ padding: 2px 0 4px;
382
+
383
+ .oa-subtitle strong {
384
+ color: var(--oa-primary);
385
+ font-weight: 650;
386
+ }
387
+ }
388
+
389
+ .oa-home__role {
390
+ padding: 1px 7px;
391
+ border-radius: 4px;
392
+ background: var(--oa-primary-soft);
393
+ color: var(--oa-primary);
394
+ font-size: 10px;
395
+ font-weight: 600;
396
+ letter-spacing: 0;
397
+ text-transform: none;
398
+ }
399
+
400
+ .oa-home__hero-actions {
401
+ display: flex;
402
+ gap: 8px;
403
+ padding-top: 18px;
404
+ }
405
+
406
+ .oa-home__alert {
407
+ display: flex;
408
+ align-items: center;
409
+ gap: 12px;
410
+ width: 100%;
411
+ padding: 12px 16px;
412
+ border: 1px solid #f1d7b1;
413
+ border-radius: var(--oa-radius);
414
+ background: linear-gradient(90deg, #fff8eb, #fffdf9);
415
+ color: #7e5310;
416
+ text-align: left;
417
+ cursor: pointer;
418
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
419
+
420
+ &:hover {
421
+ border-color: #e6bf87;
422
+ box-shadow: 0 4px 14px rgba(170, 106, 18, 0.08);
423
+ }
424
+
425
+ > .el-icon {
426
+ flex-shrink: 0;
427
+ color: #c07b1b;
428
+ font-size: 17px;
429
+ }
430
+
431
+ span {
432
+ flex: 1;
433
+ min-width: 0;
434
+ font-size: 12px;
435
+ line-height: 1.6;
436
+ }
437
+
438
+ strong {
439
+ margin-right: 6px;
440
+ color: #8d5b11;
441
+ font-weight: 650;
442
+ }
443
+
444
+ em {
445
+ display: inline-flex;
446
+ align-items: center;
447
+ gap: 3px;
448
+ flex-shrink: 0;
449
+ color: #a46712;
450
+ font-size: 12px;
451
+ font-style: normal;
452
+ font-weight: 600;
453
+ }
454
+ }
455
+
456
+ .oa-home__stats {
457
+ display: grid;
458
+ grid-template-columns: repeat(4, minmax(0, 1fr));
459
+ gap: 12px;
460
+ }
461
+
462
+ .oa-stat {
463
+ display: flex;
464
+ align-items: flex-start;
465
+ gap: 12px;
466
+ padding: 16px;
467
+ border: 1px solid var(--oa-line);
468
+ border-radius: var(--oa-radius);
469
+ background: var(--oa-surface);
470
+ box-shadow: var(--oa-shadow);
471
+ text-align: left;
472
+ cursor: pointer;
473
+ transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
474
+
475
+ &:hover {
476
+ border-color: #c9d7f4;
477
+ box-shadow: 0 8px 24px rgba(15, 31, 55, 0.07);
478
+ transform: translateY(-1px);
479
+ }
480
+ }
481
+
482
+ .oa-stat__icon {
483
+ display: grid;
484
+ place-items: center;
485
+ width: 36px;
486
+ height: 36px;
487
+ flex-shrink: 0;
488
+ border-radius: 9px;
489
+ font-size: 16px;
490
+
491
+ &.is-blue {
492
+ background: #edf2ff;
493
+ color: #2456d6;
494
+ }
495
+
496
+ &.is-amber {
497
+ background: #fff4e2;
498
+ color: #a86a16;
499
+ }
500
+
501
+ &.is-green {
502
+ background: #e9f7f0;
503
+ color: #0d8057;
504
+ }
505
+
506
+ &.is-violet {
507
+ background: #f0edfb;
508
+ color: #5c4bb0;
509
+ }
510
+ }
511
+
512
+ .oa-stat__body {
513
+ display: flex;
514
+ flex-direction: column;
515
+ min-width: 0;
516
+
517
+ small {
518
+ color: var(--oa-muted);
519
+ font-size: 12px;
520
+ }
521
+
522
+ strong {
523
+ margin-top: 1px;
524
+ color: var(--oa-ink-strong);
525
+ font-size: 26px;
526
+ font-weight: 650;
527
+ letter-spacing: -0.03em;
528
+ line-height: 1.25;
529
+ }
530
+
531
+ em {
532
+ margin-top: 2px;
533
+ color: var(--oa-faint);
534
+ font-size: 10.5px;
535
+ font-style: normal;
536
+ overflow: hidden;
537
+ text-overflow: ellipsis;
538
+ white-space: nowrap;
539
+ }
540
+ }
541
+
542
+ .oa-home__grid {
543
+ display: grid;
544
+ grid-template-columns: minmax(0, 1fr) 360px;
545
+ gap: 16px;
546
+ align-items: start;
547
+ }
548
+
549
+ .oa-home__main,
550
+ .oa-home__side {
551
+ display: flex;
552
+ flex-direction: column;
553
+ gap: 16px;
554
+ min-width: 0;
555
+ }
556
+
557
+ .oa-todo-card__tools {
558
+ display: flex;
559
+ align-items: center;
560
+ gap: 10px;
561
+ }
562
+
563
+ .oa-segment {
564
+ display: inline-flex;
565
+ gap: 2px;
566
+ padding: 2px;
567
+ border-radius: 7px;
568
+ background: #f1f4f9;
569
+
570
+ button {
571
+ padding: 3px 10px;
572
+ border: none;
573
+ border-radius: 5px;
574
+ background: transparent;
575
+ color: var(--oa-muted);
576
+ font-size: 11.5px;
577
+ cursor: pointer;
578
+ transition: background 0.15s ease, color 0.15s ease;
579
+
580
+ &:hover {
581
+ color: var(--oa-ink);
582
+ }
583
+
584
+ &.is-active {
585
+ background: #fff;
586
+ color: var(--oa-ink);
587
+ font-weight: 600;
588
+ box-shadow: 0 1px 3px rgba(15, 31, 55, 0.08);
589
+ }
590
+ }
591
+ }
592
+
593
+ .oa-todo-list {
594
+ padding: 0 8px 8px;
595
+ }
596
+
597
+ .oa-todo {
598
+ position: relative;
599
+ display: flex;
600
+ align-items: center;
601
+ gap: 12px;
602
+ width: 100%;
603
+ padding: 12px 12px 12px 14px;
604
+ border: 1px solid transparent;
605
+ border-radius: 8px;
606
+ background: transparent;
607
+ text-align: left;
608
+ cursor: pointer;
609
+ transition: background 0.15s ease, border-color 0.15s ease;
610
+
611
+ &:hover {
612
+ border-color: #e2e9f5;
613
+ background: #f8faff;
614
+
615
+ .oa-todo__cta {
616
+ color: var(--oa-primary);
617
+ opacity: 1;
618
+ }
619
+ }
620
+
621
+ & + & {
622
+ border-top: 1px solid #f0f3f8;
623
+ border-top-left-radius: 0;
624
+ border-top-right-radius: 0;
625
+ }
626
+ }
627
+
628
+ .oa-todo__mark {
629
+ width: 3px;
630
+ height: 30px;
631
+ flex-shrink: 0;
632
+ border-radius: 3px;
633
+ background: #d8dfeb;
634
+
635
+ &.is-danger {
636
+ background: #d05248;
637
+ }
638
+
639
+ &.is-warning {
640
+ background: #d59a3b;
641
+ }
642
+ }
643
+
644
+ .oa-todo__main {
645
+ display: flex;
646
+ flex-direction: column;
647
+ min-width: 0;
648
+ flex: 1;
649
+ }
650
+
651
+ .oa-todo__title-row {
652
+ display: flex;
653
+ align-items: center;
654
+ gap: 6px;
655
+ min-width: 0;
656
+
657
+ strong {
658
+ overflow: hidden;
659
+ color: var(--oa-ink);
660
+ font-size: 13px;
661
+ font-weight: 600;
662
+ text-overflow: ellipsis;
663
+ white-space: nowrap;
664
+ }
665
+ }
666
+
667
+ .oa-todo__meta {
668
+ display: flex;
669
+ align-items: center;
670
+ gap: 6px;
671
+ margin-top: 3px;
672
+ color: var(--oa-faint);
673
+ font-size: 11px;
674
+ overflow: hidden;
675
+ white-space: nowrap;
676
+
677
+ i {
678
+ width: 2px;
679
+ height: 2px;
680
+ border-radius: 50%;
681
+ background: #c5cedd;
682
+ }
683
+ }
684
+
685
+ .oa-todo__amount {
686
+ flex-shrink: 0;
687
+ color: var(--oa-ink-strong);
688
+ font-size: 13px;
689
+ font-weight: 650;
690
+ }
691
+
692
+ .oa-todo__cta {
693
+ display: inline-flex;
694
+ align-items: center;
695
+ gap: 2px;
696
+ flex-shrink: 0;
697
+ color: #9aa6b8;
698
+ font-size: 11px;
699
+ font-weight: 600;
700
+ opacity: 0.8;
701
+ transition: color 0.15s ease, opacity 0.15s ease;
702
+ }
703
+
704
+ .oa-mine-list {
705
+ padding: 0 8px 8px;
706
+ }
707
+
708
+ .oa-mine {
709
+ display: flex;
710
+ align-items: center;
711
+ gap: 16px;
712
+ width: 100%;
713
+ padding: 12px 12px;
714
+ border: none;
715
+ border-radius: 8px;
716
+ background: transparent;
717
+ text-align: left;
718
+ cursor: pointer;
719
+
720
+ &:hover {
721
+ background: #f8faff;
722
+ }
723
+
724
+ & + & {
725
+ border-top: 1px solid #f0f3f8;
726
+ }
727
+ }
728
+
729
+ .oa-mine__info {
730
+ flex: 1;
731
+ min-width: 0;
732
+ }
733
+
734
+ .oa-mine__title {
735
+ display: flex;
736
+ align-items: center;
737
+ gap: 7px;
738
+
739
+ strong {
740
+ overflow: hidden;
741
+ color: var(--oa-ink);
742
+ font-size: 12.5px;
743
+ font-weight: 600;
744
+ text-overflow: ellipsis;
745
+ white-space: nowrap;
746
+ }
747
+ }
748
+
749
+ .oa-mine__meta {
750
+ display: flex;
751
+ align-items: center;
752
+ gap: 6px;
753
+ margin-top: 3px;
754
+ color: var(--oa-faint);
755
+ font-size: 11px;
756
+ overflow: hidden;
757
+ white-space: nowrap;
758
+
759
+ i {
760
+ width: 2px;
761
+ height: 2px;
762
+ border-radius: 50%;
763
+ background: #c5cedd;
764
+ }
765
+ }
766
+
767
+ .oa-mine__progress {
768
+ display: block;
769
+ max-width: 320px;
770
+ margin-top: 8px;
771
+ }
772
+
773
+ .oa-mine__side {
774
+ flex-shrink: 0;
775
+ text-align: right;
776
+
777
+ span {
778
+ display: block;
779
+ color: var(--oa-ink);
780
+ font-size: 15px;
781
+ font-weight: 650;
782
+ }
783
+
784
+ small {
785
+ color: var(--oa-faint);
786
+ font-size: 10px;
787
+ }
788
+ }
789
+
790
+ .oa-quick-list {
791
+ padding: 0 8px 8px;
792
+ }
793
+
794
+ .oa-quick {
795
+ display: flex;
796
+ align-items: center;
797
+ gap: 10px;
798
+ width: 100%;
799
+ padding: 9px 10px;
800
+ border: none;
801
+ border-radius: 8px;
802
+ background: transparent;
803
+ text-align: left;
804
+ cursor: pointer;
805
+
806
+ &:hover {
807
+ background: #f8faff;
808
+
809
+ .oa-quick__plus {
810
+ color: var(--oa-primary);
811
+ opacity: 1;
812
+ }
813
+ }
814
+ }
815
+
816
+ .oa-quick__body {
817
+ flex: 1;
818
+ min-width: 0;
819
+ display: flex;
820
+ flex-direction: column;
821
+
822
+ strong {
823
+ color: var(--oa-ink);
824
+ font-size: 12.5px;
825
+ font-weight: 600;
826
+ }
827
+
828
+ small {
829
+ overflow: hidden;
830
+ color: var(--oa-faint);
831
+ font-size: 10.5px;
832
+ text-overflow: ellipsis;
833
+ white-space: nowrap;
834
+ }
835
+ }
836
+
837
+ .oa-quick__sla {
838
+ flex-shrink: 0;
839
+ color: var(--oa-faint);
840
+ font-size: 10.5px;
841
+ }
842
+
843
+ .oa-quick__plus {
844
+ flex-shrink: 0;
845
+ color: #b3bdcd;
846
+ font-size: 15px;
847
+ opacity: 0.72;
848
+ }
849
+
850
+ .oa-activity {
851
+ padding: 0 8px 8px;
852
+ }
853
+
854
+ .oa-activity__item {
855
+ display: flex;
856
+ align-items: flex-start;
857
+ gap: 9px;
858
+ width: 100%;
859
+ padding: 8px 10px;
860
+ border: none;
861
+ border-radius: 7px;
862
+ background: transparent;
863
+ text-align: left;
864
+ cursor: pointer;
865
+
866
+ &:hover {
867
+ background: #f8faff;
868
+ }
869
+
870
+ > time {
871
+ flex-shrink: 0;
872
+ padding-top: 1px;
873
+ color: var(--oa-faint);
874
+ font-size: 10px;
875
+ }
876
+ }
877
+
878
+ .oa-activity__body {
879
+ display: flex;
880
+ flex-direction: column;
881
+ flex: 1;
882
+ min-width: 0;
883
+
884
+ strong {
885
+ overflow: hidden;
886
+ color: var(--oa-ink);
887
+ font-size: 11.5px;
888
+ font-weight: 600;
889
+ text-overflow: ellipsis;
890
+ white-space: nowrap;
891
+ }
892
+
893
+ small {
894
+ display: -webkit-box;
895
+ overflow: hidden;
896
+ margin-top: 1px;
897
+ color: var(--oa-faint);
898
+ font-size: 10.5px;
899
+ line-height: 1.5;
900
+ -webkit-box-orient: vertical;
901
+ -webkit-line-clamp: 2;
902
+ }
903
+ }
904
+
905
+ .oa-activity__item.is-unread .oa-activity__body strong::after {
906
+ content: '';
907
+ display: inline-block;
908
+ width: 5px;
909
+ height: 5px;
910
+ margin-left: 5px;
911
+ border-radius: 50%;
912
+ background: var(--oa-primary);
913
+ vertical-align: 2px;
914
+ }
915
+
916
+ .oa-home__note {
917
+ display: flex;
918
+ gap: 10px;
919
+ padding: 4px 6px;
920
+ color: var(--oa-faint);
921
+
922
+ > .el-icon {
923
+ margin-top: 2px;
924
+ color: #89a39a;
925
+ }
926
+
927
+ strong {
928
+ display: block;
929
+ color: var(--oa-muted);
930
+ font-size: 11.5px;
931
+ font-weight: 600;
932
+ }
933
+
934
+ p {
935
+ margin: 2px 0 0;
936
+ font-size: 10.5px;
937
+ line-height: 1.7;
938
+ }
939
+ }
940
+
941
+ .oa-empty--sm {
942
+ padding: 26px 18px;
943
+ }
944
+
945
+ @media (max-width: 1200px) {
946
+ .oa-home__stats {
947
+ grid-template-columns: repeat(2, minmax(0, 1fr));
948
+ }
949
+
950
+ .oa-home__grid {
951
+ grid-template-columns: minmax(0, 1fr) 320px;
952
+ }
953
+ }
954
+
955
+ @media (max-width: 960px) {
956
+ .oa-home__hero-actions {
957
+ width: 100%;
958
+ padding-top: 0;
959
+ }
960
+
961
+ .oa-home__stats {
962
+ grid-template-columns: repeat(2, minmax(0, 1fr));
963
+ gap: 8px;
964
+ }
965
+
966
+ .oa-stat {
967
+ padding: 13px;
968
+ }
969
+
970
+ .oa-stat__body strong {
971
+ font-size: 22px;
972
+ }
973
+
974
+ .oa-home__grid {
975
+ grid-template-columns: minmax(0, 1fr);
976
+ }
977
+
978
+ .oa-home__side {
979
+ gap: 12px;
980
+ }
981
+
982
+ .oa-todo__amount,
983
+ .oa-todo__cta {
984
+ display: none;
985
+ }
986
+
987
+ .oa-home__alert em {
988
+ display: none;
989
+ }
990
+ }
991
+
992
+ @media (max-width: 560px) {
993
+ .oa-home__stats {
994
+ gap: 8px;
995
+ }
996
+
997
+ .oa-stat {
998
+ gap: 9px;
999
+ padding: 12px;
1000
+
1001
+ &__icon {
1002
+ width: 30px;
1003
+ height: 30px;
1004
+ font-size: 14px;
1005
+ }
1006
+
1007
+ &__body {
1008
+ strong {
1009
+ font-size: 20px;
1010
+ }
1011
+
1012
+ em {
1013
+ max-width: 118px;
1014
+ }
1015
+ }
1016
+ }
1017
+
1018
+ .oa-todo-card .oa-section-head,
1019
+ .oa-mine-card .oa-section-head {
1020
+ flex-wrap: wrap;
1021
+ gap: 6px;
1022
+ }
1023
+
1024
+ .oa-todo-card .oa-section-head__title,
1025
+ .oa-mine-card .oa-section-head__title {
1026
+ width: 100%;
1027
+ }
1028
+
1029
+ .oa-todo-card .oa-section-head__title small {
1030
+ display: none;
1031
+ }
1032
+
1033
+ .oa-todo-card__tools {
1034
+ width: 100%;
1035
+ justify-content: space-between;
1036
+ }
1037
+
1038
+ .oa-todo__title-row {
1039
+ flex-wrap: wrap;
1040
+ }
1041
+
1042
+ .oa-mine__side {
1043
+ display: none;
1044
+ }
1045
+
1046
+ .oa-home__hero-actions .el-button {
1047
+ flex: 1;
1048
+ }
1049
+ }
1050
+ </style>