|
@@ -3,7 +3,7 @@
|
|
:append-to-body="true"
|
|
:append-to-body="true"
|
|
v-model="settingVisible"
|
|
v-model="settingVisible"
|
|
:show-close="false"
|
|
:show-close="false"
|
|
- :size="550"
|
|
|
|
|
|
+ :size="630"
|
|
:before-close="saveConfig"
|
|
:before-close="saveConfig"
|
|
>
|
|
>
|
|
<template #header>
|
|
<template #header>
|
|
@@ -121,62 +121,114 @@
|
|
</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 !== ''"
|
|
|
|
|
|
+ <!-- 表单数据修改触发器 -->
|
|
|
|
+ <div v-if="configForm.type === TriggerTypeEnum.UPDATE_NORMAL_FORM">
|
|
|
|
+ <div v-for="(formSetting, index) in configForm.formSettings" :key="index">
|
|
|
|
+ <el-card class="w-580px mt-4">
|
|
|
|
+ <template #header>
|
|
|
|
+ <div class="flex items-center justify-between">
|
|
|
|
+ <div>修改表单设置 {{ index + 1 }}</div>
|
|
|
|
+ <el-button
|
|
|
|
+ type="primary"
|
|
|
|
+ plain
|
|
|
|
+ circle
|
|
|
|
+ v-if="configForm.formSettings!.length > 1"
|
|
|
|
+ @click="deleteFormSetting(index)"
|
|
|
|
+ >
|
|
|
|
+ <Icon icon="ep:close" />
|
|
|
|
+ </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+
|
|
|
|
+ <!-- 条件设置 -->
|
|
|
|
+ <ConditionDialog
|
|
|
|
+ :ref="`condition-${index}`"
|
|
|
|
+ @update-condition="(val) => handleConditionUpdate(index, val)"
|
|
|
|
+ />
|
|
|
|
+ <div class="cursor-pointer" v-if="formSetting.conditionType">
|
|
|
|
+ <el-tag
|
|
|
|
+ type="success"
|
|
|
|
+ effect="light"
|
|
|
|
+ closable
|
|
|
|
+ @close="deleteFormUpdateCondition(formSetting)"
|
|
|
|
+ @click="openFormUpdateCondition(index, formSetting)"
|
|
>
|
|
>
|
|
- <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'
|
|
|
|
- }"
|
|
|
|
|
|
+ {{ showConditionText(formSetting) }}
|
|
|
|
+ </el-tag>
|
|
|
|
+ </div>
|
|
|
|
+ <el-button
|
|
|
|
+ v-else
|
|
|
|
+ type="primary"
|
|
|
|
+ text
|
|
|
|
+ @click="addFormUpdateCondition(index, formSetting)"
|
|
>
|
|
>
|
|
- <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>
|
|
|
|
|
|
+ <Icon icon="ep:link" class="mr-5px" />添加条件
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-divider content-position="left">修改表单字段设置</el-divider>
|
|
|
|
+ <!-- 表单字段修改设置 -->
|
|
|
|
+ <div
|
|
|
|
+ class="flex items-center"
|
|
|
|
+ v-for="key in Object.keys(formSetting.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(formSetting, 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="`formSettings.${index}.updateFormFields.${key}`"
|
|
|
|
+ :rules="{
|
|
|
|
+ required: true,
|
|
|
|
+ message: '值不能为空',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }"
|
|
|
|
+ >
|
|
|
|
+ <el-input
|
|
|
|
+ class="w-160px"
|
|
|
|
+ v-model="formSetting.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(formSetting, key)"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <!-- 添加表单字段按钮 -->
|
|
|
|
+ <el-button type="primary" text @click="addFormFieldSetting(formSetting)">
|
|
|
|
+ <Icon icon="ep:memo" class="mr-5px" />添加修改字段
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-card>
|
|
</div>
|
|
</div>
|
|
- <el-button type="primary" text @click="addFormFieldSetting()">
|
|
|
|
- <Icon icon="ep:plus" class="mr-5px" />添加修改字段
|
|
|
|
|
|
+
|
|
|
|
+ <!-- 添加新的设置 -->
|
|
|
|
+ <el-button class="mt-6" type="primary" text @click="addFormSetting">
|
|
|
|
+ <Icon icon="ep:setting" class="mr-5px" />添加设置
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</el-form>
|
|
</el-form>
|
|
@@ -191,10 +243,26 @@
|
|
</el-drawer>
|
|
</el-drawer>
|
|
</template>
|
|
</template>
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { SimpleFlowNode, NodeType, TriggerSetting, TRIGGER_TYPES, TriggerTypeEnum } from '../consts'
|
|
|
|
-import { useWatchNode, useDrawer, useNodeName, useFormFields } from '../node'
|
|
|
|
|
|
+import {
|
|
|
|
+ SimpleFlowNode,
|
|
|
|
+ NodeType,
|
|
|
|
+ TriggerSetting,
|
|
|
|
+ TRIGGER_TYPES,
|
|
|
|
+ TriggerTypeEnum,
|
|
|
|
+ FormTriggerSetting,
|
|
|
|
+ DEFAULT_CONDITION_GROUP_VALUE
|
|
|
|
+} from '../consts'
|
|
|
|
+import {
|
|
|
|
+ useWatchNode,
|
|
|
|
+ useDrawer,
|
|
|
|
+ useNodeName,
|
|
|
|
+ useFormFields,
|
|
|
|
+ useFormFieldsAndStartUser,
|
|
|
|
+ getConditionShowText
|
|
|
|
+} from '../node'
|
|
import HttpRequestParamSetting from './components/HttpRequestParamSetting.vue'
|
|
import HttpRequestParamSetting from './components/HttpRequestParamSetting.vue'
|
|
-
|
|
|
|
|
|
+import ConditionDialog from './components/ConditionDialog.vue'
|
|
|
|
+const { proxy } = getCurrentInstance() as any
|
|
defineOptions({
|
|
defineOptions({
|
|
name: 'TriggerNodeConfig'
|
|
name: 'TriggerNodeConfig'
|
|
})
|
|
})
|
|
@@ -227,28 +295,25 @@ const configForm = ref<TriggerSetting>({
|
|
body: [],
|
|
body: [],
|
|
response: []
|
|
response: []
|
|
},
|
|
},
|
|
- normalFormSetting: { updateFormFields: {} }
|
|
|
|
|
|
+ formSettings: [
|
|
|
|
+ {
|
|
|
|
+ conditionGroups: DEFAULT_CONDITION_GROUP_VALUE,
|
|
|
|
+ updateFormFields: {}
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
})
|
|
})
|
|
// 流程表单字段
|
|
// 流程表单字段
|
|
const formFields = useFormFields()
|
|
const formFields = useFormFields()
|
|
|
|
|
|
// 可选的修改的表单字段
|
|
// 可选的修改的表单字段
|
|
const optionalUpdateFormFields = computed(() => {
|
|
const optionalUpdateFormFields = computed(() => {
|
|
- const usedFields = Object.keys(configForm.value.normalFormSetting?.updateFormFields || {})
|
|
|
|
return formFields.map((field) => ({
|
|
return formFields.map((field) => ({
|
|
title: field.title,
|
|
title: field.title,
|
|
field: field.field,
|
|
field: field.field,
|
|
- disabled: usedFields.includes(field.field)
|
|
|
|
|
|
+ disabled: false
|
|
}))
|
|
}))
|
|
})
|
|
})
|
|
|
|
|
|
-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>[]) => {
|
|
responseSetting.push({
|
|
responseSetting.push({
|
|
@@ -262,17 +327,69 @@ 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 = {}
|
|
|
|
|
|
+/** 添加新的修改表单设置 */
|
|
|
|
+const addFormSetting = () => {
|
|
|
|
+ configForm.value.formSettings!.push({
|
|
|
|
+ conditionGroups: DEFAULT_CONDITION_GROUP_VALUE,
|
|
|
|
+ updateFormFields: {}
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 删除修改表单设置 */
|
|
|
|
+const deleteFormSetting = (index: number) => {
|
|
|
|
+ configForm.value.formSettings!.splice(index, 1)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 添加条件配置 */
|
|
|
|
+const addFormUpdateCondition = (index: number, formSetting: FormTriggerSetting) => {
|
|
|
|
+ const conditionDialog = proxy.$refs[`condition-${index}`][0]
|
|
|
|
+ conditionDialog.open(formSetting)
|
|
|
|
+}
|
|
|
|
+/** 删除条件配置 */
|
|
|
|
+const deleteFormUpdateCondition = (formSetting: FormTriggerSetting) => {
|
|
|
|
+ formSetting.conditionType = undefined
|
|
|
|
+}
|
|
|
|
+/** 打开条件配置弹窗 */
|
|
|
|
+const openFormUpdateCondition = (index: number, formSetting: FormTriggerSetting) => {
|
|
|
|
+ const conditionDialog = proxy.$refs[`condition-${index}`][0]
|
|
|
|
+ conditionDialog.open(formSetting)
|
|
|
|
+}
|
|
|
|
+/** 处理条件配置保存 */
|
|
|
|
+const handleConditionUpdate = (index: number, condition: any) => {
|
|
|
|
+ configForm.value.formSettings![index].conditionType = condition.conditionType
|
|
|
|
+ configForm.value.formSettings![index].conditionExpression = condition.conditionExpression
|
|
|
|
+ configForm.value.formSettings![index].conditionGroups = condition.conditionGroups
|
|
|
|
+}
|
|
|
|
+/** 条件配置展示 */
|
|
|
|
+const showConditionText = (formSetting: FormTriggerSetting) => {
|
|
|
|
+ return getConditionShowText(
|
|
|
|
+ formSetting.conditionType,
|
|
|
|
+ formSetting.conditionExpression,
|
|
|
|
+ formSetting.conditionGroups,
|
|
|
|
+ formFields
|
|
|
|
+ )
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 添加修改字段设置项 */
|
|
|
|
+const addFormFieldSetting = (formSetting: FormTriggerSetting) => {
|
|
|
|
+ if (!formSetting) return
|
|
|
|
+ if (!formSetting.updateFormFields) {
|
|
|
|
+ formSetting.updateFormFields = {}
|
|
}
|
|
}
|
|
- configForm.value.normalFormSetting!.updateFormFields[''] = undefined
|
|
|
|
|
|
+ formSetting.updateFormFields[''] = undefined
|
|
|
|
+}
|
|
|
|
+/** 更新字段 KEY */
|
|
|
|
+const updateFormFieldKey = (formSetting: FormTriggerSetting, oldKey: string, newKey: string) => {
|
|
|
|
+ if (!formSetting?.updateFormFields) return
|
|
|
|
+ const value = formSetting.updateFormFields[oldKey]
|
|
|
|
+ delete formSetting.updateFormFields[oldKey]
|
|
|
|
+ formSetting.updateFormFields[newKey] = value
|
|
}
|
|
}
|
|
-/** 删除修改表单设置项 */
|
|
|
|
-const deleteFormFieldSetting = (key: string) => {
|
|
|
|
- if (!configForm.value.normalFormSetting?.updateFormFields) return
|
|
|
|
- delete configForm.value.normalFormSetting.updateFormFields[key]
|
|
|
|
|
|
+
|
|
|
|
+/** 删除修改字段设置项 */
|
|
|
|
+const deleteFormFieldSetting = (formSetting: FormTriggerSetting, key: string) => {
|
|
|
|
+ if (!formSetting?.updateFormFields) return
|
|
|
|
+ delete formSetting.updateFormFields[key]
|
|
}
|
|
}
|
|
|
|
|
|
/** 保存配置 */
|
|
/** 保存配置 */
|
|
@@ -285,7 +402,7 @@ const saveConfig = async () => {
|
|
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) {
|
|
if (configForm.value.type === TriggerTypeEnum.HTTP_REQUEST) {
|
|
- configForm.value.normalFormSetting = undefined
|
|
|
|
|
|
+ configForm.value.formSettings = undefined
|
|
}
|
|
}
|
|
if (configForm.value.type === TriggerTypeEnum.UPDATE_NORMAL_FORM) {
|
|
if (configForm.value.type === TriggerTypeEnum.UPDATE_NORMAL_FORM) {
|
|
configForm.value.httpRequestSetting = undefined
|
|
configForm.value.httpRequestSetting = undefined
|
|
@@ -301,12 +418,13 @@ const getShowText = (): string => {
|
|
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) {
|
|
} 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 = '修改表单数据'
|
|
|
|
|
|
+ for (const [index, setting] of configForm.value.formSettings!.entries()) {
|
|
|
|
+ if (!setting.updateFormFields || Object.keys(setting.updateFormFields).length === 0) {
|
|
|
|
+ message.warning(`请添加表单设置${index + 1}的修改字段`)
|
|
|
|
+ return ''
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ showText = '修改表单数据'
|
|
}
|
|
}
|
|
return showText
|
|
return showText
|
|
}
|
|
}
|
|
@@ -323,7 +441,12 @@ const showTriggerNodeConfig = (node: SimpleFlowNode) => {
|
|
body: [],
|
|
body: [],
|
|
response: []
|
|
response: []
|
|
},
|
|
},
|
|
- normalFormSetting: node.triggerSetting.normalFormSetting || { updateFormFields: {} }
|
|
|
|
|
|
+ formSettings: node.triggerSetting.formSettings || [
|
|
|
|
+ {
|
|
|
|
+ conditionGroups: DEFAULT_CONDITION_GROUP_VALUE,
|
|
|
|
+ updateFormFields: {}
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|