From e15245c624a20a3b46e428d646f5f2dd863cd1bc Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期四, 17 四月 2025 14:22:36 +0800
Subject: [PATCH] 完善

---
 src/store/simulation.js                    |   44 +++
 vue.config.js                              |   14 
 src/api/trApi.js                           |   51 ++++
 src/views/Screen.vue                       |  272 ++++++++++++-----------
 src/views/left/Left.vue                    |   58 ++--
 src/views/left/CitySim.vue                 |  113 +++++++--
 src/components/monifangzhen/schemeCard.vue |   85 +++++++
 src/views/left/Simulation.vue              |   23 +
 8 files changed, 439 insertions(+), 221 deletions(-)

diff --git a/src/api/trApi.js b/src/api/trApi.js
index 17319e6..b479b83 100644
--- a/src/api/trApi.js
+++ b/src/api/trApi.js
@@ -2,11 +2,48 @@
 
 // 鑾峰彇闆ㄩ噺鏁版嵁
 export async function getData() {
-    try {
-      const response = await axios.get("/api/region/selectPage", {
-      });
-      console.log("Response:", response);
-    } catch (error) {
-      console.error("Error fetching data:", error);
-    }
+  try {
+    const response = await axios.get("/region/selectPage", {
+    });
+    // console.log("Response:", response);
+  } catch (error) {
+    console.error("Error fetching data:", error);
   }
+}
+
+// 鑾峰彇鏂规鍒楄〃
+export async function getSimData() {
+  try {
+    const res = await axios.get("/simu/selectPage");
+    return res.data; // 杩斿洖瀹為檯鏁版嵁锛堥�氬父 res.data 鎵嶆槸鎺ュ彛杩斿洖鐨勫唴瀹癸級
+  } catch (error) {
+    console.error("Error fetching data:", error);
+    throw error; // 鎶涘嚭閿欒锛岃璋冪敤鏂瑰彲浠ユ崟鑾�
+  }
+}
+
+// 鏂板缓浠跨湡鏂规
+export async function createSimData(simData) {
+  try {
+    const res = await axios.post("/simu/insert", simData, {
+      headers: {
+        "Content-Type": "application/json",
+      },
+    });
+    return res;
+  } catch (error) {
+    console.error("Error creating simulation data:", error);
+    throw error; // 鎶涘嚭閿欒锛岃璋冪敤鏂瑰彲浠ユ崟鑾�
+  }
+}
+
+// 鍒犻櫎浠跨湡鏂规
+export async function deleteSimData(ids) {
+  try {
+    const res = await axios.delete(`/simu/deleteByIds?ids=${ids}`);
+    return res.data;
+  } catch (error) {
+    console.error('Error deleting simulation data:', error);
+    throw error;
+  }
+}
\ No newline at end of file
diff --git a/src/components/monifangzhen/schemeCard.vue b/src/components/monifangzhen/schemeCard.vue
index d43de36..a54ea6b 100644
--- a/src/components/monifangzhen/schemeCard.vue
+++ b/src/components/monifangzhen/schemeCard.vue
@@ -1,19 +1,33 @@
 <template>
   <div class="listCard">
     <!-- <div>鏂规鏁伴噺: {{ simStore.schemCard.length }}</div> -->
-    <el-card v-for="(item, key) in simStore.schemCard" :key="key" :class="{ selected: selectedId === item.id }"
-    @click="selectScheme(item.id)">
+    <!-- 鎺ュ彛鐗堟湰鍒犻櫎璇ヤ唬鐮佸潡 -->
+    <el-card
+      v-for="(item, key) in simStore.schemCard"
+      :key="key"
+      :class="{ selected: selectedId === item.id }"
+      @click="selectScheme(item.id)"
+    >
+      <!-- <el-card
+      v-for="(item, key) in schemeList"
+      :key="key"
+      @click="selectScheme(item.id)"
+    > -->
       <div>
         <p>鏂规鍚嶇О : {{ item.name }}</p>
         <p>鍒涘缓鏃堕棿 : {{ formatTime(item.createTime) }}</p>
         <p>
           鏂规鐘舵�� :
-          <span style="color: aquamarine">{{ statusText[item.taskStatus] || "鏈煡" }}</span>
+          <span style="color: aquamarine">{{
+            statusText[item.taskStatus] || "鏈煡"
+          }}</span>
         </p>
       </div>
       <div class="cardMenu">
         <div style="float: right; margin-top: 3px">
-          <el-button size="small" @click="setSchemClick(item)">鏂规璇︽儏</el-button>
+          <el-button size="small" @click="setSchemClick(item)"
+            >鏂规璇︽儏</el-button
+          >
           <el-button size="small" @click="startPlay(item)">杩涘叆妯℃嫙</el-button>
           <!--  :disabled="item.taskStatus !== 2" -->
         </div>
@@ -29,11 +43,12 @@
 </template>
 
 <script setup>
-import { ref } from "vue";
+import { onMounted, ref, watch } from "vue";
 import dayjs from "dayjs";
 import { initeWaterPrimitiveView } from "@/utils/water";
 import Message from "@/components/tools/Message.vue";
 import { useSimStore } from "@/store/simulation.js";
+import { ElMessage, ElMessageBox } from "element-plus";
 
 const simStore = useSimStore();
 // 閫変腑鐨勬柟妗� ID
@@ -310,14 +325,70 @@
   initeWaterPrimitiveView();
   emit("start");
 }
-const emit = defineEmits(["start", "end"]);
+const emit = defineEmits(["start", "end", "reset"]);
 function endPlay() {
   emit("end");
 }
-// 鏆撮湶閫変腑鐨� ID 缁欑埗缁勪欢
+
+//////////////////////////////////// 鏆撮湶閫変腑鐨� ID 缁欑埗缁勪欢锛堟帴鍙g増鏈垹闄わ級////////////////////////////////////
 defineExpose({
   getSelectedId: () => selectedId.value,
 });
+
+/////////////////////// 璋冪敤鎺ュ彛锛堜娇鐢ㄦ椂鎵撳紑锛� ///////////////////////
+// import { getData, getSimData, deleteSimData } from "@/api/trApi.js";
+// onMounted(() => {
+//   getScheme();
+// });
+
+// const props = defineProps({
+//   deleteSim: Boolean, // 鎺ユ敹鐖剁粍浠朵紶閫掔殑鍑芥暟
+// });
+
+// watch(
+//   () => props.deleteSim,
+//   (newVal) => {
+//     if (newVal) {
+//       console.log(newVal);
+//       deleteSim();
+//       emit("reset");
+//     }
+//   }
+// );
+
+// const schemeList = ref([]);
+
+// async function getScheme() {
+//   try {
+//     const res = await getSimData();
+//     schemeList.value = res.data;
+//   } catch (error) {
+//     console.error("Error fetching data:", error);
+//   }
+// }
+
+// const deleteSim = () => {
+//   ElMessageBox.confirm("纭畾瑕佸垹闄よ鏂规鍚�?", "鍒犻櫎鏂规", {
+//     confirmButtonText: "OK",
+//     cancelButtonText: "Cancel",
+//   })
+//     .then(() => {
+//       deleteSimData(selectedId.value).then((res) => {
+//         getScheme();
+//       });
+//       ElMessage({
+//         type: "success",
+//         message: "鍒犻櫎鎴愬姛",
+//       });
+//     })
+//     .catch(() => {
+//       ElMessage({
+//         type: "info",
+//         message: "宸插彇娑堝垹闄�",
+//       });
+//     });
+// };
+/////////////////////// 璋冪敤鎺ュ彛缁撴潫 ///////////////////////
 </script>
 
 <style lang="less" scoped>
diff --git a/src/store/simulation.js b/src/store/simulation.js
index cbb2e60..d99e4d2 100644
--- a/src/store/simulation.js
+++ b/src/store/simulation.js
@@ -1,6 +1,7 @@
 // stores/ui.js
 import { defineStore } from 'pinia'
 import { ref } from 'vue'
+import { createSimData } from '@/api/trApi';
 
 export const useSimStore = defineStore('ui', () => {
     // 鎵�鏈塙I鐘舵��
@@ -24,6 +25,7 @@
     const showLayerTree = ref(true)
     const showDangerAssess = ref(false)
     const schemCard = ref([])
+    const selectTab = ref("琛屾斂鍖哄垝浠跨湡")
 
     // 鍒濆鍖栨柟娉�
     const init = () => {
@@ -43,7 +45,44 @@
         showResultAssess.value = false
         showDangerAssess.value = false
         schemCard.value = []
+        selectTab.value = "琛屾斂鍖哄垝浠跨湡"
+
     }
+
+    const handleClickTab = (data) => {
+        selectTab.value = data
+    }
+
+    // 鏂板缓鏂规
+    const createSimulation = async (forms) => {
+        const getAreaType = (tabName) => {
+            switch (tabName) {
+                case '琛屾斂鍖哄垝浠跨湡':
+                    return 1
+                case '閲嶇偣鍖哄煙浠跨湡':
+                    return 2
+                case '閲嶇偣娌熶豢鐪�':
+                    return 3
+                default:
+                    return 0 // 鑷畾涔�
+            }
+        }
+        const params = {
+            areaType: getAreaType(selectTab),
+            createTime: Date.now(),
+            name: forms.name,
+            // 1涓洪娴嬫ā鎷燂紝2涓哄疄鏃舵ā鎷燂紝3涓哄巻鍙叉ā鎷�
+            type: 1,
+            // 0涓哄垱寤轰豢鐪燂紝1涓洪澶勭悊锛�2涓哄垎鏋愪腑锛�10涓哄畬鎴愶紝20涓哄嚭閿�
+            status: 0,
+        }
+        try {
+            await createSimData(params)
+        } catch (error) {
+            console.error('鍒涘缓浠跨湡澶辫触:', error)
+        }
+    }
+
     // 鏂规鐩稿叧
     const setSchemCard = (data) => {
         schemCard.value = data
@@ -128,16 +167,19 @@
         showResultAssess,
         showLayerTree,
         showDangerAssess,
+        schemCard,
+        selectTab,
         handleNavClick,
         init,
         startYHGL,
         startZHJC,
         startMNFZ,
         startMNPG,
-        schemCard,
         setSchemCard,
         addSchemCard,
         removeSchemCardItem,
         updateSchemCardItem,
+        handleClickTab,
+        createSimulation,
     }
 })
\ No newline at end of file
diff --git a/src/views/Screen.vue b/src/views/Screen.vue
index b6907aa..0135f5f 100644
--- a/src/views/Screen.vue
+++ b/src/views/Screen.vue
@@ -1,141 +1,151 @@
 <template>
-	<div class="screen">
-		<div class="screen-top" :class="bgVisible ? '' : 'nonebg'">
-			<div class="screen-top-logo" @click="initScene()"></div>
-		</div>
-		<div class="screen-left" :class="bgVisible ? '' : 'nonebg'"></div>
-		<div class="screen-right" :class="bgVisible ? '' : 'nonebg'"></div>
-		<div class="screen-bottom" :class="bgVisible ? '' : 'nonebg'"></div>
+  <div class="screen">
+    <div class="screen-top" :class="bgVisible ? '' : 'nonebg'">
+      <div class="screen-top-logo" @click="initScene()"></div>
+    </div>
+    <div class="screen-left" :class="bgVisible ? '' : 'nonebg'"></div>
+    <div class="screen-right" :class="bgVisible ? '' : 'nonebg'"></div>
+    <div class="screen-bottom" :class="bgVisible ? '' : 'nonebg'"></div>
 
-		<div class="screen-leftbg"></div>
-		<div class="screen-rightbg"></div>
+    <div class="screen-leftbg"></div>
+    <div class="screen-rightbg"></div>
 
-		<div class="screen-widget">
-			<div class="screen-widget-weather" @click="openWeather">
-				<div class="screen-widget-icon">
-					<img style="width: 26px; height: 26px" :src="weatherIcon" alt="" />
-				</div>
-				<div class="screen-widget-text">
-					{{ weather.now.text }} {{ weather.now.temperature + "鈩�" }}
-				</div>
-				<div class="screen-widget-time screen-widget-text" style="margin-left: 20px">
-					{{ $dayjs().format("YYYY/MM/DD HH:mm") }}
-				</div>
-			</div>
-			<div class="screen-widget-home">
-				<div class="screen-widget-icon"></div>
-				<div class="screen-widget-text" @click="flyToHomeView">杩斿洖涓婚〉</div>
-			</div>
-			<div class="screen-widget-location">
-				<div class="screen-widget-icon"></div>
-				<div class="screen-widget-text">{{ defaultCity }}</div>
-			</div>
-		</div>
-	</div>
+    <div class="screen-widget">
+      <div class="screen-widget-weather" @click="openWeather">
+        <div class="screen-widget-icon">
+          <img style="width: 26px; height: 26px" :src="weatherIcon" alt="" />
+        </div>
+        <div class="screen-widget-text">
+          {{ weather.now.text }} {{ weather.now.temperature + "鈩�" }}
+        </div>
+        <div
+          class="screen-widget-time screen-widget-text"
+          style="margin-left: 20px"
+        >
+          {{ $dayjs().format("YYYY/MM/DD HH:mm") }}
+        </div>
+      </div>
+      <div class="screen-widget-home">
+        <div class="screen-widget-icon"></div>
+        <div class="screen-widget-text" @click="flyToHomeView">杩斿洖涓婚〉</div>
+      </div>
+      <div class="screen-widget-location">
+        <div class="screen-widget-icon"></div>
+        <div class="screen-widget-text">{{ defaultCity }}</div>
+      </div>
+    </div>
+  </div>
 </template>
 
 <script setup>
-	import { ref, onMounted, computed, defineEmits } from "vue"
-	import { useRouter } from "vue-router"
-	const router = useRouter()
-	const bgVisible = ref(true)
-	const defaultCity = ref(cityData.name)
-	const emits = defineEmits("showWeatherDetail")
-	function init(visible) {
-		bgVisible.value = visible
-	}
-	const weatherIcon = computed(() => {
-		return `https://cdn.sencdn.com/widget2/assets/img/chameleon/weather/${weather.value.now.code}.svg `
-	})
-	const weather = ref({
-		location: {
-			id: "WKNM0GVFCUJJ",
-			name: "鍖椾含",
-			country: "CN",
-			path: "鍖椾含,鍖椾含,涓浗",
-			timezone: "Asia/Shanghai",
-			timezone_offset: "+08:00",
-		},
-		now: {
-			text: "鏅�",
-			code: "9",
-			temperature: "20",
-			feels_like: "31",
-			pressure: "990",
-			humidity: "84",
-			visibility: "24.13",
-			wind_direction: "涓�",
-			wind_direction_degree: "79",
-			wind_speed: "10.0",
-			wind_scale: "2",
-			clouds: "62",
-			dew_point: "",
-		},
-		last_update: "2023-04-21T11:02:40+08:00",
-	})
-	const air = ref({
-		city: {
-			quality: "浼�",
-		},
-	})
-	const getWeatherData = () => {
-		fetch(
-			"https://api.seniverse.com/v3/weather/now.json?key=Sn4df5dIxeplgBv3X&location=beijing&language=zh-Hans&unit=c",
-			{
-				mode: "cors", // no-cors, *cors, same-origin
-				cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
-				headers: {
-					// "Content-Type": "application/json",
-					"Content-Type": "application/x-www-form-urlencoded",
-				},
-			}
-		)
-			.then(response => response.json())
-			.then(data => {
-				weather.value = data.results[0]
-				// console.log(weather.value)
-			})
-	}
-	function initScene() {
-		flyToHomeView()
-		let desc = {
-			func_name: "FlyTo",
-			vectorType: "WGS84",
-			x: "102.410951",
-			y: "36.838083",
-			z: "20611.588439",
-			yaw: "-87.464172",
-			pitch: "-89.0",
-			distance: "4918164.228809",
-			PlayRate: "5",
-			Name: "鐢樿們椤惰鍥�",
-		}
-		ps.emitMessage(desc)
-	}
+import { ref, onMounted, computed, defineEmits } from "vue";
+import { useRouter } from "vue-router";
+const router = useRouter();
+const bgVisible = ref(true);
+const defaultCity = ref(cityData.name);
+const emits = defineEmits("showWeatherDetail");
+function init(visible) {
+  bgVisible.value = visible;
+}
+const weatherIcon = computed(() => {
+  return `https://cdn.sencdn.com/widget2/assets/img/chameleon/weather/${weather.value.now.code}.svg `;
+});
+const weather = ref({
+  location: {
+    id: "WKNM0GVFCUJJ",
+    name: "鍖椾含",
+    country: "CN",
+    path: "鍖椾含,鍖椾含,涓浗",
+    timezone: "Asia/Shanghai",
+    timezone_offset: "+08:00",
+  },
+  now: {
+    text: "鏅�",
+    code: "9",
+    temperature: "20",
+    feels_like: "31",
+    pressure: "990",
+    humidity: "84",
+    visibility: "24.13",
+    wind_direction: "涓�",
+    wind_direction_degree: "79",
+    wind_speed: "10.0",
+    wind_scale: "2",
+    clouds: "62",
+    dew_point: "",
+  },
+  last_update: "2023-04-21T11:02:40+08:00",
+});
+const air = ref({
+  city: {
+    quality: "浼�",
+  },
+});
+const getWeatherData = () => {
+  fetch(
+    "https://api.seniverse.com/v3/weather/now.json?key=Sn4df5dIxeplgBv3X&location=beijing&language=zh-Hans&unit=c",
+    {
+      mode: "cors", // no-cors, *cors, same-origin
+      cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
+      headers: {
+        // "Content-Type": "application/json",
+        "Content-Type": "application/x-www-form-urlencoded",
+      },
+    }
+  )
+    .then((response) => response.json())
+    .then((data) => {
+      weather.value = data.results[0];
+      // console.log(weather.value)
+    });
+};
+function initScene() {
+  flyToHomeView();
+  let desc = {
+    func_name: "FlyTo",
+    vectorType: "WGS84",
+    x: "102.410951",
+    y: "36.838083",
+    z: "20611.588439",
+    yaw: "-87.464172",
+    pitch: "-89.0",
+    distance: "4918164.228809",
+    PlayRate: "5",
+    Name: "鐢樿們椤惰鍥�",
+  };
+  ps.emitMessage(desc);
+}
 
-	function openWeather() {
-		emits("showWeatherDetail")
-	}
-	function flyToHomeView() {
-		router.push("/")
-		const view = {
-			destination: {
-				x: -2355432.569004413,
-				y: 4687573.191838412,
-				z: 4098726.315265574,
-			},
-			orientation: {
-				pitch: -0.9541030830183503,
-				roll: 0.00031421159527500464,
-				heading: 6.140424766644804,
-			},
-		}
-		viewer.scene.camera.flyTo(view)
-	}
-	onMounted(() => {
-		// getWeatherData()
-	})
+function openWeather() {
+  emits("showWeatherDetail");
+}
+
+import { useSimStore } from "@/store/simulation";
+import { storeToRefs } from "pinia";
+const simStore = useSimStore();
+const { showDangerAssess, rightRiverShow } = storeToRefs(simStore);
+function flyToHomeView() {
+  rightRiverShow.value = false;
+  showDangerAssess.value = false;
+  router.push("/");
+  const view = {
+    destination: {
+      x: -2355432.569004413,
+      y: 4687573.191838412,
+      z: 4098726.315265574,
+    },
+    orientation: {
+      pitch: -0.9541030830183503,
+      roll: 0.00031421159527500464,
+      heading: 6.140424766644804,
+    },
+  };
+  viewer.scene.camera.flyTo(view);
+}
+onMounted(() => {
+  // getWeatherData()
+});
 </script>
 <style lang="less" scoped>
-	@import url("../assets/css/screen.css");
+@import url("../assets/css/screen.css");
 </style>
diff --git a/src/views/left/CitySim.vue b/src/views/left/CitySim.vue
index 6b3daa1..b38e91f 100644
--- a/src/views/left/CitySim.vue
+++ b/src/views/left/CitySim.vue
@@ -2,16 +2,24 @@
   <div style="width: 100%; height: 100%">
     <div
       class="left-top"
-      v-if="disForm == '琛屾斂鍖哄垝浠跨湡'"
+      v-if="simStore.selectTab == '琛屾斂鍖哄垝浠跨湡'"
       style="margin-top: 0px"
     >
       琛屾斂鍖哄垝浠跨湡锛�30m绮惧害锛�
     </div>
-    <div class="left-top" v-if="disForm == '閲嶇偣鍖哄煙浠跨湡'">
+    <div class="left-top" v-if="simStore.selectTab == '閲嶇偣鍖哄煙浠跨湡'">
       閲嶇偣鍖哄煙浠跨湡锛�10m绮惧害锛�
     </div>
     <div class="forms">
       <el-form :model="forms" label-width="auto" style="max-width: 600px">
+        <el-form-item label="鏂规鍚嶇О:">
+          <el-input
+            v-model="forms.name"
+            style="max-width: 600px"
+            placeholder="Please input"
+          >
+          </el-input>
+        </el-form-item>
         <el-form-item label="涓婁紶鍙傛暟">
           <el-upload
             v-model:file-list="forms.fileList"
@@ -28,7 +36,10 @@
             <template #append>mm/h</template>
           </el-upload>
         </el-form-item>
-        <el-form-item label="琛屾斂鍖哄煙:" v-if="disForm == '琛屾斂鍖哄垝浠跨湡'">
+        <el-form-item
+          label="琛屾斂鍖哄煙:"
+          v-if="simStore.selectTab == '琛屾斂鍖哄垝浠跨湡'"
+        >
           <el-select
             v-model="forms.eare"
             placeholder="Select"
@@ -42,7 +53,10 @@
             />
           </el-select>
         </el-form-item>
-        <el-form-item label="閲嶇偣鍖哄煙:" v-if="disForm == '閲嶇偣鍖哄煙浠跨湡'">
+        <el-form-item
+          label="閲嶇偣鍖哄煙:"
+          v-if="simStore.selectTab == '閲嶇偣鍖哄煙浠跨湡'"
+        >
           <el-select
             v-model="forms.eares"
             placeholder="Select"
@@ -93,7 +107,7 @@
         <el-button type="primary" @click="openSaveDialog">淇濆瓨鏂规</el-button>
         <el-button type="success" @click="startPlay">寮�濮嬫ā鎷�</el-button>
       </div>
-      <!-- 淇濆瓨鏂规瀵硅瘽妗� -->
+      <!---------------------------- 淇濆瓨鏂规瀵硅瘽妗嗭紙鎺ュ彛鐗堟湰闇�鍒犻櫎锛� -------------------------------->
       <el-dialog
         v-model="saveDialogVisible"
         :title="dialogTitle"
@@ -129,14 +143,20 @@
 import { reactive, ref, watch, inject, computed } from "vue";
 import * as XLSX from "xlsx";
 import Papa from "papaparse";
-import { ElMessage } from "element-plus";
+import { ElMessage, ElMessageBox } from "element-plus";
 import { initeWaterPrimitiveView } from "@/utils/water";
+import { createSimData } from "@/api/trApi";
+
+import { useSimStore } from "@/store/simulation";
+
+const simStore = useSimStore();
 
 // 娉ㄥ叆鐖剁粍浠舵彁渚涚殑鏂规硶
 const { startSimulate, endSimulate } = inject("simulateActions");
-const saveDialogVisible = ref(false); // 鎺у埗淇濆瓨鏂规瀵硅瘽妗嗙殑鏄剧ず鐘舵��
+const saveDialogVisible = ref(false); // 鎺у埗淇濆瓨鏂规瀵硅瘽妗嗙殑鏄剧ず鐘舵�侊紙鎺ュ彛鐗堟湰鍒犻櫎锛�
 // 琛ㄥ崟鏁版嵁
 const forms = reactive({
+  name: "",
   eare: "鍖椾含甯�",
   eares: "瀛欒儭娌�",
   rainfall: "",
@@ -175,7 +195,9 @@
 
 // 璁$畻灞炴�э細鑾峰彇瀵硅瘽妗嗘爣棰�
 const dialogTitle = computed(() => {
-  return disForm.value === "琛屾斂鍖哄垝浠跨湡" ? "琛屾斂鍖哄垝浠跨湡" : "閲嶇偣鍖哄煙浠跨湡";
+  return simStore.selectTab === "琛屾斂鍖哄垝浠跨湡"
+    ? "琛屾斂鍖哄垝浠跨湡"
+    : "閲嶇偣鍖哄煙浠跨湡";
 });
 
 // 璁$畻灞炴�э細鑾峰彇涓婁紶鏂囦欢鐨勫悕绉板垪琛�
@@ -183,22 +205,21 @@
   return forms.fileList.map((file) => file.name).join(", ") || "鏃�";
 });
 
+////////////////////////////////////// 鎺ュ彛鐗堟湰闇�鍒犻櫎//////////////////////////////////////
 // 鎵撳紑淇濆瓨鏂规瀵硅瘽妗�
 const openSaveDialog = () => {
   if (
     !forms.rainfall ||
     !forms.duration ||
     !forms.intensity ||
-    (disForm.value === "琛屾斂鍖哄垝浠跨湡" && !forms.eare) ||
-    (disForm.value === "閲嶇偣鍖哄煙浠跨湡" && !forms.eares)
+    (simStore.selectTab === "琛屾斂鍖哄垝浠跨湡" && !forms.eare) ||
+    (simStore.selectTab === "閲嶇偣鍖哄煙浠跨湡" && !forms.eares)
   ) {
     ElMessage.warning("璇峰厛濉啓鎵�鏈夊繀濉」");
     return;
   }
   saveDialogVisible.value = true;
-};
-
-// 鍏抽棴淇濆瓨鏂规瀵硅瘽妗�
+}
 const handleClose = () => {
   saveDialogVisible.value = false;
 };
@@ -207,8 +228,8 @@
 const confirmSave = () => {
   console.log("淇濆瓨鏂规鎴愬姛", {
     妯℃嫙绫诲瀷: dialogTitle.value,
-    琛屾斂鍖哄煙: disForm.value === "琛屾斂鍖哄垝浠跨湡" ? forms.eare : null,
-    閲嶇偣鍖哄煙: disForm.value === "閲嶇偣鍖哄煙浠跨湡" ? forms.eares : null,
+    琛屾斂鍖哄煙: simStore.selectTab === "琛屾斂鍖哄垝浠跨湡" ? forms.eare : null,
+    閲嶇偣鍖哄煙: simStore.selectTab === "閲嶇偣鍖哄煙浠跨湡" ? forms.eares : null,
     闄嶉洦閲�: `${forms.rainfall} mm`,
     闄嶉洦鏃堕暱: `${forms.duration} h`,
     闄嶉洦寮哄害: `${forms.intensity} mm/h`,
@@ -218,6 +239,53 @@
   saveDialogVisible.value = false;
   resetForm();
 };
+////////////////////////////////////// 缁撴潫鍒犻櫎//////////////////////////////////////
+
+//////////////////////////////////鎺ュ彛鐗堟湰鍚敤//////////////////////////////////
+// const isLoading = ref(false);
+// // 淇濆瓨鏂规
+// const openSaveDialog = () => {
+//   if (
+//     !forms.rainfall ||
+//     !forms.duration ||
+//     !forms.intensity ||
+//     (simStore.selectTab === "琛屾斂鍖哄垝浠跨湡" && !forms.eare) ||
+//     (simStore.selectTab === "閲嶇偣鍖哄煙浠跨湡" && !forms.eares)
+//   ) {
+//     ElMessage.warning("璇峰厛濉啓鎵�鏈夊繀濉」");
+//     return;
+//   }
+//   ElMessageBox.confirm("纭畾瑕佷繚瀛樺綋鍓嶆柟妗堝悧?", dialogTitle.value, {
+//     confirmButtonText: "纭畾",
+//     cancelButtonText: "鍙栨秷",
+//     type: "warning",
+//   })
+//     .then(confirmSave)
+//     .catch(() => {
+//       ElMessage({
+//         type: "info",
+//         message: "宸插彇娑堜繚瀛�",
+//       });
+//     });
+// };
+// const confirmSave = async () => {
+//   if (isLoading.value) {
+//     ElMessage.warning("姝e湪淇濆瓨锛岃绋嶅��...");
+//     return; // 闃叉閲嶅鎻愪氦
+//   }
+//   isLoading.value = true; // 寮�濮嬪姞杞界姸鎬�
+//   try {
+//     await simStore.createSimulation(forms); // 璋冪敤 Store 涓殑淇濆瓨鏂规硶
+//     ElMessage.success("淇濆瓨鎴愬姛");
+//     saveDialogVisible.value = true; // 鏄剧ず淇濆瓨瀵硅瘽妗嗭紙濡傛灉闇�瑕侊級
+//   } catch (error) {
+//     console.error("淇濆瓨澶辫触:", error);
+//     ElMessage.error("淇濆瓨澶辫触锛岃绋嶅悗閲嶈瘯");
+//   } finally {
+//     isLoading.value = false; // 缁撴潫鍔犺浇鐘舵��
+//   }
+// };
+//////////////////////////////////鎺ュ彛鐗堟湰鍚敤//////////////////////////////////
 
 // 閲嶇疆琛ㄥ崟
 const resetForm = () => {
@@ -345,21 +413,6 @@
   return true;
 };
 
-const disForm = ref("");
-
-// 瀹氫箟 Props
-const props = defineProps({
-  clickValue: String,
-});
-
-// 鐩戝惉 Props 鍙樺寲
-watch(
-  () => props.clickValue,
-  (newValue) => {
-    disForm.value = newValue || "琛屾斂鍖哄垝浠跨湡";
-  },
-  { immediate: true, deep: true }
-);
 
 // 寮�濮嬫ā鎷�
 function startPlay() {
diff --git a/src/views/left/Left.vue b/src/views/left/Left.vue
index 37afbff..1a8e365 100644
--- a/src/views/left/Left.vue
+++ b/src/views/left/Left.vue
@@ -15,24 +15,20 @@
         <el-button @click="deleteSelectedScheme">鍒犻櫎浠跨湡鏂规</el-button>
         <!-- <el-button>鍒犻櫎浠跨湡鏂规</el-button> -->
       </div>
-      <!-- <div class="mock">
-        <div
-          class="mock-item"
-          :class="item.name == currentMock ? 'active' : ''"
-          v-for="item in mockList"
-          :key="item.id"
-          @click="handleClick(item)"
-        >
-          <div class="mock-item-text">{{ item.name }}</div>
-        </div>
-      </div> -->
-      <!-- <RiverLevel v-show="currentMock === '鍒犻櫎浠跨湡鏂规'" />
-      <listInfo
-        v-show="currentMock === '鏂板缓浠跨湡鏂规'"
+      <!-- 鎺ュ彛鐗堟湰鍒犻櫎璇ヤ唬鐮佸潡 -->
+      <schemeCard
+        ref="schemeCardRef"
         @start="start"
         @end="end"
+        @reset="reset"
+      />
+      <!-- <schemeCard
+        ref="schemeCardRef"
+        @start="start"
+        @end="end"
+        @reset="reset"
+        :deleteSim="deleteSim"
       /> -->
-      <schemeCard ref="schemeCardRef" @start="start" @end="end" />
     </div>
   </div>
   <div class="left" v-show="showAddIns">
@@ -52,15 +48,7 @@
 // import { deviceDictList, getDictName } from "@/constant/dict.js";
 import { getDeviceData } from "@/api/index";
 const emits = defineEmits(["start", "end"]);
-// const currentMock = ref("鏂板缓浠跨湡鏂规");
-// const mockList = ref([
-//   {
-//     name: "鍒犻櫎浠跨湡鏂规",
-//   },
-//   {
-//     name: "鏂板缓浠跨湡鏂规",
-//   },
-// ]);
+
 const list = [
   {
     alias: "瀛欒儭娌熶富娌熸柇闈�1",
@@ -410,9 +398,12 @@
   // entities.push(entity)
 }
 const schemeCardRef = ref(null);
+
 function deleteSelectedScheme() {
   const selectedId = schemeCardRef.value.getSelectedId();
-  const selectedScheme = simStore.schemCard.find(item => item.id === selectedId);
+  const selectedScheme = simStore.schemCard.find(
+    (item) => item.id === selectedId
+  );
   if (!selectedId) {
     ElMessage.warning("璇峰厛閫夋嫨涓�涓柟妗堬紒");
     return;
@@ -423,16 +414,16 @@
     {
       confirmButtonText: "纭畾",
       cancelButtonText: "鍙栨秷",
-      type: "warning", 
+      type: "warning",
     }
   )
     .then(() => {
       simStore.removeSchemCardItem(selectedId);
       ElMessage.success(`鏂规 "${selectedScheme.name}" 鍒犻櫎鎴愬姛锛乣);
     })
-    .catch(() => {
-    });
+    .catch(() => {});
 }
+
 function start(form) {
   emits("start", form);
 }
@@ -451,6 +442,17 @@
   });
   divPointList = [];
 });
+
+///////////////////////////鍒犻櫎浠跨湡鏂规///////////////////////////
+// const deleteSim = ref(false);
+
+// function reset() {
+//   deleteSim.value = false; // 閲嶇疆鏍囧織浣�
+// }
+// function deleteSelectedScheme() {
+//   deleteSim.value = true;
+// }
+///////////////////////////鍒犻櫎浠跨湡鏂规///////////////////////////
 </script>
 <style lang="less" scoped>
 .mock {
diff --git a/src/views/left/Simulation.vue b/src/views/left/Simulation.vue
index c170efe..3c459ff 100644
--- a/src/views/left/Simulation.vue
+++ b/src/views/left/Simulation.vue
@@ -1,24 +1,24 @@
 <template>
   <div style="height: 100%">
-    <div class="left-top" style="margin-bottom: 20px;">
+    <div class="left-top" style="margin-bottom: 20px">
       <span>鏂板缓浠跨湡鏂规</span>
       <span class="clickable-text" @click="goBack">杩斿洖鍒楄〃</span>
     </div>
     <el-tabs
-      style="height: calc(100% - 40px);"
+      style="height: calc(100% - 40px)"
       v-model="activeName"
       type="card"
       class="demo-tabs"
       @tab-click="handleClick"
     >
       <el-tab-pane label="琛屾斂鍖哄垝浠跨湡" name="first">
-        <city-sim :clickValue="clickValue" />
+        <city-sim />
       </el-tab-pane>
       <el-tab-pane label="閲嶇偣鍖哄煙浠跨湡" name="second">
-        <city-sim :clickValue="clickValue" />
+        <city-sim />
       </el-tab-pane>
       <el-tab-pane label="閲嶇偣娌熶豢鐪�" name="third">
-        <kg-sim :clickValue="clickValue" />
+        <kg-sim />
       </el-tab-pane>
     </el-tabs>
   </div>
@@ -28,6 +28,10 @@
 import { ref, defineEmits } from "vue";
 import citySim from "./CitySim.vue";
 import kgSim from "./KGSim.vue";
+
+import { useSimStore } from "@/store/simulation";
+
+const simStore = useSimStore();
 
 // 瀹氫箟杩斿洖浜嬩欢
 const emits = defineEmits(["back"]);
@@ -40,8 +44,7 @@
 
 // 鏍囩鐐瑰嚮浜嬩欢
 const handleClick = (tab) => {
-  clickValue.value = tab.props.label;
-  console.log(clickValue.value);
+  simStore.handleClickTab(tab.props.label);
 };
 
 // 杩斿洖涓婁竴绾�
@@ -58,7 +61,7 @@
   font-weight: 600;
   height: 100%;
 }
-/deep/.el-tabs__header{
+/deep/.el-tabs__header {
   margin: 0px !important;
 }
 /deep/ .el-tabs__item.is-active,
@@ -77,7 +80,7 @@
   font-size: 14px;
   color: #61f7d4;
 }
-.el-tab-pane{
+.el-tab-pane {
   height: 100%;
 }
-</style>
\ No newline at end of file
+</style>
diff --git a/vue.config.js b/vue.config.js
index 5703929..7e985b7 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -14,19 +14,19 @@
   },
   //鏂板
   devServer: {
-    port: 8080, 
-    open: true, 
+    port: 8080,
+    open: true,
     host: '0.0.0.0',
-    https: false, 
-    hot: true, 
+    https: false,
+    hot: true,
     proxy: {
       '/api': {
-        target: 'http://192.168.1.106:8079',
+        target: 'http://192.168.56.107:8078',
         changeOrigin: true,
         pathRewrite: {
-          '^/api': '' 
+          '^/api': ''
         },
-        secure: false 
+        secure: false
       },
       '/hp': {
         target: 'http://192.168.56.106:9511',

--
Gitblit v1.9.3