@@ -36,13 +41,16 @@ import * as MapApi from '@/api/map/map' import download from '@/utils/download' import { ElMessage, ElMessageBox } from 'element-plus' +defineOptions({ name: 'MapPageRealTimeMap' }) + const message = useMessage() // 消息弹窗 const route = useRoute() const { push } = useRouter() -defineOptions({ name: 'MapPageRealTimeMap' }) + const mapValue = ref([]) const list = ref([]) const indexPageRef = ref(null) +const stopOrRestore = ref(0) // 地图暂停/恢复 (0:未暂停, 1:暂停) const downAgv = async () => { const data = await MapApi.agvDownload() @@ -112,7 +120,6 @@ const getList = async () => { } }) } - list.value = mapList if (query.mapId) { @@ -126,6 +133,8 @@ const getList = async () => { mapValue.value = [list.value[0].value, list.value[0].children[0].value] indexPageRef.value.getMapData(JSON.parse(JSON.stringify(list.value[0].children[0]))) } + + await getStopOrRestore() } const handleChangeMap = async (e) => { let item = findChildrenByValues(list.value, e) @@ -157,7 +166,30 @@ const createTask = async () => { } //一键急停 -const emergencyStop = () => {} +const emergencyStop = async () => { + await getStopOrRestore() + let res = await MapApi.emergencyStopOrRecovery({ + id: mapValue.value[1], + type: stopOrRestore.value === 0 ? 1 : 0 + }) + if (res === true) { + message.success('操作成功') + await getStopOrRestore() + } +} + +const getStopOrRestore = async () => { + let res = await MapApi.getMapIsStop({ + id: mapValue.value[1] + }) + if (res && res.length > 0) { + //暂停状态 + stopOrRestore.value = 1 + } else { + //正常状态 + stopOrRestore.value = 0 + } +} //地图编辑 const router = useRouter() // 路由