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,442 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="branch-wrap">
|
|
3
|
+
<div class="branch-box-wrap">
|
|
4
|
+
<div v-if="groupStatus" class="branch-progress-head">
|
|
5
|
+
<span class="branch-progress-head__name">{{ nodeConfig.nodeName }}</span>
|
|
6
|
+
<span v-if="groupStatus.decisionText" class="branch-progress-head__decision">
|
|
7
|
+
{{ groupStatus.decisionText }}
|
|
8
|
+
</span>
|
|
9
|
+
<NodeStatusBadge :status="groupStatus" />
|
|
10
|
+
</div>
|
|
11
|
+
<div class="branch-box">
|
|
12
|
+
<el-button class="add-branch" type="success" plain round @click="addTerm">
|
|
13
|
+
{{ addBranchLabel }}
|
|
14
|
+
</el-button>
|
|
15
|
+
<div
|
|
16
|
+
class="col-box"
|
|
17
|
+
v-for="(item, index) in nodeConfig.branchList"
|
|
18
|
+
:key="item.nodeId"
|
|
19
|
+
:class="branchStatusClass(item)"
|
|
20
|
+
>
|
|
21
|
+
<div class="condition-node">
|
|
22
|
+
<div class="condition-node-box">
|
|
23
|
+
<div
|
|
24
|
+
class="auto-judge"
|
|
25
|
+
:class="[
|
|
26
|
+
{ 'auto-judge--parallel': isParallel, 'auto-judge--inclusive': isInclusive },
|
|
27
|
+
branchStatusClass(item)
|
|
28
|
+
]"
|
|
29
|
+
@click="show(index)"
|
|
30
|
+
>
|
|
31
|
+
<div class="sort-left" v-if="index != 0" @click.stop="arrTransfer(index, -1)">
|
|
32
|
+
<el-icon><ArrowLeft /></el-icon>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="title">
|
|
35
|
+
<span class="node-title">{{ item.nodeName }}</span>
|
|
36
|
+
<span class="priority-title">优先级{{ index + 1 }}</span>
|
|
37
|
+
<el-icon class="close" @click.stop="delTerm(index)"><Close /></el-icon>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="content">
|
|
40
|
+
<span v-if="toText(item, index)">{{ toText(item, index) }}</span>
|
|
41
|
+
<span v-else class="placeholder">{{ placeholderText }}</span>
|
|
42
|
+
<NodeStatusBadge :status="branchStatus(item)" class="sc-branch-status-badge" />
|
|
43
|
+
</div>
|
|
44
|
+
<div class="sort-right" v-if="index != nodeConfig.branchList.length - 1" @click.stop="arrTransfer(index)">
|
|
45
|
+
<el-icon><ArrowRight /></el-icon>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
<AddNode v-model="item.childNode" :parent-node="item" :readonly="isReadonly" @update:model-value="(child) => updateBranchChild(index, child)" />
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<slot v-if="item.childNode" :node="item" />
|
|
52
|
+
<div class="top-left-cover-line" v-if="index == 0"></div>
|
|
53
|
+
<div class="bottom-left-cover-line" v-if="index == 0"></div>
|
|
54
|
+
<div class="top-right-cover-line" v-if="index == nodeConfig.branchList.length - 1"></div>
|
|
55
|
+
<div class="bottom-right-cover-line" v-if="index == nodeConfig.branchList.length - 1"></div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<AddNode v-model="nodeConfig.childNode" :parent-node="nodeConfig" :readonly="isReadonly" @update:model-value="updateChild" />
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<el-drawer title="条件设置" v-model="drawer" destroy-on-close append-to-body :size="600">
|
|
62
|
+
<template #header>
|
|
63
|
+
<div class="node-wrap-drawer__title">
|
|
64
|
+
<label v-if="!isEditTitle" @click="editTitle">
|
|
65
|
+
{{ form.nodeName }}
|
|
66
|
+
<el-icon class="node-wrap-drawer__title-edit"><Edit /></el-icon>
|
|
67
|
+
</label>
|
|
68
|
+
<el-input v-if="isEditTitle" ref="nodeTitle" v-model="form.nodeName" clearable @blur="saveTitle" @keyup.enter="saveTitle" />
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
<el-container>
|
|
72
|
+
<el-main style="padding: 0 20px 20px 20px" class="condition-drawer">
|
|
73
|
+
<template v-if="isDefaultBranch">
|
|
74
|
+
<el-alert
|
|
75
|
+
:title="isParallel ? '并行分支直接执行该分支内的节点' : '以上条件都不满足时进入当前分支'"
|
|
76
|
+
:type="isParallel ? 'info' : 'warning'"
|
|
77
|
+
:closable="false"
|
|
78
|
+
show-icon
|
|
79
|
+
/>
|
|
80
|
+
</template>
|
|
81
|
+
<template v-else-if="isParallel">
|
|
82
|
+
<el-alert title="并行分支无需设置条件,全部并行分支执行完成后汇聚到后续节点" type="info" :closable="false" show-icon />
|
|
83
|
+
</template>
|
|
84
|
+
<template v-else>
|
|
85
|
+
<div class="top-tips">满足以下条件时进入当前分支</div>
|
|
86
|
+
<template v-for="(conditionGroup, groupIndex) in form.conditionGroups" :key="groupIndex">
|
|
87
|
+
<div class="or-branch-link-tip" v-if="groupIndex != 0">或满足</div>
|
|
88
|
+
<div class="condition-group-editor">
|
|
89
|
+
<div class="header">
|
|
90
|
+
<span>条件组 {{ groupIndex + 1 }}</span>
|
|
91
|
+
<div @click="deleteConditionGroup(groupIndex)">
|
|
92
|
+
<el-icon class="branch-delete-icon"><Delete /></el-icon>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
<div class="main-content">
|
|
96
|
+
<div class="condition-content-box cell-box">
|
|
97
|
+
<div>描述</div>
|
|
98
|
+
<div>条件字段</div>
|
|
99
|
+
<div>运算符</div>
|
|
100
|
+
<div>值</div>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="condition-content" v-for="(condition, idx) in conditionGroup" :key="idx">
|
|
103
|
+
<div class="condition-relation">
|
|
104
|
+
<span>{{ idx == 0 ? '当' : '且' }}</span>
|
|
105
|
+
<div @click="deleteConditionList(conditionGroup, idx)">
|
|
106
|
+
<el-icon class="branch-delete-icon"><Delete /></el-icon>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<div class="condition-content">
|
|
110
|
+
<div class="condition-content-box">
|
|
111
|
+
<el-input v-model="condition.variableName" placeholder="描述" />
|
|
112
|
+
<el-select
|
|
113
|
+
v-model="condition.variable"
|
|
114
|
+
placeholder="条件字段"
|
|
115
|
+
filterable
|
|
116
|
+
clearable
|
|
117
|
+
@change="(value) => changeVariable(condition, value)"
|
|
118
|
+
>
|
|
119
|
+
<el-option
|
|
120
|
+
v-for="variable in formVariables"
|
|
121
|
+
:key="variable.variableName"
|
|
122
|
+
:label="`${variable.label} (${variable.variableName})`"
|
|
123
|
+
:value="variable.variableName"
|
|
124
|
+
/>
|
|
125
|
+
</el-select>
|
|
126
|
+
<el-select v-model="condition.operator" placeholder="运算符">
|
|
127
|
+
<el-option
|
|
128
|
+
v-for="operator in operatorsFor(condition.variable)"
|
|
129
|
+
:key="operator.value"
|
|
130
|
+
:label="operator.label"
|
|
131
|
+
:value="operator.value"
|
|
132
|
+
/>
|
|
133
|
+
</el-select>
|
|
134
|
+
<template v-if="needsValue(condition.operator)">
|
|
135
|
+
<el-select
|
|
136
|
+
v-if="controlOf(condition.variable) === 'options' || controlOf(condition.variable) === 'array'"
|
|
137
|
+
v-model="condition.value"
|
|
138
|
+
:multiple="controlOf(condition.variable) === 'array'"
|
|
139
|
+
placeholder="值"
|
|
140
|
+
clearable
|
|
141
|
+
>
|
|
142
|
+
<el-option
|
|
143
|
+
v-for="option in optionsOf(condition.variable)"
|
|
144
|
+
:key="option.value"
|
|
145
|
+
:label="option.label"
|
|
146
|
+
:value="option.value"
|
|
147
|
+
/>
|
|
148
|
+
</el-select>
|
|
149
|
+
<el-select v-else-if="controlOf(condition.variable) === 'boolean'" v-model="condition.value" placeholder="值">
|
|
150
|
+
<el-option label="是" :value="true" />
|
|
151
|
+
<el-option label="否" :value="false" />
|
|
152
|
+
</el-select>
|
|
153
|
+
<el-input-number
|
|
154
|
+
v-else-if="controlOf(condition.variable) === 'number'"
|
|
155
|
+
v-model="condition.value"
|
|
156
|
+
:precision="isInteger(condition.variable) ? 0 : 2"
|
|
157
|
+
:step="isInteger(condition.variable) ? 1 : 0.1"
|
|
158
|
+
controls-position="right"
|
|
159
|
+
style="width: 100%"
|
|
160
|
+
/>
|
|
161
|
+
<el-date-picker
|
|
162
|
+
v-else-if="controlOf(condition.variable) === 'date' || controlOf(condition.variable) === 'datetime'"
|
|
163
|
+
v-model="condition.value"
|
|
164
|
+
:type="controlOf(condition.variable) === 'datetime' ? 'datetime' : 'date'"
|
|
165
|
+
:value-format="controlOf(condition.variable) === 'datetime' ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD'"
|
|
166
|
+
placeholder="值"
|
|
167
|
+
style="width: 100%"
|
|
168
|
+
/>
|
|
169
|
+
<el-input v-else v-model="condition.value" placeholder="值" />
|
|
170
|
+
</template>
|
|
171
|
+
<span v-else class="condition-empty-value" />
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
<div class="sub-content">
|
|
177
|
+
<el-button link type="primary" :icon="Plus" @click="addConditionList(conditionGroup)">添加条件</el-button>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</template>
|
|
181
|
+
<el-button type="info" style="width: 100%" :icon="Plus" text bg @click="addConditionGroup">添加条件组</el-button>
|
|
182
|
+
</template>
|
|
183
|
+
</el-main>
|
|
184
|
+
<el-footer>
|
|
185
|
+
<el-button type="primary" @click="save">保存</el-button>
|
|
186
|
+
<el-button @click="drawer = false">取消</el-button>
|
|
187
|
+
</el-footer>
|
|
188
|
+
</el-container>
|
|
189
|
+
</el-drawer>
|
|
190
|
+
</div>
|
|
191
|
+
</template>
|
|
192
|
+
|
|
193
|
+
<script setup>
|
|
194
|
+
import { computed, inject, ref, unref } from 'vue'
|
|
195
|
+
import { ArrowLeft, ArrowRight, Close, Delete, Edit, Plus } from '@element-plus/icons-vue'
|
|
196
|
+
import { ElMessage } from 'element-plus'
|
|
197
|
+
import AddNode from './AddNode.vue'
|
|
198
|
+
import NodeStatusBadge from '../NodeStatusBadge.vue'
|
|
199
|
+
import { FlowNodeType, generateNodeId } from '../../core/flow/index.js'
|
|
200
|
+
import {
|
|
201
|
+
conditionsFromGroups,
|
|
202
|
+
getValueControl,
|
|
203
|
+
getVariableOptions,
|
|
204
|
+
groupsFromConditions,
|
|
205
|
+
isIntegerVariable,
|
|
206
|
+
needsValue,
|
|
207
|
+
operatorsForVariable,
|
|
208
|
+
summarizeConditions
|
|
209
|
+
} from '../conditionHelpers.js'
|
|
210
|
+
|
|
211
|
+
defineOptions({ name: 'ScBranchNode' })
|
|
212
|
+
|
|
213
|
+
const props = defineProps({
|
|
214
|
+
modelValue: { type: Object, required: true },
|
|
215
|
+
parentNode: { type: Object, default: null },
|
|
216
|
+
formVariables: { type: Array, default: () => [] }
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
const emit = defineEmits(['update:modelValue'])
|
|
220
|
+
|
|
221
|
+
const readonly = inject('scReadonly', ref(false))
|
|
222
|
+
const statusMap = inject('scStatusMap', ref(null))
|
|
223
|
+
const injectedVariables = inject('scFormVariables', ref([]))
|
|
224
|
+
const formVariables = computed(() =>
|
|
225
|
+
props.formVariables?.length ? props.formVariables : injectedVariables.value || []
|
|
226
|
+
)
|
|
227
|
+
const isReadonly = computed(() => readonly.value === true)
|
|
228
|
+
const nodeConfig = computed(() => props.modelValue)
|
|
229
|
+
const statusFor = (nodeId) => {
|
|
230
|
+
const map = statusMap ? unref(statusMap) : null
|
|
231
|
+
return map && nodeId !== null && nodeId !== undefined ? map[String(nodeId)] || null : null
|
|
232
|
+
}
|
|
233
|
+
const groupStatus = computed(() => statusFor(nodeConfig.value.nodeId))
|
|
234
|
+
const branchStatus = (branch) => statusFor(branch.nodeId)
|
|
235
|
+
const branchStatusClass = (branch) => {
|
|
236
|
+
const status = branchStatus(branch)
|
|
237
|
+
if (!status) return ''
|
|
238
|
+
return [`is-${status.status}`, status.selected === false ? 'is-unselected' : 'is-selected']
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const isParallel = computed(() => nodeConfig.value.type === FlowNodeType.PARALLEL)
|
|
242
|
+
const isInclusive = computed(() => nodeConfig.value.type === FlowNodeType.INCLUSIVE)
|
|
243
|
+
const addBranchLabel = computed(() => (isParallel.value ? '添加分支' : '添加条件'))
|
|
244
|
+
const placeholderText = computed(() => {
|
|
245
|
+
if (isParallel.value) return '此分支将并行执行'
|
|
246
|
+
return '请设置条件'
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
const drawer = ref(false)
|
|
250
|
+
const isEditTitle = ref(false)
|
|
251
|
+
const nodeTitle = ref(null)
|
|
252
|
+
const editingIndex = ref(0)
|
|
253
|
+
const form = ref({})
|
|
254
|
+
|
|
255
|
+
const editingItem = computed(() => nodeConfig.value.branchList?.[editingIndex.value] || {})
|
|
256
|
+
const isDefaultBranch = computed(() =>
|
|
257
|
+
isParallel.value ? false : !!editingItem.value.isDefaultCondition || !!editingItem.value.isDefaultBranch
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
const updateNode = (next) => {
|
|
261
|
+
emit('update:modelValue', next)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const updateChild = (child) => {
|
|
265
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
266
|
+
next.childNode = child
|
|
267
|
+
updateNode(next)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const updateBranchChild = (index, child) => {
|
|
271
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
272
|
+
next.branchList[index].childNode = child
|
|
273
|
+
updateNode(next)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const show = (index) => {
|
|
277
|
+
if (isReadonly.value) return
|
|
278
|
+
editingIndex.value = index
|
|
279
|
+
const item = nodeConfig.value.branchList[index]
|
|
280
|
+
form.value = {
|
|
281
|
+
nodeName: item.nodeName,
|
|
282
|
+
conditionGroups: groupsFromConditions(item.conditions)
|
|
283
|
+
}
|
|
284
|
+
isEditTitle.value = false
|
|
285
|
+
drawer.value = true
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const editTitle = () => {
|
|
289
|
+
isEditTitle.value = true
|
|
290
|
+
requestAnimationFrame(() => nodeTitle.value?.focus())
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const saveTitle = () => {
|
|
294
|
+
isEditTitle.value = false
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const save = () => {
|
|
298
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
299
|
+
const item = next.branchList[editingIndex.value]
|
|
300
|
+
item.nodeName = form.value.nodeName
|
|
301
|
+
if (!isDefaultBranch.value) {
|
|
302
|
+
item.conditions = conditionsFromGroups(form.value.conditionGroups).filter(
|
|
303
|
+
(condition) => condition.variable || condition.value !== '' || condition.variableName
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
updateNode(next)
|
|
307
|
+
drawer.value = false
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const addTerm = () => {
|
|
311
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
312
|
+
const list = next.branchList || (next.branchList = [])
|
|
313
|
+
if (isParallel.value) {
|
|
314
|
+
list.push({
|
|
315
|
+
nodeId: generateNodeId(),
|
|
316
|
+
nodeName: `分支${list.length + 1}`,
|
|
317
|
+
type: FlowNodeType.PARALLEL_BRANCH,
|
|
318
|
+
branchIndex: list.length,
|
|
319
|
+
childNode: null
|
|
320
|
+
})
|
|
321
|
+
} else if (isInclusive.value) {
|
|
322
|
+
const defaultIndex = list.findIndex((item) => item.isDefaultBranch)
|
|
323
|
+
const normalCount = list.filter((item) => !item.isDefaultBranch).length
|
|
324
|
+
const branch = {
|
|
325
|
+
nodeId: generateNodeId(),
|
|
326
|
+
nodeName: `条件${normalCount + 1}`,
|
|
327
|
+
type: FlowNodeType.INCLUSIVE_BRANCH,
|
|
328
|
+
branchIndex: 0,
|
|
329
|
+
conditions: [],
|
|
330
|
+
isDefaultBranch: false,
|
|
331
|
+
childNode: null
|
|
332
|
+
}
|
|
333
|
+
if (defaultIndex >= 0) list.splice(defaultIndex, 0, branch)
|
|
334
|
+
else list.push(branch)
|
|
335
|
+
} else {
|
|
336
|
+
const defaultIndex = list.findIndex((item) => item.isDefaultCondition)
|
|
337
|
+
const normalCount = list.filter((item) => !item.isDefaultCondition).length
|
|
338
|
+
const branch = {
|
|
339
|
+
nodeId: generateNodeId(),
|
|
340
|
+
nodeName: `条件${normalCount + 1}`,
|
|
341
|
+
type: FlowNodeType.CONDITION,
|
|
342
|
+
conditions: [],
|
|
343
|
+
isDefaultCondition: false,
|
|
344
|
+
childNode: null
|
|
345
|
+
}
|
|
346
|
+
if (defaultIndex >= 0) list.splice(defaultIndex, 0, branch)
|
|
347
|
+
else list.push(branch)
|
|
348
|
+
}
|
|
349
|
+
list.forEach((item, index) => {
|
|
350
|
+
if (item.type === FlowNodeType.PARALLEL_BRANCH || item.type === FlowNodeType.INCLUSIVE_BRANCH) {
|
|
351
|
+
item.branchIndex = index
|
|
352
|
+
}
|
|
353
|
+
})
|
|
354
|
+
updateNode(next)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const delTerm = (index) => {
|
|
358
|
+
if (isReadonly.value) return
|
|
359
|
+
const list = nodeConfig.value.branchList
|
|
360
|
+
const item = list[index]
|
|
361
|
+
if (item.isDefaultCondition || item.isDefaultBranch) {
|
|
362
|
+
ElMessage.warning('默认分支不能删除')
|
|
363
|
+
return
|
|
364
|
+
}
|
|
365
|
+
if (!isParallel.value && !isInclusive.value && list.length <= 1) {
|
|
366
|
+
ElMessage.warning('至少需要保留一个条件分支')
|
|
367
|
+
return
|
|
368
|
+
}
|
|
369
|
+
if ((isParallel.value || isInclusive.value) && list.length <= 2) {
|
|
370
|
+
ElMessage.warning('至少需要保留两个分支')
|
|
371
|
+
return
|
|
372
|
+
}
|
|
373
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
374
|
+
next.branchList.splice(index, 1)
|
|
375
|
+
next.branchList.forEach((branch, branchIndex) => {
|
|
376
|
+
if (branch.type === FlowNodeType.PARALLEL_BRANCH || branch.type === FlowNodeType.INCLUSIVE_BRANCH) {
|
|
377
|
+
branch.branchIndex = branchIndex
|
|
378
|
+
}
|
|
379
|
+
})
|
|
380
|
+
updateNode(next)
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const arrTransfer = (index, type = 1) => {
|
|
384
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
385
|
+
const list = next.branchList
|
|
386
|
+
list[index] = list.splice(index + type, 1, list[index])[0]
|
|
387
|
+
list.forEach((item, itemIndex) => {
|
|
388
|
+
item.branchIndex = itemIndex
|
|
389
|
+
})
|
|
390
|
+
updateNode(next)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const addConditionList = (group) => {
|
|
394
|
+
group.push({ variable: '', variableName: '', operator: '==', value: '', logic: 'AND' })
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const deleteConditionList = (group, index) => {
|
|
398
|
+
group.splice(index, 1)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const addConditionGroup = () => {
|
|
402
|
+
form.value.conditionGroups.push([])
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const deleteConditionGroup = (index) => {
|
|
406
|
+
form.value.conditionGroups.splice(index, 1)
|
|
407
|
+
if (form.value.conditionGroups.length === 0) form.value.conditionGroups.push([])
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const changeVariable = (condition, variableName) => {
|
|
411
|
+
const variable = formVariables.value.find((item) => item.variableName === variableName)
|
|
412
|
+
if (!variable) {
|
|
413
|
+
condition.variableName = ''
|
|
414
|
+
return
|
|
415
|
+
}
|
|
416
|
+
condition.variableName = variable.label
|
|
417
|
+
const control = getValueControl(formVariables.value, variableName)
|
|
418
|
+
if (control === 'number') condition.value = undefined
|
|
419
|
+
else if (control === 'array') condition.value = []
|
|
420
|
+
else if (control === 'boolean') condition.value = true
|
|
421
|
+
else condition.value = ''
|
|
422
|
+
const operators = operatorsForVariable(formVariables.value, variableName)
|
|
423
|
+
if (!operators.some((operator) => operator.value === condition.operator)) {
|
|
424
|
+
condition.operator = operators[0]?.value || '=='
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const controlOf = (variableName) => getValueControl(formVariables.value, variableName)
|
|
429
|
+
const optionsOf = (variableName) => getVariableOptions(formVariables.value, variableName)
|
|
430
|
+
const isInteger = (variableName) => isIntegerVariable(formVariables.value, variableName)
|
|
431
|
+
const operatorsFor = (variableName) => operatorsForVariable(formVariables.value, variableName)
|
|
432
|
+
|
|
433
|
+
const toText = (item, index) => {
|
|
434
|
+
if (isParallel.value) return false
|
|
435
|
+
const isDefault = item.isDefaultCondition || item.isDefaultBranch
|
|
436
|
+
if (isDefault) {
|
|
437
|
+
return index === nodeConfig.value.branchList.length - 1 ? '其他条件进入此流程' : false
|
|
438
|
+
}
|
|
439
|
+
const text = summarizeConditions(formVariables.value, item.conditions)
|
|
440
|
+
return text || false
|
|
441
|
+
}
|
|
442
|
+
</script>
|