From d240c411f291a11237449f4b6ab9282c28f4b621 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:20:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E3=80=91=20=E4=BF=AE=E5=A4=8D=E7=88=B6=E7=BA=A7=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=88=A0=E9=99=A4=E5=90=8E,=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=9C=AA=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#672)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/workflow/common/NodeCascader.vue | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ui/src/workflow/common/NodeCascader.vue b/ui/src/workflow/common/NodeCascader.vue index dfb50f2f0..2a0209618 100644 --- a/ui/src/workflow/common/NodeCascader.vue +++ b/ui/src/workflow/common/NodeCascader.vue @@ -37,19 +37,18 @@ const options = ref>([]) function visibleChange(bool: boolean) { if (bool) { - options.value = [] - getIncomingNode(props.nodeModel.id) + options.value = getIncomingNode(props.nodeModel.id) } } -function _getIncomingNode(id: String, startId: String) { +function _getIncomingNode(id: String, startId: String, value: Array) { let list = props.nodeModel.graphModel.getNodeIncomingNode(id) list = list.filter((item: any) => item.id !== startId) let firstElement = null if (list.length > 0) { list.forEach((item: any) => { - if (!options.value.some((obj: any) => obj.id === item.id)) { - options.value.unshift({ + if (!value.some((obj: any) => obj.id === item.id)) { + value.unshift({ value: item.id, label: item.properties.stepName, type: item.type, @@ -67,19 +66,21 @@ function _getIncomingNode(id: String, startId: String) { }) list.forEach((item: any) => { - _getIncomingNode(item.id, startId) + _getIncomingNode(item.id, startId, value) }) } if (firstElement) { - options.value.unshift(firstElement) + value.unshift(firstElement) } + return value } function getIncomingNode(id: string) { - _getIncomingNode(id, id) + return _getIncomingNode(id, id, []) } const validate = () => { - getIncomingNode(props.nodeModel.id) - if (!data.value) { + const incomingNodeValue = getIncomingNode(props.nodeModel.id) + options.value = incomingNodeValue + if (!data.value || data.value.length === 0) { return Promise.reject('引用变量必填') } if (data.value.length < 2) { @@ -87,18 +88,20 @@ const validate = () => { } const node_id = data.value[0] const node_field = data.value[1] - const nodeParent = options.value.find((item: any) => item.value === node_id) + const nodeParent = incomingNodeValue.find((item: any) => item.value === node_id) if (!nodeParent) { + data.value = [] return Promise.reject('不存在的引用变量') } if (!nodeParent.children.some((item: any) => item.value === node_field)) { + data.value = [] return Promise.reject('不存在的引用变量') } return Promise.resolve('') } defineExpose({ validate }) onMounted(() => { - getIncomingNode(props.nodeModel.id) + options.value = getIncomingNode(props.nodeModel.id) })