From bd0f44efd15abbafc498576b163030f6927bed7a Mon Sep 17 00:00:00 2001 From: CaptainB Date: Wed, 23 Jul 2025 15:07:07 +0800 Subject: [PATCH] fix: validate required fields in FunctionNodeForm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1055176 --user=刘瑞斌 【github#2996】函数引用前置节点参数,前置节点删除后,函数参数为空可以发布应用 https://www.tapd.cn/57709429/s/1739785 --- ui/src/workflow/nodes/function-lib-node/index.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/src/workflow/nodes/function-lib-node/index.vue b/ui/src/workflow/nodes/function-lib-node/index.vue index 794cabd20..51948fd22 100644 --- a/ui/src/workflow/nodes/function-lib-node/index.vue +++ b/ui/src/workflow/nodes/function-lib-node/index.vue @@ -91,6 +91,7 @@ import { ref, computed, onMounted } from 'vue' import { isLastNode } from '@/workflow/common/data' import applicationApi from '@/api/application' import { app } from '@/main' +import {t} from "@/locales"; const props = defineProps<{ nodeModel: any }>() const nodeCascaderRef = ref() @@ -119,8 +120,16 @@ const chat_data = computed({ const FunctionNodeFormRef = ref() const validate = () => { + for (const item of chat_data.value.input_field_list) { + if (item.source === 'reference' && item.is_required && item.value[0] !== 'global') { + if (props.nodeModel.graphModel.nodes.filter((node: any) => node.id === item.value[0]).length === 0 ) { + item.value = [] + return Promise.reject({node: props.nodeModel, errMessage: item.name + t('dynamicsForm.tip.requiredMessage')}) + } + } + } return FunctionNodeFormRef.value?.validate().catch((err) => { - return Promise.reject({ node: props.nodeModel, errMessage: err }) + return Promise.reject({node: props.nodeModel, errMessage: err}) }) }