From 1827968a16dfcdde2b05fdf2505b898eccfa80dc Mon Sep 17 00:00:00 2001
From: gerson <1405270578@qq.com>
Date: 星期日, 25 八月 2024 10:55:51 +0800
Subject: [PATCH] 修复bug

---
 src/components/drawer/CustomDrawer.vue |   63 +++++++++++++++++++++++--------
 1 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/src/components/drawer/CustomDrawer.vue b/src/components/drawer/CustomDrawer.vue
index 1b0aa65..79ed347 100644
--- a/src/components/drawer/CustomDrawer.vue
+++ b/src/components/drawer/CustomDrawer.vue
@@ -1,5 +1,5 @@
 <template>
-	<div class="relative h100" :style="`width: ${rightBox}px;transition: 0.7s ease-in;`">
+	<div class="relative h100" v-loading="loadingData" :style="`width: ${rightBox}px;transition: 0.7s ease-in;`">
 		<div class="retract_icon" @click="toggleShow">
 			<i class="text-[#fff] transition-all" :class="isShow ? 'ywicon icon-zuoyoujiantou1' : 'ywicon icon-zuoyoujiantou'"></i>
 		</div>
@@ -130,7 +130,7 @@
 <script setup lang="ts">
 import { Search } from '@element-plus/icons-vue';
 import { computed, onMounted, reactive, ref, toRefs, watch } from 'vue';
-import { getSelectSample, getUserTemplateList } from '/@/api/ai/chat';
+import { getSectionList, getSelectSample, getUserTemplateList } from '/@/api/ai/chat';
 import { useSearch } from '/@/hooks/useSearch';
 import { activeRoomId, activeSampleId, sectionAList, setRoomConfig } from '/@/stores/chatRoom';
 import { debounce } from '/@/utils/util';
@@ -142,8 +142,8 @@
 	],
 	activeName: 1,
 
-	activeLabelName: 0,
-	activeInstructName: 0,
+	activeLabelName: 'knowledge_base', //榛樿閫夋嫨绗竴涓�
+	activeInstructName: 'office_assistant', //榛樿閫夋嫨绗竴涓�
 	isShowExpand: false,
 	useInstructDialog: false,
 	instructInfo: {},
@@ -229,22 +229,52 @@
 		state.isShowExpand = false;
 	}
 };
-const toggleShow = () => {
+const toggleShow = async() => {
 	isShow.value = !isShow.value;
 	if (!isShow.value) {
+		loadingData.value = true
+		await getMainSectionList().finally(()=>{
+			loadingData.value = false;
+		});
+
 		getTableData();
 	}
 };
-const getTableData = () => {
-	if (state.activeName == 1) {
-		if (state.listSampleExpand) return;
-		getSelectListSample();
-		state.listSampleExpand = true;
-	}
-	if (state.activeName == 2) {
-		if (state.listInstructExpand) return;
-		getUserTemplate();
-		state.listInstructExpand = true;
+const getMainSectionList = async () => {
+	const res = await getSectionList();
+	const iconList = [
+		'biaodan',
+		'putong',
+		'zhongduancanshuchaxun',
+		'shidu',
+		'fuwenbenkuang',
+		'fuwenben',
+		'jiliandongxuanzeqi',
+		'jinridaiban',
+		'gongju',
+	];
+	res.sections.forEach((sectionItem, index) => {
+		sectionItem.Icon = iconList[index];
+	});
+	sectionAList.value = res.sections;
+};
+const loadingData = ref(false);
+const getTableData = async () => {
+	loadingData.value = true;
+
+	try {
+		if (state.activeName == 1) {
+			if (state.listSampleExpand) return;
+			await getSelectListSample();
+			state.listSampleExpand = true;
+		}
+		if (state.activeName == 2) {
+			if (state.listInstructExpand) return;
+			await getUserTemplate();
+			state.listInstructExpand = true;
+		}
+	} finally {
+		loadingData.value = false;
 	}
 };
 //鍏抽棴楂樼骇绀轰緥
@@ -273,7 +303,8 @@
 const { query: querySample, queryData: showSampleList } = useSearch(exampleList, queryParams);
 const debounceQuery = debounce(querySample);
 const finalSampleList = computed(() => {
-	return showSampleList.value.filter((item) => item.section_a_id == state.activeLabelName);
+	const result = showSampleList.value.filter((item) => item.section_a_id == state.activeLabelName);
+	return result;
 });
 
 watch(

--
Gitblit v1.9.3