添加删除画线按钮
This commit is contained in:
parent
df33711f2f
commit
e9b484d116
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue