From dd527b7615517c53d7e4de92ae6cc87c18fa844c Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期二, 22 四月 2025 11:12:22 +0800 Subject: [PATCH] 保留api --- src/views/left/CitySim.vue | 138 ++++++++++++++++++++++----------------------- 1 files changed, 68 insertions(+), 70 deletions(-) diff --git a/src/views/left/CitySim.vue b/src/views/left/CitySim.vue index ef72134..5fdc7bf 100644 --- a/src/views/left/CitySim.vue +++ b/src/views/left/CitySim.vue @@ -108,7 +108,7 @@ <el-button type="success" @click="startPlay">寮�濮嬫ā鎷�</el-button> </div> <!---------------------------- 淇濆瓨鏂规瀵硅瘽妗嗭紙鎺ュ彛鐗堟湰闇�鍒犻櫎锛� --------------------------------> - <el-dialog + <!-- <el-dialog v-model="saveDialogVisible" :title="dialogTitle" width="50%" @@ -134,7 +134,7 @@ <el-button type="primary" @click="confirmSave">纭畾淇濆瓨</el-button> </span> </template> - </el-dialog> + </el-dialog> --> </div> </div> </template> @@ -145,8 +145,6 @@ import Papa from "papaparse"; import { ElMessage, ElMessageBox } from "element-plus"; import { initeWaterPrimitiveView } from "@/utils/water"; -import { createSimData } from "@/api/trApi"; - import { useSimStore } from "@/store/simulation"; const simStore = useSimStore(); @@ -206,44 +204,7 @@ }); ////////////////////////////////////// 鎺ュ彛鐗堟湰闇�鍒犻櫎////////////////////////////////////// -// 鎵撳紑淇濆瓨鏂规瀵硅瘽妗� -const openSaveDialog = () => { - if ( - !forms.rainfall || - !forms.duration || - !forms.intensity || - (simStore.selectTab === "琛屾斂鍖哄垝浠跨湡" && !forms.eare) || - (simStore.selectTab === "閲嶇偣鍖哄煙浠跨湡" && !forms.eares) - ) { - ElMessage.warning("璇峰厛濉啓鎵�鏈夊繀濉」"); - return; - } - saveDialogVisible.value = true; -} -const handleClose = () => { - saveDialogVisible.value = false; -}; - -// 纭淇濆瓨 -const confirmSave = () => { - console.log("淇濆瓨鏂规鎴愬姛", { - 妯℃嫙绫诲瀷: dialogTitle.value, - 琛屾斂鍖哄煙: simStore.selectTab === "琛屾斂鍖哄垝浠跨湡" ? forms.eare : null, - 閲嶇偣鍖哄煙: simStore.selectTab === "閲嶇偣鍖哄煙浠跨湡" ? forms.eares : null, - 闄嶉洦閲�: `${forms.rainfall} mm`, - 闄嶉洦鏃堕暱: `${forms.duration} h`, - 闄嶉洦寮哄害: `${forms.intensity} mm/h`, - 涓婁紶鏂囦欢: forms.fileList.map((file) => file.name), - }); - ElMessage.success("鏂规宸蹭繚瀛�"); - saveDialogVisible.value = false; - resetForm(); -}; -////////////////////////////////////// 缁撴潫鍒犻櫎////////////////////////////////////// - -//////////////////////////////////鎺ュ彛鐗堟湰鍚敤////////////////////////////////// -// const isLoading = ref(false); -// // 淇濆瓨鏂规 +// // 鎵撳紑淇濆瓨鏂规瀵硅瘽妗� // const openSaveDialog = () => { // if ( // !forms.rainfall || @@ -255,36 +216,73 @@ // ElMessage.warning("璇峰厛濉啓鎵�鏈夊繀濉」"); // return; // } -// ElMessageBox.confirm("纭畾瑕佷繚瀛樺綋鍓嶆柟妗堝悧?", dialogTitle.value, { -// confirmButtonText: "纭畾", -// cancelButtonText: "鍙栨秷", -// type: "warning", -// }) -// .then(confirmSave) -// .catch(() => { -// ElMessage({ -// type: "info", -// message: "宸插彇娑堜繚瀛�", -// }); -// }); +// saveDialogVisible.value = true; +// } +// const handleClose = () => { +// saveDialogVisible.value = false; // }; -// 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 confirmSave = () => { +// console.log("淇濆瓨鏂规鎴愬姛", { +// 妯℃嫙绫诲瀷: dialogTitle.value, +// 琛屾斂鍖哄煙: simStore.selectTab === "琛屾斂鍖哄垝浠跨湡" ? forms.eare : null, +// 閲嶇偣鍖哄煙: simStore.selectTab === "閲嶇偣鍖哄煙浠跨湡" ? forms.eares : null, +// 闄嶉洦閲�: `${forms.rainfall} mm`, +// 闄嶉洦鏃堕暱: `${forms.duration} h`, +// 闄嶉洦寮哄害: `${forms.intensity} mm/h`, +// 涓婁紶鏂囦欢: forms.fileList.map((file) => file.name), +// }); +// ElMessage.success("鏂规宸蹭繚瀛�"); +// 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; // 缁撴潫鍔犺浇鐘舵�� + } +}; //////////////////////////////////鎺ュ彛鐗堟湰鍚敤////////////////////////////////// // 閲嶇疆琛ㄥ崟 -- Gitblit v1.9.3