42
42
>
43
43
</div >
44
44
</template >
45
- <el-form-item label =" 配置方式" prop =" conditionType" >
46
- <el-radio-group v-model =" item.conditionType" @change =" changeConditionType" >
47
- <el-radio
48
- v-for =" (dict, indexConditionType) in conditionConfigTypes"
49
- :key =" indexConditionType"
50
- :value =" dict.value"
51
- :label =" dict.value"
52
- >
53
- {{ dict.label }}
54
- </el-radio >
55
- </el-radio-group >
56
- </el-form-item >
57
- <!-- TODO @lesan:1)1、2 使用枚举;2)默认先 条件组关系,再 条件表达式;3)这种可以封装成一个小组件么? -->
58
- <el-form-item
59
- v-if =" item.conditionType === 1"
60
- label =" 条件表达式"
61
- prop =" conditionExpression"
62
- >
63
- <el-input
64
- type =" textarea"
65
- v-model =" item.conditionExpression"
66
- clearable
67
- style =" width : 100% "
68
- />
69
- </el-form-item >
70
- <el-form-item v-if =" item.conditionType === 2" label =" 条件规则" >
71
- <div class =" condition-group-tool" >
72
- <div class =" flex items-center" >
73
- <div class =" mr-4" >条件组关系</div >
74
- <el-switch
75
- v-model =" item.conditionGroups.and"
76
- inline-prompt
77
- active-text =" 且"
78
- inactive-text =" 或"
79
- />
80
- </div >
81
- </div >
82
- <el-space direction =" vertical" :spacer =" item.conditionGroups.and ? '且' : '或'" >
83
- <el-card
84
- class =" condition-group"
85
- style =" width : 530px "
86
- v-for =" (condition, cIdx) in item.conditionGroups.conditions"
87
- :key =" cIdx"
88
- >
89
- <div
90
- class =" condition-group-delete"
91
- v-if =" item.conditionGroups.conditions.length > 1"
92
- >
93
- <Icon
94
- color =" #0089ff"
95
- icon =" ep:circle-close-filled"
96
- :size =" 18"
97
- @click =" deleteConditionGroup(item.conditionGroups.conditions, cIdx)"
98
- />
99
- </div >
100
- <template #header >
101
- <div class =" flex items-center justify-between" >
102
- <div >条件组</div >
103
- <div class =" flex" >
104
- <div class =" mr-4" >规则关系</div >
105
- <el-switch
106
- v-model =" condition.and"
107
- inline-prompt
108
- active-text =" 且"
109
- inactive-text =" 或"
110
- />
111
- </div >
112
- </div >
113
- </template >
114
-
115
- <div class =" flex pt-2" v-for =" (rule, rIdx) in condition.rules" :key =" rIdx" >
116
- <div class =" mr-2" >
117
- <el-select style =" width : 160px " v-model =" rule.leftSide" >
118
- <el-option
119
- v-for =" (field, fIdx) in fieldOptions"
120
- :key =" fIdx"
121
- :label =" field.title"
122
- :value =" field.field"
123
- :disabled =" !field.required"
124
- />
125
- </el-select >
126
- </div >
127
- <div class =" mr-2" >
128
- <el-select v-model =" rule.opCode" style =" width : 100px " >
129
- <el-option
130
- v-for =" operator in COMPARISON_OPERATORS"
131
- :key =" operator.value"
132
- :label =" operator.label"
133
- :value =" operator.value"
134
- />
135
- </el-select >
136
- </div >
137
- <div class =" mr-2" >
138
- <el-input v-model =" rule.rightSide" style =" width : 160px " />
139
- </div >
140
- <div class =" mr-1 flex items-center" v-if =" condition.rules.length > 1" >
141
- <Icon
142
- icon =" ep:delete"
143
- :size =" 18"
144
- @click =" deleteConditionRule(condition, rIdx)"
145
- />
146
- </div >
147
- <div class =" flex items-center" >
148
- <Icon icon =" ep:plus" :size =" 18" @click =" addConditionRule(condition, rIdx)" />
149
- </div >
150
- </div >
151
- </el-card >
152
- </el-space >
153
- <div title =" 添加条件组" class =" mt-4 cursor-pointer" >
154
- <Icon
155
- color =" #0089ff"
156
- icon =" ep:plus"
157
- :size =" 24"
158
- @click =" addConditionGroup(item.conditionGroups.conditions)"
159
- />
160
- </div >
161
- </el-form-item >
45
+ <Condition v-model =" routeGroups[index]" />
162
46
</el-card >
163
47
</el-form >
164
48
177
61
</template >
178
62
<script setup lang="ts">
179
63
import { Plus } from ' @element-plus/icons-vue'
180
- import {
181
- SimpleFlowNode ,
182
- NodeType ,
183
- CONDITION_CONFIG_TYPES ,
184
- ConditionType ,
185
- COMPARISON_OPERATORS ,
186
- RouteCondition ,
187
- ProcessVariableEnum
188
- } from ' ../consts'
64
+ import { SimpleFlowNode , NodeType , ConditionType , RouteCondition } from ' ../consts'
189
65
import { useWatchNode , useDrawer , useNodeName } from ' ../node'
190
- import { BpmModelFormType } from ' @/utils/constants'
191
- import { useFormFields } from ' ../node'
66
+ import Condition from ' ./components/Condition.vue'
192
67
defineOptions ({
193
68
name: ' RouteNodeConfig'
194
69
})
@@ -206,28 +81,6 @@ const { settingVisible, closeDrawer, openDrawer } = useDrawer()
206
81
const currentNode = useWatchNode (props )
207
82
// 节点名称
208
83
const { nodeName, showInput, clickIcon, blurEvent } = useNodeName (NodeType .ROUTE_BRANCH_NODE )
209
- const formType = inject <Ref <number >>(' formType' ) // 表单类型
210
- const conditionConfigTypes = computed (() => {
211
- return CONDITION_CONFIG_TYPES .filter ((item ) => {
212
- // 业务表单暂时去掉条件规则选项
213
- if (formType ?.value === BpmModelFormType .CUSTOM && item .value === ConditionType .RULE ) {
214
- return false
215
- } else {
216
- return true
217
- }
218
- })
219
- })
220
- /** 条件规则可选择的表单字段 */
221
- const fieldOptions = computed (() => {
222
- const fieldsCopy = useFormFields ().slice ()
223
- // 固定添加发起人 ID 字段
224
- fieldsCopy .unshift ({
225
- field: ProcessVariableEnum .START_USER_ID ,
226
- title: ' 发起人' ,
227
- required: true
228
- })
229
- return fieldsCopy
230
- })
231
84
const routeGroups = ref <RouteCondition []>([])
232
85
const nodeOptions = ref ()
233
86
@@ -279,48 +132,10 @@ const getShowText = () => {
279
132
return ` ${routeGroups .value .length }条路由分支 `
280
133
}
281
134
282
- // TODO @lesan:这个需要实现么?
283
- const changeConditionType = () => {}
284
-
285
- const deleteConditionGroup = (conditions , index ) => {
286
- conditions .splice (index , 1 )
287
- }
288
-
289
- const deleteConditionRule = (condition , index ) => {
290
- condition .rules .splice (index , 1 )
291
- }
292
-
293
- const addConditionRule = (condition , index ) => {
294
- const rule = {
295
- type: 1 ,
296
- opName: ' 等于' ,
297
- opCode: ' ==' ,
298
- leftSide: ' ' ,
299
- rightSide: ' '
300
- }
301
- condition .rules .splice (index + 1 , 0 , rule )
302
- }
303
-
304
- const addConditionGroup = (conditions ) => {
305
- const condition = {
306
- and: true ,
307
- rules: [
308
- {
309
- type: 1 ,
310
- opName: ' 等于' ,
311
- opCode: ' ==' ,
312
- leftSide: ' ' ,
313
- rightSide: ' '
314
- }
315
- ]
316
- }
317
- conditions .push (condition )
318
- }
319
-
320
135
const addRouteGroup = () => {
321
136
routeGroups .value .push ({
322
137
nodeId: ' ' ,
323
- conditionType: ConditionType .EXPRESSION ,
138
+ conditionType: ConditionType .RULE ,
324
139
conditionExpression: ' ' ,
325
140
conditionGroups: {
326
141
and: true ,
@@ -347,7 +162,7 @@ const deleteRouteGroup = (index) => {
347
162
}
348
163
349
164
const getRoutableNode = () => {
350
- // TODO 还需要满足以下要求
165
+ // TODO @lesan 还需要满足以下要求
351
166
// 并行分支、包容分支内部节点不能跳转到外部节点
352
167
// 条件分支节点可以向上跳转到外部节点
353
168
let node = processNodeTree ?.value
@@ -369,39 +184,3 @@ const getRoutableNode = () => {
369
184
370
185
defineExpose ({ openDrawer , showRouteNodeConfig }) // 暴露方法给父组件
371
186
</script >
372
-
373
- <style lang="scss" scoped>
374
- .condition-group-tool {
375
- display : flex ;
376
- justify-content : space-between ;
377
- width : 500px ;
378
- margin-bottom : 20px ;
379
- }
380
-
381
- .condition-group {
382
- position : relative ;
383
-
384
- & :hover {
385
- border-color : #0089ff ;
386
-
387
- .condition-group-delete {
388
- opacity : 1 ;
389
- }
390
- }
391
-
392
- .condition-group-delete {
393
- position : absolute ;
394
- top : 0 ;
395
- left : 0 ;
396
- display : flex ;
397
- cursor : pointer ;
398
- opacity : 0 ;
399
- }
400
- }
401
-
402
- ::v-deep(.el-card__header ) {
403
- padding : 8px var (--el-card-padding );
404
- border-bottom : 1px solid var (--el-card-border-color );
405
- box-sizing : border-box ;
406
- }
407
- </style >
0 commit comments