Skip to content

Commit 4680a7d

Browse files
committed
仿钉钉流程设计器, 条件节点修改
1 parent 4a2a7b7 commit 4680a7d

File tree

5 files changed

+44
-46
lines changed

5 files changed

+44
-46
lines changed

src/components/SimpleProcessDesignerV2/src/NodeHandler.vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,18 @@ const addNode = (type: number) => {
120120
showText: '',
121121
type: NodeType.CONDITION_NODE,
122122
childNode: undefined,
123-
attributes: {
124-
conditionType: 1,
125-
defaultFlow: false
126-
}
123+
conditionType: 1,
124+
defaultFlow: false
125+
127126
},
128127
{
129128
id: 'Flow_' + generateUUID(),
130129
name: '其它情况',
131130
showText: '其它情况进入此流程',
132131
type: NodeType.CONDITION_NODE,
133132
childNode: undefined,
134-
attributes: {
135-
conditionType: undefined,
136-
defaultFlow: true
137-
}
133+
conditionType: undefined,
134+
defaultFlow: true
138135
}
139136
]
140137
}

src/components/SimpleProcessDesignerV2/src/consts.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export interface SimpleFlowNode {
6262
type: NodeType
6363
name: string
6464
showText?: string
65-
attributes?: any
6665
// 孩子节点
6766
childNode?: SimpleFlowNode
6867
// 条件节点
@@ -89,6 +88,15 @@ export interface SimpleFlowNode {
8988
assignEmptyHandler?: AssignEmptyHandler
9089
// 审批节点的审批人与发起人相同时,对应的处理类型
9190
assignStartUserHandlerType?: number
91+
// 条件类型
92+
conditionType?: ConditionType
93+
// 条件表达式
94+
conditionExpression?: string
95+
// 条件组
96+
conditionGroups?: ConditionGroup
97+
// 是否默认的条件
98+
defaultFlow?: boolean
99+
92100
}
93101
// 候选人策略枚举 ( 用于审批节点。抄送节点 )
94102
export enum CandidateStrategy {
@@ -292,7 +300,7 @@ export enum TimeUnitType {
292300
}
293301

294302
// 条件配置类型 ( 用于条件节点配置 )
295-
export enum ConditionConfigType {
303+
export enum ConditionType {
296304
/**
297305
* 条件表达式
298306
*/
@@ -428,8 +436,8 @@ export const APPROVE_METHODS: DictDataVO[] = [
428436
]
429437

430438
export const CONDITION_CONFIG_TYPES: DictDataVO[] = [
431-
{ label: '条件表达式', value: 1 },
432-
{ label: '条件规则', value: 2 }
439+
{ label: '条件表达式', value: ConditionType.EXPRESSION },
440+
{ label: '条件规则', value: ConditionType.RULE }
433441
]
434442

435443
// 时间单位类型

src/components/SimpleProcessDesignerV2/src/nodes-config/ConditionNodeConfig.vue

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@
2626
</div>
2727
</template>
2828
<div>
29-
<div class="mb-3 text-size-sm" v-if="currentNode.attributes.defaultFlow"
30-
>其它条件不满足进入此分支(该分支不可编辑和删除)</div
31-
>
29+
<div class="mb-3 font-size-16px" v-if="currentNode.defaultFlow">其它条件不满足进入此分支(该分支不可编辑和删除)</div>
3230
<div v-else>
3331
<el-form
3432
ref="formRef"
35-
:model="currentNode.attributes"
33+
:model="currentNode"
3634
:rules="formRules"
3735
label-position="top"
3836
>
3937
<el-form-item label="配置方式" prop="conditionType">
4038
<el-radio-group
41-
v-model="currentNode.attributes.conditionType"
39+
v-model="currentNode.conditionType"
4240
@change="changeConditionType"
4341
>
4442
<el-radio
@@ -53,18 +51,18 @@
5351
</el-form-item>
5452

5553
<el-form-item
56-
v-if="currentNode.attributes.conditionType === 1"
54+
v-if="currentNode.conditionType === 1"
5755
label="条件表达式"
5856
prop="conditionExpression"
5957
>
6058
<el-input
6159
type="textarea"
62-
v-model="currentNode.attributes.conditionExpression"
60+
v-model="currentNode.conditionExpression"
6361
clearable
6462
style="width: 100%"
6563
/>
6664
</el-form-item>
67-
<el-form-item v-if="currentNode.attributes.conditionType === 2" label="条件规则">
65+
<el-form-item v-if="currentNode.conditionType === 2" label="条件规则">
6866
<div class="condition-group-tool">
6967
<div class="flex items-center">
7068
<div class="mr-4">条件组关系</div>
@@ -75,9 +73,6 @@
7573
inactive-text=""
7674
/>
7775
</div>
78-
<!-- <div class="flex items-center">
79-
<el-button size="small" type="primary">添加条件组</el-button>
80-
</div> -->
8176
</div>
8277
<el-space direction="vertical" :spacer="conditionGroups.and ? '且' : '或'">
8378
<el-card
@@ -166,7 +161,7 @@
166161
import {
167162
SimpleFlowNode,
168163
CONDITION_CONFIG_TYPES,
169-
ConditionConfigType,
164+
ConditionType,
170165
COMPARISON_OPERATORS,
171166
ConditionGroup,
172167
Condition,
@@ -183,7 +178,7 @@ const conditionConfigTypes = computed(() => {
183178
return CONDITION_CONFIG_TYPES.filter((item) => {
184179
// 业务表单暂时去掉条件规则选项
185180
if (formType?.value !== 10) {
186-
return item.value === 1
181+
return item.value === ConditionType.RULE
187182
} else {
188183
return true
189184
}
@@ -202,9 +197,9 @@ const props = defineProps({
202197
})
203198
const settingVisible = ref(false)
204199
const open = () => {
205-
if (currentNode.value.attributes.conditionType === ConditionConfigType.RULE) {
206-
if (currentNode.value.attributes.conditionGroups) {
207-
conditionGroups.value = currentNode.value.attributes.conditionGroups
200+
if (currentNode.value.conditionType === ConditionType.RULE) {
201+
if (currentNode.value.conditionGroups) {
202+
conditionGroups.value = currentNode.value.conditionGroups
208203
}
209204
}
210205
settingVisible.value = true
@@ -227,7 +222,7 @@ const blurEvent = () => {
227222
showInput.value = false
228223
currentNode.value.name =
229224
currentNode.value.name ||
230-
getDefaultConditionNodeName(props.nodeIndex, currentNode.value.attributes?.defaultFlow)
225+
getDefaultConditionNodeName(props.nodeIndex, currentNode.value?.defaultFlow)
231226
}
232227
233228
const currentNode = ref<SimpleFlowNode>(props.conditionNode)
@@ -256,7 +251,7 @@ const formRef = ref() // 表单 Ref
256251
257252
// 保存配置
258253
const saveConfig = async () => {
259-
if (!currentNode.value.attributes.defaultFlow) {
254+
if (!currentNode.value.defaultFlow) {
260255
// 校验表单
261256
if (!formRef) return false
262257
const valid = await formRef.value.validate()
@@ -266,25 +261,25 @@ const saveConfig = async () => {
266261
return false
267262
}
268263
currentNode.value.showText = showText
269-
if (currentNode.value.attributes.conditionType === ConditionConfigType.EXPRESSION) {
270-
currentNode.value.attributes.conditionGroups = undefined
264+
if (currentNode.value.conditionType === ConditionType.EXPRESSION) {
265+
currentNode.value.conditionGroups = undefined
271266
}
272-
if (currentNode.value.attributes.conditionType === ConditionConfigType.RULE) {
273-
currentNode.value.attributes.conditionExpression = undefined
274-
currentNode.value.attributes.conditionGroups = conditionGroups.value
267+
if (currentNode.value.conditionType === ConditionType.RULE) {
268+
currentNode.value.conditionExpression = undefined
269+
currentNode.value.conditionGroups = conditionGroups.value
275270
}
276271
}
277272
settingVisible.value = false
278273
return true
279274
}
280275
const getShowText = (): string => {
281276
let showText = ''
282-
if (currentNode.value.attributes.conditionType === ConditionConfigType.EXPRESSION) {
283-
if (currentNode.value.attributes.conditionExpression) {
284-
showText = `表达式:${currentNode.value.attributes.conditionExpression}`
277+
if (currentNode.value.conditionType === ConditionType.EXPRESSION) {
278+
if (currentNode.value.conditionExpression) {
279+
showText = `表达式:${currentNode.value.conditionExpression}`
285280
}
286281
}
287-
if (currentNode.value.attributes.conditionType === ConditionConfigType.RULE) {
282+
if (currentNode.value.conditionType === ConditionType.RULE) {
288283
// 条件组是否为与关系
289284
const groupAnd = conditionGroups.value.and
290285
let warningMesg: undefined | string = undefined
@@ -298,7 +293,7 @@ const getShowText = (): string => {
298293
getFieldTitle(rule.leftSide) + ' ' + getOpName(rule.opCode) + ' ' + rule.rightSide
299294
)
300295
} else {
301-
// 又一条规则不完善。提示错误
296+
// 有一条规则不完善。提示错误
302297
warningMesg = '请完善条件规则'
303298
return ''
304299
}

src/components/SimpleProcessDesignerV2/src/nodes/ExclusiveNode.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const blurEvent = (index: number) => {
130130
showInputs.value[index] = false
131131
const conditionNode = currentNode.value.conditionNodes?.at(index) as SimpleFlowNode
132132
conditionNode.name =
133-
conditionNode.name || getDefaultConditionNodeName(index, conditionNode.attributes?.defaultFlow)
133+
conditionNode.name || getDefaultConditionNodeName(index, conditionNode.defaultFlow)
134134
}
135135
136136
// 点击条件名称
@@ -156,10 +156,8 @@ const addCondition = () => {
156156
type: NodeType.CONDITION_NODE,
157157
childNode: undefined,
158158
conditionNodes: [],
159-
attributes: {
160-
conditionType: 1,
161-
defaultFlow: false
162-
}
159+
conditionType: 1,
160+
defaultFlow: false
163161
}
164162
conditionNodes.splice(lastIndex, 0, conditionData)
165163
}

src/components/SimpleProcessDesignerV2/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TimeUnitType, ApproveType, APPROVE_TYPE } from './consts'
22

33
// 获取条件节点默认的名称
4-
export const getDefaultConditionNodeName = (index: number, defaultFlow: boolean): string => {
4+
export const getDefaultConditionNodeName = (index: number, defaultFlow: boolean | undefined): string => {
55
if (defaultFlow) {
66
return '其它情况'
77
}

0 commit comments

Comments
 (0)