Files
wvp/web/src/views/jtDevice/channel/record.vue

624 lines
20 KiB
Vue
Raw Normal View History

2025-05-11 08:01:45 +08:00
<template>
2025-05-15 18:32:03 +08:00
<div id="DeviceRecord" class="app-container">
<div :style="boxStyle">
<div>
2025-05-11 08:01:45 +08:00
<div class="record-list-box-box">
2025-05-15 18:32:03 +08:00
<div v-if="showSidebar">
<el-date-picker
v-model="chooseDate"
size="mini"
:picker-options="pickerOptions"
type="date"
value-format="yyyy-MM-dd"
placeholder="日期"
style="width: 190px"
@change="dateChange()"
/>
<!-- <el-button :disabled="!mediaServerId" size="mini" type="primary" icon="fa fa-cloud-download" style="margin: auto; margin-left: 12px " title="裁剪合并" @click="drawerOpen"></el-button>-->
</div>
<div class="record-list-box" style="height: calc(100vh - 170px); overflow: auto">
2025-05-14 15:48:35 +08:00
<ul v-if="detailFiles.length >0" class="infinite-list record-list">
2025-05-15 18:32:03 +08:00
<li v-for="(item,index) in detailFiles" :key="index" class="infinite-list-item record-list-item">
<el-tag
v-if="chooseFileIndex !== index"
style="background-color: #ecf5ff; color: #017690; "
@click="chooseFile(index)"
>
2025-05-14 15:48:35 +08:00
<i class="el-icon-video-camera" />
2025-05-15 18:32:03 +08:00
{{ getFileShowName(item) }}
2025-05-11 08:01:45 +08:00
</el-tag>
2025-05-15 18:32:03 +08:00
<el-tag v-if="chooseFileIndex === index" type="danger">
2025-05-14 15:48:35 +08:00
<i class="el-icon-video-camera" />
2025-05-15 18:32:03 +08:00
{{ getFileShowName(item) }}
2025-05-11 08:01:45 +08:00
</el-tag>
2025-05-15 18:32:03 +08:00
<a
class="el-icon-download"
style="color: #409EFF;font-weight: 600;margin-left: 10px;"
target="_blank"
@click="downloadFile(item)"
/>
2025-05-11 08:01:45 +08:00
</li>
</ul>
2025-05-15 18:32:03 +08:00
<div v-if="detailFiles.length === 0" class="record-list-no-val">暂无数据</div>
2025-05-11 08:01:45 +08:00
</div>
</div>
2025-05-15 18:32:03 +08:00
</div>
<div id="playerBox">
<div class="playBox" style="height: calc(100% - 90px); width: 100%; background-color: #000000">
<div
v-if="playLoading"
style="position: relative; left: calc(50% - 32px); top: 43%; z-index: 100;color: #fff;float: left; text-align: center;"
>
<div class="el-icon-loading" />
<div style="width: 100%; line-height: 2rem">正在加载</div>
</div>
<h265web
2025-05-14 15:48:35 +08:00
ref="recordVideoPlayer"
:video-url="videoUrl"
2025-05-15 18:32:03 +08:00
:height="'calc(100vh - 250px)'"
:show-button="false"
:has-audio="true"
@playStatusChange="playingChange"
@playTimeChange="showPlayTimeChange"
2025-05-14 15:48:35 +08:00
/>
2025-05-11 08:01:45 +08:00
</div>
<div class="player-option-box">
2025-05-15 18:32:03 +08:00
<VideoTimeline
ref="Timeline"
:init-time="initTime"
:time-segments="timeSegments"
:init-zoom-index="4"
@timeChange="playTimeChange"
@mousedown="timelineMouseDown"
@mouseup="mouseupTimeline"
/>
<div v-if="showTime" class="time-line-show">{{ showTimeValue }}</div>
</div>
<div style="height: 40px; background-color: #383838; display: grid; grid-template-columns: 1fr 400px 1fr">
<div style="text-align: left;">
<div class="record-play-control" style="background-color: transparent; box-shadow: 0 0 10px transparent">
<a
target="_blank"
class="record-play-control-item iconfont icon-list"
title="列表"
@click="sidebarControl()"
2025-05-14 15:48:35 +08:00
/>
2025-05-15 18:32:03 +08:00
<a
target="_blank"
class="record-play-control-item iconfont icon-camera1196054easyiconnet"
title="截图"
@click="snap()"
/>
<a
target="_blank"
class="record-play-control-item iconfont icon-xiazai1"
title="下载录像"
@click="chooseTimeForRecord()"
/>
<!-- <a target="_blank" class="record-play-control-item iconfont icon-xiazai011" title="下载" @click="gbPause()" />-->
</div>
</div>
<div style="text-align: center;">
<div class="record-play-control">
<a
v-if="chooseFileIndex > 0"
target="_blank"
class="record-play-control-item iconfont icon-diyigeshipin"
title="上一个"
@click="playLast()"
/>
<a
v-else
style="color: #acacac; cursor: not-allowed"
target="_blank"
class="record-play-control-item iconfont icon-diyigeshipin"
title="上一个"
/>
<a
target="_blank"
class="record-play-control-item iconfont icon-kuaijin"
title="快退五秒"
@click="seekBackward()"
/>
<a
target="_blank"
class="record-play-control-item iconfont icon-stop1"
style="font-size: 14px"
title="停止"
@click="stopPLay()"
/>
<a
v-if="playing"
target="_blank"
class="record-play-control-item iconfont icon-zanting"
title="暂停"
@click="pausePlay()"
/>
<a v-if="!playing" target="_blank" class="record-play-control-item iconfont icon-kaishi" title="播放" @click="play()" />
<a
target="_blank"
class="record-play-control-item iconfont icon-houtui"
title="快进五秒"
@click="seekForward()"
/>
<a
v-if="chooseFileIndex < detailFiles.length - 1"
target="_blank"
class="record-play-control-item iconfont icon-zuihouyigeshipin"
title="下一个"
@click="playNext()"
/>
<a
v-else
style="color: #acacac; cursor: not-allowed"
target="_blank"
class="record-play-control-item iconfont icon-zuihouyigeshipin"
title="下一个"
@click="playNext()"
/>
<el-dropdown @command="changePlaySpeed">
<a
target="_blank"
class="record-play-control-item record-play-control-speed"
title="倍速播放"
>快进/快退</a>
2025-05-14 15:48:35 +08:00
<el-dropdown-menu slot="dropdown">
2025-05-11 08:01:45 +08:00
<el-dropdown-item :command="[3, 1]">正常快进</el-dropdown-item>
<el-dropdown-item :command="[3, 2]">2倍速快进</el-dropdown-item>
<el-dropdown-item :command="[3, 4]">4倍速快进</el-dropdown-item>
<el-dropdown-item :command="[3, 8]">8倍速快进</el-dropdown-item>
<el-dropdown-item :command="[3, 16]">16倍速快进</el-dropdown-item>
<el-dropdown-item :command="[4, 1]">正常快退</el-dropdown-item>
<el-dropdown-item :command="[4, 2]">2倍速快退</el-dropdown-item>
<el-dropdown-item :command="[4, 4]">4倍速快退</el-dropdown-item>
<el-dropdown-item :command="[4, 8]">8倍速快退</el-dropdown-item>
<el-dropdown-item :command="[4, 16]">16倍速快退</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
2025-05-15 18:32:03 +08:00
</div>
2025-05-11 08:01:45 +08:00
</div>
2025-05-15 18:32:03 +08:00
<div style="text-align: right;">
<div class="record-play-control" style="background-color: transparent; box-shadow: 0 0 10px transparent">
<a
v-if="!isFullScreen"
target="_blank"
class="record-play-control-item iconfont icon-fangdazhanshi"
title="全屏"
@click="fullScreen()"
/>
<a
v-else
target="_blank"
class="record-play-control-item iconfont icon-suoxiao1"
title="全屏"
@click="fullScreen()"
/>
</div>
2025-05-11 08:01:45 +08:00
</div>
</div>
2025-05-15 18:32:03 +08:00
</div>
</div>
<record-download ref="recordDownload" />
<chooseTimeRange ref="chooseTimeRange" />
2025-05-11 08:01:45 +08:00
</div>
</template>
<script>
2025-05-15 18:32:03 +08:00
import h265web from '../../common/h265web.vue'
import VideoTimeline from '../../common/VideoTimeLine/index.vue'
import recordDownload from '../../dialog/recordDownload.vue'
import ChooseTimeRange from '../../dialog/chooseTimeRange.vue'
2025-05-14 15:48:35 +08:00
import moment from 'moment'
2025-05-15 18:32:03 +08:00
import screenfull from 'screenfull'
2025-05-11 08:01:45 +08:00
export default {
2025-05-15 18:32:03 +08:00
name: 'DeviceRecord',
2025-05-11 08:01:45 +08:00
components: {
2025-05-15 18:32:03 +08:00
h265web, VideoTimeline, recordDownload, ChooseTimeRange
2025-05-11 08:01:45 +08:00
},
data() {
return {
2025-05-15 18:32:03 +08:00
showSidebar: false,
2025-05-11 08:01:45 +08:00
phoneNumber: this.$route.params.phoneNumber,
channelId: this.$route.params.channelId,
2025-05-15 18:32:03 +08:00
mediaServerId: null,
dateFilesObj: [],
mediaServerList: [],
2025-05-11 08:01:45 +08:00
detailFiles: [],
videoUrl: null,
streamInfo: null,
2025-05-15 18:32:03 +08:00
loading: false,
chooseDate: null,
2025-05-11 08:01:45 +08:00
playTime: null,
2025-05-15 18:32:03 +08:00
playerTime: 0,
playSpeed: 1,
chooseFileIndex: null,
queryDate: new Date(),
currentPage: 1,
count: 1000000, // TODO 分页导致滑轨视频有效值无法获取完全
total: 0,
playLoading: false,
showTime: true,
isFullScreen: false,
playSeekValue: 0,
playing: false,
taskTimeRange: [],
timeFormat: '00:00:00',
initTime: null,
timelineControl: false,
showOtherSpeed: true,
timeSegments: [],
pickerOptions: {
cellClassName: (date) => {
// 通过显示一个点标识这一天有录像
const time = moment(date).format('YYYY-MM-DD')
if (this.dateFilesObj[time]) {
return 'data-picker-true'
} else {
return 'data-picker-false'
}
}
},
2025-05-14 15:48:35 +08:00
}
2025-05-11 08:01:45 +08:00
},
computed: {
2025-05-15 18:32:03 +08:00
boxStyle() {
if (this.showSidebar) {
return {
display: 'grid',
gridTemplateColumns: '210px minmax(0, 1fr)'
}
} else {
return {
display: 'grid', gridTemplateColumns: '0 minmax(0, 1fr)'
}
}
},
showTimeValue() {
return moment(this.playTime).format('YYYY-MM-DD HH:mm:ss')
},
startTime() {
return this.chooseDate + ' 00:00:00'
},
endTime() {
return this.chooseDate + ' 23:59:59'
}
2025-05-11 08:01:45 +08:00
},
mounted() {
2025-05-15 18:32:03 +08:00
// 查询当年有视频的日期
2025-05-11 08:01:45 +08:00
this.chooseDate = moment().format('YYYY-MM-DD')
2025-05-14 15:48:35 +08:00
this.dateChange()
2025-05-11 08:01:45 +08:00
window.addEventListener('beforeunload', this.stopPlayRecord)
},
destroyed() {
2025-05-14 15:48:35 +08:00
this.$destroy('recordVideoPlayer')
2025-05-11 08:01:45 +08:00
window.removeEventListener('beforeunload', this.stopPlayRecord)
},
methods: {
2025-05-15 18:32:03 +08:00
sidebarControl() {
this.showSidebar = !this.showSidebar
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
snap() {
this.$refs.recordVideoPlayer.screenshot()
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
chooseTimeForRecord() {
let startTime = this.startTime
let endTime = this.endTime
if (this.detailFiles.length > 0) {
startTime = this.detailFiles[0].startTime
endTime = this.detailFiles[this.detailFiles.length - 1].endTime
}
console.log(startTime)
console.log(endTime)
this.$refs.chooseTimeRange.openDialog([new Date(startTime), new Date(endTime)], (time) => {
console.log(time)
const startTime = moment(time[0]).format('YYYY-MM-DD HH:mm:ss')
const endTime = moment(time[1]).format('YYYY-MM-DD HH:mm:ss')
this.downloadFile({
startTime: startTime,
endTime: endTime
})
})
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
playLast() {
// 播放上一个
if (this.chooseFileIndex === 0) {
return
}
this.chooseFile(this.chooseFileIndex - 1)
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
playNext() {
// 播放上一个
if (this.chooseFileIndex === this.detailFiles.length - 1) {
return
}
this.chooseFile(this.chooseFileIndex + 1)
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
changePlaySpeed(speed) {
console.log(this.streamInfo)
console.log(speed)
// 倍速播放
this.playSpeed = speed
this.$store.dispatch('playback/setSpeed', [this.streamInfo.stream, speed])
.then(data => {
this.$refs.recordVideoPlayer.setPlaybackRate(this.playSpeed)
2025-05-11 08:01:45 +08:00
})
2025-05-15 18:32:03 +08:00
.catch((err) => {
console.log(err)
2025-05-14 15:48:35 +08:00
})
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
seekBackward() {
// 快退五秒
this.playSeekValue -= 5 * 1000
this.play()
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
seekForward() {
// 快进五秒
this.playSeekValue += 5 * 1000
this.play()
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
stopPLay() {
// 停止
this.$refs.recordVideoPlayer.destroy()
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
pausePlay() {
// 暂停
this.$refs.recordVideoPlayer.pause()
},
play() {
if (this.$refs.recordVideoPlayer.loaded) {
this.$refs.recordVideoPlayer.unPause()
} else {
this.playRecord(this.showTimeValue, this.endTime)
2025-05-11 08:01:45 +08:00
}
},
2025-05-15 18:32:03 +08:00
fullScreen() {
// 全屏
if (this.isFullScreen) {
screenfull.exit()
this.isFullScreen = false
return
}
const playerWidth = this.$refs.recordVideoPlayer.playerWidth
const playerHeight = this.$refs.recordVideoPlayer.playerHeight
screenfull.request(document.getElementById('playerBox'))
screenfull.on('change', (event) => {
this.$refs.recordVideoPlayer.resize(playerWidth, playerHeight)
this.isFullScreen = screenfull.isFullscreen
2025-05-14 15:48:35 +08:00
})
2025-05-15 18:32:03 +08:00
this.isFullScreen = true
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
dateChange() {
this.detailFiles = []
this.$store.dispatch('jtDevice/queryRecordList', {
phoneNumber: this.phoneNumber,
channelId: this.channelId,
startTime: this.startTime,
endTime: this.endTime
})
.then((data) => {
// 处理时间信息
if (data.length === 0) {
return
}
this.detailFiles = data
this.initTime = new Date(this.detailFiles[0].startTime).getTime()
for (let i = 0; i < this.detailFiles.length; i++) {
this.timeSegments.push({
beginTime: new Date(this.detailFiles[i].startTime).getTime(),
endTime: new Date(this.detailFiles[i].endTime).getTime(),
color: '#017690',
startRatio: 0.7,
endRatio: 0.85,
index: i
})
}
})
.catch((e) => {
console.log(e)
})
.finally(() => {
this.recordsLoading = false
})
},
stopPlayRecord(callback) {
2025-05-14 15:48:35 +08:00
console.log('停止录像回放')
2025-05-15 18:32:03 +08:00
if (this.streamInfo !== null) {
2025-05-14 15:48:35 +08:00
this.$refs['recordVideoPlayer'].pause()
this.videoUrl = ''
2025-05-15 18:32:03 +08:00
this.$store.dispatch('jtDevice/stopPlayback', {
phoneNumber: this.phoneNumber,
channelId: this.channelId,
streamId: this.streamId
2025-05-14 15:48:35 +08:00
})
2025-05-15 18:32:03 +08:00
.then(function(res) {
if (callback) callback()
})
} else {
if (callback) callback()
2025-05-11 08:01:45 +08:00
}
},
2025-05-15 18:32:03 +08:00
chooseFile(index) {
this.chooseFileIndex = index
const chooseFile = this.detailFiles[this.chooseFileIndex]
this.playTime = new Date(chooseFile.startTime).getTime()
this.playRecord(chooseFile.startTime, this.endTime)
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
playRecord(startTime, endTime) {
if (this.streamInfo !== null) {
this.stopPlayRecord(() => {
this.playRecord(startTime, endTime)
})
} else {
this.playerTime = 0
this.$store.dispatch('jtDevice/startPlayback', {
phoneNumber: this.phoneNumber,
channelId: this.channelId,
startTime: this.startTime,
endTime: this.endTime,
type: 0,
rate: 0,
playbackType: 0,
playbackSpeed: 0
})
.then((data) => {
this.streamInfo = data
this.videoUrl = this.getUrlByStreamInfo()
this.hasAudio = this.streamInfo.tracks && this.streamInfo.tracks.length > 1
})
}
2025-05-11 08:01:45 +08:00
},
2025-05-14 15:48:35 +08:00
getUrlByStreamInfo() {
if (location.protocol === 'https:') {
this.videoUrl = this.streamInfo['wss_flv']
} else {
this.videoUrl = this.streamInfo['ws_flv']
2025-05-11 08:01:45 +08:00
}
2025-05-14 15:48:35 +08:00
return this.videoUrl
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
downloadFile(row) {
if (!row) {
const startTimeStr = moment(new Date(this.chooseDate + ' 00:00:00').getTime() + this.playTime[0] * 1000).format('YYYY-MM-DD HH:mm:ss')
const endTimeStr = moment(new Date(this.chooseDate + ' 00:00:00').getTime() + this.playTime[1] * 1000).format('YYYY-MM-DD HH:mm:ss')
row = {
startTime: startTimeStr,
endTime: endTimeStr
2025-05-11 08:01:45 +08:00
}
2025-05-15 18:32:03 +08:00
}
if (this.streamInfo !== null) {
this.stopPlayRecord(() => {
this.downloadFile(row)
})
2025-05-14 15:48:35 +08:00
} else {
2025-05-15 18:32:03 +08:00
const loading = this.$loading({
lock: true,
text: '正在请求录像',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
this.$store.dispatch('gbRecord/startDownLoad', [
this.deviceId, this.channelId, row.startTime, row.endTime, this.playSpeedRange[this.playSpeedRange.length - 1]
])
.then(streamInfo => {
this.$refs.recordDownload.openDialog(this.deviceId, this.channelId, streamInfo.app, streamInfo.stream, streamInfo.mediaServerId)
})
.finally(() => {
loading.close()
})
2025-05-11 08:01:45 +08:00
}
},
2025-05-15 18:32:03 +08:00
getFileShowName(item) {
return moment(item.startTime).format('HH:mm:ss') + '-' + moment(item.endTime).format('HH:mm:ss')
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
showPlayTimeChange(val) {
this.playTime += (val * 1000 - this.playerTime)
this.playerTime = val * 1000
},
playingChange(val) {
this.playing = val
},
playTimeChange(val) {
if (val === this.playTime) {
return
2025-05-11 08:01:45 +08:00
}
2025-05-15 18:32:03 +08:00
this.playTime = val
2025-05-11 08:01:45 +08:00
},
2025-05-15 18:32:03 +08:00
timelineMouseDown() {
this.timelineControl = true
},
mouseupTimeline(event) {
if (!this.timelineControl) {
this.timelineControl = false
return
2025-05-11 08:01:45 +08:00
}
2025-05-15 18:32:03 +08:00
this.timelineControl = false
this.playRecord(this.showTimeValue, this.endTime)
2025-05-14 15:48:35 +08:00
}
2025-05-11 08:01:45 +08:00
}
2025-05-14 15:48:35 +08:00
}
2025-05-11 08:01:45 +08:00
</script>
<style>
2025-05-15 18:32:03 +08:00
.record-list-box-box {
width: fit-content;
2025-05-11 08:01:45 +08:00
float: left;
}
2025-05-15 18:32:03 +08:00
.record-list-box {
width: 100%;
2025-05-11 08:01:45 +08:00
overflow: auto;
list-style: none;
padding: 0;
margin: 0;
background-color: #FFF;
margin-top: 10px;
}
2025-05-15 18:32:03 +08:00
.record-list {
2025-05-11 08:01:45 +08:00
list-style: none;
padding: 0;
margin: 0;
background-color: #FFF;
}
2025-05-15 18:32:03 +08:00
2025-05-11 08:01:45 +08:00
.record-list-no-val {
2025-05-15 18:32:03 +08:00
width: fit-content;
position: relative;
2025-05-11 08:01:45 +08:00
color: #9f9f9f;
top: 50%;
2025-05-15 18:32:03 +08:00
left: calc(50% - 2rem);
2025-05-11 08:01:45 +08:00
}
2025-05-15 18:32:03 +08:00
.record-list-item {
2025-05-11 08:01:45 +08:00
padding: 0;
margin: 0;
margin: 0.5rem 0;
cursor: pointer;
}
2025-05-15 18:32:03 +08:00
.record-play-control {
height: 32px;
line-height: 32px;
display: inline-block;
width: fit-content;
padding: 0 10px;
-webkit-box-shadow: 0 0 10px #262626;
box-shadow: 0 0 10px #262626;
background-color: #262626;
margin: 4px 0;
2025-05-11 08:01:45 +08:00
}
2025-05-15 18:32:03 +08:00
.record-play-control-item {
display: inline-block;
padding: 0 10px;
color: #fff;
margin-right: 2px;
}
.record-play-control-item:hover {
color: #1f83e6;
}
.record-play-control-speed {
font-weight: bold;
color: #fff;
user-select: none;
}
.player-option-box {
height: 50px
}
.time-line-show {
position: relative;
color: rgba(250, 249, 249, 0.89);
left: calc(50% - 85px);
top: -72px;
text-shadow: 1px 0 #5f6b7c, -1px 0 #5f6b7c, 0 1px #5f6b7c, 0 -1px #5f6b7c, 1.1px 1.1px #5f6b7c, 1.1px -1.1px #5f6b7c, -1.1px 1.1px #5f6b7c, -1.1px -1.1px #5f6b7c;
2025-05-11 08:01:45 +08:00
}
</style>