From c6d991dcafc9f422dffbdd43e4dd41a5eebd5ffe Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期一, 23 十二月 2024 10:22:25 +0800 Subject: [PATCH] 分析节点 --- src/views/project/yw/systemManage/flowApp/FlowApp.vue | 68 +++++++++++++++++++++++---------- 1 files changed, 47 insertions(+), 21 deletions(-) diff --git a/src/views/project/yw/systemManage/flowApp/FlowApp.vue b/src/views/project/yw/systemManage/flowApp/FlowApp.vue index b094c05..4a1c654 100644 --- a/src/views/project/yw/systemManage/flowApp/FlowApp.vue +++ b/src/views/project/yw/systemManage/flowApp/FlowApp.vue @@ -1,12 +1,11 @@ <template> - <div class="absolute bottom-0 left-0 right-0 top-0"> + <div class="absolute bottom-0 left-0 right-0 top-0 bg-page text-base"> <div class="relative flex h-full w-full flex-col"> - <Header /> + <Header v-if="flowAgent" :flowAgent="flowAgent" :queryId="queryId" /> <main class="relative flex h-full w-full flex-1"> - - <Sidebar @dragstart="handleOnDragStart"/> - <div class="relative h-full flex-1 overflow-hidden"> - <MainCanvas /> + <Sidebar class="w-52" @dragstart="handleOnDragStart" /> + <div class="relative h-full flex-1 overflow-hidden" v-if="flowJson"> + <MainCanvas :flowJson="flowJson" :agentNames="agentNames" :funcNames="funcNames"/> </div> </main> </div> @@ -18,9 +17,12 @@ import { useVueFlow } from '@vue-flow/core'; import { useClipboard } from '@vueuse/core'; // import MainCanvas from '@/components/vue-flow/MainCanvas.vue'; -import MainCanvas from '/@/components/vue-flow/MainCanvas.vue'; +import { computed, onMounted, ref } from 'vue'; import Header from './components/Header.vue'; import Sidebar from './components/Sidebar.vue'; +import { get_agent_names, get_flow_func_names, get_workflow_agent_list, get_workflow_json_flow } from '/@/api/workflow'; +import MainCanvas from '/@/components/vue-flow/MainCanvas.vue'; +import router from '/@/router'; // import { Button } from '@/components/ui/button'; // import { Toaster, useToast } from '@/components/ui/toast'; @@ -32,21 +34,45 @@ } } +const queryId = computed(() => router.currentRoute.value.query.id as string); + const { toObject } = useVueFlow(); const { copy } = useClipboard(); -// const { toast } = useToast(); -// function handleClickGetData() { -// copy(JSON.stringify(toObject())).then(() => { -// toast({ -// title: 'copied success', -// }); -// }); -// } -// function handleClickPublishBtn() { -// toast({ -// title: 'Save Data', -// description: '1.valid data 2.fetch backend api to save result', -// }); -// } +const flowJson = ref(null); + +const flowAgent = ref(null); + +const handleGetJSON = async (id: string) => { + const res = await get_workflow_json_flow({ + agent_id: id, + }); + flowJson.value = res.json_ok ? res.json_flow ?? {} : {}; +}; + +const getFlowAgent = async () => { + const res = await get_workflow_agent_list(); + const flowAgentList = res.values ?? []; + const currentFlowAgent = flowAgentList.find((item: any) => item.id === queryId.value); + flowAgent.value = currentFlowAgent; +}; + +const agentNames = ref([]); +const getAgentNames = async () => { + const res = await get_agent_names(); + agentNames.value = res.agents ?? []; +}; +const funcNames = ref([]); + +const getFuncNames = async () => { + const res = await get_flow_func_names(); + funcNames.value = res.funcs ?? []; +}; +onMounted(() => { + if (!queryId.value) return; + handleGetJSON(queryId.value); + getFlowAgent(); + getAgentNames(); + getFuncNames(); +}); </script> -- Gitblit v1.9.3