From 59951a7031d50c8528764c624628886c31a6ea2c Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期五, 13 十二月 2024 16:35:51 +0800
Subject: [PATCH] 完全对接JSON,添加描述

---
 src/components/vue-flow/ui/nodes/FuncNode.vue |  110 +++++++++---------------------------------------------
 1 files changed, 19 insertions(+), 91 deletions(-)

diff --git a/src/components/vue-flow/ui/nodes/FuncNode.vue b/src/components/vue-flow/ui/nodes/FuncNode.vue
index 37c0d4d..8a32672 100644
--- a/src/components/vue-flow/ui/nodes/FuncNode.vue
+++ b/src/components/vue-flow/ui/nodes/FuncNode.vue
@@ -1,112 +1,40 @@
 <template>
-	<div
-		class="w-max-[520px] border-2 rounded-lg border-solid border-gray-100 bg-white p-3 shadow-md relative hover:border-blue-500 group"
-	>
+	<NodeBasicLayout v-model:title="data.title"  :type="NodeType.Func" :description="VueFlowHelper.getConfigValue(data, 'description', '')">
 		<Handle :id="targetHandleId" type="target" :position="Position.Left" />
-		<div
-			class="group-hover:visible invisible flex absolute divide-y-[1.5px] divide-solid divide-gray-100 rounded-lg right-0 -top-0.5 translate-y-[-100%]"
-			style="box-shadow: 0 0 15px #dbdee6"
-		>
-			<el-tooltip effect="dark" content="澶嶅埗" placement="top">
-				<div
-					class="flex content-center items-center border-x-0 p-1 hover:bg-gray-200 active:bg-gray-300 cursor-pointer"
-					@click="handleClickDuplicateBtn"
-				>
-					<span class="ywifont !text-[20px] mb-1 p-1.5 ywicon-copy"></span>
-				</div>
-			</el-tooltip>
-			<el-tooltip effect="dark" content="鍒犻櫎" placement="top">
-				<div
-					@click="clickDeleteBtn"
-					class="flex content-center items-center border-x-0 p-1 hover:bg-gray-200 active:bg-gray-300 hover:text-red-400 cursor-pointer"
-				>
-					<span class="ywifont !text-[20px] mb-1 p-1.5 ywicon-shanchu"></span>
-				</div>
-			</el-tooltip>
-		</div>
-		<div class="flex flex-col gap-y-2">
-			<div class="flex justify-between flex-0">
-				<div class="flex items-center gap-x-2">
-					<YWIcon
-						:name="VueFlowConfig.nodeStyleMap.get(NodeType.Agent).icon"
-						:fontSize="VueFlowConfig.nodeStyleMap.get(NodeType.Agent).fontSize"
-						:color="VueFlowConfig.nodeStyleMap.get(NodeType.Agent).color"
-						class="rounded-lg p-1.5"
-						:class="VueFlowConfig.nodeStyleMap.get(NodeType.Agent).class"
-					/>
-					<div class="flex flex-col gap-y-1">
-						<p v-if="!titleIsEdit" class="text-xl font-bold text-gray-500" @click="titleIsEdit = true">{{ data.title }}</p>
-						<el-input v-elInputFocus="false" v-else v-model="data.title" @blur="() => (titleIsEdit = false)"></el-input>
-					</div>
-				</div>
-			</div>
-
-			<div class="flex-auto gap-y-2 flex-col flex nodrag">
-				<div class="text-lg font-bold">鍑芥暟鍚嶇О</div>
-
-				<div class="min-w-[340px] flex-items-center gap-x-2">
-					<div class="flex-column gap-y-1.5">
-						<!-- <span class="text-gray-500">妯″瀷</span> -->
-						<el-select filterable placeholder="璇烽�夋嫨鍑芥暟鍚嶇О"  v-model="funcNameParams.value" @change="agentParamsValueChange">
-							<el-option v-for="item in funcNames"  :key="item.id" :value="item.id" :label="item.title"></el-option>
-						</el-select>
-					</div>
-				</div>
-			</div>
-		</div>
+		<FieldLayout :title="VueFlowHelper.getConfigValue(VueFlowHelper.getGroupParam(data), 'name', '鍑芥暟鍚嶇О')">
+			<el-select
+				class="w-[340px]"
+				filterable
+				:placeholder="funcNameParams.placeholder"
+				v-model="funcNameParams.value"
+				@change="agentParamsValueChange"
+			>
+				<el-option v-for="item in funcNames" :key="item.id" :value="item.id" :label="item.title"></el-option>
+			</el-select>
+		</FieldLayout>
 		<Handle :id="sourceHandleId" type="source" :position="Position.Right" />
-	</div>
-
-	<!-- <div>
-		<span>璧峰</span>
-
-		<Handle type="source" :position="Position.Right" />
-	</div> -->
+	</NodeBasicLayout>
 </template>
 
 <script lang="ts" setup>
 import { Handle, Position, useNode, useVueFlow } from '@vue-flow/core';
 import { ref } from 'vue';
+import FieldLayout from './components/FieldLayout.vue';
+import NodeBasicLayout from './components/NodeBasicLayout.vue';
+import { NodeType } from '../../vueFlowEnum';
 
 import { VueFlowHelper } from '../../VueFlowHelper';
-import { NodeType } from '../../vueFlowEnum';
-import { VueFlowConfig } from '../VueFlowConfig';
-import { deepClone } from '/@/utils/other';
 
-// defineProps<NodeProps<LLMNodeData, LLMNodeEvents>>();
-
-const props = defineProps(['funcNames'])
-const agentParamsValueChange = () => {
-	// const foundNames = props.agentNames.find(item=>item.id == agentParams.value);
-	// agentParams.value.value_label =  foundNames?.title ??'';
-};
+const props = defineProps(['funcNames']);
+const agentParamsValueChange = () => {};
 const node = useNode();
 const sourceHandleId = ref(VueFlowHelper.getHandleId(node.node, 'source'));
 const targetHandleId = ref(VueFlowHelper.getHandleId(node.node, 'target'));
 
 const data = ref(node.node.data);
 
-const varList = ref(VueFlowHelper.getFieldValue(data.value, 'var_list'));
-const titleIsEdit = ref(false);
-
 const funcNameParams = ref(VueFlowHelper.getParams(VueFlowHelper.getGroupParam(data.value), 'func_name'));
 
-const { removeNodes, nodes, addNodes } = useVueFlow();
 
-function handleClickDuplicateBtn() {
-	const { type, position, data } = node.node;
-	const newNode = {
-		id: VueFlowHelper.genGeometryId(),
-		type,
-		position: {
-			x: position.x + 100,
-			y: position.y + 100,
-		},
-		data: deepClone(data),
-	};
-	addNodes(newNode);
-}
-const clickDeleteBtn = () => {
-	removeNodes(node.id);
-};
+VueFlowHelper.getConfigValue(funcNameParams.value, 'label', '')
 </script>

--
Gitblit v1.9.3