From d9c26a8b8b4336c53696b96d0ce3340758597777 Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期二, 22 四月 2025 15:10:22 +0800 Subject: [PATCH] 增加接口 --- src/views/left/CitySim.vue | 136 ++++++++++++--------------------------------- 1 files changed, 37 insertions(+), 99 deletions(-) diff --git a/src/views/left/CitySim.vue b/src/views/left/CitySim.vue index 5fdc7bf..20eca2a 100644 --- a/src/views/left/CitySim.vue +++ b/src/views/left/CitySim.vue @@ -107,34 +107,6 @@ <el-button type="primary" @click="openSaveDialog">淇濆瓨鏂规</el-button> <el-button type="success" @click="startPlay">寮�濮嬫ā鎷�</el-button> </div> - <!---------------------------- 淇濆瓨鏂规瀵硅瘽妗嗭紙鎺ュ彛鐗堟湰闇�鍒犻櫎锛� --------------------------------> - <!-- <el-dialog - v-model="saveDialogVisible" - :title="dialogTitle" - width="50%" - :before-close="handleClose" - custom-class="custom-dialog" - > - <div class="dialog-content"> - <p><strong>妯℃嫙绫诲瀷锛�</strong>{{ dialogTitle }}</p> - <p v-if="disForm === '琛屾斂鍖哄垝浠跨湡'"> - <strong>琛屾斂鍖哄煙锛�</strong>{{ forms.eare }} - </p> - <p v-if="disForm === '閲嶇偣鍖哄煙浠跨湡'"> - <strong>閲嶇偣鍖哄煙锛�</strong>{{ forms.eares }} - </p> - <p><strong>闄嶉洦閲忥細</strong>{{ forms.rainfall }} mm</p> - <p><strong>闄嶉洦鏃堕暱锛�</strong>{{ forms.duration }} h</p> - <p><strong>闄嶉洦寮哄害锛�</strong>{{ forms.intensity }} mm/h</p> - <p><strong>涓婁紶鏂囦欢锛�</strong>{{ uploadedFilesText }}</p> - </div> - <template #footer> - <span class="dialog-footer"> - <el-button @click="saveDialogVisible = false">鍙栨秷</el-button> - <el-button type="primary" @click="confirmSave">纭畾淇濆瓨</el-button> - </span> - </template> - </el-dialog> --> </div> </div> </template> @@ -145,13 +117,12 @@ import Papa from "papaparse"; import { ElMessage, ElMessageBox } from "element-plus"; import { initeWaterPrimitiveView } from "@/utils/water"; -import { useSimStore } from "@/store/simulation"; +import { SimAPIStore } from "@/store/simAPI"; -const simStore = useSimStore(); +const simStore = SimAPIStore(); // 娉ㄥ叆鐖剁粍浠舵彁渚涚殑鏂规硶 const { startSimulate, endSimulate } = inject("simulateActions"); -const saveDialogVisible = ref(false); // 鎺у埗淇濆瓨鏂规瀵硅瘽妗嗙殑鏄剧ず鐘舵�侊紙鎺ュ彛鐗堟湰鍒犻櫎锛� // 琛ㄥ崟鏁版嵁 const forms = reactive({ name: "", @@ -203,8 +174,13 @@ return forms.fileList.map((file) => file.name).join(", ") || "鏃�"; }); -////////////////////////////////////// 鎺ュ彛鐗堟湰闇�鍒犻櫎////////////////////////////////////// -// // 鎵撳紑淇濆瓨鏂规瀵硅瘽妗� +//////////////////////////////////鎺ュ彛鐗堟湰鍚敤////////////////////////////////// +const openSaveDialog = async () => { + await simStore.openSaveDialog(forms); +}; + +// const isLoading = ref(false); +// // 淇濆瓨鏂规 // const openSaveDialog = () => { // if ( // !forms.rainfall || @@ -216,73 +192,36 @@ // ElMessage.warning("璇峰厛濉啓鎵�鏈夊繀濉」"); // return; // } -// saveDialogVisible.value = true; -// } -// const handleClose = () => { -// saveDialogVisible.value = false; +// ElMessageBox.confirm("纭畾瑕佷繚瀛樺綋鍓嶆柟妗堝悧?", dialogTitle.value, { +// confirmButtonText: "纭畾", +// cancelButtonText: "鍙栨秷", +// type: "warning", +// }) +// .then(confirmSave) +// .catch(() => { +// ElMessage({ +// type: "info", +// message: "宸插彇娑堜繚瀛�", +// }); +// }); // }; - -// // 纭淇濆瓨 -// 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 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 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; // 缁撴潫鍔犺浇鐘舵�� - } -}; //////////////////////////////////鎺ュ彛鐗堟湰鍚敤////////////////////////////////// // 閲嶇疆琛ㄥ崟 @@ -410,7 +349,6 @@ } return true; }; - // 寮�濮嬫ā鎷� function startPlay() { -- Gitblit v1.9.3