From e15245c624a20a3b46e428d646f5f2dd863cd1bc Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期四, 17 四月 2025 14:22:36 +0800
Subject: [PATCH] 完善

---
 src/store/simulation.js |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/src/store/simulation.js b/src/store/simulation.js
index cbb2e60..d99e4d2 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,7 @@
     const showLayerTree = ref(true)
     const showDangerAssess = ref(false)
     const schemCard = ref([])
+    const selectTab = ref("琛屾斂鍖哄垝浠跨湡")
 
     // 鍒濆鍖栨柟娉�
     const init = () => {
@@ -43,7 +45,44 @@
         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
@@ -128,16 +167,19 @@
         showResultAssess,
         showLayerTree,
         showDangerAssess,
+        schemCard,
+        selectTab,
         handleNavClick,
         init,
         startYHGL,
         startZHJC,
         startMNFZ,
         startMNPG,
-        schemCard,
         setSchemCard,
         addSchemCard,
         removeSchemCardItem,
         updateSchemCardItem,
+        handleClickTab,
+        createSimulation,
     }
 })
\ No newline at end of file

--
Gitblit v1.9.3