From c478619b44e437b9df2179adfa79a1e50b6be222 Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期三, 23 四月 2025 10:22:05 +0800 Subject: [PATCH] 提交 --- src/views/left/CitySim.vue | 70 +++++++++++++++++++--------------- 1 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/views/left/CitySim.vue b/src/views/left/CitySim.vue index 7565ca9..45d5aa2 100644 --- a/src/views/left/CitySim.vue +++ b/src/views/left/CitySim.vue @@ -46,7 +46,7 @@ style="max-width: 600px" > <el-option - v-for="item in cityOptions" + v-for="item in options" :key="item.value" :label="item.label" :value="item.value" @@ -63,7 +63,7 @@ style="max-width: 600px" > <el-option - v-for="item in earesOptions" + v-for="item in options" :key="item.value" :label="item.label" :value="item.value" @@ -119,57 +119,60 @@ import { initeWaterPrimitiveView } from "@/utils/water"; import { SimAPIStore } from "@/store/simAPI"; import { getRegionData } from "@/api/trApi"; +import { storeToRefs } from "pinia"; -const cityOptions = reactive([]); +const simStore = SimAPIStore(); +const { selectTab } = storeToRefs(simStore); -onMounted(() => { - getRegionData({ type: 1 }).then((res) => { - console.log(res, "res"); +const options = reactive([]); + +// 瀹氫箟涓�涓柟娉曪紝鐢ㄤ簬鏍规嵁 type 鑾峰彇鍖哄煙鏁版嵁 +const fetchRegionData = (type) => { + getRegionData({ type: type }).then((res) => { // 浣跨敤鍝嶅簲寮忔暟缁勭殑鏂规硶鏇存柊鍐呭 - cityOptions.splice( + options.splice( 0, - cityOptions.length, + options.length, ...res.data.map((item) => ({ value: item.geom, label: item.name, })) ); }); +}; + +onMounted(() => { + fetchRegionData(1); }); -const simStore = SimAPIStore(); +// 鐩戝惉 selectTab 鐨勫彉鍖� +watch(selectTab, (newVal) => { + let type; + switch (newVal) { + case "琛屾斂鍖哄垝浠跨湡": + type = 1; + break; + case "閲嶇偣鍖哄煙浠跨湡": + type = 2; + break; + default: + type = 1; // 榛樿鍊� + } + fetchRegionData(type); +}); // 娉ㄥ叆鐖剁粍浠舵彁渚涚殑鏂规硶 const { startSimulate, endSimulate } = inject("simulateActions"); // 琛ㄥ崟鏁版嵁 const forms = reactive({ name: "", - eare: "鍖椾含甯�", + eare: "", eares: "瀛欒儭娌�", rainfall: "", duration: "", intensity: "", fileList: [], -}); - -const earesOptions = [ - { value: "瀛欒儭娌�", label: "瀛欒儭娌�" }, - { value: "楸兼按娲炲悗娌�", label: "楸兼按娲炲悗娌�" }, - { value: "浜庡瑗挎矡", label: "浜庡瑗挎矡" }, - { value: "鍖楁渤娌�", label: "鍖楁渤娌�" }, - { value: "榫欐硥宄潙", label: "榫欐硥宄潙" }, -]; - -// 璁$畻灞炴�э細鑾峰彇瀵硅瘽妗嗘爣棰� -const dialogTitle = computed(() => { - return simStore.selectTab === "琛屾斂鍖哄垝浠跨湡" - ? "琛屾斂鍖哄垝浠跨湡" - : "閲嶇偣鍖哄煙浠跨湡"; -}); - -// 璁$畻灞炴�э細鑾峰彇涓婁紶鏂囦欢鐨勫悕绉板垪琛� -const uploadedFilesText = computed(() => { - return forms.fileList.map((file) => file.name).join(", ") || "鏃�"; + type: 3, }); const addSimCheme = async () => { @@ -178,7 +181,7 @@ // 閲嶇疆琛ㄥ崟 const resetForm = () => { - forms.eare = "鍖椾含甯�"; + forms.eare = ""; forms.eares = "瀛欒儭娌�"; forms.rainfall = ""; forms.duration = ""; @@ -186,6 +189,11 @@ forms.fileList = []; }; +// 璁$畻灞炴�э細鑾峰彇涓婁紶鏂囦欢鐨勫悕绉板垪琛� +const uploadedFilesText = computed(() => { + return forms.fileList.map((file) => file.name).join(", ") || "鏃�"; +}); + // 鏂囦欢鍙樺寲鏃惰Е鍙戣В鏋� const handleFileChange = (file) => { const reader = new FileReader(); -- Gitblit v1.9.3