This commit is contained in:
2025-07-25 18:43:20 +08:00
parent 1bdd91fb42
commit 1b9c2ba8e4
6 changed files with 650 additions and 14 deletions

View File

@@ -41,7 +41,7 @@
</template>
<script>
import { startMapping, setStation, stopMapping, getLocalMaps, oneClickDeployment } from '@config/getData.js'
import { startMapping, setStation, stopMapping, getLocalMaps, oneClickDeployment, abandonMapping } from '@config/getData.js'
export default {
beforeRouteLeave (to, from, next) {
if (this.needsConfirmation) {
@@ -49,8 +49,32 @@ export default {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
next() // 允许离开
}).then(async () => {
try {
// 显示加载中状态
this.loading = this.$loading({
lock: true,
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.6)'
})
// 调用放弃建图接口
const res = await abandonMapping()
this.loading.close()
if (res && res.code === 200) {
// 接口成功,允许离开页面
this.needsConfirmation = false // 标记无需再确认
next()
} else {
// 接口返回失败,提示错误并阻止离开
this.$message.error(res.message || '放弃建图失败,请重试')
next(false)
}
} catch (error) {
// 发生异常,提示错误并阻止离开
this.loading.close()
this.$message.error('操作失败:' + error.message)
next(false)
}
}).catch(() => {
next(false) // 阻止离开
})