gbflowengine 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +270 -2
  3. package/dist/gbflowengine.css +1 -0
  4. package/dist/gbflowengine.js +19682 -0
  5. package/dist/gbflowengine.js.map +1 -0
  6. package/dist/gbflowengine.umd.cjs +5 -0
  7. package/dist/gbflowengine.umd.cjs.map +1 -0
  8. package/package.json +83 -4
  9. package/src/center/DefinitionInspect.vue +291 -0
  10. package/src/center/FlowCenter.vue +33 -0
  11. package/src/center/index.js +29 -0
  12. package/src/center/storage.js +748 -0
  13. package/src/core/flow/condition.js +160 -0
  14. package/src/core/flow/customNode.js +385 -0
  15. package/src/core/flow/defaults.js +124 -0
  16. package/src/core/flow/flowConstant.js +265 -0
  17. package/src/core/flow/flowNodeUtils.js +30 -0
  18. package/src/core/flow/index.js +47 -0
  19. package/src/core/flow/node.js +44 -0
  20. package/src/core/flow/nodeFactory.js +58 -0
  21. package/src/core/flow/prediction.js +325 -0
  22. package/src/core/flow/runtime/auto.js +83 -0
  23. package/src/core/flow/runtime/decide.js +329 -0
  24. package/src/core/flow/runtime/event.js +28 -0
  25. package/src/core/flow/runtime/execute.js +357 -0
  26. package/src/core/flow/runtime/helpers.js +52 -0
  27. package/src/core/flow/runtime/query.js +146 -0
  28. package/src/core/flow/runtime/reject.js +137 -0
  29. package/src/core/flow/runtime/token.js +269 -0
  30. package/src/core/flow/runtime.js +129 -0
  31. package/src/core/flow/schema.js +864 -0
  32. package/src/definition/FlowDefinitionDesigner.vue +338 -0
  33. package/src/definition/index.js +9 -0
  34. package/src/index.js +39 -0
  35. package/src/storage.js +200 -0
  36. package/src/testing/FlowTestPanel.vue +2502 -0
  37. package/src/testing/UserConfigDrawer.vue +376 -0
  38. package/src/testing/diagram/FlowProgressDiagram.vue +318 -0
  39. package/src/testing/diagramModel.js +517 -0
  40. package/src/testing/index.js +23 -0
  41. package/src/testing/mock.js +246 -0
  42. package/src/testing/oaExecutors.js +51 -0
  43. package/src/testing/oaSeed.js +467 -0
  44. package/src/testing/sample.js +412 -0
  45. package/src/testing/seed.js +122 -0
  46. package/src/utils/format.js +27 -0
  47. package/src/visual/FlowCanvas.vue +441 -0
  48. package/src/visual/NodeProgressDetail.vue +43 -0
  49. package/src/visual/NodeStatusBadge.vue +17 -0
  50. package/src/visual/NodeWrap.vue +47 -0
  51. package/src/visual/ScWorkflow.vue +50 -0
  52. package/src/visual/SelectDialog.vue +460 -0
  53. package/src/visual/conditionHelpers.js +117 -0
  54. package/src/visual/index.js +6 -0
  55. package/src/visual/nodes/AddNode.vue +223 -0
  56. package/src/visual/nodes/ApproverNode.vue +348 -0
  57. package/src/visual/nodes/BranchNode.vue +442 -0
  58. package/src/visual/nodes/CustomNode.vue +339 -0
  59. package/src/visual/nodes/EndNode.vue +22 -0
  60. package/src/visual/nodes/PassNode.vue +101 -0
  61. package/src/visual/nodes/PromoterNode.vue +135 -0
  62. package/src/visual/nodes/RejectNode.vue +101 -0
  63. package/src/visual/nodes/SendNode.vue +152 -0
  64. package/src/visual/styles.scss +879 -0
  65. package/src/visual/useScNodeStatus.js +18 -0
  66. package/src/workbench/OaWorkbench.vue +1341 -0
  67. package/src/workbench/components/ApprovalWorkspace.vue +2090 -0
  68. package/src/workbench/components/CategoryIcon.vue +74 -0
  69. package/src/workbench/components/NotificationIcon.vue +73 -0
  70. package/src/workbench/components/ProcessSteps.vue +557 -0
  71. package/src/workbench/components/ResubmitDialog.vue +227 -0
  72. package/src/workbench/components/SidebarNav.vue +138 -0
  73. package/src/workbench/components/StartFlowDialog.vue +1058 -0
  74. package/src/workbench/components/UserAvatar.vue +68 -0
  75. package/src/workbench/custom-tasks.js +130 -0
  76. package/src/workbench/model.js +1080 -0
  77. package/src/workbench/pages/DesignPage.vue +798 -0
  78. package/src/workbench/pages/HomePage.vue +1050 -0
  79. package/src/workbench/pages/MonitorPage.vue +1029 -0
  80. package/src/workbench/pages/NotificationsPage.vue +554 -0
  81. package/src/workbench/pages/RequestsPage.vue +644 -0
  82. package/src/workbench/pages/TaskCenterPage.vue +1155 -0
  83. package/src/workbench/pages/TemplatesPage.vue +680 -0
  84. package/src/workbench/persistence.js +89 -0
  85. package/src/workbench/shared.js +18 -0
  86. package/src/workbench/styles.scss +555 -0
  87. package/src/workbench/useWorkbench.js +955 -0
  88. package/types/center.d.ts +5 -0
  89. package/types/core.d.ts +479 -0
  90. package/types/definition.d.ts +4 -0
  91. package/types/index.d.ts +34 -0
  92. package/types/testing.d.ts +20 -0
  93. package/types/visual.d.ts +20 -0
@@ -0,0 +1,798 @@
1
+ <template>
2
+ <div class="oa-design">
3
+ <aside class="oa-design__side">
4
+ <div class="oa-design__side-head">
5
+ <div>
6
+ <p class="oa-eyebrow">流程建模</p>
7
+ <h2>流程设计</h2>
8
+ </div>
9
+ <el-button size="small" type="primary" :icon="Plus" @click="createDefinition">新建</el-button>
10
+ </div>
11
+
12
+ <el-input
13
+ v-model="search"
14
+ :prefix-icon="Search"
15
+ placeholder="搜索流程名称"
16
+ clearable
17
+ size="small"
18
+ />
19
+
20
+ <div class="oa-design__side-actions">
21
+ <el-button size="small" plain :icon="Upload" @click="triggerImport">导入 JSON</el-button>
22
+ <span>{{ filteredDefinitions.length }} 个流程</span>
23
+ </div>
24
+
25
+ <div class="oa-design__list">
26
+ <button
27
+ v-for="item in filteredDefinitions"
28
+ :key="item.meta.id"
29
+ type="button"
30
+ class="oa-design-item"
31
+ :class="{ 'is-active': activeId === item.meta.id }"
32
+ @click="openDefinition(item)"
33
+ >
34
+ <span class="oa-design-item__icon">
35
+ <el-icon><Document /></el-icon>
36
+ </span>
37
+ <span class="oa-design-item__main">
38
+ <span class="oa-design-item__title">
39
+ <strong>{{ item.meta.name || '未命名流程' }}</strong>
40
+ <span
41
+ class="oa-design-item__status"
42
+ :class="statusClass(item)"
43
+ >
44
+ {{ statusLabel(item) }}
45
+ </span>
46
+ </span>
47
+ <span class="oa-design-item__meta">
48
+ {{ nodeCount(item) }} 个节点 · {{ formatDateTime(item.meta.updatedAt, { short: true }) }}
49
+ </span>
50
+ <span v-if="activeId === item.meta.id && dirty" class="oa-design-item__dirty">有未保存的修改</span>
51
+ </span>
52
+ </button>
53
+ <div v-if="!filteredDefinitions.length" class="oa-empty oa-design__empty">
54
+ <strong>没有匹配的流程</strong>
55
+ <p>新建流程或导入 JSON 开始设计。</p>
56
+ </div>
57
+ </div>
58
+ </aside>
59
+
60
+ <main class="oa-design__main">
61
+ <template v-if="draft">
62
+ <header class="oa-design__toolbar">
63
+ <div class="oa-design__toolbar-title">
64
+ <div class="oa-design__name">
65
+ <h1>{{ draft.meta.name || '未命名流程' }}</h1>
66
+ <span class="oa-design-item__status" :class="statusClass(draft)">
67
+ {{ statusLabel(draft) }}
68
+ </span>
69
+ <span v-if="dirty" class="oa-chip oa-chip--warning">未保存</span>
70
+ </div>
71
+ <p>
72
+ {{ business.category }} · {{ formatSla(business.slaHours) }} · v{{ draft.meta.version || 0 }}
73
+ <span v-if="hasUnpublished(draft)" class="oa-chip oa-chip--warning">未发布修改</span>
74
+ </p>
75
+ </div>
76
+
77
+ <div class="oa-design__actions">
78
+ <el-button v-if="view === 'inspect'" :icon="EditPen" @click="view = 'design'">返回设计</el-button>
79
+ <template v-else>
80
+ <el-button :icon="DataAnalysis" @click="view = 'inspect'">流程检测</el-button>
81
+ <el-button :icon="Collection" @click="openBusinessDialog">上架信息</el-button>
82
+ <el-button :icon="Download" @click="exportDefinition">导出</el-button>
83
+ <el-button :icon="Check" :disabled="!dirty" @click="saveDraft(false)">保存</el-button>
84
+ <el-button type="primary" :icon="Promotion" @click="publishDraft">发布</el-button>
85
+ <el-dropdown v-if="revisionOptions.length" trigger="click" @command="rollback">
86
+ <el-button :icon="Timer">版本</el-button>
87
+ <template #dropdown>
88
+ <el-dropdown-menu>
89
+ <el-dropdown-item
90
+ v-for="revision in revisionOptions"
91
+ :key="revision.version"
92
+ :command="revision.version"
93
+ >
94
+ v{{ revision.version }} · {{ formatDateTime(revision.publishedAt) }}
95
+ </el-dropdown-item>
96
+ </el-dropdown-menu>
97
+ </template>
98
+ </el-dropdown>
99
+ <el-dropdown trigger="click" @command="handleMore">
100
+ <el-button :icon="MoreFilled" aria-label="更多操作" />
101
+ <template #dropdown>
102
+ <el-dropdown-menu>
103
+ <el-dropdown-item command="duplicate" :icon="CopyDocument">复制流程</el-dropdown-item>
104
+ <el-dropdown-item
105
+ v-if="draft.meta.status !== 'disabled'"
106
+ command="disable"
107
+ :icon="CircleClose"
108
+ >
109
+ 停用流程
110
+ </el-dropdown-item>
111
+ <el-dropdown-item command="delete" :icon="Delete" divided>删除流程</el-dropdown-item>
112
+ </el-dropdown-menu>
113
+ </template>
114
+ </el-dropdown>
115
+ </template>
116
+ </div>
117
+ </header>
118
+
119
+ <div class="oa-design__editor">
120
+ <FlowDefinitionDesigner
121
+ v-if="view === 'design'"
122
+ :key="`${draft.meta.id}_${designerKey}`"
123
+ v-model="draft"
124
+ :file-name="draft.meta.id"
125
+ :meta="draft.meta"
126
+ />
127
+ <DefinitionInspect v-else :definition="draft" @start-flow="startDraftFlow" />
128
+ </div>
129
+ </template>
130
+
131
+ <div v-else class="oa-design__no-selection">
132
+ <div class="oa-empty">
133
+ <span class="oa-empty__icon"><el-icon><EditPen /></el-icon></span>
134
+ <strong>选择一个流程开始设计</strong>
135
+ <p>设计器包含基本信息、表单设计与流程设计三个页签,发布后模板中心即可发起。</p>
136
+ <el-button type="primary" :icon="Plus" @click="createDefinition">新建流程</el-button>
137
+ </div>
138
+ </div>
139
+ </main>
140
+
141
+ <input
142
+ ref="fileInput"
143
+ type="file"
144
+ accept="application/json,.json"
145
+ class="oa-hidden-input"
146
+ @change="handleImportFile"
147
+ />
148
+
149
+ <el-dialog
150
+ v-model="businessVisible"
151
+ title="模板上架信息"
152
+ width="min(620px, 94vw)"
153
+ append-to-body
154
+ class="oa-business-dialog"
155
+ >
156
+ <p class="oa-business-dialog__hint">
157
+ 模板中心展示的分类、适用场景、预计时长与材料要求,会随流程发布版本冻结。
158
+ </p>
159
+ <el-form label-position="top">
160
+ <div class="oa-business-dialog__grid">
161
+ <el-form-item label="业务分类">
162
+ <el-select v-model="businessForm.category" style="width: 100%">
163
+ <el-option v-for="category in categories" :key="category" :label="category" :value="category" />
164
+ </el-select>
165
+ </el-form-item>
166
+ <el-form-item label="单号前缀">
167
+ <el-input v-model="businessForm.codePrefix" maxlength="4" placeholder="如 CG" />
168
+ </el-form-item>
169
+ <el-form-item label="预计耗时(小时)">
170
+ <el-input-number v-model="businessForm.slaHours" :min="1" :max="720" style="width: 100%" />
171
+ </el-form-item>
172
+ <el-form-item label="归口部门">
173
+ <el-input v-model="businessForm.owner" placeholder="如 采购管理部" />
174
+ </el-form-item>
175
+ </div>
176
+ <el-form-item label="适用场景">
177
+ <el-input v-model="businessForm.scenario" type="textarea" :rows="2" maxlength="120" show-word-limit />
178
+ </el-form-item>
179
+ <el-form-item label="所需材料">
180
+ <el-select
181
+ v-model="businessForm.materials"
182
+ multiple
183
+ filterable
184
+ allow-create
185
+ default-first-option
186
+ placeholder="输入材料名称后回车"
187
+ style="width: 100%"
188
+ />
189
+ </el-form-item>
190
+ </el-form>
191
+ <template #footer>
192
+ <el-button @click="businessVisible = false">取消</el-button>
193
+ <el-button type="primary" @click="applyBusiness">保存并更新草稿</el-button>
194
+ </template>
195
+ </el-dialog>
196
+ </div>
197
+ </template>
198
+
199
+ <script setup>
200
+ import { computed, inject, reactive, ref, watch } from 'vue'
201
+ import { ElMessage, ElMessageBox } from 'element-plus'
202
+ import {
203
+ Check,
204
+ CircleClose,
205
+ Collection,
206
+ CopyDocument,
207
+ DataAnalysis,
208
+ Delete,
209
+ Document,
210
+ Download,
211
+ EditPen,
212
+ MoreFilled,
213
+ Plus,
214
+ Promotion,
215
+ Search,
216
+ Timer,
217
+ Upload
218
+ } from 'gbicons'
219
+ import FlowDefinitionDesigner from '../../definition/FlowDefinitionDesigner.vue'
220
+ import DefinitionInspect from '../../center/DefinitionInspect.vue'
221
+ import { downloadJSON, getAllNodes, validateDefinition } from '../../core/flow/index.js'
222
+ import { formatDateTime } from '../../utils/format.js'
223
+ import { formatSla, resolveBusiness } from '../model.js'
224
+ import {
225
+ hasUnpublishedChanges,
226
+ isDefinitionRunnable
227
+ } from '../../center/storage.js'
228
+
229
+ defineOptions({ name: 'OaDesignPage' })
230
+
231
+ const oa = inject('oaStore')
232
+
233
+ const search = ref('')
234
+ const activeId = ref(null)
235
+ const draft = ref(null)
236
+ const view = ref('design')
237
+ const designerKey = ref(0)
238
+ const fileInput = ref(null)
239
+ const businessVisible = ref(false)
240
+ const businessForm = reactive({
241
+ category: '通用',
242
+ codePrefix: 'SP',
243
+ slaHours: 24,
244
+ owner: '流程管理部',
245
+ scenario: '',
246
+ materials: []
247
+ })
248
+
249
+ const categories = ['采购', '财务', '法务', '人事', '通用']
250
+ const clone = (value) => JSON.parse(JSON.stringify(value))
251
+
252
+ const filteredDefinitions = computed(() => {
253
+ const text = search.value.trim().toLowerCase()
254
+ if (!text) return oa.definitions.value
255
+ return oa.definitions.value.filter((definition) =>
256
+ String(definition.meta?.name || '').toLowerCase().includes(text)
257
+ )
258
+ })
259
+ const activeDefinition = computed(
260
+ () => oa.definitions.value.find((item) => item.meta.id === activeId.value) || null
261
+ )
262
+ const dirty = computed(
263
+ () =>
264
+ Boolean(draft.value && activeDefinition.value) &&
265
+ JSON.stringify(draft.value) !== JSON.stringify(activeDefinition.value)
266
+ )
267
+ const revisionOptions = computed(() =>
268
+ [...(activeDefinition.value?.meta?.revisions || [])].reverse()
269
+ )
270
+ const business = computed(() => resolveBusiness(draft.value))
271
+
272
+ watch(
273
+ () => oa.definitions.value,
274
+ (list) => {
275
+ if (!draft.value && list.length) openDefinition(list[0])
276
+ },
277
+ { immediate: true }
278
+ )
279
+
280
+ function nodeCount(definition) {
281
+ return definition?.workflow ? getAllNodes(definition.workflow).length : 0
282
+ }
283
+
284
+ function statusLabel(definition) {
285
+ const status = definition?.meta?.status
286
+ if (status === 'disabled') return '已停用'
287
+ if (status === 'published') return `已发布 v${definition.meta.version || 1}`
288
+ return '草稿'
289
+ }
290
+
291
+ function statusClass(definition) {
292
+ const status = definition?.meta?.status
293
+ if (status === 'disabled') return 'is-disabled'
294
+ if (status === 'published') return 'is-published'
295
+ return 'is-draft'
296
+ }
297
+
298
+ function hasUnpublished(definition) {
299
+ return isDefinitionRunnable(definition) && hasUnpublishedChanges(definition)
300
+ }
301
+
302
+ async function openDefinition(item) {
303
+ if (activeId.value === item.meta.id) return
304
+ if (dirty.value) await saveDraft(true)
305
+ activeId.value = item.meta.id
306
+ draft.value = clone(item)
307
+ view.value = 'design'
308
+ designerKey.value += 1
309
+ }
310
+
311
+ async function saveDraft(silent = false) {
312
+ if (!draft.value) return null
313
+ const saved = await oa.saveDesign(draft.value)
314
+ draft.value = clone(saved)
315
+ if (!silent) ElMessage.success('流程已保存')
316
+ return saved
317
+ }
318
+
319
+ async function publishDraft() {
320
+ if (!draft.value) return
321
+ if (dirty.value) await saveDraft(true)
322
+ const report = validateDefinition(draft.value)
323
+ if (!report.valid || report.errors?.length) {
324
+ view.value = 'inspect'
325
+ ElMessage.error(report.errors?.[0]?.message || '流程校验未通过,请先修复问题')
326
+ return
327
+ }
328
+ try {
329
+ const published = await oa.publishDesign(draft.value.meta.id)
330
+ draft.value = clone(published)
331
+ ElMessage.success(`已发布 v${published.meta.version}`)
332
+ } catch (error) {
333
+ ElMessage.error(error.message || '发布失败')
334
+ }
335
+ }
336
+
337
+ async function createDefinition() {
338
+ try {
339
+ const { value } = await ElMessageBox.prompt('输入流程名称', '新建流程', {
340
+ confirmButtonText: '创建',
341
+ cancelButtonText: '取消',
342
+ inputPlaceholder: '例如:用印申请流程',
343
+ inputValidator: (text) => Boolean(String(text || '').trim()) || '请输入流程名称'
344
+ })
345
+ if (dirty.value) await saveDraft(true)
346
+ const definition = await oa.createDesign(String(value).trim())
347
+ activeId.value = definition.meta.id
348
+ draft.value = clone(definition)
349
+ view.value = 'design'
350
+ designerKey.value += 1
351
+ ElMessage.success('已创建空白流程,包含开始与结束节点')
352
+ } catch {
353
+ // 用户取消
354
+ }
355
+ }
356
+
357
+ async function duplicateCurrent() {
358
+ if (!draft.value) return
359
+ const copy = await oa.duplicateDesign(draft.value)
360
+ activeId.value = copy.meta.id
361
+ draft.value = clone(copy)
362
+ view.value = 'design'
363
+ ElMessage.success('已复制流程')
364
+ }
365
+
366
+ async function disableCurrent() {
367
+ if (!draft.value) return
368
+ try {
369
+ await ElMessageBox.confirm(
370
+ `停用「${draft.value.meta.name}」后,模板中心将不再展示,运行中的实例不受影响。`,
371
+ '停用流程',
372
+ { type: 'warning', confirmButtonText: '停用', cancelButtonText: '取消' }
373
+ )
374
+ } catch {
375
+ return
376
+ }
377
+ const disabled = await oa.disableDesign(draft.value.meta.id)
378
+ draft.value = clone(disabled)
379
+ ElMessage.success('流程已停用')
380
+ }
381
+
382
+ async function deleteCurrent() {
383
+ if (!draft.value) return
384
+ try {
385
+ await ElMessageBox.confirm(
386
+ `删除「${draft.value.meta.name}」后不可恢复,已创建的流程实例会保留快照。确定继续?`,
387
+ '删除流程',
388
+ { type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
389
+ )
390
+ } catch {
391
+ return
392
+ }
393
+ await oa.removeDesign(draft.value.meta.id)
394
+ activeId.value = null
395
+ draft.value = null
396
+ if (oa.definitions.value.length) openDefinition(oa.definitions.value[0])
397
+ ElMessage.success('流程已删除')
398
+ }
399
+
400
+ async function handleMore(command) {
401
+ if (command === 'duplicate') await duplicateCurrent()
402
+ else if (command === 'disable') await disableCurrent()
403
+ else if (command === 'delete') await deleteCurrent()
404
+ }
405
+
406
+ async function rollback(version) {
407
+ if (!draft.value) return
408
+ try {
409
+ await ElMessageBox.confirm(
410
+ `将「${draft.value.meta.name}」回滚到 v${version}?回滚会生成新的发布版本。`,
411
+ '版本回滚',
412
+ { type: 'warning', confirmButtonText: '回滚', cancelButtonText: '取消' }
413
+ )
414
+ } catch {
415
+ return
416
+ }
417
+ try {
418
+ const restored = await oa.rollbackDesign(draft.value.meta.id, version)
419
+ draft.value = clone(restored)
420
+ designerKey.value += 1
421
+ ElMessage.success(`已回滚并发布为 v${restored.meta.version}`)
422
+ } catch (error) {
423
+ ElMessage.error(error.message || '回滚失败')
424
+ }
425
+ }
426
+
427
+ function triggerImport() {
428
+ fileInput.value?.click()
429
+ }
430
+
431
+ async function handleImportFile(event) {
432
+ const file = event.target.files?.[0]
433
+ event.target.value = ''
434
+ if (!file) return
435
+ try {
436
+ const text = await file.text()
437
+ if (dirty.value) await saveDraft(true)
438
+ const definition = await oa.importDesign(text)
439
+ activeId.value = definition.meta.id
440
+ draft.value = clone(definition)
441
+ view.value = 'design'
442
+ designerKey.value += 1
443
+ ElMessage.success(`已导入「${definition.meta.name}」`)
444
+ } catch (error) {
445
+ ElMessage.error(`导入失败:${error.message || error}`)
446
+ }
447
+ }
448
+
449
+ function exportDefinition() {
450
+ if (!draft.value) return
451
+ downloadJSON(draft.value, `${draft.value.meta.name || 'flow'}.gbflow.json`)
452
+ }
453
+
454
+ function openBusinessDialog() {
455
+ const info = resolveBusiness(draft.value)
456
+ businessForm.category = info.category
457
+ businessForm.codePrefix = info.codePrefix
458
+ businessForm.slaHours = info.slaHours
459
+ businessForm.owner = info.owner
460
+ businessForm.scenario = info.scenario
461
+ businessForm.materials = [...info.materials]
462
+ businessVisible.value = true
463
+ }
464
+
465
+ async function applyBusiness() {
466
+ if (!draft.value) return
467
+ const existing = draft.value.meta.business || {}
468
+ draft.value.meta.business = {
469
+ ...existing,
470
+ category: businessForm.category,
471
+ codePrefix: (businessForm.codePrefix || 'SP').toUpperCase(),
472
+ slaHours: Number(businessForm.slaHours) || 24,
473
+ owner: businessForm.owner,
474
+ scenario: businessForm.scenario,
475
+ materials: [...businessForm.materials]
476
+ }
477
+ businessVisible.value = false
478
+ await saveDraft(true)
479
+ ElMessage.success('模板上架信息已更新,发布后生效')
480
+ }
481
+
482
+ function startDraftFlow() {
483
+ if (!draft.value || !isDefinitionRunnable(draft.value)) {
484
+ ElMessage.warning('请先发布流程后再发起')
485
+ return
486
+ }
487
+ oa.openStartDialog(draft.value.meta.id)
488
+ }
489
+ </script>
490
+
491
+ <style scoped lang="scss">
492
+ .oa-design {
493
+ display: flex;
494
+ height: 100%;
495
+ min-height: 0;
496
+ background: #f3f5f9;
497
+ }
498
+
499
+ .oa-design__side {
500
+ display: flex;
501
+ flex-direction: column;
502
+ width: 272px;
503
+ flex-shrink: 0;
504
+ min-height: 0;
505
+ padding: 16px 12px;
506
+ background: #fff;
507
+ border-right: 1px solid var(--oa-line);
508
+ }
509
+
510
+ .oa-design__side-head {
511
+ display: flex;
512
+ align-items: flex-start;
513
+ justify-content: space-between;
514
+ gap: 8px;
515
+ margin-bottom: 10px;
516
+
517
+ h2 {
518
+ margin: 0;
519
+ color: var(--oa-ink);
520
+ font-size: 17px;
521
+ font-weight: 650;
522
+ }
523
+ }
524
+
525
+ .oa-design__side-actions {
526
+ display: flex;
527
+ align-items: center;
528
+ justify-content: space-between;
529
+ margin-top: 8px;
530
+ color: var(--oa-faint);
531
+ font-size: 10px;
532
+ }
533
+
534
+ .oa-design__list {
535
+ flex: 1;
536
+ min-height: 0;
537
+ overflow: auto;
538
+ margin: 8px -4px 0;
539
+ padding: 0 4px;
540
+ }
541
+
542
+ .oa-design-item {
543
+ display: flex;
544
+ align-items: flex-start;
545
+ gap: 8px;
546
+ width: 100%;
547
+ padding: 9px 8px;
548
+ border: 1px solid transparent;
549
+ border-radius: 7px;
550
+ background: transparent;
551
+ text-align: left;
552
+ cursor: pointer;
553
+
554
+ &:hover {
555
+ background: #f8faff;
556
+ }
557
+
558
+ &.is-active {
559
+ border-color: #d2def4;
560
+ background: var(--oa-primary-soft);
561
+ }
562
+ }
563
+
564
+ .oa-design-item__icon {
565
+ display: grid;
566
+ place-items: center;
567
+ width: 27px;
568
+ height: 27px;
569
+ flex-shrink: 0;
570
+ border-radius: 6px;
571
+ background: #f1f4f9;
572
+ color: var(--oa-muted);
573
+ font-size: 13px;
574
+ }
575
+
576
+ .oa-design-item__main {
577
+ flex: 1;
578
+ min-width: 0;
579
+ }
580
+
581
+ .oa-design-item__title {
582
+ display: flex;
583
+ align-items: center;
584
+ gap: 5px;
585
+ min-width: 0;
586
+
587
+ strong {
588
+ flex: 1;
589
+ overflow: hidden;
590
+ color: var(--oa-ink);
591
+ font-size: 11.5px;
592
+ font-weight: 600;
593
+ text-overflow: ellipsis;
594
+ white-space: nowrap;
595
+ }
596
+ }
597
+
598
+ .oa-design-item__status {
599
+ flex-shrink: 0;
600
+ padding: 0 4px;
601
+ border-radius: 3px;
602
+ font-size: 8.5px;
603
+ font-weight: 600;
604
+ line-height: 15px;
605
+
606
+ &.is-published {
607
+ background: var(--oa-success-soft);
608
+ color: var(--oa-success);
609
+ }
610
+
611
+ &.is-draft {
612
+ background: var(--oa-warning-soft);
613
+ color: var(--oa-warning);
614
+ }
615
+
616
+ &.is-disabled {
617
+ background: #f1f4f9;
618
+ color: var(--oa-faint);
619
+ }
620
+ }
621
+
622
+ .oa-design-item__meta {
623
+ display: block;
624
+ margin-top: 2px;
625
+ color: var(--oa-faint);
626
+ font-size: 9.5px;
627
+ }
628
+
629
+ .oa-design-item__dirty {
630
+ display: block;
631
+ margin-top: 2px;
632
+ color: var(--oa-warning);
633
+ font-size: 9px;
634
+ }
635
+
636
+ .oa-design__empty {
637
+ padding: 30px 10px;
638
+ }
639
+
640
+ .oa-design__main {
641
+ flex: 1;
642
+ min-width: 0;
643
+ min-height: 0;
644
+ display: flex;
645
+ flex-direction: column;
646
+ }
647
+
648
+ .oa-design__toolbar {
649
+ flex-shrink: 0;
650
+ display: flex;
651
+ align-items: center;
652
+ justify-content: space-between;
653
+ gap: 14px;
654
+ padding: 11px 16px;
655
+ background: #fff;
656
+ border-bottom: 1px solid var(--oa-line);
657
+ }
658
+
659
+ .oa-design__toolbar-title {
660
+ min-width: 0;
661
+
662
+ > p {
663
+ display: flex;
664
+ align-items: center;
665
+ gap: 7px;
666
+ margin: 3px 0 0;
667
+ color: var(--oa-faint);
668
+ font-size: 10.5px;
669
+ }
670
+ }
671
+
672
+ .oa-design__name {
673
+ display: flex;
674
+ align-items: center;
675
+ gap: 7px;
676
+ min-width: 0;
677
+
678
+ h1 {
679
+ margin: 0;
680
+ overflow: hidden;
681
+ color: var(--oa-ink);
682
+ font-size: 15px;
683
+ font-weight: 650;
684
+ text-overflow: ellipsis;
685
+ white-space: nowrap;
686
+ }
687
+ }
688
+
689
+ .oa-design__actions {
690
+ display: flex;
691
+ align-items: center;
692
+ gap: 6px;
693
+ flex-shrink: 0;
694
+
695
+ .el-button {
696
+ min-height: 30px;
697
+ padding: 5px 10px;
698
+ font-size: 11.5px;
699
+ }
700
+ }
701
+
702
+ .oa-design__editor {
703
+ flex: 1;
704
+ min-height: 0;
705
+ padding: 10px;
706
+ overflow: hidden;
707
+
708
+ > * {
709
+ height: 100%;
710
+ min-height: 0;
711
+ }
712
+ }
713
+
714
+ .oa-design__no-selection {
715
+ flex: 1;
716
+ display: grid;
717
+ place-items: center;
718
+ }
719
+
720
+ .oa-hidden-input {
721
+ display: none;
722
+ }
723
+
724
+ .oa-business-dialog__hint {
725
+ margin: -2px 0 14px;
726
+ color: var(--oa-faint);
727
+ font-size: 11px;
728
+ line-height: 1.7;
729
+ }
730
+
731
+ .oa-business-dialog__grid {
732
+ display: grid;
733
+ grid-template-columns: repeat(2, minmax(0, 1fr));
734
+ gap: 0 14px;
735
+ }
736
+
737
+ @media (max-width: 1240px) {
738
+ .oa-design__toolbar {
739
+ flex-wrap: wrap;
740
+ }
741
+
742
+ .oa-design__actions {
743
+ flex-wrap: wrap;
744
+ }
745
+ }
746
+
747
+ @media (max-width: 960px) {
748
+ .oa-design {
749
+ display: block;
750
+ overflow: auto;
751
+ }
752
+
753
+ .oa-design__side {
754
+ width: 100%;
755
+ height: auto;
756
+ border-right: none;
757
+ border-bottom: 1px solid var(--oa-line);
758
+ }
759
+
760
+ .oa-design__list {
761
+ display: flex;
762
+ gap: 6px;
763
+ overflow-x: auto;
764
+ max-height: 120px;
765
+ }
766
+
767
+ .oa-design-item {
768
+ width: 210px;
769
+ flex-shrink: 0;
770
+ }
771
+
772
+ .oa-design__main {
773
+ height: calc(100vh - 250px);
774
+ }
775
+
776
+ .oa-design__toolbar {
777
+ align-items: flex-start;
778
+ flex-direction: column;
779
+ }
780
+
781
+ .oa-design__actions {
782
+ width: 100%;
783
+ flex-wrap: wrap;
784
+
785
+ .el-button {
786
+ min-height: 44px;
787
+ }
788
+ }
789
+
790
+ .oa-design__editor {
791
+ padding: 0;
792
+ }
793
+
794
+ .oa-business-dialog__grid {
795
+ grid-template-columns: minmax(0, 1fr);
796
+ }
797
+ }
798
+ </style>