From 6be64a219e16e2f9d82b1c57bd1106fc5cdbf317 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Mon, 17 Feb 2025 13:24:02 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E8=A7=A6=E5=8F=91=E5=99=A8=E6=B7=BB=E5=8A=A0=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleProcessDesignerV2/src/consts.ts | 10 +- .../SimpleProcessDesignerV2/src/node.ts | 67 +++- .../src/nodes-config/ConditionNodeConfig.vue | 72 +---- .../src/nodes-config/TriggerNodeConfig.vue | 291 ++++++++++++----- .../components/ConditionDialog.vue | 303 ++++++++++++++++++ 5 files changed, 593 insertions(+), 150 deletions(-) create mode 100644 src/components/SimpleProcessDesignerV2/src/nodes-config/components/ConditionDialog.vue diff --git a/src/components/SimpleProcessDesignerV2/src/consts.ts b/src/components/SimpleProcessDesignerV2/src/consts.ts index b51bb919..31ee8370 100644 --- a/src/components/SimpleProcessDesignerV2/src/consts.ts +++ b/src/components/SimpleProcessDesignerV2/src/consts.ts @@ -735,7 +735,7 @@ export type RouterSetting = { export type TriggerSetting = { type: TriggerTypeEnum httpRequestSetting?: HttpRequestTriggerSetting - normalFormSetting?: NormalFormTriggerSetting + formSettings?: FormTriggerSetting[] } /** @@ -769,7 +769,13 @@ export type HttpRequestTriggerSetting = { /** * 流程表单触发器配置结构定义 */ -export type NormalFormTriggerSetting = { +export type FormTriggerSetting = { + // 条件类型 + conditionType?: ConditionType + // 条件表达式 + conditionExpression?: string + // 条件组 + conditionGroups?: ConditionGroup // 更新表单字段 updateFormFields?: Record } diff --git a/src/components/SimpleProcessDesignerV2/src/node.ts b/src/components/SimpleProcessDesignerV2/src/node.ts index e415dc12..edd38fcd 100644 --- a/src/components/SimpleProcessDesignerV2/src/node.ts +++ b/src/components/SimpleProcessDesignerV2/src/node.ts @@ -15,7 +15,10 @@ import { AssignEmptyHandlerType, FieldPermissionType, HttpRequestParam, - ProcessVariableEnum + ProcessVariableEnum, + ConditionType, + ConditionGroup, + COMPARISON_OPERATORS } from './consts' import { parseFormFields } from '@/components/FormCreate/src/utils' @@ -543,6 +546,66 @@ export function useTaskStatusClass(taskStatus: TaskStatusEnum | undefined): stri if (taskStatus === TaskStatusEnum.CANCEL) { return 'status-cancel' } - return '' } + +/** 条件组件文字展示 */ +export function getConditionShowText( + conditonType: ConditionType | undefined, + conditionExpression: string | undefined, + conditionGroups: ConditionGroup | undefined, + fieldOptions: Array> +) { + 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>, 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 +} diff --git a/src/components/SimpleProcessDesignerV2/src/nodes-config/ConditionNodeConfig.vue b/src/components/SimpleProcessDesignerV2/src/nodes-config/ConditionNodeConfig.vue index e9b387a7..c7881cd2 100644 --- a/src/components/SimpleProcessDesignerV2/src/nodes-config/ConditionNodeConfig.vue +++ b/src/components/SimpleProcessDesignerV2/src/nodes-config/ConditionNodeConfig.vue @@ -43,13 +43,9 @@