Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6be64a21
authored
Feb 17, 2025
by
jason
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能优化】触发器添加条件
parent
425e66b0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
386 additions
and
66 deletions
+386
-66
src/components/SimpleProcessDesignerV2/src/consts.ts
+8
-2
src/components/SimpleProcessDesignerV2/src/node.ts
+65
-2
src/components/SimpleProcessDesignerV2/src/nodes-config/ConditionNodeConfig.vue
+10
-62
src/components/SimpleProcessDesignerV2/src/nodes-config/TriggerNodeConfig.vue
+0
-0
src/components/SimpleProcessDesignerV2/src/nodes-config/components/ConditionDialog.vue
+303
-0
No files found.
src/components/SimpleProcessDesignerV2/src/consts.ts
View file @
6be64a21
...
@@ -735,7 +735,7 @@ export type RouterSetting = {
...
@@ -735,7 +735,7 @@ export type RouterSetting = {
export
type
TriggerSetting
=
{
export
type
TriggerSetting
=
{
type
:
TriggerTypeEnum
type
:
TriggerTypeEnum
httpRequestSetting
?:
HttpRequestTriggerSetting
httpRequestSetting
?:
HttpRequestTriggerSetting
normalFormSetting
?:
NormalFormTriggerSetting
formSettings
?:
FormTriggerSetting
[]
}
}
/**
/**
...
@@ -769,7 +769,13 @@ export type HttpRequestTriggerSetting = {
...
@@ -769,7 +769,13 @@ export type HttpRequestTriggerSetting = {
/**
/**
* 流程表单触发器配置结构定义
* 流程表单触发器配置结构定义
*/
*/
export
type
NormalFormTriggerSetting
=
{
export
type
FormTriggerSetting
=
{
// 条件类型
conditionType
?:
ConditionType
// 条件表达式
conditionExpression
?:
string
// 条件组
conditionGroups
?:
ConditionGroup
// 更新表单字段
// 更新表单字段
updateFormFields
?:
Record
<
string
,
any
>
updateFormFields
?:
Record
<
string
,
any
>
}
}
...
...
src/components/SimpleProcessDesignerV2/src/node.ts
View file @
6be64a21
...
@@ -15,7 +15,10 @@ import {
...
@@ -15,7 +15,10 @@ import {
AssignEmptyHandlerType
,
AssignEmptyHandlerType
,
FieldPermissionType
,
FieldPermissionType
,
HttpRequestParam
,
HttpRequestParam
,
ProcessVariableEnum
ProcessVariableEnum
,
ConditionType
,
ConditionGroup
,
COMPARISON_OPERATORS
}
from
'./consts'
}
from
'./consts'
import
{
parseFormFields
}
from
'@/components/FormCreate/src/utils'
import
{
parseFormFields
}
from
'@/components/FormCreate/src/utils'
...
@@ -543,6 +546,66 @@ export function useTaskStatusClass(taskStatus: TaskStatusEnum | undefined): stri
...
@@ -543,6 +546,66 @@ export function useTaskStatusClass(taskStatus: TaskStatusEnum | undefined): stri
if (taskStatus === TaskStatusEnum.CANCEL) {
if (taskStatus === TaskStatusEnum.CANCEL) {
return 'status-cancel'
return 'status-cancel'
}
}
return ''
return ''
}
}
/** 条件组件文字展示 */
export function getConditionShowText(
conditonType: ConditionType | undefined,
conditionExpression: string | undefined,
conditionGroups: ConditionGroup | undefined,
fieldOptions: Array<Record<string, any>>
) {
let showText = ''
if (conditonType === ConditionType.EXPRESSION) {
if (conditionExpression) {
showText = `
表达式:
$
{
conditionExpression
}
`
}
}
if (conditonType === ConditionType.RULE) {
// 条件组是否为与关系
const groupAnd = conditionGroups?.and
let warningMesg: undefined | string = undefined
const conditionGroup = conditionGroups?.conditions.map((item) => {
return (
'(' +
item.rules
.map((rule) => {
if (rule.leftSide && rule.rightSide) {
return (
getFormFieldTitle(fieldOptions, rule.leftSide) +
' ' +
getOpName(rule.opCode) +
' ' +
rule.rightSide
)
} else {
// 有一条规则不完善。提示错误
warningMesg = '请完善条件规则'
return ''
}
})
.join(item.and ? ' 且 ' : ' 或 ') +
' ) '
)
})
if (warningMesg) {
showText = ''
} else {
showText = conditionGroup!.join(groupAnd ? ' 且 ' : ' 或 ')
}
}
return showText
}
/** 获取表单字段名称*/
const getFormFieldTitle = (fieldOptions: Array<Record<string, any>>, field: string) => {
const item = fieldOptions.find((item) => item.field === field)
return item?.title
}
/** 获取操作符名称 */
const getOpName = (opCode: string): string => {
const opName = COMPARISON_OPERATORS.find((item: any) => item.value === opCode)
return opName?.label
}
src/components/SimpleProcessDesignerV2/src/nodes-config/ConditionNodeConfig.vue
View file @
6be64a21
...
@@ -43,13 +43,9 @@
...
@@ -43,13 +43,9 @@
</el-drawer>
</el-drawer>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
import
{
SimpleFlowNode
,
ConditionType
}
from
'../consts'
SimpleFlowNode
,
ConditionType
,
COMPARISON_OPERATORS
,
}
from
'../consts'
import
{
getDefaultConditionNodeName
}
from
'../utils'
import
{
getDefaultConditionNodeName
}
from
'../utils'
import
{
useFormFieldsAndStartUser
}
from
'../node'
import
{
useFormFieldsAndStartUser
,
getConditionShowText
}
from
'../node'
import
Condition
from
'./components/Condition.vue'
import
Condition
from
'./components/Condition.vue'
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
defineOptions
({
defineOptions
({
...
@@ -93,8 +89,6 @@ const blurEvent = () => {
...
@@ -93,8 +89,6 @@ const blurEvent = () => {
getDefaultConditionNodeName
(
props
.
nodeIndex
,
currentNode
.
value
?.
conditionSetting
?.
defaultFlow
)
getDefaultConditionNodeName
(
props
.
nodeIndex
,
currentNode
.
value
?.
conditionSetting
?.
defaultFlow
)
}
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
// 关闭
// 关闭
...
@@ -110,6 +104,8 @@ const handleClose = async (done: (cancel?: boolean) => void) => {
...
@@ -110,6 +104,8 @@ const handleClose = async (done: (cancel?: boolean) => void) => {
done
()
done
()
}
}
}
}
// 流程表单字段和发起人字段
const
fieldOptions
=
useFormFieldsAndStartUser
()
const
conditionRef
=
ref
()
const
conditionRef
=
ref
()
// 保存配置
// 保存配置
...
@@ -118,7 +114,12 @@ const saveConfig = async () => {
...
@@ -118,7 +114,12 @@ const saveConfig = async () => {
// 校验表单
// 校验表单
const
valid
=
await
conditionRef
.
value
.
validate
()
const
valid
=
await
conditionRef
.
value
.
validate
()
if
(
!
valid
)
return
false
if
(
!
valid
)
return
false
const
showText
=
getShowText
()
const
showText
=
getConditionShowText
(
condition
.
value
?.
conditionType
,
condition
.
value
?.
conditionExpression
,
condition
.
value
.
conditionGroups
,
fieldOptions
)
if
(
!
showText
)
{
if
(
!
showText
)
{
return
false
return
false
}
}
...
@@ -136,59 +137,6 @@ const saveConfig = async () => {
...
@@ -136,59 +137,6 @@ const saveConfig = async () => {
settingVisible
.
value
=
false
settingVisible
.
value
=
false
return
true
return
true
}
}
const
getShowText
=
():
string
=>
{
let
showText
=
''
if
(
condition
.
value
?.
conditionType
===
ConditionType
.
EXPRESSION
)
{
if
(
condition
.
value
.
conditionExpression
)
{
showText
=
`表达式:
${
condition
.
value
.
conditionExpression
}
`
}
}
if
(
condition
.
value
?.
conditionType
===
ConditionType
.
RULE
)
{
// 条件组是否为与关系
const
groupAnd
=
condition
.
value
.
conditionGroups
?.
and
let
warningMesg
:
undefined
|
string
=
undefined
const
conditionGroup
=
condition
.
value
.
conditionGroups
?.
conditions
.
map
((
item
)
=>
{
return
(
'('
+
item
.
rules
.
map
((
rule
)
=>
{
if
(
rule
.
leftSide
&&
rule
.
rightSide
)
{
return
(
getFieldTitle
(
rule
.
leftSide
)
+
' '
+
getOpName
(
rule
.
opCode
)
+
' '
+
rule
.
rightSide
)
}
else
{
// 有一条规则不完善。提示错误
warningMesg
=
'请完善条件规则'
return
''
}
})
.
join
(
item
.
and
?
' 且 '
:
' 或 '
)
+
' ) '
)
})
if
(
warningMesg
)
{
message
.
warning
(
warningMesg
)
showText
=
''
}
else
{
showText
=
conditionGroup
!
.
join
(
groupAnd
?
' 且 '
:
' 或 '
)
}
}
return
showText
}
// 流程表单字段和发起人字段
const
fieldOptions
=
useFormFieldsAndStartUser
()
/** 获取字段名称 */
const
getFieldTitle
=
(
field
:
string
)
=>
{
const
item
=
fieldOptions
.
find
((
item
)
=>
item
.
field
===
field
)
return
item
?.
title
}
/** 获取操作符名称 */
const
getOpName
=
(
opCode
:
string
):
string
=>
{
const
opName
=
COMPARISON_OPERATORS
.
find
((
item
:
any
)
=>
item
.
value
===
opCode
)
return
opName
?.
label
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
...
...
src/components/SimpleProcessDesignerV2/src/nodes-config/TriggerNodeConfig.vue
View file @
6be64a21
This diff is collapsed.
Click to expand it.
src/components/SimpleProcessDesignerV2/src/nodes-config/components/ConditionDialog.vue
0 → 100644
View file @
6be64a21
<
template
>
<Dialog
v-model=
"dialogVisible"
title=
"条件配置"
width=
"600px"
:fullscreen=
"false"
>
<div
class=
"h-410px"
>
<el-scrollbar
wrap-class=
"h-full"
>
<el-form
ref=
"formRef"
:model=
"condition"
:rules=
"formRules"
label-position=
"top"
>
<el-form-item
label=
"配置方式"
prop=
"conditionType"
>
<el-radio-group
v-model=
"condition.conditionType"
@
change=
"changeConditionType"
>
<el-radio
v-for=
"(dict, indexConditionType) in conditionConfigTypes"
:key=
"indexConditionType"
:value=
"dict.value"
:label=
"dict.value"
>
{{
dict
.
label
}}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
v-if=
"condition.conditionType === ConditionType.RULE && condition.conditionGroups"
label=
"条件规则"
>
<div
class=
"condition-group-tool"
>
<div
class=
"flex items-center"
>
<div
class=
"mr-4"
>
条件组关系
</div>
<el-switch
v-model=
"condition.conditionGroups.and"
inline-prompt
active-text=
"且"
inactive-text=
"或"
/>
</div>
</div>
<el-space
direction=
"vertical"
:spacer=
"condition.conditionGroups.and ? '且' : '或'"
>
<el-card
class=
"condition-group"
style=
"width: 530px"
v-for=
"(equation, cIdx) in condition.conditionGroups.conditions"
:key=
"cIdx"
>
<div
class=
"condition-group-delete"
v-if=
"condition.conditionGroups.conditions.length > 1"
>
<Icon
color=
"#0089ff"
icon=
"ep:circle-close-filled"
:size=
"18"
@
click=
"deleteConditionGroup(condition.conditionGroups.conditions, cIdx)"
/>
</div>
<template
#
header
>
<div
class=
"flex items-center justify-between"
>
<div>
条件组
</div>
<div
class=
"flex"
>
<div
class=
"mr-4"
>
规则关系
</div>
<el-switch
v-model=
"equation.and"
inline-prompt
active-text=
"且"
inactive-text=
"或"
/>
</div>
</div>
</
template
>
<div
class=
"flex pt-2"
v-for=
"(rule, rIdx) in equation.rules"
:key=
"rIdx"
>
<div
class=
"mr-2"
>
<el-form-item
:prop=
"`conditionGroups.conditions.${cIdx}.rules.${rIdx}.leftSide`"
:rules=
"{
required: true,
message: '左值不能为空',
trigger: 'change'
}"
>
<el-select
style=
"width: 160px"
v-model=
"rule.leftSide"
>
<el-option
v-for=
"(field, fIdx) in fieldOptions"
:key=
"fIdx"
:label=
"field.title"
:value=
"field.field"
:disabled=
"!field.required"
/>
</el-select>
</el-form-item>
</div>
<div
class=
"mr-2"
>
<el-select
v-model=
"rule.opCode"
style=
"width: 100px"
>
<el-option
v-for=
"operator in COMPARISON_OPERATORS"
:key=
"operator.value"
:label=
"operator.label"
:value=
"operator.value"
/>
</el-select>
</div>
<div
class=
"mr-2"
>
<el-form-item
:prop=
"`conditionGroups.conditions.${cIdx}.rules.${rIdx}.rightSide`"
:rules=
"{
required: true,
message: '右值不能为空',
trigger: 'blur'
}"
>
<el-input
v-model=
"rule.rightSide"
style=
"width: 160px"
/>
</el-form-item>
</div>
<div
class=
"cursor-pointer mr-1 flex items-center"
v-if=
"equation.rules.length > 1"
>
<Icon
icon=
"ep:delete"
:size=
"18"
@
click=
"deleteConditionRule(equation, rIdx)"
/>
</div>
<div
class=
"cursor-pointer flex items-center"
>
<Icon
icon=
"ep:plus"
:size=
"18"
@
click=
"addConditionRule(equation, rIdx)"
/>
</div>
</div>
</el-card>
</el-space>
<div
title=
"添加条件组"
class=
"mt-4 cursor-pointer"
>
<Icon
color=
"#0089ff"
icon=
"ep:plus"
:size=
"24"
@
click=
"addConditionGroup(condition.conditionGroups?.conditions)"
/>
</div>
</el-form-item>
<el-form-item
v-if=
"condition.conditionType === ConditionType.EXPRESSION"
label=
"条件表达式"
prop=
"conditionExpression"
>
<el-input
type=
"textarea"
v-model=
"condition.conditionExpression"
clearable
style=
"width: 100%"
/>
</el-form-item>
</el-form>
</el-scrollbar>
</div>
<
template
#
footer
>
<el-button
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
<el-button
@
click=
"dialogVisible = false"
>
取 消
</el-button>
</
template
>
</Dialog>
</template>
<
script
setup
lang=
"ts"
>
import
{
COMPARISON_OPERATORS
,
CONDITION_CONFIG_TYPES
,
ConditionType
,
ConditionGroup
,
DEFAULT_CONDITION_GROUP_VALUE
}
from
'../../consts'
import
{
BpmModelFormType
}
from
'@/utils/constants'
import
{
useFormFieldsAndStartUser
}
from
'../../node'
defineOptions
({
name
:
'ConditionDialog'
})
const
condition
=
ref
<
{
conditionType
:
ConditionType
conditionExpression
?:
string
conditionGroups
?:
ConditionGroup
}
>
({
conditionType
:
ConditionType
.
RULE
,
conditionGroups
:
DEFAULT_CONDITION_GROUP_VALUE
})
const
emit
=
defineEmits
<
{
updateCondition
:
[
condition
:
object
]
}
>
()
const
message
=
useMessage
()
// 消息弹窗
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
formType
=
inject
<
Ref
<
number
>>
(
'formType'
)
// 表单类型
const
conditionConfigTypes
=
computed
(()
=>
{
return
CONDITION_CONFIG_TYPES
.
filter
((
item
)
=>
{
// 业务表单暂时去掉条件规则选项
if
(
formType
?.
value
===
BpmModelFormType
.
CUSTOM
&&
item
.
value
===
ConditionType
.
RULE
)
{
return
false
}
else
{
return
true
}
})
})
/** 条件规则可选择的表单字段 */
const
fieldOptions
=
useFormFieldsAndStartUser
()
// 表单校验规则
const
formRules
=
reactive
({
conditionType
:
[{
required
:
true
,
message
:
'配置方式不能为空'
,
trigger
:
'blur'
}],
conditionExpression
:
[{
required
:
true
,
message
:
'条件表达式不能为空'
,
trigger
:
'blur'
}]
})
const
formRef
=
ref
()
// 表单 Ref
/** 切换条件配置方式 */
const
changeConditionType
=
()
=>
{
if
(
condition
.
value
.
conditionType
===
ConditionType
.
RULE
)
{
if
(
!
condition
.
value
.
conditionGroups
)
{
condition
.
value
.
conditionGroups
=
DEFAULT_CONDITION_GROUP_VALUE
}
}
}
const
deleteConditionGroup
=
(
conditions
,
index
)
=>
{
conditions
.
splice
(
index
,
1
)
}
const
deleteConditionRule
=
(
condition
,
index
)
=>
{
condition
.
rules
.
splice
(
index
,
1
)
}
const
addConditionRule
=
(
condition
,
index
)
=>
{
const
rule
=
{
opCode
:
'=='
,
leftSide
:
''
,
rightSide
:
''
}
condition
.
rules
.
splice
(
index
+
1
,
0
,
rule
)
}
const
addConditionGroup
=
(
conditions
)
=>
{
const
condition
=
{
and
:
true
,
rules
:
[
{
opCode
:
'=='
,
leftSide
:
''
,
rightSide
:
''
}
]
}
conditions
.
push
(
condition
)
}
/** 保存条件设置 */
const
submitForm
=
async
()
=>
{
// 校验表单
if
(
!
formRef
)
return
const
valid
=
await
formRef
.
value
.
validate
()
if
(
!
valid
)
{
message
.
warning
(
'请完善条件规则'
)
return
}
dialogVisible
.
value
=
false
// 设置完的条件传递给父组件
emit
(
'updateCondition'
,
condition
.
value
)
}
const
open
=
(
conditionObj
:
any
|
undefined
)
=>
{
if
(
conditionObj
)
{
condition
.
value
.
conditionType
=
conditionObj
.
conditionType
condition
.
value
.
conditionExpression
=
conditionObj
.
conditionExpression
condition
.
value
.
conditionGroups
=
conditionObj
.
conditionGroups
}
dialogVisible
.
value
=
true
}
defineExpose
({
open
})
</
script
>
<
style
lang=
"scss"
scoped
>
.condition-group-tool
{
display
:
flex
;
justify-content
:
space-between
;
width
:
500px
;
margin-bottom
:
20px
;
}
.condition-group
{
position
:
relative
;
&:hover
{
border-color
:
#0089ff
;
.condition-group-delete
{
opacity
:
1
;
}
}
.condition-group-delete
{
position
:
absolute
;
top
:
0
;
left
:
0
;
display
:
flex
;
cursor
:
pointer
;
opacity
:
0
;
}
}
::v-deep
(
.el-card__header
)
{
padding
:
8px
var
(
--el-card-padding
);
border-bottom
:
1px
solid
var
(
--el-card-border-color
);
box-sizing
:
border-box
;
}
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment