From 4b96a6458be622feba3ceef6d785e3ba0f051c7c Mon Sep 17 00:00:00 2001
From: Lemon <1599456917@qq.com>
Date: Sat, 22 Feb 2025 19:28:53 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E8=8A=82=E7=82=B9-=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81-=E4=BF=AE=E5=A4=8D=E8=B7=B3?=
=?UTF-8?q?=E8=BD=AC=E4=BB=BB=E6=84=8F=E8=8A=82=E7=82=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/ProcessNodeTree.vue | 22 ++++++--
.../SimpleProcessDesignerV2/src/consts.ts | 29 +++++++---
.../SimpleProcessDesignerV2/src/node.ts | 1 +
.../src/nodes-config/UserTaskNodeConfig.vue | 53 +++++++++++++++----
.../src/nodes/UserTaskNode.vue | 44 ++++++++++++++-
5 files changed, 129 insertions(+), 20 deletions(-)
diff --git a/src/components/SimpleProcessDesignerV2/src/ProcessNodeTree.vue b/src/components/SimpleProcessDesignerV2/src/ProcessNodeTree.vue
index cdb540322..31473c5c2 100644
--- a/src/components/SimpleProcessDesignerV2/src/ProcessNodeTree.vue
+++ b/src/components/SimpleProcessDesignerV2/src/ProcessNodeTree.vue
@@ -129,14 +129,28 @@ const recursiveFindParentNode = (
if (!findNode) {
return
}
- if (findNode.type === NodeType.START_USER_NODE) {
- nodeList.push(findNode)
- return
- }
+ // 检查当前节点
if (findNode.type === nodeType) {
nodeList.push(findNode)
}
+
+ // 检查子节点
+ if (findNode.childNode) {
+ if (findNode.childNode.type === nodeType) {
+ nodeList.push(findNode.childNode)
+ }
+ recursiveFindParentNode(nodeList, findNode.childNode, nodeType)
+ }
+
+ // 检查条件分支节点
+ if (findNode.type === NodeType.CONDITION_BRANCH_NODE && findNode.conditionNodes) {
+ findNode.conditionNodes.forEach(conditionNode => {
+ if (conditionNode.childNode) {
+ recursiveFindParentNode(nodeList, conditionNode.childNode, nodeType)
+ }
+ })
+ }
emits('find:recursiveFindParentNode', nodeList, props.parentNode, nodeType)
}
diff --git a/src/components/SimpleProcessDesignerV2/src/consts.ts b/src/components/SimpleProcessDesignerV2/src/consts.ts
index 7270b104e..edb676cc8 100644
--- a/src/components/SimpleProcessDesignerV2/src/consts.ts
+++ b/src/components/SimpleProcessDesignerV2/src/consts.ts
@@ -233,6 +233,8 @@ export type TimeoutHandler = {
timeDuration?: string
// 执行动作是自动提醒, 最大提醒次数
maxRemindCount?: number
+ // 执行动作是自动跳转时,跳转的节点ID
+ returnNodeId?: string
}
/**
@@ -291,6 +293,16 @@ export enum RejectHandlerType {
*/
RETURN_USER_TASK = 2
}
+export enum DelaySettingType {
+ /**
+ * 默认开启
+ */
+ FINISH_PROCESS = 1,
+ /**
+ * 延迟器指定节点
+ */
+ RETURN_USER_TASK = 2
+}
// 用户任务超时处理类型枚举
export enum TimeoutHandlerType {
/**
@@ -304,7 +316,11 @@ export enum TimeoutHandlerType {
/**
* 自动拒绝
*/
- REJECT = 3
+ REJECT = 3,
+ /**
+ * 自动跳转
+ */
+ AUTO_JUMP = 4
}
// 用户任务的审批人为空时,处理类型枚举
export enum AssignEmptyHandlerType {
@@ -570,7 +586,8 @@ export const TIME_UNIT_TYPES: DictDataVO[] = [
export const TIMEOUT_HANDLER_TYPES: DictDataVO[] = [
{ label: '自动提醒', value: 1 },
{ label: '自动同意', value: 2 },
- { label: '自动拒绝', value: 3 }
+ { label: '自动拒绝', value: 3 },
+ { label: '自动跳转', value: 4 }
]
export const REJECT_HANDLER_TYPES: DictDataVO[] = [
{ label: '终止流程', value: RejectHandlerType.FINISH_PROCESS },
@@ -695,11 +712,11 @@ export enum ProcessVariableEnum {
/**
* 延迟设置
*/
-export type DelaySetting = {
- // 延迟类型
- delayType: number
- // 延迟时间表达式
+export interface DelaySetting {
+ delayType: DelayTypeEnum
delayTime: string
+ autoJumpEnable?: boolean
+ returnNodeId?: string
}
/**
* 延迟类型
diff --git a/src/components/SimpleProcessDesignerV2/src/node.ts b/src/components/SimpleProcessDesignerV2/src/node.ts
index e3ac7c263..bbbca9855 100644
--- a/src/components/SimpleProcessDesignerV2/src/node.ts
+++ b/src/components/SimpleProcessDesignerV2/src/node.ts
@@ -156,6 +156,7 @@ export type UserTaskFormType = {
assignStartUserHandlerType?: AssignStartUserHandlerType
timeDuration?: number
maxRemindCount?: number
+ timeoutReturnNodeId?: string
buttonsSetting: any[]
taskCreateListenerEnable?: boolean
taskCreateListenerPath?: string
diff --git a/src/components/SimpleProcessDesignerV2/src/nodes-config/UserTaskNodeConfig.vue b/src/components/SimpleProcessDesignerV2/src/nodes-config/UserTaskNodeConfig.vue
index 433864b02..02ae42120 100644
--- a/src/components/SimpleProcessDesignerV2/src/nodes-config/UserTaskNodeConfig.vue
+++ b/src/components/SimpleProcessDesignerV2/src/nodes-config/UserTaskNodeConfig.vue
@@ -347,6 +347,25 @@
>
+
+
+
+
+
{{ nodeTypeName }}人为空时
@@ -729,7 +748,9 @@ const saveConfig = async () => {
enable: configForm.value.timeoutHandlerEnable!,
type: cTimeoutType.value,
timeDuration: isoTimeDuration.value,
- maxRemindCount: cTimeoutMaxRemindCount.value
+ maxRemindCount: cTimeoutMaxRemindCount.value,
+ returnNodeId: configForm.value.timeoutHandlerType === TimeoutHandlerType.AUTO_JUMP ?
+ configForm.value.timeoutReturnNodeId : undefined
}
// 设置审批人为空时
currentNode.value.assignEmptyHandler = {
@@ -803,15 +824,24 @@ const showUserTaskNodeConfig = (node: SimpleFlowNode) => {
returnTaskList.value = matchNodeList
// 2.4 设置审批超时处理
configForm.value.timeoutHandlerEnable = node.timeoutHandler?.enable
- if (node.timeoutHandler?.enable && node.timeoutHandler?.timeDuration) {
- const strTimeDuration = node.timeoutHandler.timeDuration
- let parseTime = strTimeDuration.slice(2, strTimeDuration.length - 1)
- let parseTimeUnit = strTimeDuration.slice(strTimeDuration.length - 1)
- configForm.value.timeDuration = parseInt(parseTime)
- timeUnit.value = convertTimeUnit(parseTimeUnit)
+ if (node.timeoutHandler?.enable) {
+ configForm.value.timeoutHandlerType = node.timeoutHandler.type
+ configForm.value.timeoutReturnNodeId = node.timeoutHandler.returnNodeId
+
+ if (node.timeoutHandler.timeDuration) {
+ const strTimeDuration = node.timeoutHandler.timeDuration
+ let parseTime = strTimeDuration.slice(2, strTimeDuration.length - 1)
+ let parseTimeUnit = strTimeDuration.slice(strTimeDuration.length - 1)
+ configForm.value.timeDuration = parseInt(parseTime)
+ timeUnit.value = convertTimeUnit(parseTimeUnit)
+ }
+
+ if (node.timeoutHandler.type === TimeoutHandlerType.AUTO_JUMP) {
+ const matchNodeList: SimpleFlowNode[] = []
+ emits('find:returnTaskNodes', matchNodeList)
+ returnTaskList.value = matchNodeList
+ }
}
- configForm.value.timeoutHandlerType = node.timeoutHandler?.type
- configForm.value.maxRemindCount = node.timeoutHandler?.maxRemindCount
// 2.5 设置审批人为空时
configForm.value.assignEmptyHandlerType = node.assignEmptyHandler?.type
configForm.value.assignEmptyHandlerUserIds = node.assignEmptyHandler?.userIds
@@ -902,6 +932,11 @@ function useTimeoutHandler() {
const timeoutHandlerTypeChanged = () => {
if (configForm.value.timeoutHandlerType === TimeoutHandlerType.REMINDER) {
configForm.value.maxRemindCount = 1 // 超时提醒次数,默认为1
+ } else if (configForm.value.timeoutHandlerType === TimeoutHandlerType.AUTO_JUMP) {
+ // 获取可跳转节点列表
+ const matchNodeList: SimpleFlowNode[] = []
+ emits('find:returnTaskNodes', matchNodeList)
+ returnTaskList.value = matchNodeList
}
}
diff --git a/src/components/SimpleProcessDesignerV2/src/nodes/UserTaskNode.vue b/src/components/SimpleProcessDesignerV2/src/nodes/UserTaskNode.vue
index ae1af6c28..4adae5e4b 100644
--- a/src/components/SimpleProcessDesignerV2/src/nodes/UserTaskNode.vue
+++ b/src/components/SimpleProcessDesignerV2/src/nodes/UserTaskNode.vue
@@ -169,8 +169,50 @@ const deleteNode = () => {
const findReturnTaskNodes = (
matchNodeList: SimpleFlowNode[] // 匹配的节点
) => {
- // 从父节点查找
+ // 从父节点查找所有用户任务节点
emits('find:parentNode', matchNodeList, NodeType.USER_TASK_NODE)
+
+ // 递归查找当前节点的子节点
+ findChildUserTaskNodes(currentNode.value, matchNodeList)
+
+ // 过滤掉当前节点和重复节点
+ const currentNodeId = currentNode.value.id
+ // 使用 Map 来去重,以节点 id 为 key
+ const uniqueNodes = new Map()
+ matchNodeList.forEach(node => {
+ if (node.id !== currentNodeId) {
+ uniqueNodes.set(node.id, node)
+ }
+ })
+
+ // 清空原数组并添加去重后的节点
+ matchNodeList.length = 0
+ matchNodeList.push(...Array.from(uniqueNodes.values()))
+}
+
+// 递归查找子节点中的用户任务节点
+const findChildUserTaskNodes = (node: SimpleFlowNode, matchNodeList: SimpleFlowNode[]) => {
+ if (!node) return
+
+ // 检查子节点
+ if (node.childNode) {
+ if (node.childNode.type === NodeType.USER_TASK_NODE) {
+ matchNodeList.push(node.childNode)
+ }
+ findChildUserTaskNodes(node.childNode, matchNodeList)
+ }
+
+ // 检查条件分支节点
+ if (node.type === NodeType.CONDITION_BRANCH_NODE && node.conditionNodes) {
+ node.conditionNodes.forEach(conditionNode => {
+ if (conditionNode.childNode) {
+ if (conditionNode.childNode.type === NodeType.USER_TASK_NODE) {
+ matchNodeList.push(conditionNode.childNode)
+ }
+ findChildUserTaskNodes(conditionNode.childNode, matchNodeList)
+ }
+ })
+ }
}
// 任务的弹窗显示,用于只读模式