From 39ab910fe59480a35ebca316cd66e3995e70d4ed Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期五, 13 九月 2024 11:58:49 +0800
Subject: [PATCH] 支持刷新低代码,

---
 src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue |   67 ++++++++++++++++++++-------------
 1 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue b/src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue
index 7b2a3b9..3542edc 100644
--- a/src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue
+++ b/src/views/project/yw/lowCode/sqlAmis/SqlAmis.vue
@@ -43,25 +43,17 @@
 					:data="displayTableData"
 					highlight-current-row
 				>
-					<!-- <el-table-column type="expand" fixed="left">
-					<template #default="scope">
-						<div class="px-4">
-							<h3 class="mb-2">椤甸潰鍙傛暟</h3>
-							<JsonEditor currentMode="view" :modelValue="scope.row.args" />
-						</div>
-					</template>
-				</el-table-column> -->
-					<!-- <el-table-column prop="id" label="id" width="130" fixed="left" show-overflow-tooltip> </el-table-column> -->
-
 					<el-table-column prop="title" label="鏍囬" width="300" fixed="left" show-overflow-tooltip> </el-table-column>
-					<el-table-column prop="prompt" label="鎻愮ず璇�" show-overflow-tooltip> </el-table-column>
+					<el-table-column prop="prompt" label="鎻愮ず璇�" width="300" show-overflow-tooltip> </el-table-column>
 
 					<el-table-column label="鍒涘缓浜�" prop="creator" width="100" show-overflow-tooltip> </el-table-column>
 					<el-table-column label="鍒涘缓鏃堕棿" prop="create_time" width="105" show-overflow-tooltip> </el-table-column>
 					<el-table-column label="鏇存柊鏃堕棿" prop="update_time" width="105" show-overflow-tooltip> </el-table-column>
 					<el-table-column label="鍙戝竷鐘舵��" prop="published" width="85" show-overflow-tooltip>
 						<template #default="scope">
-							{{ supervisorPublishedMap[scope.row.published] }}
+							<el-tag :type="scope.row.published === SupervisorPublished.Y ? 'primary' : 'info'">{{
+								supervisorPublishedMap[scope.row.published]
+							}}</el-tag>
 						</template>
 					</el-table-column>
 
@@ -69,12 +61,13 @@
 					<el-table-column label="鎿嶄綔" width="200" fixed="right" show-overflow-tooltip>
 						<template #default="scope">
 							<div class="space-x-3 items-center flex">
-								<el-tooltip effect="dark" content="SQL缂栬緫" placement="top">
-									<i class="ywifont ywicon-sql !text-[14px] text-blue-400 cursor-pointer" @click="editSqlClick(scope.row)"></i>
-								</el-tooltip>
 								<el-tooltip effect="dark" content="AMIS浣庝唬鐮佺紪杈�" placement="top">
 									<i class="ywifont ywicon-didaima !text-[21px] text-blue-400 cursor-pointer" @click="gotoAmisPage(scope.row)"></i>
 								</el-tooltip>
+								<el-tooltip effect="dark" content="鏁版嵁瀵规帴" placement="top">
+									<i class="ywifont ywicon-sjdj !text-[17px] text-blue-400 cursor-pointer" @click="editSqlClick(scope.row)"></i>
+								</el-tooltip>
+
 								<el-tooltip effect="dark" content="瀵硅瘽娴嬭瘯" placement="top">
 									<i class="ywifont ywicon-ceshi !text-[20px] text-blue-400 cursor-pointer" @click="openChatTest(scope.row)"></i>
 								</el-tooltip>
@@ -144,7 +137,7 @@
 		<el-dialog
 			:destroy-on-close="true"
 			v-model="moduleDialogIsShow"
-			width="400"
+			width="300"
 			:close-on-click-modal="false"
 			@closed="closeModuleDialog"
 		>
@@ -159,11 +152,11 @@
 				<el-form-item label="鍚嶇О" prop="title">
 					<el-input placeholder="璇疯緭鍏ュ悕绉�" v-model="moduleDialogFormValue.title"></el-input>
 				</el-form-item>
-				<el-form-item label="鐖剁骇" prop="parent" v-if="!isEditModuleDialog">
+				<el-form-item label="鐖剁骇" prop="parent_id" v-if="!isEditModuleDialog">
 					<el-tree-select
 						filterable
 						class="w100"
-						v-model="moduleDialogFormValue.parent"
+						v-model="moduleDialogFormValue.parent_id"
 						:props="{
 							id: 'id',
 							label: 'title',
@@ -188,7 +181,12 @@
 			</template>
 		</el-dialog>
 	</AHMContainer>
-	<SqlAmisEdit v-else :supervisor="sqlEditMapSupervisor" @backLastPage="backLastPage" @updatePublished="updatePublishedById"></SqlAmisEdit>
+	<SqlAmisEdit
+		v-else
+		:supervisor="sqlEditMapSupervisor"
+		@backLastPage="backLastPage"
+		@updatePublished="updatePublishedById"
+	></SqlAmisEdit>
 </template>
 
 <script setup lang="ts">
@@ -215,13 +213,14 @@
 import { useCompRef } from '/@/utils/types';
 import { convertListToTree } from '/@/utils/util';
 
+import axios, { CancelTokenSource } from 'axios';
 import * as supervisorGroupApi from '/@/api/supervisorAdmin/supervisorGroup';
-import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue';
 import AHMContainer from '/@/components/layout/AHMContainer.vue';
+import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue';
 import { useUpdateData } from '/@/hooks/useUpdateData';
 
 //#region ====================== 宸︿晶鏍戞暟鎹紝tree init ======================
-const leftTreeRef = ref(null);
+const leftTreeRef = useCompRef(LeftTreeByMgr);
 const treeLoading = ref(false);
 const listData = ref([]);
 const currentListID = computed(() => currentNode.value?.id);
@@ -270,6 +269,9 @@
 		ElMessage.success('鍒犻櫎鎴愬姛锛�');
 		const foundIndex = listData.value.findIndex((item) => row.id === item.id);
 		listData.value.splice(foundIndex, 1);
+		if (listData.value.length > 0) {
+			handleClickNode(listData.value[foundIndex]);
+		}
 	});
 };
 //#endregion
@@ -300,7 +302,7 @@
 		moduleDialogFormValue.value = deepClone({ group_id: id, title });
 	} else {
 		isEditModuleDialog.value = false;
-		moduleDialogFormValue.value = { title: '', parent: '' };
+		moduleDialogFormValue.value = { title: '', parent_id: '' };
 	}
 	moduleDialogIsShow.value = true;
 };
@@ -341,10 +343,14 @@
 		ElMessage.success('淇敼椤甸潰鍒嗙粍鎴愬姛');
 	} else {
 		const res = await supervisorGroupApi.addSupervisorGroup(moduleDialogFormValue.value);
-		listData.value.push({
+		const newNode = {
 			...moduleDialogFormValue.value,
 			id: res.group_id,
-		});
+			parent: moduleDialogFormValue.value.parent_id,
+		};
+		Reflect.deleteProperty(newNode, 'parent_id');
+		listData.value.push(newNode);
+		handleClickNode(newNode);
 		moduleDialogIsShow.value = false;
 		ElMessage.success('娣诲姞椤甸潰鍒嗙粍鎴愬姛');
 	}
@@ -409,6 +415,9 @@
 
 const backLastPage = () => {
 	supervisorMgrShow.value = true;
+	nextTick(() => {
+		leftTreeRef.value?.treeRef.setCurrentKey(currentListID.value);
+	});
 };
 //#endregion
 
@@ -485,7 +494,9 @@
 
 	nextTick(() => {
 		chatRef.value.clear();
-		chatRef.value.autoSend(row.prompt);
+		setTimeout(() => {
+			chatRef.value.autoSend(row.prompt);
+		}, 30);
 	});
 };
 
@@ -507,7 +518,9 @@
 	},
 });
 
-const questionAi = async (text) => {
+const questionAi = async (text, sourceObj: { source: CancelTokenSource }) => {
+	const currentSource = axios.CancelToken.source();
+	sourceObj.source = currentSource;
 	const res = await checkSupervisorValidate(
 		{
 			id: chatTestMapRow.value.id,
@@ -515,6 +528,7 @@
 		},
 		{
 			loading: false,
+			cancelToken: currentSource.token,
 		}
 	);
 	return res;
@@ -525,7 +539,6 @@
 useUpdateData({
 	event: 'supervisor.publish',
 	updateFun({ id, published }) {
-
 		updatePublishedById(id, published);
 	},
 });

--
Gitblit v1.9.3