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
e32fc81d
authored
Feb 07, 2025
by
jason
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能新增】新增修改表单数据触发器
parent
5e801a8e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
9 deletions
+135
-9
src/components/SimpleProcessDesignerV2/src/consts.ts
+17
-3
src/components/SimpleProcessDesignerV2/src/nodes-config/TriggerNodeConfig.vue
+118
-6
No files found.
src/components/SimpleProcessDesignerV2/src/consts.ts
View file @
e32fc81d
...
@@ -716,7 +716,8 @@ export type RouterSetting = {
...
@@ -716,7 +716,8 @@ export type RouterSetting = {
*/
*/
export
type
TriggerSetting
=
{
export
type
TriggerSetting
=
{
type
:
TriggerTypeEnum
type
:
TriggerTypeEnum
httpRequestSetting
:
HttpRequestTriggerSetting
httpRequestSetting
?:
HttpRequestTriggerSetting
normalFormSetting
?:
NormalFormTriggerSetting
}
}
/**
/**
...
@@ -726,7 +727,11 @@ export enum TriggerTypeEnum {
...
@@ -726,7 +727,11 @@ export enum TriggerTypeEnum {
/**
/**
* 发送 HTTP 请求触发器
* 发送 HTTP 请求触发器
*/
*/
HTTP_REQUEST
=
1
HTTP_REQUEST
=
1
,
/**
* 更新流程表单触发器
*/
UPDATE_NORMAL_FORM
=
2
}
}
/**
/**
...
@@ -743,6 +748,15 @@ export type HttpRequestTriggerSetting = {
...
@@ -743,6 +748,15 @@ export type HttpRequestTriggerSetting = {
response
?:
Record
<
string
,
string
>
[]
response
?:
Record
<
string
,
string
>
[]
}
}
/**
* 流程表单触发器配置结构定义
*/
export
type
NormalFormTriggerSetting
=
{
// 更新表单字段
updateFormFields
?:
Record
<
string
,
any
>
}
export
const
TRIGGER_TYPES
:
DictDataVO
[]
=
[
export
const
TRIGGER_TYPES
:
DictDataVO
[]
=
[
{
label
:
'HTTP 请求'
,
value
:
TriggerTypeEnum
.
HTTP_REQUEST
}
{
label
:
'HTTP 请求'
,
value
:
TriggerTypeEnum
.
HTTP_REQUEST
},
{
label
:
'修改表单数据'
,
value
:
TriggerTypeEnum
.
UPDATE_NORMAL_FORM
}
]
]
src/components/SimpleProcessDesignerV2/src/nodes-config/TriggerNodeConfig.vue
View file @
e32fc81d
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
>
>
<el-select
class=
"w-160px!"
v-model=
"item.key"
placeholder=
"请选择表单字段"
>
<el-select
class=
"w-160px!"
v-model=
"item.key"
placeholder=
"请选择表单字段"
>
<el-option
<el-option
v-for=
"(field, fIdx) in formField
Option
s"
v-for=
"(field, fIdx) in formFields"
:key=
"fIdx"
:key=
"fIdx"
:label=
"field.title"
:label=
"field.title"
:value=
"field.field"
:value=
"field.field"
...
@@ -121,6 +121,64 @@
...
@@ -121,6 +121,64 @@
</el-button>
</el-button>
</el-form-item>
</el-form-item>
</div>
</div>
<div
v-if=
"
configForm.type === TriggerTypeEnum.UPDATE_NORMAL_FORM && configForm.normalFormSetting
"
>
<el-divider
content-position=
"left"
>
修改表单设置
</el-divider>
<div
class=
"flex items-center"
v-for=
"key in Object.keys(configForm.normalFormSetting.updateFormFields!)"
:key=
"key"
>
<div
class=
"mr-2 flex items-center"
>
<el-form-item>
<el-select
class=
"w-160px!"
:model-value=
"key"
@
update:model-value=
"(newKey) => updateFormFieldKey(key, newKey)"
placeholder=
"请选择表单字段"
:disabled=
"key !== ''"
>
<el-option
v-for=
"(field, fIdx) in optionalUpdateFormFields"
:key=
"fIdx"
:label=
"field.title"
:value=
"field.field"
:disabled=
"field.disabled"
/>
</el-select>
</el-form-item>
</div>
<div
class=
"mx-2"
><el-form-item>
的值设置为
</el-form-item></div>
<div
class=
"mr-2"
>
<el-form-item
:prop=
"`normalFormSetting.updateFormFields.${key}`"
:rules=
"{
required: true,
message: '值不能为空',
trigger: 'blur'
}"
>
<el-input
class=
"w-160px"
v-model=
"configForm.normalFormSetting.updateFormFields![key]"
placeholder=
"请输入"
:disabled=
"!key"
/>
</el-form-item>
</div>
<div
class=
"mr-1 pt-1 cursor-pointer"
>
<el-form-item>
<Icon
icon=
"ep:delete"
:size=
"18"
@
click=
"deleteFormFieldSetting(key)"
/>
</el-form-item>
</div>
</div>
<el-button
type=
"primary"
text
@
click=
"addFormFieldSetting()"
>
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
添加修改字段
</el-button>
</div>
</el-form>
</el-form>
</div>
</div>
<
template
#
footer
>
<
template
#
footer
>
...
@@ -146,6 +204,7 @@ const props = defineProps({
...
@@ -146,6 +204,7 @@ const props = defineProps({
required
:
true
required
:
true
}
}
})
})
const
message
=
useMessage
()
// 消息弹窗
// 抽屉配置
// 抽屉配置
const
{
settingVisible
,
closeDrawer
,
openDrawer
}
=
useDrawer
()
const
{
settingVisible
,
closeDrawer
,
openDrawer
}
=
useDrawer
()
// 当前节点
// 当前节点
...
@@ -167,10 +226,28 @@ const configForm = ref<TriggerSetting>({
...
@@ -167,10 +226,28 @@ const configForm = ref<TriggerSetting>({
header
:
[],
header
:
[],
body
:
[],
body
:
[],
response
:
[]
response
:
[]
}
},
normalFormSetting
:
{
updateFormFields
:
{}
}
})
})
// 流程表单字段
// 流程表单字段
const
formFieldOptions
=
useFormFields
()
const
formFields
=
useFormFields
()
// 可选的修改的表单字段
const
optionalUpdateFormFields
=
computed
(()
=>
{
const
usedFields
=
Object
.
keys
(
configForm
.
value
.
normalFormSetting
?.
updateFormFields
||
{})
return
formFields
.
map
((
field
)
=>
({
title
:
field
.
title
,
field
:
field
.
field
,
disabled
:
usedFields
.
includes
(
field
.
field
)
}))
})
const
updateFormFieldKey
=
(
oldKey
:
string
,
newKey
:
string
)
=>
{
if
(
!
configForm
.
value
.
normalFormSetting
?.
updateFormFields
)
return
const
value
=
configForm
.
value
.
normalFormSetting
.
updateFormFields
[
oldKey
]
delete
configForm
.
value
.
normalFormSetting
.
updateFormFields
[
oldKey
]
configForm
.
value
.
normalFormSetting
.
updateFormFields
[
newKey
]
=
value
}
/** 添加 HTTP 请求返回值设置项*/
/** 添加 HTTP 请求返回值设置项*/
const
addHttpResponseSetting
=
(
responseSetting
:
Record
<
string
,
string
>
[])
=>
{
const
addHttpResponseSetting
=
(
responseSetting
:
Record
<
string
,
string
>
[])
=>
{
...
@@ -185,6 +262,19 @@ const deleteHttpResponseSetting = (responseSetting: Record<string, string>[], in
...
@@ -185,6 +262,19 @@ const deleteHttpResponseSetting = (responseSetting: Record<string, string>[], in
responseSetting
.
splice
(
index
,
1
)
responseSetting
.
splice
(
index
,
1
)
}
}
/** 添加修改表单设置项 */
const
addFormFieldSetting
=
()
=>
{
if
(
configForm
.
value
.
normalFormSetting
!
.
updateFormFields
===
undefined
)
{
configForm
.
value
.
normalFormSetting
!
.
updateFormFields
=
{}
}
configForm
.
value
.
normalFormSetting
!
.
updateFormFields
[
''
]
=
undefined
}
/** 删除修改表单设置项 */
const
deleteFormFieldSetting
=
(
key
:
string
)
=>
{
if
(
!
configForm
.
value
.
normalFormSetting
?.
updateFormFields
)
return
delete
configForm
.
value
.
normalFormSetting
.
updateFormFields
[
key
]
}
/** 保存配置 */
/** 保存配置 */
const
saveConfig
=
async
()
=>
{
const
saveConfig
=
async
()
=>
{
if
(
!
formRef
)
return
false
if
(
!
formRef
)
return
false
...
@@ -194,15 +284,29 @@ const saveConfig = async () => {
...
@@ -194,15 +284,29 @@ const saveConfig = async () => {
if
(
!
showText
)
return
false
if
(
!
showText
)
return
false
currentNode
.
value
.
name
=
nodeName
.
value
!
currentNode
.
value
.
name
=
nodeName
.
value
!
currentNode
.
value
.
showText
=
showText
currentNode
.
value
.
showText
=
showText
if
(
configForm
.
value
.
type
===
TriggerTypeEnum
.
HTTP_REQUEST
)
{
configForm
.
value
.
normalFormSetting
=
undefined
}
if
(
configForm
.
value
.
type
===
TriggerTypeEnum
.
UPDATE_NORMAL_FORM
)
{
configForm
.
value
.
httpRequestSetting
=
undefined
}
currentNode
.
value
.
triggerSetting
=
configForm
.
value
currentNode
.
value
.
triggerSetting
=
configForm
.
value
settingVisible
.
value
=
false
settingVisible
.
value
=
false
return
true
return
true
}
}
/** 获取节点展示内容 */
/** 获取节点展示内容 */
const
getShowText
=
():
string
=>
{
const
getShowText
=
():
string
=>
{
let
showText
=
''
let
showText
=
''
if
(
configForm
.
value
.
type
===
TriggerTypeEnum
.
HTTP_REQUEST
)
{
if
(
configForm
.
value
.
type
===
TriggerTypeEnum
.
HTTP_REQUEST
)
{
showText
=
`
${
configForm
.
value
.
httpRequestSetting
.
url
}
`
showText
=
`
${
configForm
.
value
.
httpRequestSetting
?.
url
}
`
} else if (configForm.value.type === TriggerTypeEnum.UPDATE_NORMAL_FORM) {
const updatefields = Object.keys(configForm.value.normalFormSetting?.updateFormFields || {})
if (updatefields.length === 0) {
message.warning('请设置修改表单字段')
} else {
showText = '修改表单数据'
}
}
}
return showText
return showText
}
}
...
@@ -211,8 +315,16 @@ const getShowText = (): string => {
...
@@ -211,8 +315,16 @@ const getShowText = (): string => {
const showTriggerNodeConfig = (node: SimpleFlowNode) => {
const showTriggerNodeConfig = (node: SimpleFlowNode) => {
nodeName.value = node.name
nodeName.value = node.name
if (node.triggerSetting) {
if (node.triggerSetting) {
configForm
.
value
.
type
=
node
.
triggerSetting
.
type
configForm.value = {
configForm
.
value
.
httpRequestSetting
=
node
.
triggerSetting
.
httpRequestSetting
type: node.triggerSetting.type,
httpRequestSetting: node.triggerSetting.httpRequestSetting || {
url: '',
header: [],
body: [],
response: []
},
normalFormSetting: node.triggerSetting.normalFormSetting || { updateFormFields: {} }
}
}
}
}
}
...
...
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