| src/api/device-setting/index.js | ●●●●● patch | view | raw | blame | history | |
| src/store/modules/device.js | ●●●●● patch | view | raw | blame | history | |
| src/types/enums.js | ●●●●● patch | view | raw | blame | history | |
| src/views/device/components/DockControlPanel.vue | ●●●●● patch | view | raw | blame | history |
src/api/device-setting/index.js
@@ -8,16 +8,30 @@ * * Copyright (c) 2024 by shuishen, All Rights Reserved. */ import request from '@/axios'; import request from '@/axios' import { ELocalStorageKey } from '@/types'; import { ELocalStorageKey } from '@/types' const workspaceId = localStorage.getItem(ELocalStorageKey.WorkspaceId) || ''; const workspaceId = localStorage.getItem(ELocalStorageKey.WorkspaceId) || '' export const putDeviceProps = (deviceSn, body) => { return request({ url: `/drone-device-core/manage/api/v1/devices/${workspaceId}/devices/${deviceSn}/property`, method: 'put', body, }); }; }) } /** * 设置调色盘 * @param {机场编码} deviceSn * @param {*} body * @returns */ export const setThermalCurrentPaletteStyle = (deviceSn, workspaceId, body) => { return request({ // /manage/api/v1/devices/selectDevicePage url: `/drone-device-core/manage/api/v1/devices/${workspaceId}/devices/${deviceSn}/setThermalCurrentPaletteStyle`, method: 'put', body, }) } src/store/modules/device.js
@@ -1,4 +1,4 @@ import { EDeviceTypeName } from '@/types'; import { EDeviceTypeName } from '@/types' const initStateFunc = () => ({ Layers: [ @@ -46,6 +46,7 @@ currentSn: '', currentType: -1, }, videoSurveillance: {}, // 视频监控相关信息 osdVisible: { // osd 显示设备相关信息 sn: '', @@ -74,143 +75,148 @@ selectedAction: undefined, kmzPath: '', }, }); }) const mutations = { SET_LAYER_INFO(state, info) { state.Layers = info; // 获取视频相关信息 SAVE_VIDEO_SURVEILLANCE_INFO (state, info) { console.log('videoSurveillanceInfo', info) state.videoSurveillance = info }, SET_DEVICE_INFO(state, info) { state.deviceState.deviceInfo[info.sn] = info.host; state.deviceState.currentSn = info.sn; state.deviceState.currentType = EDeviceTypeName.Aircraft; SET_LAYER_INFO (state, info) { state.Layers = info }, SET_GATEWAY_INFO(state, info) { state.deviceState.gatewayInfo[info.sn] = info.host; state.deviceState.currentSn = info.sn; state.deviceState.currentType = EDeviceTypeName.Gateway; SET_DEVICE_INFO (state, info) { state.deviceState.deviceInfo[info.sn] = info.host state.deviceState.currentSn = info.sn state.deviceState.currentType = EDeviceTypeName.Aircraft }, SET_DOCK_INFO(state, info) { SET_GATEWAY_INFO (state, info) { state.deviceState.gatewayInfo[info.sn] = info.host state.deviceState.currentSn = info.sn state.deviceState.currentType = EDeviceTypeName.Gateway }, SET_DOCK_INFO (state, info) { if (Object.keys(info.host).length === 0) { return; return } if (!state.deviceState.dockInfo[info.sn]) { state.deviceState.dockInfo[info.sn] = {}; state.deviceState.dockInfo[info.sn] = {} } state.deviceState.currentSn = info.sn; state.deviceState.currentType = EDeviceTypeName.Dock; const dock = state.deviceState.dockInfo[info.sn]; state.deviceState.currentSn = info.sn state.deviceState.currentType = EDeviceTypeName.Dock const dock = state.deviceState.dockInfo[info.sn] if (info.host.mode_code !== undefined) { dock.basic_osd = info.host; return; dock.basic_osd = info.host return } if (info.host.sdr) { dock.link_osd = info.host; return; dock.link_osd = info.host return } if (info.host.job_number !== undefined) { dock.work_osd = info.host; dock.work_osd = info.host } }, SET_HMSInfo_DetailSn(state, data) { state.hmsInfoDetailSn = data; SET_HMSInfo_DetailSn (state, data) { state.hmsInfoDetailSn = data }, SET_DRAW_VISIBLE_INFO(state, bool) { state.drawVisible = bool; SET_DRAW_VISIBLE_INFO (state, bool) { state.drawVisible = bool }, SET_MAP_ELEMENT_CREATE(state, info) { state.wsEvent.mapElementCreat = info; SET_MAP_ELEMENT_CREATE (state, info) { state.wsEvent.mapElementCreat = info }, SET_MAP_ELEMENT_UPDATE(state, info) { state.wsEvent.mapElementUpdate = info; SET_MAP_ELEMENT_UPDATE (state, info) { state.wsEvent.mapElementUpdate = info }, SET_MAP_ELEMENT_DELETE(state, info) { state.wsEvent.mapElementDelete = info; SET_MAP_ELEMENT_DELETE (state, info) { state.wsEvent.mapElementDelete = info }, SET_DEVICE_ONLINE(state, info) { state.deviceStatusEvent.deviceOnline = info; SET_DEVICE_ONLINE (state, info) { state.deviceStatusEvent.deviceOnline = info }, SET_DEVICE_OFFLINE(state, info) { state.deviceStatusEvent.deviceOffline = info; delete state.deviceState.gatewayInfo[info.sn]; delete state.deviceState.deviceInfo[info.sn]; delete state.deviceState.dockInfo[info.sn]; delete state.hmsInfo[info.sn]; SET_DEVICE_OFFLINE (state, info) { state.deviceStatusEvent.deviceOffline = info delete state.deviceState.gatewayInfo[info.sn] delete state.deviceState.deviceInfo[info.sn] delete state.deviceState.dockInfo[info.sn] delete state.hmsInfo[info.sn] // delete state.markerInfo.coverMap[info.sn] // delete state.markerInfo.pathMap[info.sn] }, SET_OSD_VISIBLE_INFO(state, info) { state.osdVisible = info; SET_OSD_VISIBLE_INFO (state, info) { state.osdVisible = info }, SET_SELECT_WAYLINE_INFO(state, info) { state.waylineInfo = info; SET_SELECT_WAYLINE_INFO (state, info) { state.waylineInfo = info }, SET_SELECT_DOCK_INFO(state, info) { state.dockInfo = info; SET_SELECT_DOCK_INFO (state, info) { state.dockInfo = info }, SET_DEVICE_HMS_INFO(state, info) { const hmsList = state.hmsInfo[info.sn]; state.hmsInfo[info.sn] = info.host.concat(hmsList ?? []); SET_DEVICE_HMS_INFO (state, info) { const hmsList = state.hmsInfo[info.sn] state.hmsInfo[info.sn] = info.host.concat(hmsList ?? []) }, SET_DEVICES_CMD_EXECUTE_INFO(state, info) { SET_DEVICES_CMD_EXECUTE_INFO (state, info) { // 保存设备指令ws消息推送 if (!info.sn) { return; return } if (state.devicesCmdExecuteInfo[info.sn]) { const index = state.devicesCmdExecuteInfo[info.sn].findIndex( cmdExecuteInfo => cmdExecuteInfo.biz_code === info.biz_code ); ) if (index >= 0) { // 丢弃前面的消息 if (state.devicesCmdExecuteInfo[info.sn][index].timestamp > info.timestamp) { return; return } state.devicesCmdExecuteInfo[info.sn][index] = info; state.devicesCmdExecuteInfo[info.sn][index] = info } else { state.devicesCmdExecuteInfo[info.sn].push(info); state.devicesCmdExecuteInfo[info.sn].push(info) } } else { state.devicesCmdExecuteInfo[info.sn] = [info]; state.devicesCmdExecuteInfo[info.sn] = [info] } }, SET_MQTT_STATE(state, mqttState) { state.mqttState = mqttState; SET_MQTT_STATE (state, mqttState) { state.mqttState = mqttState }, SET_CLIENT_ID(state, clientId) { state.clientId = clientId; SET_CLIENT_ID (state, clientId) { state.clientId = clientId }, // 设置wayline中的信息 SET_WAYLINE_INFO(state, { isShow, selectedPoint, selectedAction }) { isShow !== undefined && (state.waylineTool.isShow = isShow); state.waylineTool.selectedPoint = selectedPoint; selectedAction !== undefined && (state.waylineTool.selectedAction = selectedAction); SET_WAYLINE_INFO (state, { isShow, selectedPoint, selectedAction }) { isShow !== undefined && (state.waylineTool.isShow = isShow) state.waylineTool.selectedPoint = selectedPoint selectedAction !== undefined && (state.waylineTool.selectedAction = selectedAction) }, SET_WAYLINE_KMZPATH(state, kmzPath) { state.waylineTool.kmzPath = kmzPath; SET_WAYLINE_KMZPATH (state, kmzPath) { state.waylineTool.kmzPath = kmzPath }, }; } const actions = { updateElement({ state }, content) { const key = content.id.replaceAll('resource__', ''); const type = content.type; const layers = state.Layers; const layer = layers.find(item => item.id === key); updateElement ({ state }, content) { const key = content.id.replaceAll('resource__', '') const type = content.type const layers = state.Layers const layer = layers.find(item => item.id === key) if (layer) { layer[type] = content.bool; layer[type] = content.bool } }, getLayerInfo({ state }, id) { return state.layerBaseInfo[id]; getLayerInfo ({ state }, id) { return state.layerBaseInfo[id] }, }; } const device = { state: initStateFunc, mutations, actions, }; } export default device; export default device src/types/enums.js
@@ -1,135 +1,137 @@ export let ERouterName; (function (ERouterName) { ERouterName['ELEMENT'] = 'element'; ERouterName['LOGIN'] = 'login'; ERouterName['PROJECT'] = 'project'; ERouterName['ADD_PROJECT'] = 'add_project'; ERouterName['EDIT_PROJECT'] = 'edit_project'; ERouterName['PROJECT_LIST'] = 'project_list'; ERouterName['HOME'] = 'home'; ERouterName['TSA'] = 'tsa'; ERouterName['LAYER'] = 'layer'; ERouterName['MEDIA'] = 'media'; ERouterName['WAYLINE'] = 'wayline'; ERouterName['LIVESTREAM'] = 'livestream'; ERouterName['LIVING'] = 'living'; ERouterName['WORKSPACE'] = 'workspace'; ERouterName['MEMBERS'] = 'members'; ERouterName['DEVICES'] = 'devices'; ERouterName['TASK'] = 'task'; ERouterName['CREATE_PLAN'] = 'create-plan'; ERouterName['SELECT_PLAN'] = 'select-plan'; ERouterName['FIRMWARES'] = 'firmwares'; ERouterName['PILOT'] = 'pilot-login'; ERouterName['PILOT_HOME'] = 'pilot-home'; ERouterName['PILOT_MEDIA'] = 'pilot-media'; ERouterName['PILOT_LIVESHARE'] = 'pilot-liveshare'; ERouterName['PILOT_BIND'] = 'pilot-bind'; ERouterName['IMPLEMENT'] = 'implement'; ERouterName['ROUTE_HISTORY'] = 'route-history'; })(ERouterName || (ERouterName = {})); ERouterName['ELEMENT'] = 'element' ERouterName['LOGIN'] = 'login' ERouterName['PROJECT'] = 'project' ERouterName['ADD_PROJECT'] = 'add_project' ERouterName['EDIT_PROJECT'] = 'edit_project' ERouterName['PROJECT_LIST'] = 'project_list' ERouterName['HOME'] = 'home' ERouterName['TSA'] = 'tsa' ERouterName['LAYER'] = 'layer' ERouterName['MEDIA'] = 'media' ERouterName['WAYLINE'] = 'wayline' ERouterName['LIVESTREAM'] = 'livestream' ERouterName['LIVING'] = 'living' ERouterName['WORKSPACE'] = 'workspace' ERouterName['MEMBERS'] = 'members' ERouterName['DEVICES'] = 'devices' ERouterName['TASK'] = 'task' ERouterName['CREATE_PLAN'] = 'create-plan' ERouterName['SELECT_PLAN'] = 'select-plan' ERouterName['FIRMWARES'] = 'firmwares' ERouterName['PILOT'] = 'pilot-login' ERouterName['PILOT_HOME'] = 'pilot-home' ERouterName['PILOT_MEDIA'] = 'pilot-media' ERouterName['PILOT_LIVESHARE'] = 'pilot-liveshare' ERouterName['PILOT_BIND'] = 'pilot-bind' ERouterName['IMPLEMENT'] = 'implement' ERouterName['ROUTE_HISTORY'] = 'route-history' })(ERouterName || (ERouterName = {})) export let EStorageKey; (function (EStorageKey) { EStorageKey['LANG_CODE'] = 'DJI_CREATE_VITE_H5_APP:lang_code'; EStorageKey['TEST_TOOLS_POSITION_STORAGE_KEY'] = 'DJI_CREATE_VITE_H5_APP:test_tools_position'; EStorageKey['SESSION_ID'] = 'DJI_CREATE_VITE_H5_APP:sess'; })(EStorageKey || (EStorageKey = {})); EStorageKey['LANG_CODE'] = 'DJI_CREATE_VITE_H5_APP:lang_code' EStorageKey['TEST_TOOLS_POSITION_STORAGE_KEY'] = 'DJI_CREATE_VITE_H5_APP:test_tools_position' EStorageKey['SESSION_ID'] = 'DJI_CREATE_VITE_H5_APP:sess' })(EStorageKey || (EStorageKey = {})) export let EStatusValue; (function (EStatusValue) { EStatusValue['CONNECTED'] = 'Connected'; EStatusValue['DISCONNECT'] = 'Disconnect'; EStatusValue['LIVING'] = 'Living'; })(EStatusValue || (EStatusValue = {})); EStatusValue['CONNECTED'] = 'Connected' EStatusValue['DISCONNECT'] = 'Disconnect' EStatusValue['LIVING'] = 'Living' })(EStatusValue || (EStatusValue = {})) export let ELiveStatusValue; (function (ELiveStatusValue) { ELiveStatusValue[(ELiveStatusValue['DISCONNECT'] = 0)] = 'DISCONNECT'; ELiveStatusValue[(ELiveStatusValue['CONNECTED'] = 1)] = 'CONNECTED'; ELiveStatusValue[(ELiveStatusValue['LIVING'] = 2)] = 'LIVING'; })(ELiveStatusValue || (ELiveStatusValue = {})); ELiveStatusValue[(ELiveStatusValue['DISCONNECT'] = 0)] = 'DISCONNECT' ELiveStatusValue[(ELiveStatusValue['CONNECTED'] = 1)] = 'CONNECTED' ELiveStatusValue[(ELiveStatusValue['LIVING'] = 2)] = 'LIVING' })(ELiveStatusValue || (ELiveStatusValue = {})) export let EComponentName; (function (EComponentName) { EComponentName['Thing'] = 'thing'; EComponentName['Liveshare'] = 'liveshare'; EComponentName['Api'] = 'api'; EComponentName['Ws'] = 'ws'; EComponentName['Map'] = 'map'; EComponentName['Tsa'] = 'tsa'; EComponentName['Media'] = 'media'; EComponentName['Mission'] = 'mission'; })(EComponentName || (EComponentName = {})); EComponentName['Thing'] = 'thing' EComponentName['Liveshare'] = 'liveshare' EComponentName['Api'] = 'api' EComponentName['Ws'] = 'ws' EComponentName['Map'] = 'map' EComponentName['Tsa'] = 'tsa' EComponentName['Media'] = 'media' EComponentName['Mission'] = 'mission' })(EComponentName || (EComponentName = {})) export let ELocalStorageKey; (function (ELocalStorageKey) { ELocalStorageKey['Username'] = 'username'; ELocalStorageKey['WorkspaceId'] = 'workspace_id'; ELocalStorageKey['Token'] = 'x-auth-token'; ELocalStorageKey['PlatformName'] = 'platform_name'; ELocalStorageKey['WorkspaceName'] = 'workspace_name'; ELocalStorageKey['WorkspaceDesc'] = 'workspace_desc'; ELocalStorageKey['Flag'] = 'flag'; ELocalStorageKey['UserId'] = 'user_id'; ELocalStorageKey['Device'] = 'device'; ELocalStorageKey['GatewayOnline'] = 'gateway_online'; ELocalStorageKey['UserInfo'] = 'user_info'; })(ELocalStorageKey || (ELocalStorageKey = {})); ELocalStorageKey['Username'] = 'username' ELocalStorageKey['WorkspaceId'] = 'workspace_id' ELocalStorageKey['Token'] = 'x-auth-token' ELocalStorageKey['PlatformName'] = 'platform_name' ELocalStorageKey['WorkspaceName'] = 'workspace_name' ELocalStorageKey['WorkspaceDesc'] = 'workspace_desc' ELocalStorageKey['Flag'] = 'flag' ELocalStorageKey['UserId'] = 'user_id' ELocalStorageKey['Device'] = 'device' ELocalStorageKey['GatewayOnline'] = 'gateway_online' ELocalStorageKey['UserInfo'] = 'user_info' })(ELocalStorageKey || (ELocalStorageKey = {})) export let EPhotoType; (function (EPhotoType) { EPhotoType[(EPhotoType['Original'] = 0)] = 'Original'; EPhotoType[(EPhotoType['Preview'] = 1)] = 'Preview'; EPhotoType[(EPhotoType['Unknown'] = -1)] = 'Unknown'; })(EPhotoType || (EPhotoType = {})); EPhotoType[(EPhotoType['Original'] = 0)] = 'Original' EPhotoType[(EPhotoType['Preview'] = 1)] = 'Preview' EPhotoType[(EPhotoType['Unknown'] = -1)] = 'Unknown' })(EPhotoType || (EPhotoType = {})) export let EDownloadOwner; (function (EDownloadOwner) { EDownloadOwner[(EDownloadOwner['Mine'] = 0)] = 'Mine'; EDownloadOwner[(EDownloadOwner['Others'] = 1)] = 'Others'; EDownloadOwner[(EDownloadOwner['Unknown'] = -1)] = 'Unknown'; })(EDownloadOwner || (EDownloadOwner = {})); EDownloadOwner[(EDownloadOwner['Mine'] = 0)] = 'Mine' EDownloadOwner[(EDownloadOwner['Others'] = 1)] = 'Others' EDownloadOwner[(EDownloadOwner['Unknown'] = -1)] = 'Unknown' })(EDownloadOwner || (EDownloadOwner = {})) export let EUserType; (function (EUserType) { EUserType[(EUserType['Web'] = 1)] = 'Web'; EUserType[(EUserType['Pilot'] = 2)] = 'Pilot'; })(EUserType || (EUserType = {})); EUserType[(EUserType['Web'] = 1)] = 'Web' EUserType[(EUserType['Pilot'] = 2)] = 'Pilot' })(EUserType || (EUserType = {})) export let EBizCode; (function (EBizCode) { EBizCode['GatewayOsd'] = 'gateway_osd'; EBizCode['DeviceOsd'] = 'device_osd'; EBizCode['DockOsd'] = 'dock_osd'; EBizCode['MapElementCreate'] = 'map_element_create'; EBizCode['MapElementUpdate'] = 'map_element_update'; EBizCode['MapElementDelete'] = 'map_element_delete'; EBizCode['DeviceOnline'] = 'device_online'; EBizCode['DeviceOffline'] = 'device_offline'; EBizCode['DeviceHms'] = 'device_hms'; EBizCode['FlightTaskProgress'] = 'flighttask_progress'; EBizCode['FlightTaskMediaProgress'] = 'file_upload_callback'; EBizCode['FlightTaskMediaHighestPriority'] = 'highest_priority_upload_flighttask_media'; EBizCode['DeviceReboot'] = 'device_reboot'; EBizCode['DroneOpen'] = 'drone_open'; EBizCode['DroneClose'] = 'drone_close'; EBizCode['DeviceFormat'] = 'device_format'; EBizCode['DroneFormat'] = 'drone_format'; EBizCode['CoverOpen'] = 'cover_open'; EBizCode['CoverClose'] = 'cover_close'; EBizCode['PutterOpen'] = 'putter_open'; EBizCode['PutterClose'] = 'putter_close'; EBizCode['ChargeOpen'] = 'charge_open'; EBizCode['ChargeClose'] = 'charge_close'; EBizCode['DeviceUpgrade'] = 'ota_progress'; EBizCode['DeviceLogUploadProgress'] = 'fileupload_progress'; EBizCode['ControlSourceChange'] = 'control_source_change'; EBizCode['FlyToPointProgress'] = 'fly_to_point_progress'; EBizCode['TakeoffToPointProgress'] = 'takeoff_to_point_progress'; EBizCode['JoystickInvalidNotify'] = 'joystick_invalid_notify'; EBizCode['DrcStatusNotify'] = 'drc_status_notify'; })(EBizCode || (EBizCode = {})); EBizCode['GatewayOsd'] = 'gateway_osd' EBizCode['DeviceOsd'] = 'device_osd' EBizCode['DockOsd'] = 'dock_osd' EBizCode['MapElementCreate'] = 'map_element_create' EBizCode['MapElementUpdate'] = 'map_element_update' EBizCode['MapElementDelete'] = 'map_element_delete' EBizCode['DeviceOnline'] = 'device_online' EBizCode['DeviceOffline'] = 'device_offline' EBizCode['DeviceHms'] = 'device_hms' EBizCode['FlightTaskProgress'] = 'flighttask_progress' EBizCode['FlightTaskMediaProgress'] = 'file_upload_callback' EBizCode['FlightTaskMediaHighestPriority'] = 'highest_priority_upload_flighttask_media' EBizCode['DeviceReboot'] = 'device_reboot' EBizCode['DroneOpen'] = 'drone_open' EBizCode['DroneClose'] = 'drone_close' EBizCode['DeviceFormat'] = 'device_format' EBizCode['DroneFormat'] = 'drone_format' EBizCode['CoverOpen'] = 'cover_open' EBizCode['CoverClose'] = 'cover_close' EBizCode['PutterOpen'] = 'putter_open' EBizCode['PutterClose'] = 'putter_close' EBizCode['ChargeOpen'] = 'charge_open' EBizCode['ChargeClose'] = 'charge_close' EBizCode['DeviceUpgrade'] = 'ota_progress' EBizCode['DeviceLogUploadProgress'] = 'fileupload_progress' EBizCode['ControlSourceChange'] = 'control_source_change' EBizCode['FlyToPointProgress'] = 'fly_to_point_progress' EBizCode['TakeoffToPointProgress'] = 'takeoff_to_point_progress' EBizCode['JoystickInvalidNotify'] = 'joystick_invalid_notify' EBizCode['DrcStatusNotify'] = 'drc_status_notify' EBizCode['VideoSurveillance'] = 'live_status' // 视频监控 })(EBizCode || (EBizCode = {})) export const EBizCodeMessage = { [EBizCode.DeviceOnline]: '设备在线', @@ -161,18 +163,18 @@ [EBizCode.TakeoffToPointProgress]: '一键起飞', [EBizCode.DrcStatusNotify]: '飞行控制模式状态', [EBizCode.JoystickInvalidNotify]: '设备端退出drc模式', }; } export let EDeviceTypeName; (function (EDeviceTypeName) { EDeviceTypeName[(EDeviceTypeName['Aircraft'] = 0)] = 'Aircraft'; EDeviceTypeName[(EDeviceTypeName['Gateway'] = 2)] = 'Gateway'; EDeviceTypeName[(EDeviceTypeName['Dock'] = 3)] = 'Dock'; })(EDeviceTypeName || (EDeviceTypeName = {})); EDeviceTypeName[(EDeviceTypeName['Aircraft'] = 0)] = 'Aircraft' EDeviceTypeName[(EDeviceTypeName['Gateway'] = 2)] = 'Gateway' EDeviceTypeName[(EDeviceTypeName['Dock'] = 3)] = 'Dock' })(EDeviceTypeName || (EDeviceTypeName = {})) export let EHmsLevel; (function (EHmsLevel) { EHmsLevel[(EHmsLevel['NOTICE'] = 0)] = 'NOTICE'; EHmsLevel[(EHmsLevel['CAUTION'] = 1)] = 'CAUTION'; EHmsLevel[(EHmsLevel['WARN'] = 2)] = 'WARN'; })(EHmsLevel || (EHmsLevel = {})); EHmsLevel[(EHmsLevel['NOTICE'] = 0)] = 'NOTICE' EHmsLevel[(EHmsLevel['CAUTION'] = 1)] = 'CAUTION' EHmsLevel[(EHmsLevel['WARN'] = 2)] = 'WARN' })(EHmsLevel || (EHmsLevel = {})) src/views/device/components/DockControlPanel.vue
@@ -8,14 +8,8 @@ <div class="control-cmd-wrapper"> <div class="control-cmd-header"> 远程调试 <el-switch v-model="debugStatus" @change="onDeviceStatusChange" active-text="开" inactive-text="关" class="debug-btn" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" /> <el-switch v-model="debugStatus" @change="onDeviceStatusChange" active-text="开" inactive-text="关" class="debug-btn" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" /> <el-divider /> </div> <div class="control-cmd-box"> @@ -25,15 +19,24 @@ <div class="item-status">{{ cmdItem.status }}</div> </div> <div class="control-cmd-item-right"> <el-button :disabled="!debugStatus || cmdItem.disabled" :loading="cmdItem.loading" size="small" type="primary" @click="sendControlCmd(cmdItem, index)" > <el-button :disabled="!debugStatus || cmdItem.disabled" :loading="cmdItem.loading" size="small" type="primary" @click="sendControlCmd(cmdItem, index)"> {{ cmdItem.operateText }} </el-button> </div> </div> </div> <el-divider>无人机设置</el-divider> <!-- 设置 0:白热,1:黑热,2:描红,3:医疗,5:彩虹 1,6:铁红,8:北极,11:熔岩,12:热铁,13:彩虹 2 --> <div class="control-cmd-box"> <div class="control-cmd-item"> <div class="control-cmd-item-left">调色盘样式</div> <div class="control-cmd-item-right"> <el-select @change="changs" v-model="valueStyle" placeholder="请选择"> <el-option v-for="item in paletteOptions" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </div> </div> </div> @@ -42,137 +45,188 @@ </template> <script setup> import EventBus from '@/event-bus'; import { EBizCode, ELocalStorageKey, ERouterName } from '@/types'; import { useConnectWebSocket } from '@/hooks/use-connect-websocket'; import { getWebsocketUrl } from '@/websocket/util/config'; import { defineProps, ref, watch } from 'vue'; import { cmdList as baseCmdList } from '@/types/device-cmd'; import { useDockControl } from './use-dock-control'; import { EDockModeCode } from '@/types/device'; import { updateDeviceCmdInfoByOsd, updateDeviceCmdInfoByExecuteInfo } from '@/utils/device-cmd'; import Store from '@/store'; import EventBus from '@/event-bus' import { EBizCode, ELocalStorageKey, ERouterName } from '@/types' import { useConnectWebSocket } from '@/hooks/use-connect-websocket' import { getWebsocketUrl } from '@/websocket/util/config' import { defineProps, ref, watch, reactive } from 'vue' import { cmdList as baseCmdList } from '@/types/device-cmd' import { useDockControl } from './use-dock-control' import { EDockModeCode } from '@/types/device' import { updateDeviceCmdInfoByOsd, updateDeviceCmdInfoByExecuteInfo } from '@/utils/device-cmd' import { setThermalCurrentPaletteStyle } from '@/api/device-setting' const props = defineProps(['sn', 'deviceInfo']); const initCmdList = baseCmdList.map(cmdItem => Object.assign({}, cmdItem)); const cmdList = ref(initCmdList); import Store from '@/store' const valueStyle = ref(0) // 定义一个数据videoList const videoList = reactive([]) // 调色盘选项数据 const paletteOptions = [ { label: '白热', value: 0 }, { label: '黑热', value: 1 }, { label: '描红', value: 2 }, { label: '医疗', value: 3 }, { label: '彩虹1', value: 5 }, { label: '铁红', value: 6 }, { label: '北极', value: 8 }, { label: '熔岩', value: 11 }, { label: '热铁', value: 12 }, { label: '彩虹2', value: 13 }, ] const props = defineProps(['sn', 'deviceInfo']) const initCmdList = baseCmdList.map(cmdItem => Object.assign({}, cmdItem)) const cmdList = ref(initCmdList) // dock 控制指令 const debugStatus = ref(props.deviceInfo.mode_code == EDockModeCode.Remote_Debugging); const debugStatus = ref(props.deviceInfo.mode_code == EDockModeCode.Remote_Debugging) // 根据机场指令执行状态更新信息 watch( () => Store.getters.devicesCmdExecuteInfo, devicesCmdExecuteInfo => { // console.log('设备指令执行状态变化', devicesCmdExecuteInfo) if (props.sn && devicesCmdExecuteInfo[props.sn]) { updateDeviceCmdInfoByExecuteInfo(cmdList.value, devicesCmdExecuteInfo[props.sn]); updateDeviceCmdInfoByExecuteInfo(cmdList.value, devicesCmdExecuteInfo[props.sn]) } }, { immediate: true, deep: true, } ); ) watch( () => Store.state.device.videoSurveillance, newObj => { // console.log('视频类型监听中', newObj) // if (newObj && newObj.live_status && newObj.live_status.length) { // let arr = newObj.live_status || [] // if (videoList.length == arr.length) { // return // } // arr.forEach(element => { // let video_id = element.video_id // element.payIndex = video_id.split('/')[1].split('-')[1] // }) // // videoList.length = 0 // 清空数组 // videoList.push(...arr) // 添加新元素 // } }, { immediate: true, deep: true, } ) // 根据设备osd信息更新信息 watch( () => Store.getters.deviceState, value => { if (props.sn && (value.currentSn===props.deviceInfo.child_sn || value.currentSn===props.deviceInfo.device_sn)) { // console.log('设备状态变化', value) if (props.sn && (value.currentSn === props.deviceInfo.child_sn || value.currentSn === props.deviceInfo.device_sn)) { debugStatus.value = value.dockInfo[props.deviceInfo.device_sn]?.basic_osd?.mode_code === EDockModeCode.Remote_Debugging const devices = {} devices['device'] = value.deviceInfo[props.deviceInfo.child_sn] devices['dock'] = value.dockInfo[props.deviceInfo.device_sn] devices['gateway'] = value.gatewayInfo updateDeviceCmdInfoByOsd(cmdList.value, devices); updateDeviceCmdInfoByOsd(cmdList.value, devices) } }, { immediate: true, deep: true, } ); ) // 远程控制开关 async function onDeviceStatusChange(status) { let result = false; async function onDeviceStatusChange (status) { let result = false if (status) { result = await dockDebugOnOff(props.sn, true); result = await dockDebugOnOff(props.sn, true) } else { result = await dockDebugOnOff(props.sn, false); result = await dockDebugOnOff(props.sn, false) } console.log(result, '---1------'); if (!result) { if (status) { debugStatus.value = false; debugStatus.value = false } else { debugStatus.value = true; debugStatus.value = true } } } const { sendDockControlCmd, dockDebugOnOff } = useDockControl(); const { sendDockControlCmd, dockDebugOnOff } = useDockControl() async function sendControlCmd(cmdItem, index) { async function sendControlCmd (cmdItem, index) { const params = { sn: props.sn, cmd: cmdItem.cmdKey, action: cmdItem.action, }; const success = await sendDockControlCmd(params, true); } const success = await sendDockControlCmd(params, true) if (success) { updateDeviceSingleCmdInfo(cmdList.value[index]); updateDeviceSingleCmdInfo(cmdList.value[index]) } } // webSocket 监听 const messageHandler = async payload => { if (!payload) { return; return } switch (payload.biz_code) { case EBizCode.GatewayOsd: { Store.commit('SET_GATEWAY_INFO', payload.data); break; Store.commit('SET_GATEWAY_INFO', payload.data) break } // 飞行器 case EBizCode.DeviceOsd: { Store.commit('SET_DEVICE_INFO', payload.data); break; Store.commit('SET_DEVICE_INFO', payload.data) break } // 机场 case EBizCode.DockOsd: { Store.commit('SET_DOCK_INFO', payload.data); break; Store.commit('SET_DOCK_INFO', payload.data) break } case EBizCode.MapElementCreate: { Store.commit('SET_MAP_ELEMENT_CREATE', payload.data); break; Store.commit('SET_MAP_ELEMENT_CREATE', payload.data) break } case EBizCode.MapElementUpdate: { Store.commit('SET_MAP_ELEMENT_UPDATE', payload.data); break; Store.commit('SET_MAP_ELEMENT_UPDATE', payload.data) break } case EBizCode.MapElementDelete: { Store.commit('SET_MAP_ELEMENT_DELETE', payload.data); break; Store.commit('SET_MAP_ELEMENT_DELETE', payload.data) break } case EBizCode.DeviceOnline: { Store.commit('SET_DEVICE_ONLINE', payload.data); break; Store.commit('SET_DEVICE_ONLINE', payload.data) break } case EBizCode.DeviceOffline: { Store.commit('SET_DEVICE_OFFLINE', payload.data); break; Store.commit('SET_DEVICE_OFFLINE', payload.data) break } case EBizCode.FlightTaskProgress: case EBizCode.FlightTaskMediaProgress: case EBizCode.FlightTaskMediaHighestPriority: { EventBus.emit('flightTaskWs', payload); break; EventBus.emit('flightTaskWs', payload) break } case EBizCode.DeviceHms: { Store.commit('SET_DEVICE_HMS_INFO', payload.data); break; Store.commit('SET_DEVICE_HMS_INFO', payload.data) break } case EBizCode.VideoSurveillance: { if (payload.data.live_status && payload.data.live_status.length) { Store.commit('SAVE_VIDEO_SURVEILLANCE_INFO', payload.data) } break } case EBizCode.DeviceReboot: case EBizCode.DroneOpen: @@ -189,25 +243,39 @@ biz_code: payload.biz_code, timestamp: payload.timestamp, ...payload.data, }); break; }) break } case EBizCode.ControlSourceChange: case EBizCode.FlyToPointProgress: case EBizCode.TakeoffToPointProgress: case EBizCode.JoystickInvalidNotify: case EBizCode.DrcStatusNotify: { EventBus.emit('droneControlWs', payload); break; EventBus.emit('droneControlWs', payload) break } default: break; break } }; } const webSorketUrl = getWebsocketUrl() + '&workspace-id=' + props.deviceInfo.workspace_id; const webSorketUrl = getWebsocketUrl() + '&workspace-id=' + props.deviceInfo.workspace_id // 监听ws 消息 useConnectWebSocket(messageHandler, webSorketUrl); useConnectWebSocket(messageHandler, webSorketUrl) // 添加 changs 方法 async function changs (value) { const payload = { thermal_current_palette_style: value } console.log('payload1111111', payload) console.log('deviceInfo22222222', props.sn) console.log('deviceInfo22222222', props.deviceInfo.workspace_id) let data = await setThermalCurrentPaletteStyle(props.sn, props.deviceInfo.workspace_id, payload) if (data.code === 0) { message.success('修改成功') } } </script> <style lang="scss" scoped> @@ -236,6 +304,7 @@ flex-wrap: wrap; justify-content: space-between; padding: 4px 15px; .control-cmd-item { width: 320px; height: 58px; @@ -258,5 +327,30 @@ } } } ::v-deep { .el-form { display: flex; flex-wrap: wrap; justify-content: space-between; padding: 4px 15px; } .el-form-item { width: 320px; height: 58px; display: flex; align-items: center; justify-content: space-between; border: 1px solid #666; margin: 8px 0; padding: 0 8px; border-radius: 2px; } .el-select__wrapper { width: 160px; } } } </style> </style>