From 479c2855f93517517037dd5805ba3512e9aec37d Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期二, 15 四月 2025 14:58:01 +0800
Subject: [PATCH] change

---
 src/store/simulation.js                          |   33 ++++++++++
 src/views/left/KGSimOption/HistorySimulation.vue |   42 +++++++++----
 src/components/monifangzhen/schemeCard.vue       |   46 ++++++++------
 3 files changed, 86 insertions(+), 35 deletions(-)

diff --git a/src/components/monifangzhen/schemeCard.vue b/src/components/monifangzhen/schemeCard.vue
index 06402eb..11112fe 100644
--- a/src/components/monifangzhen/schemeCard.vue
+++ b/src/components/monifangzhen/schemeCard.vue
@@ -1,20 +1,19 @@
 <template>
   <div class="listCard">
-    <el-card v-for="(item, key) in schemCard" :key="key">
+    <!-- <div>鏂规鏁伴噺: {{ simStore.schemCard.length }}</div> -->
+    <el-card v-for="(item, key) in simStore.schemCard" :key="key">
       <div>
         <p>鏂规鍚嶇О : {{ item.name }}</p>
-        <p>鍒涘缓鏃堕棿 : {{ item.createTime }}</p>
+        <p>鍒涘缓鏃堕棿 : {{ formatTime(item.createTime) }}</p>
         <p>
           鏂规鐘舵�� :
-          <span style="color: aquamarine">{{ item.status || "宸插畬鎴�" }}</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="startPlay"> 杩涘叆妯℃嫙 </el-button>
+          <el-button size="small" @click="setSchemClick(item)">鏂规璇︽儏</el-button>
+          <el-button size="small" @click="startPlay(item)" :disabled="item.taskStatus !== 2">杩涘叆妯℃嫙</el-button>
         </div>
       </div>
     </el-card>
@@ -29,13 +28,14 @@
 
 <script setup>
 import { ref } from "vue";
+import dayjs from "dayjs";
 import { initeWaterPrimitiveView } from "@/utils/water";
 import Message from "@/components/tools/Message.vue";
-// import { useSimStore } from "@/store/simulation";
+import { useSimStore } from "@/store/simulation.js";
 
-// const simStore = useSimStore();
+const simStore = useSimStore();
 
-const schemCard = ref([
+simStore.setSchemCard([
   {
     area: "瀛欒儭娌�",
     areaId: "0",
@@ -277,28 +277,34 @@
     userId: "0",
   },
 ]);
-// function setSchemClick(res) {
-//   simStore.messageShow = true;
-// }
+const statusText = {
+  0: "鏈紑濮�",
+  1: "杩涜涓�",
+  2: "宸插畬鎴�",
+};
+function formatTime(time) {
+  return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
+}
 const messageShow = ref(false);
 const mesData = ref(null);
 function setSchemClick(item) {
-  
   mesData.value = item;
-  console.log(mesData.value,'dadadaddaadaadadadad');
   messageShow.value = true;
 }
 function close() {
   messageShow.value = false;
 }
+function startPlay(item) {
+  // if (item.taskStatus !== 2) {
+  //   alert("褰撳墠鏂规灏氭湭瀹屾垚锛屾棤娉曡繘鍏ユā鎷燂紒");
+  //   return;
+  // }
+  initeWaterPrimitiveView();
+  emit("start");
+}
 const emit = defineEmits(["start", "end"]);
 function endPlay() {
   emit("end");
-}
-
-function startPlay() {
-  initeWaterPrimitiveView();
-  emit("start");
 }
 </script>
 
diff --git a/src/store/simulation.js b/src/store/simulation.js
index 5976841..8fd427c 100644
--- a/src/store/simulation.js
+++ b/src/store/simulation.js
@@ -23,6 +23,7 @@
     const showResultAssess = ref(false)
     const showLayerTree = ref(true)
     const showDangerAssess = ref(false)
+    const schemCard = ref([])
 
     // 鍒濆鍖栨柟娉�
     const init = () => {
@@ -41,6 +42,31 @@
         deviceShow.value = false
         showResultAssess.value = false
         showDangerAssess.value = false
+        schemCard.value = []
+    }
+    // 鏂规鐩稿叧
+    const setSchemCard = (data) => {
+        schemCard.value = data
+        console.log(schemCard,'aaaaaaaaaaaaaa');
+        
+    }
+
+    // 娣诲姞鍗曚釜鏂规鏁版嵁
+    const addSchemCardItem = (item) => {
+        schemCard.value.push(item)
+    }
+
+    // 鍒犻櫎鎸囧畾鏂规鏁版嵁
+    const removeSchemCardItem = (id) => {
+        schemCard.value = schemCard.value.filter(item => item.id !== id)
+    }
+
+    // 鏇存柊鎸囧畾鏂规鏁版嵁
+    const updateSchemCardItem = (id, newData) => {
+        const index = schemCard.value.findIndex(item => item.id === id)
+        if (index !== -1) {
+            schemCard.value[index] = { ...schemCard.value[index], ...newData }
+        }
     }
 
 
@@ -109,6 +135,11 @@
         startYHGL,
         startZHJC,
         startMNFZ,
-        startMNPG
+        startMNPG,
+        schemCard,
+        setSchemCard,
+        addSchemCardItem,
+        removeSchemCardItem,
+        updateSchemCardItem,
     }
 })
\ No newline at end of file
diff --git a/src/views/left/KGSimOption/HistorySimulation.vue b/src/views/left/KGSimOption/HistorySimulation.vue
index f7dc304..c3431e0 100644
--- a/src/views/left/KGSimOption/HistorySimulation.vue
+++ b/src/views/left/KGSimOption/HistorySimulation.vue
@@ -93,14 +93,14 @@
 import { ref, computed, inject } from "vue";
 import { ElMessage } from "element-plus";
 import { initeWaterPrimitiveView } from "@/utils/water";
+import { useSimStore } from "@/store/simulation.js"; // 寮曞叆 Store
+
+// 鑾峰彇 Store 瀹炰緥
+const simStore = useSimStore();
+
+// 娉ㄥ叆妯℃嫙鎿嶄綔鏂规硶
 const { startSimulate, endSimulate } = inject("simulateActions");
 
-function startPlay() {
-  console.log("寮�濮嬫ā鎷熸寜閽鐐瑰嚮");
-  console.log("褰撳墠閫変腑鐨勫尯鍩燂細", props.selectedArea);
-  initeWaterPrimitiveView();
-  startSimulate();
-}
 // 瀹氫箟 Props
 const props = defineProps({
   selectedArea: {
@@ -161,17 +161,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: 0, // 鍒濆鐘舵�佷负鏈紑濮�
+    totalRainfall: totalRainfall.value, // 闄嶉洦鎬婚噺
+    rainfallIntensity: rainfallIntensity.value, // 闄嶉洦寮哄害
+    rainfallDuration: rainfallDuration.value, // 闄嶉洦鏃堕暱
+  };
+
+  simStore.addSchemCardItem(newScheme);
   ElMessage.success("鏂规宸蹭繚瀛�");
+  // 鍏抽棴瀵硅瘽妗�
   saveDialogVisible.value = false;
 };
+
+// 寮�濮嬫ā鎷�
+function startPlay() {
+  console.log("寮�濮嬫ā鎷熸寜閽鐐瑰嚮");
+  console.log("褰撳墠閫変腑鐨勫尯鍩燂細", props.selectedArea);
+  initeWaterPrimitiveView();
+  startSimulate();
+}
 </script>
 
 <style scoped>

--
Gitblit v1.9.3