From 0f01c4bbce19fa8489a4e835c83cb9415549f681 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期一, 17 二月 2025 17:54:22 +0800
Subject: [PATCH] 表单校验

---
 src/views/project/yw/systemManage/flowApp/FlowApp.vue |   88 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 75 insertions(+), 13 deletions(-)

diff --git a/src/views/project/yw/systemManage/flowApp/FlowApp.vue b/src/views/project/yw/systemManage/flowApp/FlowApp.vue
index 8934eb7..b0bd394 100644
--- a/src/views/project/yw/systemManage/flowApp/FlowApp.vue
+++ b/src/views/project/yw/systemManage/flowApp/FlowApp.vue
@@ -1,11 +1,18 @@
 <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 v-if="flowAgent" :flowAgent="flowAgent" :queryId="queryId" />
+			<Header :isViewMode="isViewMode" v-if="flowAgent" :flowAgent="flowAgent" :queryId="queryId" @saveClick="validateForm" />
 			<main class="relative flex h-full w-full flex-1">
-				<Sidebar @dragstart="handleOnDragStart" />
+				<Sidebar v-if="!isViewMode" class="w-52" @dragstart="handleOnDragStart" />
 				<div class="relative h-full flex-1 overflow-hidden" v-if="flowJson">
-					<MainCanvas :flowJson="flowJson"/>
+					<MainCanvas
+						ref="mainCanvasRef"
+						:isViewMode="isViewMode"
+						:flowJson="flowJson"
+						:agentNames="agentNames"
+						:funcNames="funcNames"
+						:llmInfoList="llmInfoList"
+					/>
 				</div>
 			</main>
 		</div>
@@ -20,13 +27,23 @@
 import { computed, onMounted, ref } from 'vue';
 import Header from './components/Header.vue';
 import Sidebar from './components/Sidebar.vue';
-import { get_workflow_agent_list, get_workflow_json_flow } from '/@/api/workflow';
+import {
+	get_agent_names,
+	get_flow_func_names,
+	get_workflow_agent_list,
+	get_workflow_json_flow,
+	get_llm_info_list,
+} from '/@/api/workflow';
 import MainCanvas from '/@/components/vue-flow/MainCanvas.vue';
 import router from '/@/router';
-
+const props = defineProps<{
+	isViewMode: {
+		type: Boolean;
+		default: false;
+	};
+}>();
 // import { Button } from '@/components/ui/button';
 // import { Toaster, useToast } from '@/components/ui/toast';
-
 function handleOnDragStart(event: DragEvent, nodeType: any) {
 	if (event.dataTransfer) {
 		event.dataTransfer.setData('application/vueflow', nodeType);
@@ -47,20 +64,65 @@
 	const res = await get_workflow_json_flow({
 		agent_id: id,
 	});
-	flowJson.value = res.json_ok ? res.json_flow : {};
+	flowJson.value = res.json_ok ? res.json_flow ?? {} : {};
 };
 
-
-const getFlowAgent =async()=>{
+const getFlowAgent = async () => {
 	const res = await get_workflow_agent_list();
-	const flowAgentList = res.values??[]
-	const currentFlowAgent = flowAgentList.find((item:any)=>item.id===queryId.value)
+	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 ?? [];
+};
+
+const llmInfoList = ref([]);
+const getLlmInfoList = async () => {
+	const res = await get_llm_info_list();
+	const factorys = res.factorys ?? [];
+	const connections = res.connections ?? [];
+	const logicTree = [];
+	factorys.forEach((factory: any) => {
+		logicTree.push({
+			id: factory.factory_id,
+			name: factory.factory_name,
+			type: 'factory',
+			model: factory,
+			children: connections
+				.filter((connection: any) => connection.factory_id === factory.factory_id)
+				.map((item: any) => ({
+					id: item.connect_id,
+					name: item.connect_title,
+					type: 'connection',
+					model: item,
+				})),
+		});
+	});
+	llmInfoList.value = logicTree;
+};
+
+const mainCanvasRef = ref();
+const validateForm = () => {
+	mainCanvasRef.value.validateForm();
+};
+
 
 onMounted(() => {
 	if (!queryId.value) return;
 	handleGetJSON(queryId.value);
 	getFlowAgent();
+	getAgentNames();
+	getFuncNames();
+	getLlmInfoList();
 });
 </script>

--
Gitblit v1.9.3