添加删除画线按钮

This commit is contained in:
cwchen 2026-01-20 14:40:39 +08:00
parent df33711f2f
commit e9b484d116
1 changed files with 55 additions and 4 deletions

View File

@ -23,6 +23,7 @@
icon="el-icon-edit"> icon="el-icon-edit">
画线 画线
</el-button> </el-button>
<template v-else> <template v-else>
<el-button type="success" class="save-line-btn" @click="handleSaveLines" <el-button type="success" class="save-line-btn" @click="handleSaveLines"
icon="el-icon-check" :loading="saving"> icon="el-icon-check" :loading="saving">
@ -33,6 +34,12 @@
取消 取消
</el-button> </el-button>
</template> </template>
<el-button v-if="!isDrawingMode && (initialLine || savedLine)" type="danger" plain
class="delete-line-btn" @click="handleDeleteLine" :loading="deleting" icon="el-icon-delete">
删除画线
</el-button>
</div> </div>
<div class="device-control-buttons"> <div class="device-control-buttons">
<!-- <el-button type="warning" class="lock-position-btn" @click="handleLockPosition" <!-- <el-button type="warning" class="lock-position-btn" @click="handleLockPosition"
@ -91,7 +98,7 @@
</template> </template>
<script> <script>
import { getLineDetailAPI, updateLineAPI, getVideoStreamAPI, operDeviceAPI,recordingVideoAPI } from '@/api/device/video' import { getLineDetailAPI, updateLineAPI, getVideoStreamAPI, operDeviceAPI, recordingVideoAPI,deleteLineAPI } from '@/api/device/video'
export default { export default {
name: 'VideoMonitor', name: 'VideoMonitor',
@ -135,6 +142,7 @@ export default {
// //
isRecording: false, // isRecording: false, //
recordingLoading: false, // loading recordingLoading: false, // loading
deleting: false, // loading
} }
}, },
computed: { computed: {
@ -508,6 +516,49 @@ export default {
this.isDrawing = false this.isDrawing = false
}, },
/* 删除画线功能 */
handleDeleteLine() {
this.$confirm('确定要删除当前的电子围栏画线吗?删除后将无法恢复', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.deleting = true
try {
//
// await updateLineAPI({ startX: '', startY: '', endX: '', endY: '' })
const res = await deleteLineAPI({})
if (res.code === 200) {
this.$message.success('画线删除成功')
// === 线 ===
// 1.
this.initialLine = null
this.savedLine = null
this.line = null
this.currentLine = null
// 2. 线
this.lineInfo.startX = ''
this.lineInfo.startY = ''
this.lineInfo.endX = ''
this.lineInfo.endY = ''
// 3. (redrawCanvas clearRect )
this.clearCanvas() //
this.redrawCanvas() //
} else {
this.$message.error(res.msg || '删除失败')
}
} catch (error) {
console.error('删除画线异常:', error)
this.$message.error('删除失败,请稍后重试')
} finally {
this.deleting = false
}
}).catch(() => { })
},
redrawCanvas() { redrawCanvas() {
const savedCanvas = this.$refs.savedLineCanvas const savedCanvas = this.$refs.savedLineCanvas
if (savedCanvas) { if (savedCanvas) {
@ -612,7 +663,7 @@ export default {
try { try {
// //
// ID { deviceId: this.lineInfo.deviceId } // ID { deviceId: this.lineInfo.deviceId }
const res = await recordingVideoAPI({recordingType:1}) const res = await recordingVideoAPI({ recordingType: 1 })
if (res.code === 200) { if (res.code === 200) {
this.isRecording = true this.isRecording = true
@ -638,7 +689,7 @@ export default {
this.recordingLoading = true this.recordingLoading = true
try { try {
// //
const res = await recordingVideoAPI({recordingType:2}) const res = await recordingVideoAPI({ recordingType: 2 })
if (res.code === 200) { if (res.code === 200) {
this.isRecording = false this.isRecording = false
@ -810,7 +861,7 @@ export default {
gap: 12px; gap: 12px;
} }
} }
} }