forked from drone/command-center-dashboard

罗广辉
2025-04-18 61e6956be147e1e84e7104f16dd47e9f87f20dfd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<template>
    <div class="detailsHead">
        <div class="droneName">小蓝工业园</div>
        <div class="infoListBox">
            <div v-for="item in infoList">
                <div class="infoValue">{{ item.value }}</div>
                <div class="infoTitle">{{ item.title }}</div>
            </div>
        </div>
        <div class="controlBtn">
            <el-icon class="refresh">
                <Refresh />
            </el-icon>
            <div class="switchBtn" @click="switchBtn">
                <div :class="{ open: open }">NO</div>
                <div :class="{ open: !open }">OFF</div>
            </div>
        </div>
    </div>
</template>
 
<script setup>
import { Refresh } from '@element-plus/icons-vue'
import { getFlightStatistics } from '@/api/home/machineNest'
import { throttle } from 'lodash'
import { getLnglatAltitude } from '@/utils/cesium/mapUtil'
import _ from 'lodash'
 
const taskDetailsViewer = inject('taskDetailsViewer')
const deviceOsdInfo = inject('deviceOsdInfo')
const dockSn = inject('dockSn')
const open = ref(true)
const singleTotal = ref({})
const host = computed(() => deviceOsdInfo?.value?.data?.host || {})
 
const infoList = computed(() => {
    const { longitude, latitude, height, payloads } = host?.value || {}
    return [
        { title: '实时真高', value: '0' },
        { title: '绝对高度', value: _.round(height || 0, 1) + 'm' },
        { title: '水平速度', value: '0' },
        { title: '垂直速度', value: '0' },
        { title: '经度', value: _.round(longitude || 0, 2) },
        { title: '纬度', value: _.round(latitude || 0, 2) },
        { title: '4G信号', value: '0' },
        { title: 'SDR信号', value: '0' },
        { title: 'GPS搜星数', value: '0' },
        { title: 'RTK搜星数', value: '0' },
        { title: '距离机场', value: '0' },
        { title: '飞行时长', value: (singleTotal.value?.hour_count || 0) + '小时' },
        { title: '电池电量', value: (host?.value?.battery?.capacity_percent || 0) + '%' },
    ]
})
 
const switchBtn = () => {
    open.value = !open.value
}
 
function getFlightStatisticsFun() {
    if (!dockSn.value) return
    getFlightStatistics(dockSn.value).then(res => {
        singleTotal.value = res.data.data
    })
}
 
function getRealTimeReallyHigh() {
    if (!taskDetailsViewer?.value) return
    const { latitude, longitude, height } = host?.value || {}
    if (!latitude) return
    getLnglatAltitude(longitude, latitude, taskDetailsViewer.value).then(res => {
        const findIndex = infoList.value.findIndex(item => item.title === '实时真高')
        infoList.value[findIndex].value = _.round(height - res?.height, 1) + 'm'
    })
}
 
const getRealTimeReallyHighThrottle = throttle(getRealTimeReallyHigh, 500, { leading: true, trailing: true })
watch(
    deviceOsdInfo,
    () => {
        getRealTimeReallyHighThrottle()
    },
    { immediate: true }
)
 
watch(
    dockSn,
    () => {
        getFlightStatisticsFun()
    },
    { immediate: true }
)
</script>
 
<style scoped lang="scss">
.detailsHead {
    position: absolute;
    top: 0;
    z-index: 5;
    width: 100%;
    height: 68px;
    background: rgb(0, 0, 0, 0.4); /* 半透明背景 */
    backdrop-filter: blur(5px);
    padding: 0 31px;
    display: flex;
    align-items: center;
 
    .droneName {
        width: 132px;
        height: 42px;
        background: rgba(74, 72, 72, 0.54);
        box-shadow: 0px 4px 72px 0px rgba(0, 0, 0, 0.25);
        border-radius: 8px 8px 8px 8px;
        border: 1px solid rgba(255, 255, 255, 0.99);
        font-family: Segoe UI, Segoe UI;
        font-weight: normal;
        font-size: 18px;
        color: #ededed;
        text-align: center;
        line-height: 42px;
    }
 
    .infoListBox {
        width: 0;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-around;
        font-family: Segoe UI, Segoe UI;
        font-weight: 400;
 
        .infoValue {
            font-size: 20px;
            color: #ffffff;
            line-height: 15px;
            margin-bottom: 10px;
        }
 
        .infoTitle {
            font-size: 12px;
            color: #d2e8fa;
            line-height: 15px;
        }
    }
 
    .controlBtn {
        width: 130px;
        display: flex;
        align-items: center;
        justify-content: space-between;
 
        .refresh {
            color: white;
            font-size: 30px;
            cursor: pointer;
        }
 
        .switchBtn {
            width: 70px;
            height: 30px;
            box-shadow: 2px 4px 20px 0px rgba(0, 13, 26, 0.23);
            border-radius: 4px 4px 4px 4px;
            border: 1px solid #ffffff;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-family: Segoe UI, Segoe UI;
            font-weight: bold;
            font-size: 14px;
            line-height: 30px;
            text-align: center;
            color: #ffffff;
            cursor: pointer;
 
            > div {
                width: 50%;
            }
 
            .open {
                background: #ffffff;
                color: #242424;
            }
        }
    }
}
</style>