From 11cef93fa041289db9fafd4cb654b20d53cb2c51 Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期三, 23 四月 2025 11:30:03 +0800 Subject: [PATCH] 新建方案 --- src/views/left/KGSimOption/HistorySimulation.vue | 107 +++++++---------------------------------------------- 1 files changed, 15 insertions(+), 92 deletions(-) diff --git a/src/views/left/KGSimOption/HistorySimulation.vue b/src/views/left/KGSimOption/HistorySimulation.vue index f19670f..22daa86 100644 --- a/src/views/left/KGSimOption/HistorySimulation.vue +++ b/src/views/left/KGSimOption/HistorySimulation.vue @@ -19,7 +19,7 @@ v-for="item in HistoricalRainData" :key="item.id" :label="item.name" - :value="item.id" + :value="item.name" ></el-option> </el-select> </div> @@ -104,9 +104,11 @@ import { initeWaterPrimitiveView } from "@/utils/water"; import { useSimStore } from "@/store/simulation.js"; // 寮曞叆 Store import { getRainfallData } from "@/api/hpApi.js"; +import { SimAPIStore } from "@/store/simAPI"; // 鑾峰彇 Store 瀹炰緥 -const simStore = useSimStore(); +const simStore = SimAPIStore(); + // 娴嬭瘯鑾峰彇闆ㄩ噺鏁版嵁 // const getRainData = () => { // getRainfallData() @@ -127,7 +129,7 @@ }); // 鏁版嵁缁戝畾 -const rainfallHistory = ref("2"); // 榛樿閫変腑绗簩椤� +const rainfallHistory = ref("XX骞�50mm闄嶉洦"); // 榛樿閫変腑绗簩椤� const totalRainfall = ref(50); // 闄嶉洦鎬婚噺 const schemeName = ref("鏂规鍚嶇О"); // 鏂规鍚嶇О const rainfallIntensity = ref(70); // 闄嶉洦寮哄害 @@ -147,7 +149,7 @@ // 鑾峰彇褰撳墠閫変腑鐨勫巻鍙查洦鎯呭悕绉� const selectedRainfallName = computed(() => { const selected = HistoricalRainData.find( - (item) => item.id === rainfallHistory.value + (item) => item.name === rainfallHistory.value ); return selected ? selected.name : ""; }); @@ -158,102 +160,23 @@ }; // 鎵撳紑淇濆瓨鏂规瀵硅瘽妗� -const openSaveDialog = () => { - if ( - !props.selectedArea || - !rainfallHistory.value || - !totalRainfall.value || - !schemeName.value || - !rainfallIntensity.value || - !rainfallDuration.value - ) { - ElMessage.warning("璇峰厛濉啓鎵�鏈夊繀濉」"); - return; - } - 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; // 寮�濮嬪姞杞界姸鎬� - console.log("褰撳墠閫変腑鐨勫尯鍩� (selectedArea):", props.selectedArea); - - const params = { +const openSaveDialog = async () => { + const forms = { name: schemeName.value, - type: "鍘嗗彶妯℃嫙", - eares: props.selectedArea, - data: { - rainFall: totalRainfall.value, - rainfallIntensity: rainfallIntensity.value, - rainfallDuration: rainfallDuration.value, - rainfallHistory: rainfallHistory.value, - }, + geom: props.selectedArea, + type: 3, + rainfall: totalRainfall.value, + intensity: rainfallIntensity.value, + duration: rainfallDuration.value, + history: rainfallHistory.value, }; - - try { - await simStore.createSimulation(params); // 璋冪敤 Store 涓殑淇濆瓨鏂规硶 - ElMessage.success("淇濆瓨鎴愬姛"); - saveDialogVisible.value = false; // 鍏抽棴淇濆瓨瀵硅瘽妗� - } catch (error) { - console.error("淇濆瓨澶辫触:", error); - ElMessage.error("淇濆瓨澶辫触锛岃绋嶅悗閲嶈瘯"); - } finally { - isLoading.value = false; // 缁撴潫鍔犺浇鐘舵�� - } + await simStore.addSimCheme(forms); }; // 鍏抽棴淇濆瓨鏂规瀵硅瘽妗� const handleClose = () => { 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, // 闄嶉洦鏃堕暱 -// }; - -// simStore.addSchemCard(newScheme); -// ElMessage.success("鏂规宸蹭繚瀛�"); -// // 鍏抽棴瀵硅瘽妗� -// saveDialogVisible.value = false; -// }; // 寮�濮嬫ā鎷� function startPlay() { -- Gitblit v1.9.3