From a536b494ca955c8a669f127d35d8e7e72789cbd2 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 21 Apr 2025 19:41:31 +0800
Subject: [PATCH] feat:删除无用store方法调用

---
 src/views/SignMachineNest/SignMachineNest.vue |   89 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/src/views/SignMachineNest/SignMachineNest.vue b/src/views/SignMachineNest/SignMachineNest.vue
index 2ff56b8..48913f7 100644
--- a/src/views/SignMachineNest/SignMachineNest.vue
+++ b/src/views/SignMachineNest/SignMachineNest.vue
@@ -1,9 +1,88 @@
 <template>
-  <MachineLeft></MachineLeft>
-  <MachineRight></MachineRight>
+	<MachineLeft></MachineLeft>
+	<MachineRight></MachineRight>
 </template>
 
 <script setup>
-import MachineLeft from './components/MachineLeft/MachineLeft.vue'
-import MachineRight from './components/MachineRight/MachineRight.vue';
-</script>
\ No newline at end of file
+import MachineLeft from '@/views/SignMachineNest/MachineLeft/MachineLeft.vue'
+import MachineRight from '@/views/SignMachineNest/MachineRight/MachineRight.vue'
+import { useStore } from 'vuex'
+import { getDeviceDetail, getEventList, getFlightStatistics } from '@/api/home/machineNest'
+import { useSingleDroneMap } from '@/hooks/useSingleDroneMap/useSingleDroneMap'
+import { useDroneWS } from '@/hooks/useDroneWS'
+import _ from 'lodash'
+import { getAreaCodeApi } from '@/api/home'
+const store = useStore()
+let connectWs = ref(null)
+// 单个机巢信息
+const singleUavHome = computed(() => store.state.home.singleUavHome)
+let workspaceId = ref('')
+let { wsInfo } = useDroneWS(workspaceId) //ws信息,是一个ref对象
+const dockSn = computed(() => singleUavHome.value.device_sn) //机巢sn
+const droneSn = computed(() => wsInfo.value?.device_osd?.data?.sn) //无人机sn
+const singleTotal = ref({})
+const dockDetails = ref('')
+provide('dockSn', dockSn)
+provide('droneSn', droneSn)
+provide('wsInfo', wsInfo)
+provide('dockDetails', dockDetails)
+provide('singleTotal', singleTotal)
+
+// 单机巢初始化及事件撒点
+const { init, initEventLayer, initDroneEntity } = useSingleDroneMap({
+	eventApi: getEventList,
+	eventApiParams: {
+		device_sn: singleUavHome.value.device_sn,
+	},
+})
+
+const getSingleDetails = () => {
+	getDeviceDetail(singleUavHome.value.device_sn).then(res => {
+		const result = res.data.data
+		dockDetails.value = result
+    const storageObj  = _.pick(result, ['latitude', 'longitude'])
+		setSingleUavAreaCode(storageObj)
+		initDroneEntity({
+			lng: result.longitude,
+			lat: result.latitude,
+			status: result.status,
+		})
+		workspaceId.value = result.workspace_id
+	})
+}
+
+// 设置单机巢得位置信息
+const setSingleUavAreaCode = (position) =>{
+	store.commit('setSingleUavHome',{...singleUavHome.value, ...position})
+	const params = {
+		output:'json',
+		location: position.longitude+','+position.latitude,
+		key:'6c3ea75b215f0c0efcbcfdf13273991b',
+		radius:'0',
+		extensions:'base',
+	}
+	// todo 2025年4月23号 后端提供接口然后对接
+	// getAreaCodeApi(params).then(res => {
+	// 	console.log(res,66666666)
+	// })
+}
+
+
+// 获取机巢统计数据 提供给左右侧组件使用
+const getMachineData = () => {
+	getFlightStatistics(singleUavHome.value.device_sn).then(res => {
+		if (res.data.code !== 0) return
+		singleTotal.value = res.data.data
+	})
+}
+
+onMounted(() => {
+	initEventLayer()
+	getSingleDetails()
+	getMachineData()
+})
+
+onUnmounted(() => {
+	connectWs?.value?.close()
+})
+</script>

--
Gitblit v1.9.3