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

---
 src/views/left/CitySim.vue |  113 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 83 insertions(+), 30 deletions(-)

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() {

--
Gitblit v1.9.3