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 |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 52 insertions(+), 6 deletions(-)

diff --git a/src/store/simulation.js b/src/store/simulation.js
index 009cfcc..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鐘舵��
@@ -24,6 +25,8 @@
     const showLayerTree = ref(true)
     const showDangerAssess = ref(false)
     const schemCard = ref([])
+    const selectTab = ref("琛屾斂鍖哄垝浠跨湡")
+    const backToHome = ref(false)
 
     // 鍒濆鍖栨柟娉�
     const init = () => {
@@ -37,18 +40,54 @@
         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
-        console.log(schemCard,'aaaaaaaaaaaaaa');
-        
     }
 
     // 娣诲姞鍗曚釜鏂规鏁版嵁
@@ -89,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) {
@@ -130,16 +171,21 @@
         showResultAssess,
         showLayerTree,
         showDangerAssess,
+        schemCard,
+        selectTab,
         handleNavClick,
         init,
         startYHGL,
         startZHJC,
         startMNFZ,
         startMNPG,
-        schemCard,
         setSchemCard,
         addSchemCard,
         removeSchemCardItem,
         updateSchemCardItem,
+        handleClickTab,
+        createSimulation,
+        backToHome,
+        setBackToHome
     }
 })
\ No newline at end of file

--
Gitblit v1.9.3