From 2a45e8331f65e4fc6dee2fba898bfbeaa01b0f5c Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Mon, 21 Apr 2025 16:34:15 +0800
Subject: [PATCH] Merge branch 'test' of http://139.196.74.78:10010/r/drone/command-center-dashboard into test

---
 src/views/SignMachineNest/MachineRight/MachineStatus/MachineStatus.vue |  131 +++++++++++--------------------------------
 1 files changed, 34 insertions(+), 97 deletions(-)

diff --git a/src/views/SignMachineNest/MachineRight/MachineStatus/MachineStatus.vue b/src/views/SignMachineNest/MachineRight/MachineStatus/MachineStatus.vue
index ad8534a..c735d0b 100644
--- a/src/views/SignMachineNest/MachineRight/MachineStatus/MachineStatus.vue
+++ b/src/views/SignMachineNest/MachineRight/MachineStatus/MachineStatus.vue
@@ -7,7 +7,7 @@
 				<img src="../../../../assets/images/signMachineNest/machineRight/wrj.png" alt="" />
 				<div class="info-right">
 					<!-- <div class="name">{{ osdVisible?.callsign || '--' }}</div> -->
-					<div class="name">{{ osdVisible?.nickname || '--' }}</div>
+					<div class="name">{{ dockDetails?.nickname || '--' }}</div>
 					<div class="wz">
 						<span class="left">当前位置:</span>
 						<span class="right">{{ detailInfo.longitude }},{{ detailInfo.latitude }}</span>
@@ -96,16 +96,18 @@
 import { useStore } from 'vuex'
 import MachineTableDetails from '@/views/SignMachineNest/MachineRight/MachineStatus/MachineTableDetails/MachineTableDetails.vue'
 
-const store = useStore()
 // 获取机巢信息
-let osdVisible = ref({}) //computed(() => store.state.home.osdVisible);
-const singleUavHome = computed(() => store.state.home.singleUavHome)
+const wsInfo = inject('wsInfo')
+const dockDetails = inject('dockDetails')
+let device_osd_info = computed(() => wsInfo.value?.device_osd || {})
+let device_osd_host = computed(() => device_osd_info?.value?.data?.host || {})
+let dock_osd_info = computed(() => wsInfo.value?.dock_osd || {})
+let dock_osd_host = computed(() => dock_osd_info.value?.data?.host || {})
 // 单个机巢统计数据
-const singleTotal = computed(() => store.state.home.singleTotal)
+const singleTotal = inject('singleTotal')
 // 是否展示机机巢状态详情
 let isShowDetails = ref(false)
 
-let str = '--'
 let drone_charge_state = ref({
 	capacity_percent: '--',
 	state: 0,
@@ -122,55 +124,16 @@
 	capacity_percent: '--',
 })
 let quality = ref(['弱', '较弱', '中等', '较强', '强'])
-let deviceInfo = ref({
-	gateway: {
-		capacity_percent: str,
-		transmission_signal_quality: str,
-	},
-	dock: {},
-	device: {
-		gear: -1,
-		mode_code: EModeCode.Disconnected,
-		height: str,
-		home_distance: str,
-		horizontal_speed: str,
-		vertical_speed: str,
-		wind_speed: str,
-		wind_direction: str,
-		elevation: str,
-		position_state: {
-			gps_number: str,
-			is_fixed: 0,
-			rtk_number: str,
-		},
-		battery: {
-			capacity_percent: str,
-			landing_power: str,
-			remain_flight_time: 0,
-			return_home_power: str,
-		},
-		latitude: 0,
-		longitude: 0,
-	},
-})
-let mode_code = ref('已断开连接')
-
-watch(
-	() => store.state.home.osdVisible,
-	newValue => {
-		osdVisible.value = newValue
-	}
-)
 
 // 监听实时信息
 watch(
-	() => store.state.home.wsMessage,
+	device_osd_host,
 	newValue => {
-		if (newValue.mode_code === 14) return
+		if (!newValue) return
+		if (newValue?.mode_code === 14) return
 		if (Object.keys(newValue).length === 0) return
 		detailInfo.value.longitude = newValue?.longitude.toFixed(6) || '--'
 		detailInfo.value.latitude = newValue?.latitude.toFixed(6) || '--'
-		// console.log(window.$viewer)
 		getLnglatAltitude(Number(detailInfo.value.longitude), Number(detailInfo.value.latitude), window.$viewer).then(
 			res => {
 				const height = newValue?.height - res?.height
@@ -191,57 +154,32 @@
 	},
 	{ immediate: true, deep: true }
 )
+
+// EDeviceTypeName.Dock
 // 获取最新机场状态
 watch(
-	store.state.home.deviceState,
-	newValue => {
-		// console.log('newValue', newValue);
-		if (newValue.currentType === EDeviceTypeName.Dock && newValue?.dockInfo[newValue.currentSn]) {
-			// 机场状态
-			mode_code.value = EDockModeText[newValue?.dockInfo[newValue.currentSn]?.basic_osd?.mode_code]
-			// this.$emit('updateModeCode', mode_code.value);
-			// 舱内状态
-			AircraftStatus.value =
-				EModeText[
-					newValue.deviceInfo[deviceInfo.value.dock.basic_osd?.sub_device?.device_sn ?? osdVisible.sn]?.mode_code
-				]
-			// 舱内关机时显示的电量
-			let child_sn = newValue?.dockInfo[newValue.currentSn].basic_osd?.sub_device?.device_sn
-			// 飞机在线时取飞机中的电量
-			if (newValue.deviceInfo[child_sn]) {
-				drone_charge_state.value = {
-					capacity_percent: newValue.deviceInfo[child_sn].battery.capacity_percent,
-					state: newValue.deviceInfo[child_sn].battery.landing_power,
-				}
-			} else {
-				// 遥控器这里拿不到值data.drone_charge_state_new == undefined 会一直报错
-				if (newValue.drone_charge_state_new) {
-					drone_charge_state.value = newValue.drone_charge_state_new
-				}
+	wsInfo,
+	() => {
+		if (device_osd_host.value?.mode_code !== undefined) {
+			AircraftStatus.value = EModeText?.[device_osd_host.value?.mode_code] || '--'
+		}
+		// 飞机在线时取飞机中的电量
+		if (device_osd_host.value?.battery) {
+			drone_charge_state.value = {
+				capacity_percent: device_osd_host.value.battery.capacity_percent,
+				state: device_osd_host.value.battery.landing_power,
 			}
-			if (osdVisible.value.visible && osdVisible.value.is_dock && osdVisible.value.gateway_sn !== '') {
-				deviceInfo.value.dock = newValue.dockInfo[osdVisible.value.gateway_sn]
-				deviceInfo.value.device =
-					newValue.deviceInfo[deviceInfo.value.dock.basic_osd?.sub_device?.device_sn ?? osdVisible.value.sn]
-				// 设备关机即不显示信息
-				// 兼容遥控器 关闭无人机 mode_code返回的是14 不是undefined
-				if (
-					newValue.deviceInfo[deviceInfo.value.dock.basic_osd?.sub_device?.device_sn ?? osdVisible.value.sn]
-						?.mode_code === undefined ||
-					newValue.deviceInfo[deviceInfo.value.dock.basic_osd?.sub_device?.device_sn ?? osdVisible.value.sn]
-						?.mode_code == 14
-				) {
-					detailInfo.value = {
-						longitude: '--',
-						latitude: '--',
-						home_distance: '--',
-						quality: '--',
-						horizontal_speed: '--',
-						remain_flight_time: '--',
-						height: '--',
-						capacity_percent: '--',
-					}
-				}
+		}
+		if (device_osd_host.value?.mode_code === undefined || device_osd_host.value?.mode_code === 14) {
+			detailInfo.value = {
+				longitude: '--',
+				latitude: '--',
+				home_distance: '--',
+				quality: '--',
+				horizontal_speed: '--',
+				remain_flight_time: '--',
+				height: '--',
+				capacity_percent: '--',
 			}
 		}
 	},
@@ -343,7 +281,6 @@
 				.close {
 					width: 60px;
 					height: 20px;
-					line-height: 20px;
 					background: rgba(255, 178, 106, 0.2);
 					border-radius: 4px 4px 4px 4px;
 					border: 1px solid #ffb26a;

--
Gitblit v1.9.3