From 19185288125e859f12179c739c7a638e642b56f7 Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Mon, 13 Apr 2026 11:27:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BE=AA=E7=8E=AF=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/flow/components/ParamsDrawer.vue | 4 +- src/views/flow/config.js | 10 +- src/views/flow/index.vue | 22 +- src/views/flow/nodes/common/serviceNode.js | 6 +- src/views/flow/nodes/function/currentLoop.vue | 217 ------- .../flow/nodes/function/currentLoopNode.js | 6 +- src/views/flow/nodes/function/loop.js | 552 +++++++++--------- src/views/flow/nodes/function/loop.vue | 34 +- 8 files changed, 324 insertions(+), 527 deletions(-) diff --git a/src/views/flow/components/ParamsDrawer.vue b/src/views/flow/components/ParamsDrawer.vue index 82cff94..b69047f 100644 --- a/src/views/flow/components/ParamsDrawer.vue +++ b/src/views/flow/components/ParamsDrawer.vue @@ -42,7 +42,7 @@ -
+
@@ -342,7 +342,7 @@ watch( () => { if (props.data.type === "start") { formData.inputParams = props.data.properties?.inputParams || []; - } else if (props.data.type === "serviceNode") { + } else if (['currentLoop', 'serviceNode'].includes(props.data.type)) { formData.nodeParams = props.data.properties.nodeParams; formData.outputParams = props.data.properties.outputParams; console.log('formData', formData) diff --git a/src/views/flow/config.js b/src/views/flow/config.js index 3c5ccc8..e52acdd 100644 --- a/src/views/flow/config.js +++ b/src/views/flow/config.js @@ -306,7 +306,7 @@ export const collapseList = [ { name: "input", type: "input", input: "", required: true } ], outputType: 'json', - outputParams: [{ name: 'result', type: 'Object', children: [], desc: 'js节点返回'}] + outputParams: [{ name: 'result', type: 'object', children: [], desc: 'js节点返回'}] }, { icon: microphoneSvg, @@ -316,12 +316,14 @@ export const collapseList = [ action: 'GET_CURRENT_OBJECT', nodeType: 'getCurrentObject', nodeParams: [ - { name: "array", type: "input", input: "", disabled: true } + { name: "array", type: "input", input: "" } ], outputType: 'json', outputParams: [ - { name: 'index', type: 'number', desc: '索引', disabled: true}, - { name: 'object', type: 'Object', children: [], desc: '当前循环对象', } + { name: 'index', type: 'number', desc: '索引'}, + { name: 'object', type: 'object', children: [ + { name: 'test', type: 'string', desc: '占位属性' } + ], desc: '当前循环对象', } ] }, ], diff --git a/src/views/flow/index.vue b/src/views/flow/index.vue index 187dbaa..1688fd2 100644 --- a/src/views/flow/index.vue +++ b/src/views/flow/index.vue @@ -282,15 +282,15 @@ const testRun = async () => { } let allValid = true; - for (const node of nodes) { - const nodeModel = lf.getNodeModelById(node.id); - if (nodeModel && nodeModel.validateForm) { - const result = await nodeModel.validateForm(); - if (!result.valid) { - allValid = false; - } - } - } + // for (const node of nodes) { + // const nodeModel = lf.getNodeModelById(node.id); + // if (nodeModel && nodeModel.validateForm) { + // const result = await nodeModel.validateForm(); + // if (!result.valid) { + // allValid = false; + // } + // } + // } if (allValid) { isOpen.value = true; @@ -645,7 +645,9 @@ const initFlow = () => { lf.on("node:mouseleave", ({ data }) => { const node = lf.getNodeModelById(data.id); - node.setCustomProperties && node.setCustomProperties(); + if (node.setCustomProperties) { + node.setCustomProperties(); + } }); lf.on("node:dbclick", ({ data, e }) => { diff --git a/src/views/flow/nodes/common/serviceNode.js b/src/views/flow/nodes/common/serviceNode.js index faa5eca..b351ef7 100644 --- a/src/views/flow/nodes/common/serviceNode.js +++ b/src/views/flow/nodes/common/serviceNode.js @@ -150,9 +150,9 @@ class ServiceNodeHtmlModel extends HtmlNodeModel { return result } - setCustomProperties() { - this.componentInstance.setNodeProperties() - } + // setCustomProperties() { + // this.componentInstance.setNodeProperties() + // } /** * 设置节点属性 diff --git a/src/views/flow/nodes/function/currentLoop.vue b/src/views/flow/nodes/function/currentLoop.vue index 1470b2f..43acc2f 100644 --- a/src/views/flow/nodes/function/currentLoop.vue +++ b/src/views/flow/nodes/function/currentLoop.vue @@ -26,119 +26,8 @@ :nodeName="props.properties.name" :nodeDesc="props.properties.desc" :zoom-state="nodeZoom" - @zoom="zoom" @setNodeName="setNodeName" /> -
-
-
-
-
输入
-
-
- - - -
-
-
- -
- - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
输出
-
- -
- - - - - - - - - - - - - -
-
@@ -146,7 +35,6 @@ import { ref, reactive, onMounted, onUnmounted, nextTick } from "vue"; import { getInput, initNodeZoom } from "@/utils/flow"; import { useFlowStore } from "@/store/modules/flow"; -import { Plus } from "@element-plus/icons-vue"; import NodeTitle from "../../components/NodeTitle.vue"; import NodeState from "../../components/NodeState.vue"; import "vue3-json-viewer/dist/index.css"; @@ -160,46 +48,11 @@ const props = defineProps({ const emits = defineEmits(["contentChange"]); -const flowStore = useFlowStore(); const formData = reactive({ nodeParams: [], }); -const rules = reactive({}); - -const quoteOptions = ref([]); -const handleTypeChange = (index) => { - if (formData.nodeParams[index].type === "input") { - formData.nodeParams[index].quote = ""; - } else { - formData.nodeParams[index].input = ""; - const option = getInput(props.model.id); - if (option) { - quoteOptions.value = option; - } - } -}; - -const dynamicForm = ref(); - -const setNodeProperties = async () => { - try { - const result = await dynamicForm.value.validate(); - if (result) { - const data = toRaw(formData); - const properties = lf.getProperties(props.model.id); - lf.setProperties(props.model.id, { - ...properties, - ...data, - zoom: nodeZoom.value - }); - emits("contentChange"); - } - } catch { - dynamicForm.value.clearValidate(); - } -}; const setNodeName = (name) => { const properties = lf.getProperties(props.model.id); @@ -214,72 +67,6 @@ const nodeOperatingStatus = ref("NORMAL"); const inputJsonData = ref({}); const outputJsonData = ref({}); -const visibleChange = (value) => { - if (value) { - const option = getInput(props.model.id); - if (option) { - quoteOptions.value = option; - } - } -}; - -const cascaderRefs = ref([]); -const cascaderChange = (value, index) => { - const selectedOptions = cascaderRefs.value[index].getCheckedNodes(true); - formData.nodeParams[index].quote = value; - formData.nodeParams[index].quoteType = selectedOptions[0].data.type; -}; - -const validateForm = async () => { - try { - const result = await dynamicForm.value.validate(); - if (result) { - return { valid: true, message: "验证通过" }; - } else { - return { valid: false, message: "验证失败" }; - } - } catch { - return { valid: false, message: "验证失败" }; - } -}; - -const addFormItem = () => { - formData.nodeParams.push({ - name: "", - type: "", - desc: "", - required: false, - children: [], - }); - emits("contentChange"); -}; - -const nodeZoom = ref(props?.properties?.zoom ?? true) -const zoom = (flag) => { - nodeZoom.value = flag - initNodeZoom(props.model.id, nodeZoom.value, '.node__box') -} - -watch( - () => props.properties, - () => { - if (props.properties.nodeParams && props.properties.nodeParams.length > 0) { - formData.nodeParams = props.properties.nodeParams; - const option = getInput(props.model.id); - if (option) { - quoteOptions.value = option; - } - nextTick(() => { - initNodeZoom(props.model.id, props?.properties?.zoom ?? true, '.node__box', true) - }) - } - }, - { - immediate: true, - deep: true, - } -); - onMounted(() => { emitter.on("changeNodeState", (data) => { if (data.nodeId === props.model.id) { @@ -314,10 +101,6 @@ onUnmounted(() => { emitter.off("contentChange"); }); -defineExpose({ - validateForm, - setNodeProperties, -});