gbflowengine 0.0.0-stage → 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +271 -3
- package/dist/gbflowengine.css +1 -0
- package/dist/gbflowengine.js +18363 -0
- package/dist/gbflowengine.js.map +1 -0
- package/dist/gbflowengine.umd.cjs +5 -0
- package/dist/gbflowengine.umd.cjs.map +1 -0
- package/package.json +84 -6
- package/src/center/DefinitionInspect.vue +291 -0
- package/src/center/FlowCenter.vue +33 -0
- package/src/center/index.js +29 -0
- package/src/center/storage.js +748 -0
- package/src/core/flow/condition.js +160 -0
- package/src/core/flow/customNode.js +385 -0
- package/src/core/flow/defaults.js +124 -0
- package/src/core/flow/flowConstant.js +265 -0
- package/src/core/flow/flowNodeUtils.js +30 -0
- package/src/core/flow/index.js +47 -0
- package/src/core/flow/node.js +44 -0
- package/src/core/flow/nodeFactory.js +58 -0
- package/src/core/flow/prediction.js +325 -0
- package/src/core/flow/runtime/auto.js +83 -0
- package/src/core/flow/runtime/decide.js +329 -0
- package/src/core/flow/runtime/event.js +28 -0
- package/src/core/flow/runtime/execute.js +357 -0
- package/src/core/flow/runtime/helpers.js +52 -0
- package/src/core/flow/runtime/query.js +146 -0
- package/src/core/flow/runtime/reject.js +137 -0
- package/src/core/flow/runtime/token.js +269 -0
- package/src/core/flow/runtime.js +129 -0
- package/src/core/flow/schema.js +864 -0
- package/src/definition/FlowDefinitionDesigner.vue +338 -0
- package/src/definition/index.js +9 -0
- package/src/index.js +39 -0
- package/src/storage.js +200 -0
- package/src/testing/FlowTestPanel.vue +2502 -0
- package/src/testing/UserConfigDrawer.vue +376 -0
- package/src/testing/diagram/FlowProgressDiagram.vue +318 -0
- package/src/testing/diagramModel.js +517 -0
- package/src/testing/index.js +23 -0
- package/src/testing/mock.js +246 -0
- package/src/testing/oaExecutors.js +51 -0
- package/src/testing/oaSeed.js +467 -0
- package/src/testing/sample.js +412 -0
- package/src/testing/seed.js +122 -0
- package/src/utils/format.js +27 -0
- package/src/visual/FlowCanvas.vue +441 -0
- package/src/visual/NodeProgressDetail.vue +43 -0
- package/src/visual/NodeStatusBadge.vue +17 -0
- package/src/visual/NodeWrap.vue +47 -0
- package/src/visual/ScWorkflow.vue +50 -0
- package/src/visual/SelectDialog.vue +460 -0
- package/src/visual/conditionHelpers.js +117 -0
- package/src/visual/index.js +6 -0
- package/src/visual/nodes/AddNode.vue +223 -0
- package/src/visual/nodes/ApproverNode.vue +348 -0
- package/src/visual/nodes/BranchNode.vue +442 -0
- package/src/visual/nodes/CustomNode.vue +339 -0
- package/src/visual/nodes/EndNode.vue +22 -0
- package/src/visual/nodes/PassNode.vue +101 -0
- package/src/visual/nodes/PromoterNode.vue +135 -0
- package/src/visual/nodes/RejectNode.vue +101 -0
- package/src/visual/nodes/SendNode.vue +152 -0
- package/src/visual/styles.scss +879 -0
- package/src/visual/useScNodeStatus.js +18 -0
- package/src/workbench/OaWorkbench.vue +1341 -0
- package/src/workbench/components/ApprovalWorkspace.vue +2090 -0
- package/src/workbench/components/CategoryIcon.vue +74 -0
- package/src/workbench/components/NotificationIcon.vue +73 -0
- package/src/workbench/components/ProcessSteps.vue +557 -0
- package/src/workbench/components/ResubmitDialog.vue +227 -0
- package/src/workbench/components/SidebarNav.vue +138 -0
- package/src/workbench/components/StartFlowDialog.vue +1058 -0
- package/src/workbench/components/UserAvatar.vue +68 -0
- package/src/workbench/custom-tasks.js +130 -0
- package/src/workbench/model.js +1080 -0
- package/src/workbench/pages/DesignPage.vue +798 -0
- package/src/workbench/pages/HomePage.vue +1050 -0
- package/src/workbench/pages/MonitorPage.vue +1029 -0
- package/src/workbench/pages/NotificationsPage.vue +554 -0
- package/src/workbench/pages/RequestsPage.vue +644 -0
- package/src/workbench/pages/TaskCenterPage.vue +1155 -0
- package/src/workbench/pages/TemplatesPage.vue +680 -0
- package/src/workbench/persistence.js +89 -0
- package/src/workbench/shared.js +18 -0
- package/src/workbench/styles.scss +555 -0
- package/src/workbench/useWorkbench.js +955 -0
- package/types/center.d.ts +5 -0
- package/types/core.d.ts +479 -0
- package/types/definition.d.ts +4 -0
- package/types/index.d.ts +34 -0
- package/types/testing.d.ts +20 -0
- package/types/visual.d.ts +20 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="gb-flow-canvas">
|
|
3
|
+
<div v-if="showToolbar" class="gb-flow-canvas__toolbar btn-container">
|
|
4
|
+
<el-button type="primary" @click="openJson">查看 JSON</el-button>
|
|
5
|
+
<el-button type="primary" @click="saveAsPng">保存图片</el-button>
|
|
6
|
+
<el-button v-if="!readonly" type="primary" @click="openImport">导入 JSON</el-button>
|
|
7
|
+
<el-button type="primary" @click="downloadWorkflow">导出 JSON</el-button>
|
|
8
|
+
<div class="slider">
|
|
9
|
+
<el-button type="primary" :icon="Minus" style="margin-right: 16px; width: 32px" @click="zoom -= 0.1" />
|
|
10
|
+
<el-slider v-model="zoom" :marks="marks" :min="0.1" :max="5" :step="0.1" />
|
|
11
|
+
<el-button type="primary" :icon="Plus" style="margin-left: 16px; width: 32px" @click="zoom += 0.1" />
|
|
12
|
+
</div>
|
|
13
|
+
<span class="gb-flow-canvas__count">{{ nodeCount }} 个节点</span>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="gb-flow-canvas__viewport">
|
|
17
|
+
<div class="gb-flow-canvas__stage" :style="{ transform: `scale(${zoom})` }">
|
|
18
|
+
<ScWorkflow
|
|
19
|
+
id="content-to-capture"
|
|
20
|
+
v-model="data"
|
|
21
|
+
:form-variables="formVariables"
|
|
22
|
+
:readonly="readonly"
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<el-drawer v-model="jsonVisible" size="500px" class="drawer" :append-to-body="true" :modal="false" :with-header="false">
|
|
28
|
+
<div style="height: 100%">
|
|
29
|
+
<div style="padding: 1px; background-color: #3883fa">
|
|
30
|
+
<el-button type="primary" plain @click="copyJson(true)">复制格式化后的 JSON</el-button>
|
|
31
|
+
<el-button type="primary" plain @click="copyJson(false)">复制压缩后的 JSON</el-button>
|
|
32
|
+
<el-button type="primary" plain @click="applyJson">应用修改</el-button>
|
|
33
|
+
<el-button type="primary" plain @click="jsonVisible = false">关闭弹窗</el-button>
|
|
34
|
+
</div>
|
|
35
|
+
<div v-if="jsonError || jsonValidation" class="gb-flow-canvas__feedback">
|
|
36
|
+
<span v-if="jsonError" class="is-error">{{ jsonError }}</span>
|
|
37
|
+
<span v-else-if="jsonValidation.valid">结构校验通过</span>
|
|
38
|
+
<span v-else class="is-error">
|
|
39
|
+
{{ jsonValidation.errors[0]?.message }}{{ jsonValidation.errors.length > 1 ? ` 等 ${jsonValidation.errors.length} 项问题` : '' }}
|
|
40
|
+
</span>
|
|
41
|
+
</div>
|
|
42
|
+
<textarea v-model="jsonText" class="editor" spellcheck="false"></textarea>
|
|
43
|
+
</div>
|
|
44
|
+
</el-drawer>
|
|
45
|
+
|
|
46
|
+
<el-dialog v-model="importVisible" title="导入 JSON" width="720px" append-to-body destroy-on-close>
|
|
47
|
+
<div class="gb-flow-canvas__import-bar">
|
|
48
|
+
<el-button :icon="FolderOpened" @click="chooseImportFile">选择 JSON 文件</el-button>
|
|
49
|
+
<span v-if="importFileName" class="gb-flow-canvas__file-name">{{ importFileName }}</span>
|
|
50
|
+
</div>
|
|
51
|
+
<el-input v-model="importText" type="textarea" :rows="12" placeholder="粘贴流程 JSON" @input="previewImport" />
|
|
52
|
+
<div v-if="importError" class="gb-flow-canvas__feedback"><span class="is-error">{{ importError }}</span></div>
|
|
53
|
+
<div v-else-if="importValidation" class="gb-flow-canvas__feedback">
|
|
54
|
+
<span :class="{ 'is-error': !importValidation.valid }">
|
|
55
|
+
{{ importValidation.valid ? '结构校验通过' : importValidation.errors[0]?.message }}
|
|
56
|
+
</span>
|
|
57
|
+
</div>
|
|
58
|
+
<template #footer>
|
|
59
|
+
<el-button @click="importVisible = false">取消</el-button>
|
|
60
|
+
<el-button type="primary" :disabled="!importDocument" @click="applyImport">导入</el-button>
|
|
61
|
+
</template>
|
|
62
|
+
</el-dialog>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<script setup>
|
|
67
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
68
|
+
import { ElMessage } from 'element-plus'
|
|
69
|
+
import { FolderOpened, Minus, Plus } from '@element-plus/icons-vue'
|
|
70
|
+
import ScWorkflow from './ScWorkflow.vue'
|
|
71
|
+
import {
|
|
72
|
+
countNodes,
|
|
73
|
+
createDefinition,
|
|
74
|
+
downloadJSON,
|
|
75
|
+
ensureEndNode,
|
|
76
|
+
exportWorkflow,
|
|
77
|
+
FlowNodeType,
|
|
78
|
+
importDefinition,
|
|
79
|
+
pickJSONFile,
|
|
80
|
+
validateWorkflow
|
|
81
|
+
} from '../core/flow/index.js'
|
|
82
|
+
|
|
83
|
+
defineOptions({ name: 'GbFlowCanvas' })
|
|
84
|
+
|
|
85
|
+
const props = defineProps({
|
|
86
|
+
modelValue: { type: Object, default: null },
|
|
87
|
+
formVariables: { type: Array, default: () => [] },
|
|
88
|
+
readonly: { type: Boolean, default: false },
|
|
89
|
+
meta: { type: Object, default: () => ({}) },
|
|
90
|
+
fileName: { type: String, default: 'workflow' },
|
|
91
|
+
showToolbar: { type: Boolean, default: true },
|
|
92
|
+
autoEnsureEnd: { type: Boolean, default: true },
|
|
93
|
+
exportBuilder: { type: Function, default: null }
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const emit = defineEmits(['update:modelValue', 'import', 'export', 'validate', 'change'])
|
|
97
|
+
|
|
98
|
+
const clone = (value) => JSON.parse(JSON.stringify(value))
|
|
99
|
+
|
|
100
|
+
function createDefaultWorkflow() {
|
|
101
|
+
const workflow = {
|
|
102
|
+
nodeId: 0,
|
|
103
|
+
nodeName: '发起人',
|
|
104
|
+
type: FlowNodeType.START,
|
|
105
|
+
childNode: null
|
|
106
|
+
}
|
|
107
|
+
ensureEndNode(workflow)
|
|
108
|
+
return workflow
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function normalizeInput(value) {
|
|
112
|
+
if (!value || typeof value !== 'object') return createDefaultWorkflow()
|
|
113
|
+
const next = clone(value)
|
|
114
|
+
if (props.autoEnsureEnd) ensureEndNode(next)
|
|
115
|
+
return next
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const data = ref(normalizeInput(props.modelValue))
|
|
119
|
+
const zoom = ref(1)
|
|
120
|
+
const marks = { 0.1: 'min', 1: '1', 2: '2', 3: '3', 4: '4', 5: 'max' }
|
|
121
|
+
const nodeCount = computed(() => countNodes(data.value))
|
|
122
|
+
|
|
123
|
+
let syncing = false
|
|
124
|
+
|
|
125
|
+
watch(
|
|
126
|
+
() => props.modelValue,
|
|
127
|
+
(value) => {
|
|
128
|
+
if (!value || syncing) return
|
|
129
|
+
if (JSON.stringify(value) === JSON.stringify(data.value)) return
|
|
130
|
+
syncing = true
|
|
131
|
+
data.value = normalizeInput(value)
|
|
132
|
+
requestAnimationFrame(() => {
|
|
133
|
+
syncing = false
|
|
134
|
+
})
|
|
135
|
+
},
|
|
136
|
+
{ deep: true }
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
watch(
|
|
140
|
+
data,
|
|
141
|
+
(value) => {
|
|
142
|
+
if (syncing) return
|
|
143
|
+
if (props.autoEnsureEnd) ensureEndNode(value)
|
|
144
|
+
const next = clone(value)
|
|
145
|
+
emit('update:modelValue', next)
|
|
146
|
+
emit('change', next)
|
|
147
|
+
},
|
|
148
|
+
{ deep: true }
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
onMounted(() => {
|
|
152
|
+
if (props.autoEnsureEnd) ensureEndNode(data.value)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
// ==================== JSON drawer ====================
|
|
156
|
+
|
|
157
|
+
const jsonVisible = ref(false)
|
|
158
|
+
const jsonText = ref('')
|
|
159
|
+
const jsonError = ref('')
|
|
160
|
+
const jsonValidation = ref(null)
|
|
161
|
+
|
|
162
|
+
const openJson = () => {
|
|
163
|
+
jsonText.value = JSON.stringify(data.value, null, ' ')
|
|
164
|
+
jsonError.value = ''
|
|
165
|
+
jsonValidation.value = validateWorkflow(data.value)
|
|
166
|
+
jsonVisible.value = true
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
watch(jsonText, (text) => {
|
|
170
|
+
if (!jsonVisible.value) return
|
|
171
|
+
jsonError.value = ''
|
|
172
|
+
jsonValidation.value = null
|
|
173
|
+
if (!text.trim()) return
|
|
174
|
+
try {
|
|
175
|
+
const parsed = JSON.parse(text)
|
|
176
|
+
jsonValidation.value = validateWorkflow(parsed.workflow || parsed)
|
|
177
|
+
} catch (error) {
|
|
178
|
+
jsonError.value = `JSON 解析失败:${error.message}`
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
const applyJson = () => {
|
|
183
|
+
try {
|
|
184
|
+
const result = importDefinition(jsonText.value)
|
|
185
|
+
data.value = result.document.workflow
|
|
186
|
+
jsonValidation.value = result.validation
|
|
187
|
+
ElMessage.success('流程 JSON 已应用')
|
|
188
|
+
} catch (error) {
|
|
189
|
+
jsonError.value = error.message || String(error)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const copyJson = async (pretty) => {
|
|
194
|
+
const text = pretty ? JSON.stringify(data.value, null, ' ') : JSON.stringify(data.value)
|
|
195
|
+
try {
|
|
196
|
+
await navigator.clipboard.writeText(text)
|
|
197
|
+
ElMessage.success('已复制到剪贴板')
|
|
198
|
+
} catch {
|
|
199
|
+
ElMessage.warning('复制失败,请手动复制')
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ==================== Import / export ====================
|
|
204
|
+
|
|
205
|
+
const importVisible = ref(false)
|
|
206
|
+
const importText = ref('')
|
|
207
|
+
const importFileName = ref('')
|
|
208
|
+
const importError = ref('')
|
|
209
|
+
const importValidation = ref(null)
|
|
210
|
+
const importDocument = ref(null)
|
|
211
|
+
|
|
212
|
+
const openImport = () => {
|
|
213
|
+
importVisible.value = true
|
|
214
|
+
importText.value = ''
|
|
215
|
+
importFileName.value = ''
|
|
216
|
+
importError.value = ''
|
|
217
|
+
importValidation.value = null
|
|
218
|
+
importDocument.value = null
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const previewImport = () => {
|
|
222
|
+
importError.value = ''
|
|
223
|
+
importValidation.value = null
|
|
224
|
+
importDocument.value = null
|
|
225
|
+
if (!importText.value.trim()) return
|
|
226
|
+
try {
|
|
227
|
+
const result = importDefinition(importText.value)
|
|
228
|
+
importDocument.value = result.document
|
|
229
|
+
importValidation.value = result.validation
|
|
230
|
+
} catch (error) {
|
|
231
|
+
importError.value = error.message || String(error)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const chooseImportFile = async () => {
|
|
236
|
+
const picked = await pickJSONFile()
|
|
237
|
+
if (!picked) return
|
|
238
|
+
importFileName.value = picked.file.name
|
|
239
|
+
importText.value = picked.text
|
|
240
|
+
if (picked.error) {
|
|
241
|
+
importError.value = picked.error.message || '读取文件失败'
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
previewImport()
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const applyImport = () => {
|
|
248
|
+
if (!importDocument.value) return
|
|
249
|
+
data.value = importDocument.value.workflow
|
|
250
|
+
importVisible.value = false
|
|
251
|
+
emit('import', importDocument.value)
|
|
252
|
+
ElMessage.success('流程导入成功')
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const buildExportPayload = () => {
|
|
256
|
+
if (typeof props.exportBuilder === 'function') {
|
|
257
|
+
const payload = props.exportBuilder()
|
|
258
|
+
if (payload) return payload
|
|
259
|
+
}
|
|
260
|
+
return exportWorkflow(data.value, { ...props.meta, name: props.meta?.name || props.fileName }, { raw: true })
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const exportJSON = (space = 2) => {
|
|
264
|
+
const payload = buildExportPayload()
|
|
265
|
+
emit('export', payload)
|
|
266
|
+
return JSON.stringify(payload, null, space)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const downloadWorkflow = () => {
|
|
270
|
+
const payload = buildExportPayload()
|
|
271
|
+
const isDefinition = typeof props.exportBuilder === 'function'
|
|
272
|
+
const name = isDefinition
|
|
273
|
+
? `${props.meta?.name || props.fileName}.gbflow.json`
|
|
274
|
+
: `${props.meta?.name || props.fileName}-workflow.json`
|
|
275
|
+
downloadJSON(payload, name)
|
|
276
|
+
emit('export', payload)
|
|
277
|
+
ElMessage.success('JSON 已导出')
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const saveAsPng = async () => {
|
|
281
|
+
const element = document.getElementById('content-to-capture')
|
|
282
|
+
if (!element) return
|
|
283
|
+
const html2canvas = window.html2canvas
|
|
284
|
+
if (typeof html2canvas !== 'function') {
|
|
285
|
+
ElMessage.warning('保存图片需要宿主应用提供 html2canvas')
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
const stage = element.parentElement
|
|
289
|
+
const scale = stage.style.transform
|
|
290
|
+
stage.style.transform = 'scale(1)'
|
|
291
|
+
try {
|
|
292
|
+
const canvas = await html2canvas(element, { backgroundColor: '#efefef' })
|
|
293
|
+
const image = canvas.toDataURL('image/png')
|
|
294
|
+
const link = document.createElement('a')
|
|
295
|
+
link.download = `gbflow-${Date.now()}.png`
|
|
296
|
+
link.href = image
|
|
297
|
+
link.click()
|
|
298
|
+
} finally {
|
|
299
|
+
stage.style.transform = scale
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// ==================== Public API ====================
|
|
304
|
+
|
|
305
|
+
const validate = () => {
|
|
306
|
+
const result = validateWorkflow(data.value)
|
|
307
|
+
emit('validate', result)
|
|
308
|
+
return result
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const getWorkflow = () => clone(data.value)
|
|
312
|
+
const getDefinition = () =>
|
|
313
|
+
createDefinition({
|
|
314
|
+
workflow: data.value,
|
|
315
|
+
form: [],
|
|
316
|
+
meta: { ...props.meta, name: props.meta?.name || props.fileName }
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
const importJSON = (input) => {
|
|
320
|
+
const result = importDefinition(input)
|
|
321
|
+
data.value = result.document.workflow
|
|
322
|
+
emit('import', result.document)
|
|
323
|
+
return result
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
defineExpose({
|
|
327
|
+
getWorkflow,
|
|
328
|
+
getDefinition,
|
|
329
|
+
importJSON,
|
|
330
|
+
importDefinition,
|
|
331
|
+
exportJSON,
|
|
332
|
+
downloadWorkflow,
|
|
333
|
+
validate,
|
|
334
|
+
zoomIn: () => (zoom.value = Math.min(zoom.value + 0.1, 5)),
|
|
335
|
+
zoomOut: () => (zoom.value = Math.max(zoom.value - 0.1, 0.1)),
|
|
336
|
+
resetZoom: () => (zoom.value = 1),
|
|
337
|
+
saveAsPng,
|
|
338
|
+
data
|
|
339
|
+
})
|
|
340
|
+
</script>
|
|
341
|
+
|
|
342
|
+
<style lang="scss">
|
|
343
|
+
.gb-flow-canvas {
|
|
344
|
+
display: flex;
|
|
345
|
+
flex-direction: column;
|
|
346
|
+
width: 100%;
|
|
347
|
+
height: 100%;
|
|
348
|
+
min-height: 360px;
|
|
349
|
+
overflow: hidden;
|
|
350
|
+
background-color: #efefef;
|
|
351
|
+
box-sizing: border-box;
|
|
352
|
+
|
|
353
|
+
&__toolbar {
|
|
354
|
+
flex-shrink: 0;
|
|
355
|
+
display: flex;
|
|
356
|
+
align-items: center;
|
|
357
|
+
gap: 4px;
|
|
358
|
+
padding: 8px 16px;
|
|
359
|
+
background: #fff;
|
|
360
|
+
border-bottom: 1px solid var(--el-border-color-light);
|
|
361
|
+
z-index: 5;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
&__viewport {
|
|
365
|
+
flex: 1;
|
|
366
|
+
min-height: 0;
|
|
367
|
+
overflow: auto;
|
|
368
|
+
display: flex;
|
|
369
|
+
justify-content: center;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
&__stage {
|
|
373
|
+
transform-origin: top center;
|
|
374
|
+
width: fit-content;
|
|
375
|
+
min-width: 100%;
|
|
376
|
+
padding: 10px 0 60px;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
#content-to-capture {
|
|
380
|
+
padding: 10px;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.btn-container {
|
|
384
|
+
display: flex;
|
|
385
|
+
align-items: center;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.slider {
|
|
389
|
+
margin-left: 16px;
|
|
390
|
+
width: 300px;
|
|
391
|
+
display: flex;
|
|
392
|
+
align-items: center;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
&__count {
|
|
396
|
+
margin-left: 16px;
|
|
397
|
+
font-size: 12px;
|
|
398
|
+
color: #909399;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
&__feedback {
|
|
402
|
+
padding: 8px 12px;
|
|
403
|
+
font-size: 12px;
|
|
404
|
+
color: #606266;
|
|
405
|
+
background: #f5f7fa;
|
|
406
|
+
|
|
407
|
+
.is-error {
|
|
408
|
+
color: var(--el-color-danger);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
&__import-bar {
|
|
413
|
+
display: flex;
|
|
414
|
+
align-items: center;
|
|
415
|
+
gap: 10px;
|
|
416
|
+
margin-bottom: 10px;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
&__file-name {
|
|
420
|
+
font-size: 12px;
|
|
421
|
+
color: var(--el-color-primary);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.editor {
|
|
425
|
+
width: 100%;
|
|
426
|
+
height: calc(100vh - 76px);
|
|
427
|
+
box-sizing: border-box;
|
|
428
|
+
border: none;
|
|
429
|
+
outline: none;
|
|
430
|
+
resize: none;
|
|
431
|
+
padding: 12px;
|
|
432
|
+
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
|
433
|
+
font-size: 13px;
|
|
434
|
+
line-height: 1.6;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.el-drawer__body {
|
|
438
|
+
padding: 0 !important;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="hasContent" class="sc-node-progress">
|
|
3
|
+
<div v-if="status.approvers?.length" class="sc-node-progress__row">
|
|
4
|
+
<span class="sc-node-progress__label">审批人</span>
|
|
5
|
+
<span
|
|
6
|
+
v-for="approver in status.approvers"
|
|
7
|
+
:key="approver.id"
|
|
8
|
+
class="sc-node-progress__person"
|
|
9
|
+
:class="{ 'is-done': approver.done }"
|
|
10
|
+
>
|
|
11
|
+
{{ approver.done ? '✓ ' : '' }}{{ approver.name }}
|
|
12
|
+
</span>
|
|
13
|
+
</div>
|
|
14
|
+
<div v-if="status.ccUsers?.length" class="sc-node-progress__row">
|
|
15
|
+
<span class="sc-node-progress__label">抄送人</span>
|
|
16
|
+
<span
|
|
17
|
+
v-for="user in status.ccUsers"
|
|
18
|
+
:key="user.id"
|
|
19
|
+
class="sc-node-progress__person"
|
|
20
|
+
:class="{ 'is-done': user.done }"
|
|
21
|
+
>
|
|
22
|
+
{{ user.name }}
|
|
23
|
+
</span>
|
|
24
|
+
</div>
|
|
25
|
+
<div v-if="status.note" class="sc-node-progress__note">{{ status.note }}</div>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script setup>
|
|
30
|
+
import { computed } from 'vue'
|
|
31
|
+
|
|
32
|
+
defineOptions({ name: 'ScNodeProgressDetail' })
|
|
33
|
+
|
|
34
|
+
const props = defineProps({
|
|
35
|
+
status: { type: Object, default: null }
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const hasContent = computed(
|
|
39
|
+
() =>
|
|
40
|
+
!!props.status &&
|
|
41
|
+
(!!props.status.approvers?.length || !!props.status.ccUsers?.length || !!props.status.note)
|
|
42
|
+
)
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span
|
|
3
|
+
v-if="status && status.status"
|
|
4
|
+
class="sc-status-badge"
|
|
5
|
+
:class="`is-${status.status}`"
|
|
6
|
+
>
|
|
7
|
+
{{ status.statusLabel || status.status }}
|
|
8
|
+
</span>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup>
|
|
12
|
+
defineOptions({ name: 'ScNodeStatusBadge' })
|
|
13
|
+
|
|
14
|
+
defineProps({
|
|
15
|
+
status: { type: Object, default: null }
|
|
16
|
+
})
|
|
17
|
+
</script>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PromoterNode v-if="nodeConfig.type === FlowNodeType.START" v-model="nodeConfig" />
|
|
3
|
+
<ApproverNode v-else-if="nodeConfig.type === FlowNodeType.APPROVE" v-model="nodeConfig" />
|
|
4
|
+
<SendNode v-else-if="nodeConfig.type === FlowNodeType.CC" v-model="nodeConfig" />
|
|
5
|
+
<CustomNode v-else-if="nodeConfig.type === FlowNodeType.CUSTOM" v-model="nodeConfig" />
|
|
6
|
+
<BranchNode
|
|
7
|
+
v-else-if="[FlowNodeType.BRANCH, FlowNodeType.PARALLEL, FlowNodeType.INCLUSIVE].includes(nodeConfig.type)"
|
|
8
|
+
v-model="nodeConfig"
|
|
9
|
+
:parent-node="props.parentNode"
|
|
10
|
+
>
|
|
11
|
+
<template #default="{ node }">
|
|
12
|
+
<NodeWrap v-if="node && node.childNode" v-model="node.childNode" :parent-node="node" />
|
|
13
|
+
</template>
|
|
14
|
+
</BranchNode>
|
|
15
|
+
<PassNode v-else-if="nodeConfig.type === FlowNodeType.PASS" v-model="nodeConfig" :parent-node="props.parentNode" />
|
|
16
|
+
<RejectNode v-else-if="nodeConfig.type === FlowNodeType.REJECT" v-model="nodeConfig" :parent-node="props.parentNode" />
|
|
17
|
+
<EndNode v-else-if="nodeConfig.type === FlowNodeType.END" v-model="nodeConfig" />
|
|
18
|
+
|
|
19
|
+
<NodeWrap v-if="nodeConfig.childNode && nodeConfig.type !== FlowNodeType.END" v-model="nodeConfig.childNode" :parent-node="nodeConfig" />
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
import { computed } from 'vue'
|
|
24
|
+
import PromoterNode from './nodes/PromoterNode.vue'
|
|
25
|
+
import ApproverNode from './nodes/ApproverNode.vue'
|
|
26
|
+
import SendNode from './nodes/SendNode.vue'
|
|
27
|
+
import CustomNode from './nodes/CustomNode.vue'
|
|
28
|
+
import BranchNode from './nodes/BranchNode.vue'
|
|
29
|
+
import PassNode from './nodes/PassNode.vue'
|
|
30
|
+
import RejectNode from './nodes/RejectNode.vue'
|
|
31
|
+
import EndNode from './nodes/EndNode.vue'
|
|
32
|
+
import { FlowNodeType } from '../core/flow/index.js'
|
|
33
|
+
|
|
34
|
+
defineOptions({ name: 'ScNodeWrap' })
|
|
35
|
+
|
|
36
|
+
const props = defineProps({
|
|
37
|
+
modelValue: { type: Object, required: true },
|
|
38
|
+
parentNode: { type: Object, default: null }
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits(['update:modelValue'])
|
|
42
|
+
|
|
43
|
+
const nodeConfig = computed({
|
|
44
|
+
get: () => props.modelValue,
|
|
45
|
+
set: (value) => emit('update:modelValue', value)
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="sc-workflow-design"
|
|
4
|
+
:class="{ 'is-readonly': isReadonly, 'has-progress': !!statusMap }"
|
|
5
|
+
>
|
|
6
|
+
<div class="box-scale">
|
|
7
|
+
<NodeWrap v-if="nodeConfig" v-model="nodeConfig" />
|
|
8
|
+
</div>
|
|
9
|
+
<SelectDialog ref="selectRef" />
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
14
|
+
import { computed, provide, ref } from 'vue'
|
|
15
|
+
import NodeWrap from './NodeWrap.vue'
|
|
16
|
+
import SelectDialog from './SelectDialog.vue'
|
|
17
|
+
|
|
18
|
+
defineOptions({ name: 'ScWorkflow' })
|
|
19
|
+
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
modelValue: { type: Object, required: true },
|
|
22
|
+
formVariables: { type: Array, default: () => [] },
|
|
23
|
+
readonly: { type: Boolean, default: false },
|
|
24
|
+
statusMap: { type: Object, default: null }
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits(['update:modelValue'])
|
|
28
|
+
|
|
29
|
+
const selectRef = ref(null)
|
|
30
|
+
|
|
31
|
+
const nodeConfig = computed({
|
|
32
|
+
get: () => props.modelValue,
|
|
33
|
+
set: (value) => emit('update:modelValue', value)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const isReadonly = computed(() => props.readonly === true)
|
|
37
|
+
const formVariables = computed(() => props.formVariables)
|
|
38
|
+
const flowRoot = computed(() => props.modelValue)
|
|
39
|
+
const statusMapRef = computed(() => props.statusMap || {})
|
|
40
|
+
|
|
41
|
+
provide('select', (type, data) => selectRef.value?.open(type, data))
|
|
42
|
+
provide('scReadonly', isReadonly)
|
|
43
|
+
provide('scFlowRoot', flowRoot)
|
|
44
|
+
provide('scFormVariables', formVariables)
|
|
45
|
+
provide('scStatusMap', statusMapRef)
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<style lang="scss">
|
|
49
|
+
@use './styles.scss';
|
|
50
|
+
</style>
|