From bc4ab46fb5c4cb4435efabfe4b316be4ace5b026 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期一, 22 七月 2024 15:31:04 +0800
Subject: [PATCH] 修改 customDrawer

---
 src/views/project/ch/home/component/waterRight/center.vue |  123 +++++++++++++++++++++++++++++------------
 1 files changed, 87 insertions(+), 36 deletions(-)

diff --git a/src/views/project/ch/home/component/waterRight/center.vue b/src/views/project/ch/home/component/waterRight/center.vue
index e278ee9..95d061e 100644
--- a/src/views/project/ch/home/component/waterRight/center.vue
+++ b/src/views/project/ch/home/component/waterRight/center.vue
@@ -4,10 +4,10 @@
 			<div class="flex item-center">
 				<span>鎻愰棶绀轰緥</span>
 				<span class="split"></span>
-				<span class="change cursor-pointer">楂樼骇绀轰緥 ></span>
+				<span class="change cursor-pointer" @click="advanceExampleClick">楂樼骇绀轰緥 ></span>
 			</div>
 			<div class="cursor-pointer">
-				<span class="mr-1 changeBatch">鎹竴鎵�</span>
+				<span class="mr-1 changeBatch" @click="batchChange">鎹竴鎵�</span>
 				<i class="iconfont icon-shuaxin"></i>
 			</div>
 		</div>
@@ -16,16 +16,16 @@
 			<div
 				class="main_item flex items-center cursor-pointer"
 				v-for="(item, index) in state.exampleContent"
-				:key="item.ID"
-				:class="{ main_item_active: item.ID === state.exampleIndex }"
+				:key="index"
+				:class="{ main_item_active: item.sample_id === activeSampleId }"
 				@click="changeExample(item)"
 			>
 				<div class="left flex items-center justify-center" :class="['color' + index]">
 					<img :src="item.Icon" alt="" />
 				</div>
 				<div class="right">
-					<h4>{{ item.Title }}</h4>
-					<p>{{ item.Content }}</p>
+					<h4>{{ item.sample_title }}</h4>
+					<p>{{ item.sample_question }}</p>
 				</div>
 			</div>
 		</div>
@@ -33,39 +33,74 @@
 </template>
 
 <script setup lang="ts">
-import { reactive } from 'vue';
+import { computed, onMounted, reactive, ref } from 'vue';
+import { getSelectSample } from '/@/api/ai/chat';
+import { activeRoomId, activeSampleId, setRoomConfig } from '/@/stores/chatRoom';
+import emitter from '/@/utils/mitt';
 let state = reactive({
-	exampleContent: [
-		{
-			ID: 1,
-			Icon: '/static/images/wave/ChatImg.png',
-			Title: '瑙h鏉庡洓鐨勫弽搴�',
-			Content: '寮犱笁鎵撲簡鏉庡洓涓�宸存帉,鏉庡洓瀵瑰紶涓夎:"浣犳槸涓嶆槸娌″悆楗�",鏉庡洓璇磋繖鍙ヨ瘽鍚箟鏄�?',
-		},
-		{
-			ID: 2,
-			Icon: '/static/images/wave/ChatImg.png',
-			Title: '瑙i噴鍔姏涓庡唴鍗风殑鍖哄埆',
-			Content: '鎬庝箞瑙i噴鍔姏鍜屽唴鍗风殑鍖哄埆?',
-		},
-		{
-			ID: 3,
-			Icon: '/static/images/wave/ChatImg.png',
-			Title: '鍏朵粬闂',
-			Content: '璇锋悳绱綘鎯崇煡閬撶殑闂',
-		},
-		{
-			ID: 4,
-			Icon: '/static/images/wave/ChatImg.png',
-			Title: '缁欏疂瀹濆彇鏈夋枃鍖栧唴娑电殑鍚嶅瓧',
-			Content: '璇蜂互璇楃粡涓殑鍏告晠缁欑敺瀹濆疂鍙栧悕锛屽椤撅紝鍚嶅瓧瑕佹眰3涓瓧锛岀粰5涓悕瀛椾緵鎴戦�夋嫨銆�',
-		},
-	],
-	exampleIndex: 0,
+	exampleContent: [],
+	exampleRandomContent: [],
 });
-const changeExample = (item) => {
-	state.exampleIndex = item.ID;
+const exampleList = ref([]); //妯$増鍒楄〃
+const emits = defineEmits<{
+	(event: 'advanceExampleClick', data): void;
+	(event:'updateChatInput',val):void;
+}>();
+onMounted(() => {
+	getSelectListSample();
+});
+const groupedArray = computed(() => {
+	const groups = [];
+	let i = 0;
+	while (state.exampleRandomContent.length > i) {
+		groups.push(state.exampleRandomContent.slice(i, (i += 4)));
+	}
+	return groups;
+});
+//鑾峰彇妯$増鍒楄〃
+const getSelectListSample = async () => {
+	const res = await getSelectSample({
+		section_b_id: '',
+	});
+	// console.log(res, 63);
+	state.exampleRandomContent = res.samples;
+
+	const array = [];
+	res.samples.forEach((sample, index) => {
+		sample.Icon = '/static/images/wave/ChatImg.png';
+		sample.BgColor = randomHexColor();
+		if (index < 4) {
+			array.push(sample);
+		}
+	});
+	exampleList.value = res.samples;
+	state.exampleContent = array;
 };
+
+const changeExample = (item) => {
+	emits('updateChatInput',item.sample_question)
+	setRoomConfig(activeRoomId.value, 'isAnswerByLLM', false);
+	activeSampleId.value = item.sample_id;
+};
+//鎹竴鎵�
+const batchChange = () => {
+	const index = Math.floor(Math.random() * groupedArray.value.length);
+	state.exampleContent = groupedArray.value[index];
+};
+//鎵撳紑楂樼骇绀轰緥
+const advanceExampleClick = () => {
+	emits('advanceExampleClick', true);
+};
+
+//闅忔満鐢熸垚棰滆壊
+const randomHexColor = () => {
+	return `#${Math.floor(Math.random() * 16777215)
+		.toString(16)
+		.padEnd(6, '0')}`;
+};
+defineExpose({
+	getSelectListSample,
+});
 </script>
 <style scoped lang="scss">
 .pc-prompts {
@@ -168,4 +203,20 @@
 		}
 	}
 }
+
+:deep(.el-drawer__header) {
+	padding: 30px 20px 26px !important;
+	box-sizing: border-box;
+	width: 100%;
+	background-color: #e0e7fb;
+
+	position: relative;
+
+	height: unset !important;
+	margin-bottom: unset !important;
+	border-bottom: unset !important;
+}
+:deep(.el-drawer__body) {
+	overflow-x: hidden;
+}
 </style>

--
Gitblit v1.9.3