feat: Node execution conditions (#1888)

This commit is contained in:
shaohuzhang1 2024-12-23 11:11:28 +08:00 committed by GitHub
parent f9548dd7f2
commit 1113e1ffec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 6 deletions

View File

@ -676,9 +676,17 @@ class WorkflowManage:
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
else:
for edge in self.flow.edges:
if edge.sourceNodeId == current_node.id and self.dependent_node_been_executed(edge.targetNodeId):
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
if edge.sourceNodeId == current_node.id:
next_node = [node for node in self.flow.nodes if node.id == edge.targetNodeId]
if len(next_node) == 0:
continue
if next_node[0].properties.get('condition', "AND") == 'AND':
if self.dependent_node_been_executed(edge.targetNodeId):
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
else:
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
return node_list
def get_reference_field(self, node_id: str, fields: List[str]):

View File

@ -44,8 +44,8 @@
placement="bottom-start"
>
<el-button text>
<img src="@/assets/icon_or.svg" alt="" v-if="condition==='OR'">
<img src="@/assets/icon_and.svg" alt="" v-if="condition==='AND'">
<img src="@/assets/icon_or.svg" alt="" v-if="condition === 'OR'" />
<img src="@/assets/icon_and.svg" alt="" v-if="condition === 'AND'" />
</el-button>
<template #dropdown>
<div style="width: 280px" class="p-12-16">
@ -152,8 +152,19 @@ const height = ref<{
})
const showAnchor = ref<boolean>(false)
const anchorData = ref<any>()
const condition = ref('AND')
const condition = computed({
set: (v) => {
set(props.nodeModel.properties, 'condition', v)
},
get: () => {
if (props.nodeModel.properties.condition) {
return props.nodeModel.properties.condition
}
set(props.nodeModel.properties, 'condition', 'AND')
return true
}
})
const showNode = computed({
set: (v) => {
set(props.nodeModel.properties, 'showNode', v)