From 30878d21b5fa4580da01cb87a7683fe7fa9afcb2 Mon Sep 17 00:00:00 2001
From: yangyin <1850366751@qq.com>
Date: 星期日, 30 六月 2024 12:25:21 +0800
Subject: [PATCH] fix: 联调次场景

---
 src/api/ai/chat.ts                                        |   23 +++++++++++
 src/views/project/ch/home/Scenario.vue                    |   80 ++++++++++++++-------------------------
 src/views/project/ch/home/component/waterRight/bottom.vue |   13 +++++-
 3 files changed, 61 insertions(+), 55 deletions(-)

diff --git a/src/api/ai/chat.ts b/src/api/ai/chat.ts
index 2bc9d53..ddab7f0 100644
--- a/src/api/ai/chat.ts
+++ b/src/api/ai/chat.ts
@@ -112,7 +112,28 @@
 		method: 'POST',
 	});
 };
-
+/**
+ * @summary  鑾峰彇鍗曚釜娆″満鏅�
+ */
+export const getSectionByIdList = async (params, req: any = request) => {
+	return req({
+		url: '/section/get_section_b_list',
+		method: 'POST',
+		data: params,
+		headers: {
+			'Content-Type': 'application/x-www-form-urlencoded',
+		},
+	});
+};
+/**
+ * @summary  鑾峰彇鍏ㄩ儴娆″満鏅�
+ */
+export const getSectionByAllList = async (req: any = request) => {
+	return req({
+		url: '/section/get_section_list',
+		method: 'POST',
+	});
+};
 /**
  * @summary description
  */
diff --git a/src/views/project/ch/home/Scenario.vue b/src/views/project/ch/home/Scenario.vue
index 669707d..e9cc23e 100644
--- a/src/views/project/ch/home/Scenario.vue
+++ b/src/views/project/ch/home/Scenario.vue
@@ -14,18 +14,18 @@
 					</div>
 				</div>
 			</div>
-			<div class="productivity">
+			<div class="productivity" v-for="product in state.productivityList" :key="product.section_id">
 				<div class="mb-[24px]">
-					<span class="productivity-span"><i></i>閫氱敤鐨勫満鏅�</span>
+					<span class="productivity-span"><i></i>{{ product.section_name }}</span>
 				</div>
-				<div class="flex flex-wrap items-center">
-					<div class="list_app" v-for="item in state.productivityList" :key="item.ID">
+				<div class="flex flex-wrap items-center" v-show="product.children && product.children.length > 0">
+					<div class="list_app" v-for="item in product.children" :key="item.section_id">
 						<img :src="item.Icon" alt="" class="w-[20px] h-[20px] mr-[14px]" />
-						<span class="text-[14px] text-[#333f4e]">{{ item.Name }}</span>
+						<span class="text-[14px] text-[#333f4e]">{{ item.section_name }}</span>
 					</div>
 				</div>
 			</div>
-			<div class="productivity">
+			<!-- <div class="productivity">
 				<div class="mb-[24px]">
 					<span class="productivity-span"><i></i>姘村姟搴旂敤鍦烘櫙</span>
 				</div>
@@ -46,13 +46,15 @@
 						<span class="text-[14px] text-[#333f4e]">{{ item.Name }}</span>
 					</div>
 				</div>
-			</div>
+			</div> -->
 		</div>
 	</div>
 </template>
 
 <script setup lang="ts">
-import { reactive } from 'vue';
+import { onMounted, reactive } from 'vue';
+import { getSectionByAllList } from '/@/api/ai/chat';
+
 import router from '/@/router';
 let state = reactive({
 	recentlyList: [
@@ -67,48 +69,7 @@
 			Icon: '/static/images/scene/scene_2.png',
 		},
 	], //鏈�杩戜娇鐢�
-	productivityList: [
-		{
-			ID: 1,
-			Name: '鐭ヨ瘑搴�',
-			Icon: '/static/images/scene/scene_1.png',
-		},
-		{
-			ID: 2,
-			Name: '鏂囨湰浼樺寲',
-			Icon: '/static/images/scene/scene_2.png',
-		},
-		{
-			ID: 3,
-			Name: '鐭ヨ瘑搴�',
-			Icon: '/static/images/scene/scene_3.png',
-		},
-		{
-			ID: 4,
-			Name: '甯歌鐨勫簲鐢�',
-			Icon: '/static/images/scene/scene_2.png',
-		},
-		{
-			ID: 5,
-			Name: '鏂囩敓鏂�',
-			Icon: '/static/images/scene/scene_3.png',
-		},
-		{
-			ID: 6,
-			Name: '鍚堝悓妯℃澘',
-			Icon: '/static/images/scene/scene_2.png',
-		},
-		{
-			ID: 7,
-			Name: '鐩存挱甯﹁揣',
-			Icon: '/static/images/scene/scene_3.png',
-		},
-		{
-			ID: 8,
-			Name: '鏂板獟浣撴枃妗�',
-			Icon: '/static/images/scene/scene_2.png',
-		},
-	], //閫氱敤鐨勫満鏅�
+	productivityList: [], //閫氱敤鐨勫満鏅�
 	waterApplicationList: [
 		{
 			ID: 1,
@@ -152,6 +113,23 @@
 		});
 	}
 };
+const getSectionByList = async () => {
+	const res = await getSectionByAllList();
+	const iconList = ['/static/images/scene/scene_1.png', '/static/images/scene/scene_2.png', '/static/images/scene/scene_3.png'];
+	console.log('馃殌 ~ res:', res);
+	res.sections.forEach((item: any) => {
+		if (item.children && item.children.length > 0) {
+			item.children = item.children.map((child: any) => {
+				child.Icon = iconList[Math.floor(Math.random() * 3)];
+				return child;
+			});
+		}
+	});
+	state.productivityList = res.sections;
+};
+onMounted(() => {
+	getSectionByList();
+});
 </script>
 <style scoped lang="scss">
 .set-body {
@@ -179,7 +157,7 @@
 			}
 		}
 		.list_app {
-			width: 140px;
+			width: 180px;
 			display: flex;
 			align-items: center;
 			border-radius: 8px;
diff --git a/src/views/project/ch/home/component/waterRight/bottom.vue b/src/views/project/ch/home/component/waterRight/bottom.vue
index 7a0a35d..148a61a 100644
--- a/src/views/project/ch/home/component/waterRight/bottom.vue
+++ b/src/views/project/ch/home/component/waterRight/bottom.vue
@@ -43,8 +43,13 @@
 	scenariosIds: [],
 	scenariosIndex: 0,
 });
-const changeScenarios = (item) => {
-	state.scenariosIndex = item.ID;
+const changeScenarios = async (item) => {
+	state.scenariosIndex = item.section_id;
+
+	// router.push({
+	// 	name: 'Scenario',
+	// 	query: { ID: item.section_id },
+	// });
 };
 const getMainSectionList = async () => {
 	const res = await getSectionList();
@@ -54,7 +59,7 @@
 		sectionItem.Icon = iconList[index];
 	});
 	state.applicationScenarios = res.sections;
-	state.scenariosIds = result.map((item) => item.ID);
+	// state.scenariosIds = result.map((item) => item.section_id);
 };
 
 // 鏌ョ湅鏇村
@@ -186,3 +191,5 @@
 	}
 }
 </style>
+import item from 'element-plus/es/components/space/src/item';import item from 'element-plus/es/components/space/src/item';import item
+from 'element-plus/es/components/space/src/item';

--
Gitblit v1.9.3