From bd13b522f95d4f9429eb0e8bc7df2e1ce3d58554 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期三, 16 四月 2025 16:41:55 +0800
Subject: [PATCH] change

---
 src/views/left/KGSimOption/HistorySimulation.vue |   95 +++++++++++++++++++++--------------------------
 1 files changed, 42 insertions(+), 53 deletions(-)

diff --git a/src/views/left/KGSimOption/HistorySimulation.vue b/src/views/left/KGSimOption/HistorySimulation.vue
index bc2b332..3aa57d0 100644
--- a/src/views/left/KGSimOption/HistorySimulation.vue
+++ b/src/views/left/KGSimOption/HistorySimulation.vue
@@ -1,7 +1,7 @@
 <template>
   <div class="history-simulation">
     <div class="left-top">
-      <span>鍘嗗彶妯℃嫙</span>
+      <span @click="getRainData">鍘嗗彶妯℃嫙</span>
       <span class="clickable-text" @click="toggleDetails">{{
         isCollapsed ? "灞曞紑" : "鏀惰捣"
       }}</span>
@@ -10,46 +10,26 @@
       <div class="input-group">
         <div class="input-item">
           <label>鍘嗗彶闆ㄦ儏:</label>
-          <el-select
-            v-model="rainfallHistory"
-            placeholder="璇烽�夋嫨"
-            popper-class="mySelectStyle"
-          >
-            <el-option
-              v-for="item in HistoricalRainData"
-              :key="item.id"
-              :label="item.name"
-              :value="item.id"
-            ></el-option>
+          <el-select v-model="rainfallHistory" placeholder="璇烽�夋嫨" popper-class="mySelectStyle">
+            <el-option v-for="item in HistoricalRainData" :key="item.id" :label="item.name"
+              :value="item.id"></el-option>
           </el-select>
         </div>
       </div>
       <div class="input-group">
         <div class="input-item">
           <label>闄嶉洦鎬婚噺:</label>
-          <el-input
-            v-model="totalRainfall"
-            type="number"
-            placeholder="璇疯緭鍏�"
-          ></el-input>
+          <el-input v-model="totalRainfall" type="number" placeholder="璇疯緭鍏�"></el-input>
           <span>mm</span>
         </div>
         <div class="input-item">
           <label>闄嶉洦寮哄害:</label>
-          <el-input
-            v-model="rainfallIntensity"
-            type="number"
-            placeholder="璇疯緭鍏�"
-          ></el-input>
+          <el-input v-model="rainfallIntensity" type="number" placeholder="璇疯緭鍏�"></el-input>
           <span>mm/h</span>
         </div>
         <div class="input-item">
           <label>闄嶉洦鏃堕暱:</label>
-          <el-input
-            v-model="rainfallDuration"
-            type="number"
-            placeholder="璇疯緭鍏�"
-          ></el-input>
+          <el-input v-model="rainfallDuration" type="number" placeholder="璇疯緭鍏�"></el-input>
           <span>h</span>
         </div>
       </div>
@@ -64,13 +44,8 @@
     </div>
 
     <!-- 淇濆瓨鏂规瀵硅瘽妗� -->
-    <el-dialog
-      v-model="saveDialogVisible"
-      title="淇濆瓨鏂规"
-      width="50%"
-      :before-close="handleClose"
-      custom-class="custom-dialog"
-    >
+    <el-dialog v-model="saveDialogVisible" title="淇濆瓨鏂规" width="50%" :before-close="handleClose"
+      custom-class="custom-dialog">
       <div class="dialog-content">
         <p><strong>鎵�閫夐噸鐐规矡锛�</strong>{{ props.selectedArea }}</p>
         <p><strong>妯℃嫙绫诲瀷锛�</strong>鍘嗗彶妯℃嫙</p>
@@ -90,19 +65,24 @@
 </template>
 
 <script setup>
-import { ref, computed } from "vue";
+import { ref, computed, inject } from "vue";
 import { ElMessage } from "element-plus";
 import { initeWaterPrimitiveView } from "@/utils/water";
-const emit = defineEmits(["start", "end"]);
+import { useSimStore } from "@/store/simulation.js"; // 寮曞叆 Store
+import { getRainfallData  } from "@/api/hpApi.js"
+// 鑾峰彇 Store 瀹炰緥
+const simStore = useSimStore();
+// 娴嬭瘯鑾峰彇闆ㄩ噺鏁版嵁
+// const getRainData = () => {
+//   getRainfallData()
+//     .then((a) => {
+//       console.log(a, '瀹忓浘鑾峰彇闆ㄩ噺鏁版嵁');
+//     })
+// };
 
-function endPlay() {
-  emit("end");
-}
+// 娉ㄥ叆妯℃嫙鎿嶄綔鏂规硶
+const { startSimulate, endSimulate } = inject("simulateActions");
 
-function startPlay() {
-  initeWaterPrimitiveView();
-  emit("start");
-}
 // 瀹氫箟 Props
 const props = defineProps({
   selectedArea: {
@@ -163,22 +143,31 @@
 
 // 纭淇濆瓨
 const confirmSave = () => {
-  console.log("淇濆瓨鏂规鎴愬姛", {
-    鍖哄煙: props.selectedArea,
-    妯℃嫙绫诲瀷: "鍘嗗彶妯℃嫙",
-    鍘嗗彶闆ㄦ儏: selectedRainfallName.value,
-    闄嶉洦鎬婚噺: `${totalRainfall.value} mm`,
-    闄嶉洦寮哄害: `${rainfallIntensity.value} mm/h`,
-    闄嶉洦鏃堕暱: `${rainfallDuration.value} h`,
-  });
+  // 鏋勯�犳柊鐨勬柟妗堝璞�
+  const newScheme = {
+    id: Date.now().toString(), // 鍞竴 ID
+    area: props.selectedArea, // 鍖哄煙
+    name: selectedRainfallName.value, // 鏂规鍚嶇О
+    createTime: new Date().toISOString(), // 鍒涘缓鏃堕棿
+    taskStatus: 1, // 鍒濆鐘舵�佷负鏈紑濮�
+    totalRainfall: totalRainfall.value, // 闄嶉洦鎬婚噺
+    rainfallIntensity: rainfallIntensity.value, // 闄嶉洦寮哄害
+    rainfallDuration: rainfallDuration.value, // 闄嶉洦鏃堕暱
+  };
+
+  simStore.addSchemCard(newScheme);
   ElMessage.success("鏂规宸蹭繚瀛�");
+  // 鍏抽棴瀵硅瘽妗�
   saveDialogVisible.value = false;
 };
+
 // 寮�濮嬫ā鎷�
-const startSimulation = () => {
+function startPlay() {
   console.log("寮�濮嬫ā鎷熸寜閽鐐瑰嚮");
   console.log("褰撳墠閫変腑鐨勫尯鍩燂細", props.selectedArea);
-};
+  initeWaterPrimitiveView();
+  startSimulate();
+}
 </script>
 
 <style scoped>

--
Gitblit v1.9.3