forked from drone/command-center-dashboard

罗广辉
2025-04-21 c695410b656d40f87e6a93de5f2a1876878273a4
fix: 单个机巢详情里面的飞行建议10%
3 files modified
76 ■■■■■ changed files
src/api/home/index.js 8 ●●●●● patch | view | raw | blame | history
src/router/views/index.js 12 ●●●●● patch | view | raw | blame | history
src/views/SignMachineNest/SignMachineNest.vue 56 ●●●●● patch | view | raw | blame | history
src/api/home/index.js
@@ -122,3 +122,11 @@
    })
}
// 根据经纬度获取区域code
export const getAreaCodeApi = (params) => {
    return axios({
        url: `https://restapi.amap.com/v3/geocode/regeo`,
        method: 'post',
        params
    })
}
src/router/views/index.js
@@ -17,18 +17,6 @@
                component: () => import(/* webpackChunkName: "home" */ '@/views/Home/Home.vue'),
            },
            {
                path: 'signMachineNest',
                name: '单个机巢详情',
                meta: {
                    i18n: 'dashboard',
                    menu: false,
                },
                component: () =>
                    import(
                        /* webpackChunkName: "TaskManage" */ '@/views/SignMachineNest/SignMachineNest.vue'
                    ),
            },
            {
                path: 'taskManage',
                name: '任务管理',
                meta: {
src/views/SignMachineNest/SignMachineNest.vue
@@ -7,19 +7,26 @@
import MachineLeft from '@/views/SignMachineNest/MachineLeft/MachineLeft.vue'
import MachineRight from '@/views/SignMachineNest/MachineRight/MachineRight.vue'
import { useStore } from 'vuex'
import { getDeviceDetail, getFlightStatistics, getEventList } from '@/api/home/machineNest'
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 osdVisible = ref({})
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({
@@ -29,22 +36,12 @@
    },
})
let workspace_id = ref('')
let { wsInfo } = useDroneWS(workspace_id) //ws信息,是一个ref对象
const dockSn = computed(() => singleUavHome.value.device_sn) //机巢sn
const droneSn = computed(() => wsInfo.value?.device_osd?.data?.sn) //无人机sn
provide('dockSn', dockSn)
provide('droneSn', droneSn)
provide('wsInfo',wsInfo)
// 获取单个机巢信息
const dockDetails= ref('')
provide('dockDetails', dockDetails)
const getSingleDetails = () => {
    getDeviceDetail(singleUavHome.value.device_sn).then(res => {
        const result = res.data.data
        dockDetails.value = result
        workspace_id.value = result.workspace_id
    const storageObj  = _.pick(result, ['latitude', 'longitude'])
        setSingleUavAreaCode(storageObj)
        initDroneEntity({
            lng: result.longitude,
            lat: result.latitude,
@@ -53,14 +50,29 @@
        workspaceId.value = result.workspace_id
    })
}
const singleTotal = ref({})
provide('singleTotal', singleTotal)
// 设置单机巢得位置信息
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
        const result = res.data.data
        singleTotal.value = result
        singleTotal.value = res.data.data
    })
}