diff --git a/.env.development b/.env.development index e9d5e85..59a35d9 100644 --- a/.env.development +++ b/.env.development @@ -3,5 +3,5 @@ VITE_APP_content = 机器人 # 请求的base api VITE_APP_baseApiURL = https://s.dumogu.top/api # 路由的base api -VITE_APP_routeBasePath = /base-naive-ui +VITE_APP_routeBasePath = / VITE_APP_biuldBase = / \ No newline at end of file diff --git a/.env.production b/.env.production index 7348cad..52e24f3 100644 --- a/.env.production +++ b/.env.production @@ -1,7 +1,7 @@ VITE_APP_name = 机器人 - 大屏 VITE_APP_content = 机器人 # 请求的base api -VITE_APP_baseApiURL = /api +VITE_APP_baseApiURL = /robot-screen-api # 路由的base api -VITE_APP_routeBasePath = /base-naive-ui -VITE_APP_biuldBase = /base-naive-ui \ No newline at end of file +VITE_APP_routeBasePath = /robot-screen-ui +VITE_APP_biuldBase = /robot-screen-ui \ No newline at end of file diff --git a/src/api/home.js b/src/api/home.js index 6e509f8..8440c59 100644 --- a/src/api/home.js +++ b/src/api/home.js @@ -1,15 +1,25 @@ import { service } from '@/http/request' // 获取token export const getTokenApi = (data) => { - return service.post('/api/getToken', data) + return service.post('/robot-screen-api/getToken', data) } // 获取设备信息 export const getDeviceInfoApi = (data) => { - return service.post('/api/robot/sbdUser/getDeviceList', data) + return service.post('/robot-screen-api/robot/sbdUser/getDeviceList', data) } // 操作机器人行动接口 export const handleRobotActionApi = (data) => { - return service.post('/api/robot/instruct/sedXml', data) + return service.post('/robot-screen-api/robot/instruct/sedXml', data) +} + +// 新增巡视点位接口 +export const addMarkerApi = (data) => { + return service.post('/robot-screen-api/robot/instruct/addPoint', data) +} + +// 获取全部已经添加的点位 +export const getMarkerListAllApi = (data) => { + return service.post('/robot-screen-api/robot/instruct/getPointList', data) } diff --git a/src/router/index.js b/src/router/index.js index 02300a4..a88276a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -181,8 +181,8 @@ export const constantRoutes = [ ] const router = createRouter({ - // history: createWebHistory(import.meta.env.VITE_APP_routeBasePath), - history: createWebHistory(), + history: createWebHistory(import.meta.env.VITE_APP_routeBasePath), + // history: createWebHistory(), routes: constantRoutes, }) diff --git a/src/style/naiveUi.scss b/src/style/naiveUi.scss index dde9a3f..f5d847c 100644 --- a/src/style/naiveUi.scss +++ b/src/style/naiveUi.scss @@ -97,4 +97,17 @@ .n-base-selection:not(.n-base-selection--disabled).n-base-selection--active .n-base-selection-label { background-color: #1d3861 +} + +.n-upload-dragger { + background-color: #1d3861; + border: 1px dashed #1090f0; +} + +.n-upload-trigger.n-upload-trigger--image-card .n-base-icon { + color: #fff; +} + +.n-data-table .n-data-table-td { + border-bottom: none; } \ No newline at end of file diff --git a/src/utils/getRobotInfo.js b/src/utils/getRobotInfo.js index 7b6077a..0c7ba81 100644 --- a/src/utils/getRobotInfo.js +++ b/src/utils/getRobotInfo.js @@ -53,11 +53,12 @@ export const getRobotMapInfoFn = async (puId) => { type: 4, }) if (res.code === 200) { - const { Data, Height, Width } = res.data + const { Data, Height, Width, Name } = res.data const mapInfo = { mapBase64: 'data:image/png;base64,' + Data, mapWidth: Width, mapHeight: Height, + mapName: Name, } robotData.setMapInfo(mapInfo) return mapInfo diff --git a/src/views/home/components/modal-content/add-or-edit-marker-form.vue b/src/views/home/components/modal-content/add-or-edit-marker-form.vue index 5482bf6..5ffdbf1 100644 --- a/src/views/home/components/modal-content/add-or-edit-marker-form.vue +++ b/src/views/home/components/modal-content/add-or-edit-marker-form.vue @@ -127,11 +127,17 @@ import DialogModal from '@/components/DialogModal/index.vue' import FlvPlayer from '@/components/FlvPlayer/index.vue' import ControlDeck from './control-deck.vue' -import { watch, ref, onMounted } from 'vue' -import { getRobotTokenFn, getRobotDeviceListFn } from '@/utils/getRobotInfo' +import { useMessage } from 'naive-ui' +import { watch, ref, onMounted, nextTick, onBeforeUnmount } from 'vue' +import { getRobotTokenFn, getRobotDeviceListFn, getRobotMapInfoFn } from '@/utils/getRobotInfo' +import { handleRobotActionApi, addMarkerApi } from '@/api/home' + +const message = useMessage() const deviceToken = ref('') -const deviceInfo = ref({}) +const deviceInfo = ref(null) + +const isCurrentPosition = ref(null) const emits = defineEmits(['onHandleCloseAddMarkerModal', 'onHandleConfirm']) const presetOptions = ref([ @@ -155,6 +161,11 @@ const markerParams = ref({ markerPreset: '', // 摄像头预置位 xCount: '', // 像素坐标 真实数据 yCount: '', // 像素坐标 真实数据 + PTZ_zoom: '', + mapId: '', + pointName: '', + PTZ_x: '', + PTZ_y: '', }) const props = defineProps({ markerInfo: { @@ -166,16 +177,93 @@ const onHandleCloseAddModal = () => { emits('onHandleCloseAddMarkerModal') } +// 根据X 和 Y 指令机器人去指定位置 + +const handleRobotAction = async (x, y, puId) => { + console.log(x, y, puId, 'x, y, puId') + const { data: res } = await handleRobotActionApi({ + x, + y, + type: '12', + speed: 100, + puId, + }) + + if (res.code == 200) { + isCurrentPosition.value = setInterval(async () => { + // 判断两个位置是否一致 如误差在10个像素内 则认为到达指定位置 + const { x1, y1, PTZ_x, PTZ_y, PTZ_zoom, Robot_theta } = await getRobotCurrentPosition( + puId, + ) + console.log(x, y, '指定位置x1, 指定y1') + console.log(x1, y1, '当前位置x1, 当前y1') + if (Math.abs(x1 - x) < 2 && Math.abs(y1 - y) < 2) { + console.log('已经到达指定位置') + + markerParams.value.xCount = x1 + markerParams.value.yCount = y1 + markerParams.value.PTZ_x = PTZ_x + markerParams.value.PTZ_y = PTZ_y + markerParams.value.markerAngle = Robot_theta + markerParams.value.PTZ_zoom = PTZ_zoom + + clearInterval(isCurrentPosition.value) + } + }, 2000) + } + + // console.log(res, 'res机器人正在去往指定地点') +} + +// 获取机器人当前的位置 +const getRobotCurrentPosition = async (puId) => { + const { data: res } = await handleRobotActionApi({ + puId, + type: '2', + }) + + const { Robot_x, Robot_y, PTZ_x, PTZ_y, PTZ_zoom, Robot_theta } = res?.data + return { + x1: Robot_x, + y1: Robot_y, + PTZ_x, + PTZ_y, + PTZ_zoom, + Robot_theta, + } +} + // 确认按钮 -const onHandleConfirm = () => { - emits('onHandleConfirm', markerParams.value) +const onHandleConfirm = async () => { + // emits('onHandleConfirm', markerParams.value) + + // 组装参数 + const { PTZ_zoom, markerAngle, PTZ_x, PTZ_y, xCount, yCount, mapId, markerName } = + markerParams.value + + const addMarkerParams = { + ptzz: PTZ_zoom, + zheta: markerAngle, + ptzx: PTZ_x, + ptzy: PTZ_y, + positionX: xCount, + positionY: yCount, + mapId, + pointName: markerName, + } + const { data: res } = await addMarkerApi(addMarkerParams) + + if (res.code == 200) { + message.success('新增点位成功') + // onHandleCloseAddModal() + } } const onlyAllowNumber = (value) => !value || /^\d+$/.test(value) watch( () => props.markerInfo, - (newVal) => { + async (newVal) => { markerParams.value.type = newVal?.type markerParams.value.markerIndex = newVal?.markerIndex markerParams.value.markerX = Math.ceil(newVal?.markerX).toString() @@ -195,5 +283,28 @@ watch( onMounted(async () => { deviceToken.value = await getRobotTokenFn() deviceInfo.value = await getRobotDeviceListFn() + const mapInfo = await getRobotMapInfoFn() + markerParams.value.mapId = mapInfo?.mapName + + console.log(markerParams.value, 'markerParams.value', mapInfo) }) + +onBeforeUnmount(() => { + if (isCurrentPosition.value) { + clearInterval(isCurrentPosition.value) + } +}) + +watch( + () => deviceInfo.value, + (newVal) => { + if (newVal.puId) { + handleRobotAction( + Math.ceil(markerParams.value.xCount), + Math.ceil(markerParams.value.yCount), + deviceInfo.value?.puId, + ) + } + }, +) diff --git a/src/views/home/components/modal-content/preset-setting.vue b/src/views/home/components/modal-content/preset-setting.vue index 3d1c65c..de67bc4 100644 --- a/src/views/home/components/modal-content/preset-setting.vue +++ b/src/views/home/components/modal-content/preset-setting.vue @@ -83,6 +83,7 @@ import { NIcon } from 'naive-ui' import { throttle } from 'lodash' import { AddCircleOutline, RemoveCircleOutline } from '@vicons/ionicons5' import { getRobotDeviceListFn, getRobotMapInfoFn } from '@/utils/getRobotInfo' +import { getMarkerListAllApi } from '@/api/home' const modalTitle = ref('预置位配置') // 模态框标题 const mousePosition = ref(null) // 鼠标位置 @@ -462,6 +463,17 @@ const handlePointClick = (point, index) => { emits('onHandleAddMarker', markerInfo) } +// 获取全部已经添加的点位 +const getMarkerListAll = async () => { + const { data: res } = await getMarkerListAllApi() + + console.log(res, 'res全部点位--') + if (res.code == 200) { + } +} + +getMarkerListAll() + // 关闭模态框 const onHandleCloseModal = () => { emits('onHandleCloseModal') diff --git a/src/views/home/components/right-one.vue b/src/views/home/components/right-one.vue index 28c9577..b8425cf 100644 --- a/src/views/home/components/right-one.vue +++ b/src/views/home/components/right-one.vue @@ -81,7 +81,13 @@ /> - + @@ -100,7 +106,13 @@ - +
- - + + - + -
- - - -
+
- + - + - - - + - - - + - 保存 + + 保存 +
+ + + + diff --git a/src/views/home/components/right-two/taps-one.vue b/src/views/home/components/right-two/taps-one.vue index fe0ac17..b59f3d1 100644 --- a/src/views/home/components/right-two/taps-one.vue +++ b/src/views/home/components/right-two/taps-one.vue @@ -1,30 +1,34 @@ + + diff --git a/src/views/home/components/right-two/taps-three.vue b/src/views/home/components/right-two/taps-three.vue index c8182a0..b1b81c8 100644 --- a/src/views/home/components/right-two/taps-three.vue +++ b/src/views/home/components/right-two/taps-three.vue @@ -1,36 +1,46 @@ + + diff --git a/src/views/home/components/right-two/taps-two.vue b/src/views/home/components/right-two/taps-two.vue index b063ff9..7d27c75 100644 --- a/src/views/home/components/right-two/taps-two.vue +++ b/src/views/home/components/right-two/taps-two.vue @@ -1,37 +1,59 @@ - +