From 5caf72a91b204c78cdc91ce116beae5d445dc73d Mon Sep 17 00:00:00 2001 From: wangjuncheng <1> Date: 星期二, 22 四月 2025 16:23:28 +0800 Subject: [PATCH] Merge branch 'master' of http://103.135.160.14:9034/r/NslWeb --- src/views/left/KGSimOption/HistorySimulation.vue | 134 ++++++++++++++++++++++++++++++++++---------- 1 files changed, 102 insertions(+), 32 deletions(-) diff --git a/src/views/left/KGSimOption/HistorySimulation.vue b/src/views/left/KGSimOption/HistorySimulation.vue index ebde892..03a6708 100644 --- a/src/views/left/KGSimOption/HistorySimulation.vue +++ b/src/views/left/KGSimOption/HistorySimulation.vue @@ -10,30 +10,54 @@ <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="schemeName" type="text" placeholder="璇疯緭鍏�"></el-input> + <el-input + v-model="schemeName" + type="text" + placeholder="璇疯緭鍏�" + ></el-input> </div> <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> @@ -48,8 +72,13 @@ </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>{{ schemeName }}</p> <p><strong>鎵�閫夐噸鐐规矡锛�</strong>{{ props.selectedArea }}</p> @@ -71,10 +100,11 @@ <script setup> import { ref, computed, inject } from "vue"; -import { ElMessage } from "element-plus"; +import { ElMessage, ElMessageBox } from "element-plus"; import { initeWaterPrimitiveView } from "@/utils/water"; import { useSimStore } from "@/store/simulation.js"; // 寮曞叆 Store -import { getRainfallData } from "@/api/hpApi.js" +import { getRainfallData } from "@/api/hpApi.js"; + // 鑾峰彇 Store 瀹炰緥 const simStore = useSimStore(); // 娴嬭瘯鑾峰彇闆ㄩ噺鏁版嵁 @@ -99,7 +129,7 @@ // 鏁版嵁缁戝畾 const rainfallHistory = ref("2"); // 榛樿閫変腑绗簩椤� const totalRainfall = ref(50); // 闄嶉洦鎬婚噺 -const schemeName = ref('鏂规鍚嶇О'); // 鏂规鍚嶇О +const schemeName = ref("鏂规鍚嶇О"); // 鏂规鍚嶇О const rainfallIntensity = ref(70); // 闄嶉洦寮哄害 const rainfallDuration = ref(5); // 闄嶉洦鏃堕暱 const isCollapsed = ref(false); // 鎺у埗璇︽儏鐨勫睍寮�/鏀惰捣鐘舵�� @@ -140,7 +170,47 @@ ElMessage.warning("璇峰厛濉啓鎵�鏈夊繀濉」"); return; } - saveDialogVisible.value = true; + ElMessageBox.confirm("纭畾瑕佷繚瀛樺綋鍓嶆柟妗堝悧?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }) + .then(confirmSave) + .catch(() => { + ElMessage({ + type: "info", + message: "宸插彇娑堜繚瀛�", + }); + }); + // saveDialogVisible.value = true; +}; +const params = { + name: schemeName.value, + type: "鍘嗗彶妯℃嫙", + data: { + rainFall: totalRainfall.value, + rainfallIntensity: rainfallIntensity.value, + rainfallDuration: rainfallDuration.value, + rainfallHistory: rainfallHistory.value, + }, +}; +const isLoading = ref(false); +const confirmSave = async () => { + if (isLoading.value) { + ElMessage.warning("姝e湪淇濆瓨锛岃绋嶅��..."); + return; // 闃叉閲嶅鎻愪氦 + } + isLoading.value = true; // 寮�濮嬪姞杞界姸鎬� + try { + await simStore.createSimulation(params); // 璋冪敤 Store 涓殑淇濆瓨鏂规硶 + ElMessage.success("淇濆瓨鎴愬姛"); + saveDialogVisible.value = true; // 鏄剧ず淇濆瓨瀵硅瘽妗嗭紙濡傛灉闇�瑕侊級 + } catch (error) { + console.error("淇濆瓨澶辫触:", error); + ElMessage.error("淇濆瓨澶辫触锛岃绋嶅悗閲嶈瘯"); + } finally { + isLoading.value = false; // 缁撴潫鍔犺浇鐘舵�� + } }; // 鍏抽棴淇濆瓨鏂规瀵硅瘽妗� @@ -148,26 +218,26 @@ saveDialogVisible.value = false; }; -// 纭淇濆瓨 -const confirmSave = () => { - // 鏋勯�犳柊鐨勬柟妗堝璞� - const newScheme = { - id: Date.now().toString(), // 鍞竴 ID - area: props.selectedArea, // 鍖哄煙 - name: selectedRainfallName.value, // 鏂规鍚嶇О - createTime: new Date().toISOString(), // 鍒涘缓鏃堕棿 - taskStatus: 1, // 鍒濆鐘舵�佷负鏈紑濮� - totalRainfall: totalRainfall.value, // 闄嶉洦鎬婚噺 - schemeName: schemeName.value, // 闄嶉洦鎬婚噺 - rainfallIntensity: rainfallIntensity.value, // 闄嶉洦寮哄害 - rainfallDuration: rainfallDuration.value, // 闄嶉洦鏃堕暱 - }; +// // 纭淇濆瓨 +// const confirmSave = () => { +// // 鏋勯�犳柊鐨勬柟妗堝璞� +// const newScheme = { +// id: Date.now().toString(), // 鍞竴 ID +// area: props.selectedArea, // 鍖哄煙 +// name: selectedRainfallName.value, // 鏂规鍚嶇О +// createTime: new Date().toISOString(), // 鍒涘缓鏃堕棿 +// taskStatus: 1, // 鍒濆鐘舵�佷负鏈紑濮� +// totalRainfall: totalRainfall.value, // 闄嶉洦鎬婚噺 +// schemeName: schemeName.value, // 闄嶉洦鎬婚噺 +// rainfallIntensity: rainfallIntensity.value, // 闄嶉洦寮哄害 +// rainfallDuration: rainfallDuration.value, // 闄嶉洦鏃堕暱 +// }; - simStore.addSchemCard(newScheme); - ElMessage.success("鏂规宸蹭繚瀛�"); - // 鍏抽棴瀵硅瘽妗� - saveDialogVisible.value = false; -}; +// simStore.addSchemCard(newScheme); +// ElMessage.success("鏂规宸蹭繚瀛�"); +// // 鍏抽棴瀵硅瘽妗� +// saveDialogVisible.value = false; +// }; // 寮�濮嬫ā鎷� function startPlay() { -- Gitblit v1.9.3