From c761bc5e98bd6b1fe0900f3cfb1bb4734e1aed47 Mon Sep 17 00:00:00 2001 From: wangjuncheng <1> Date: 星期四, 17 四月 2025 15:45:14 +0800 Subject: [PATCH] change --- src/store/simulation.js | 85 ++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 81 insertions(+), 4 deletions(-) diff --git a/src/store/simulation.js b/src/store/simulation.js index 5976841..a873b34 100644 --- a/src/store/simulation.js +++ b/src/store/simulation.js @@ -1,6 +1,7 @@ // stores/ui.js import { defineStore } from 'pinia' import { ref } from 'vue' +import { createSimData } from '@/api/trApi'; export const useSimStore = defineStore('ui', () => { // 鎵�鏈塙I鐘舵�� @@ -23,6 +24,9 @@ const showResultAssess = ref(false) const showLayerTree = ref(true) const showDangerAssess = ref(false) + const schemCard = ref([]) + const selectTab = ref("琛屾斂鍖哄垝浠跨湡") + const backToHome = ref(false) // 鍒濆鍖栨柟娉� const init = () => { @@ -36,11 +40,72 @@ locationShow.value = false tableShow.value = false flowShow.value = false + backToHome.value = false rightRiverShow.value = false showPreview.value = false deviceShow.value = false showResultAssess.value = false showDangerAssess.value = false + schemCard.value = [] + selectTab.value = "琛屾斂鍖哄垝浠跨湡" + + } + + const handleClickTab = (data) => { + selectTab.value = data + } + + // 鏂板缓鏂规 + const createSimulation = async (forms) => { + const getAreaType = (tabName) => { + switch (tabName) { + case '琛屾斂鍖哄垝浠跨湡': + return 1 + case '閲嶇偣鍖哄煙浠跨湡': + return 2 + case '閲嶇偣娌熶豢鐪�': + return 3 + default: + return 0 // 鑷畾涔� + } + } + const params = { + areaType: getAreaType(selectTab), + createTime: Date.now(), + name: forms.name, + // 1涓洪娴嬫ā鎷燂紝2涓哄疄鏃舵ā鎷燂紝3涓哄巻鍙叉ā鎷� + type: 1, + // 0涓哄垱寤轰豢鐪燂紝1涓洪澶勭悊锛�2涓哄垎鏋愪腑锛�10涓哄畬鎴愶紝20涓哄嚭閿� + status: 0, + } + try { + await createSimData(params) + } catch (error) { + console.error('鍒涘缓浠跨湡澶辫触:', error) + } + } + + // 鏂规鐩稿叧 + const setSchemCard = (data) => { + schemCard.value = data + } + + // 娣诲姞鍗曚釜鏂规鏁版嵁 + const addSchemCard = (item) => { + schemCard.value.unshift(item) + } + + // 鍒犻櫎鎸囧畾鏂规鏁版嵁 + const removeSchemCardItem = (id) => { + schemCard.value = schemCard.value.filter(item => item.id !== id) + } + + // 鏇存柊鎸囧畾鏂规鏁版嵁 + const updateSchemCardItem = (id, newData) => { + const index = schemCard.value.findIndex(item => item.id === id) + if (index !== -1) { + schemCard.value[index] = { ...schemCard.value[index], ...newData } + } } @@ -63,10 +128,12 @@ const startMNPG = () => { init() - showResultAssess.value = true - showDangerAssess.value = true + // showResultAssess.value = true + // showDangerAssess.value = true } - + const setBackToHome = (value) => { + backToHome.value = value; + }; // 瀵艰埅鐐瑰嚮 const handleNavClick = (index) => { switch (index) { @@ -104,11 +171,21 @@ showResultAssess, showLayerTree, showDangerAssess, + schemCard, + selectTab, handleNavClick, init, startYHGL, startZHJC, startMNFZ, - startMNPG + startMNPG, + setSchemCard, + addSchemCard, + removeSchemCardItem, + updateSchemCardItem, + handleClickTab, + createSimulation, + backToHome, + setBackToHome } }) \ No newline at end of file -- Gitblit v1.9.3