增加新版本web页面

This commit is contained in:
lin
2025-04-28 15:04:06 +08:00
parent 3c1c68d327
commit 113743a065
268 changed files with 45419 additions and 3 deletions

View File

@@ -0,0 +1,30 @@
<template>
<div id="ChannelEdit" v-loading="locading" style="width: 100%">
<div class="page-header">
<div class="page-title">
<el-page-header content="编辑通道" @back="close" />
</div>
</div>
<CommonChannelEdit :id="id" ref="commonChannelEdit" :save-success="close" :cancel="close" />
</div>
</template>
<script>
import CommonChannelEdit from '../../common/CommonChannelEdit'
export default {
name: 'ChannelEdit',
components: {
CommonChannelEdit
},
props: ['id', 'closeEdit'],
data() {
return {}
},
methods: {
close: function() {
this.closeEdit()
}
}
}
</script>

View File

@@ -0,0 +1,558 @@
<template>
<div id="channelList" style="height: calc(100vh - 124px);">
<div v-if="!editId" style="height: 100%">
<el-form :inline="true" size="mini">
<el-form-item style="margin-right: 2rem">
<el-page-header content="通道列表" @back="showDevice" />
</el-form-item>
<el-form-item label="搜索">
<el-input
v-model="searchSrt"
style="margin-right: 1rem; width: auto;"
placeholder="关键字"
prefix-icon="el-icon-search"
clearable
@input="search"
/>
</el-form-item>
<el-form-item label="通道类型">
<el-select
v-model="channelType"
style="width: 8rem; margin-right: 1rem;"
placeholder="请选择"
default-first-option
@change="search"
>
<el-option label="全部" value="" />
<el-option label="设备" value="false" />
<el-option label="子目录" value="true" />
</el-select>
</el-form-item>
<el-form-item label="在线状态">
<el-select
v-model="online"
style="width: 8rem; margin-right: 1rem;"
placeholder="请选择"
default-first-option
@change="search"
>
<el-option label="全部" value="" />
<el-option label="在线" value="true" />
<el-option label="离线" value="false" />
</el-select>
</el-form-item>
<el-form-item label="码流类型重置">
<el-select
v-model="subStream"
style="width: 16rem; margin-right: 1rem;"
placeholder="请选择码流类型"
default-first-option
@change="subStreamChange"
>
<el-option label="stream:0(主码流)" value="stream:0" />
<el-option label="stream:1(子码流)" value="stream:1" />
<el-option label="streamnumber:0(主码流-2022)" value="streamnumber:0" />
<el-option label="streamnumber:1(子码流-2022)" value="streamnumber:1" />
<el-option label="streamprofile:0(主码流-大华)" value="streamprofile:0" />
<el-option label="streamprofile:1(子码流-大华)" value="streamprofile:1" />
<el-option label="streamMode:main(主码流-水星+TP-LINK)" value="streamMode:main" />
<el-option label="streamMode:sub(子码流-水星+TP-LINK)" value="streamMode:sub" />
</el-select>
</el-form-item>
<el-form-item style="float: right;">
<el-button icon="el-icon-refresh-right" circle @click="refresh()" />
</el-form-item>
</el-form>
<el-table
ref="channelListTable"
size="small"
:data="deviceChannelList"
height="calc(100% - 64px)"
style="width: 100%; font-size: 12px;"
header-row-class-name="table-header"
>
<el-table-column prop="name" label="名称" min-width="180" />
<el-table-column prop="deviceId" label="编号" min-width="180" />
<el-table-column label="快照" min-width="100">
<template v-slot:default="scope">
<el-image
:src="getSnap(scope.row)"
:preview-src-list="getBigSnap(scope.row)"
:fit="'contain'"
style="width: 60px"
@error="getSnapErrorEvent(scope.row.deviceId, scope.row.channelId)"
>
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline" />
</div>
</el-image>
</template>
</el-table-column>
<!-- <el-table-column prop="subCount" label="子节点数" min-width="100">-->
<!-- </el-table-column>-->
<el-table-column prop="manufacturer" label="厂家" min-width="100" />
<el-table-column label="位置信息" min-width="150">
<template v-slot:default="scope">
<span v-if="scope.row.longitude && scope.row.latitude">{{ scope.row.longitude }}<br>{{ scope.row.latitude }}</span>
<span v-if="!scope.row.longitude || !scope.row.latitude"></span>
</template>
</el-table-column>
<el-table-column prop="ptzType" label="云台类型" min-width="100">
<template v-slot:default="scope">
<div>{{ scope.row.ptzTypeText }}</div>
</template>
</el-table-column>
<el-table-column label="开启音频" min-width="100">
<template v-slot:default="scope">
<el-switch v-model="scope.row.hasAudio" active-color="#409EFF" @change="updateChannel(scope.row)" />
</template>
</el-table-column>
<el-table-column label="码流类型" min-width="180">
<template v-slot:default="scope">
<el-select
v-model="scope.row.streamIdentification"
size="mini"
style="margin-right: 1rem;"
placeholder="请选择码流类型"
default-first-option
@change="channelSubStreamChange(scope.row)"
>
<el-option label="stream:0(主码流)" value="stream:0" />
<el-option label="stream:1(子码流)" value="stream:1" />
<el-option label="streamnumber:0(主码流-2022)" value="streamnumber:0" />
<el-option label="streamnumber:1(子码流-2022)" value="streamnumber:1" />
<el-option label="streamprofile:0(主码流-大华)" value="streamprofile:0" />
<el-option label="streamprofile:1(子码流-大华)" value="streamprofile:1" />
<el-option label="streamMode:main(主码流-水星+TP-LINK)" value="streamMode:main" />
<el-option label="streamMode:sub(子码流-水星+TP-LINK)" value="streamMode:sub" />
</el-select>
</template>
</el-table-column>
<el-table-column label="状态" min-width="100">
<template v-slot:default="scope">
<div slot="reference" class="name-wrapper">
<el-tag v-if="scope.row.status === 'ON'" size="medium">在线</el-tag>
<el-tag v-if="scope.row.status !== 'ON'" size="medium" type="info">离线</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="操作" min-width="340" fixed="right">
<template v-slot:default="scope">
<el-button
size="medium"
:disabled="device == null || device.online === 0"
icon="el-icon-video-play"
type="text"
:loading="scope.row.playLoading"
@click="sendDevicePush(scope.row)"
>播放
</el-button>
<el-button
v-if="!!scope.row.streamId"
size="medium"
:disabled="device == null || device.online === 0"
icon="el-icon-switch-button"
type="text"
style="color: #f56c6c"
@click="stopDevicePush(scope.row)"
>停止
</el-button>
<el-divider direction="vertical" />
<el-button
size="medium"
type="text"
icon="el-icon-edit"
@click="handleEdit(scope.row)"
>
编辑
</el-button>
<el-divider direction="vertical" />
<el-button
v-if="scope.row.subCount > 0 || scope.row.parental === 1 || scope.row.deviceId.length <= 8"
size="medium"
icon="el-icon-s-open"
type="text"
@click="changeSubchannel(scope.row)"
>查看
</el-button>
<el-divider v-if="scope.row.subCount > 0 || scope.row.parental === 1 || scope.row.deviceId.length <= 8" direction="vertical" />
<el-dropdown @command="(command)=>{moreClick(command, scope.row)}">
<el-button size="medium" type="text">
更多<i class="el-icon-arrow-down el-icon--right" />
</el-button>
<el-dropdown-menu>
<el-dropdown-item command="records" :disabled="device == null || device.online === 0">
设备录像</el-dropdown-item>
<el-dropdown-item command="cloudRecords" :disabled="device == null || device.online === 0">
云端录像</el-dropdown-item>
<el-dropdown-item command="record" :disabled="device == null || device.online === 0">
设备录像控制-开始</el-dropdown-item>
<el-dropdown-item command="stopRecord" :disabled="device == null || device.online === 0">
设备录像控制-停止</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-pagination
style="text-align: right"
:current-page="currentPage"
:page-size="count"
:page-sizes="[15, 25, 35, 50]"
layout="total, sizes, prev, pager, next"
:total="total"
@size-change="handleSizeChange"
@current-change="currentChange"
/>
</div>
<devicePlayer ref="devicePlayer" />
<channel-edit v-if="editId" :id="editId" :close-edit="closeEdit" />
</div>
</template>
<script>
import devicePlayer from '../../dialog/devicePlayer.vue'
import Edit from './edit.vue'
export default {
name: 'ChannelList',
components: {
devicePlayer,
ChannelEdit: Edit
},
props: {
defaultPage: {
type: Number,
default: 1
},
defaultCount: {
type: Number,
default: 15
},
deviceId: {
type: String,
default: null
},
parentChannelId: {
type: String || null,
default: null
}
},
data() {
return {
device: null,
deviceChannelList: [],
videoComponentList: [],
currentPlayerInfo: {}, // 当前播放对象
updateLooper: 0, // 数据刷新轮训标志
searchSrt: '',
channelType: '',
online: '',
subStream: '',
winHeight: window.innerHeight - 200,
currentPage: this.defaultPage | 1,
count: this.defaultCount | 15,
total: 0,
beforeUrl: '/device',
editId: null,
loadSnap: {},
ptzTypes: {
0: '未知',
1: '球机',
2: '半球',
3: '固定枪机',
4: '遥控枪机'
}
}
},
watch: {
deviceId: function(val) {
this.$store.dispatch('device/queryDeviceOne', this.deviceId)
.then(data => {
this.device = data
})
this.initData()
}
},
mounted() {
console.log(23222)
if (this.deviceId) {
this.$store.dispatch('device/queryDeviceOne', this.deviceId)
.then(data => {
this.device = data
})
}
this.initData()
},
destroyed() {
this.$destroy('videojs')
clearTimeout(this.updateLooper)
},
methods: {
initData: function() {
if (this.parentChannelId === null || typeof (this.parentChannelId) === 'undefined' || this.parentChannelId === 0) {
this.getDeviceChannelList()
} else {
this.showSubChannels()
}
},
initParam: function() {
this.deviceId = this.$route.params.deviceId
this.parentChannelId = this.$route.params.parentChannelId
this.currentPage = 1
this.count = 15
if (this.parentChannelId === '' || this.parentChannelId === 0) {
this.beforeUrl = '/device/list'
}
},
currentChange: function(val) {
this.currentPage = val
this.initData()
},
handleSizeChange: function(val) {
this.count = val
this.getDeviceChannelList()
},
getDeviceChannelList: function() {
console.log(this.deviceId)
if (typeof (this.deviceId) === 'undefined') return
this.$store.dispatch('device/queryChannels', [this.deviceId, {
page: this.currentPage,
count: this.count,
query: this.searchSrt,
online: this.online,
channelType: this.channelType
}]).then(data => {
this.total = data.total
this.deviceChannelList = data.list
this.deviceChannelList.forEach(e => {
e.ptzType = e.ptzType + ''
this.$set(e, 'playLoading', false)
})
// 防止出现表格错位
this.$nextTick(() => {
this.$refs.channelListTable.doLayout()
})
})
},
// 通知设备上传媒体流
sendDevicePush: function(itemData) {
const deviceId = this.deviceId
const channelId = itemData.deviceId
itemData.playLoading = true
console.log('通知设备推流1' + deviceId + ' : ' + channelId)
this.$store.dispatch('play/play', [deviceId, channelId])
.then((data) => {
setTimeout(() => {
const snapId = deviceId + '_' + channelId
this.loadSnap[deviceId + channelId] = 0
this.getSnapErrorEvent(snapId)
}, 5000)
itemData.streamId = data.stream
this.$refs.devicePlayer.openDialog('media', deviceId, channelId, {
streamInfo: data,
hasAudio: itemData.hasAudio
})
setTimeout(() => {
this.initData()
}, 1000)
}).finally(() => {
itemData.playLoading = false
})
},
moreClick: function(command, itemData) {
if (command === 'records') {
this.queryRecords(itemData)
} else if (command === 'cloudRecords') {
this.queryCloudRecords(itemData)
} else if (command === 'record') {
this.startRecord(itemData)
} else if (command === 'stopRecord') {
this.stopRecord(itemData)
}
},
queryRecords: function(itemData) {
const deviceId = this.deviceId
const channelId = itemData.deviceId
this.$router.push(`/device/record/${deviceId}/${channelId}`)
},
queryCloudRecords: function(itemData) {
const deviceId = this.deviceId
const channelId = itemData.deviceId
this.$router.push(`/cloudRecord/detail/rtp/${deviceId}_${channelId}`)
},
startRecord: function(itemData) {
this.$store.dispatch('device/deviceRecord', {
deviceId: this.deviceId,
channelId: itemData.deviceId,
recordCmdStr: 'Record'
}).then(data => {
this.$message.success({
showClose: true,
message: '开始录像成功'
})
}).catch((error) => {
this.$message.error({
showClose: true,
message: error.message
})
})
},
stopRecord: function(itemData) {
this.$store.dispatch('device/deviceRecord', {
deviceId: this.deviceId,
channelId: itemData.deviceId,
recordCmdStr: 'StopRecord'
}).then(data => {
this.$message.success({
showClose: true,
message: '停止录像成功'
})
}).catch((error) => {
this.$message.error({
showClose: true,
message: error.message
})
})
},
stopDevicePush: function(itemData) {
this.$store.dispatch('play/stop', [this.deviceId, itemData.deviceId]).then(data => {
this.initData()
}).catch((error) => {
if (error.response.status === 402) { // 已经停止过
this.initData()
} else {
console.log(error)
}
})
},
getSnap: function(row) {
const baseUrl = window.baseUrl ? window.baseUrl : ''
return ((process.env.NODE_ENV === 'development') ? process.env.VUE_APP_BASE_API : baseUrl) + '/api/device/query/snap/' + this.deviceId + '/' + row.deviceId
},
getBigSnap: function(row) {
return [this.getSnap(row)]
},
getSnapErrorEvent: function(deviceId, channelId) {
if (typeof (this.loadSnap[deviceId + channelId]) !== 'undefined') {
console.log('下载截图' + this.loadSnap[deviceId + channelId])
if (this.loadSnap[deviceId + channelId] > 5) {
delete this.loadSnap[deviceId + channelId]
return
}
setTimeout(() => {
const url = (process.env.NODE_ENV === 'development' ? 'debug' : '') + '/api/device/query/snap/' + deviceId + '/' + channelId
this.loadSnap[deviceId + channelId]++
document.getElementById(deviceId + channelId).setAttribute('src', url + '?' + new Date().getTime())
}, 1000)
}
},
showDevice: function() {
// this.$router.push(this.beforeUrl).then(() => {
// this.initParam()
// this.initData()
// })
this.$emit('show-device')
},
changeSubchannel(itemData) {
this.beforeUrl = this.$router.currentRoute.path
var url = `/${this.$router.currentRoute.name}/${this.$router.currentRoute.params.deviceId}/${itemData.deviceId}`
this.$router.push(url).then(() => {
this.searchSrt = ''
this.channelType = ''
this.online = ''
this.initParam()
this.initData()
})
},
showSubChannels: function() {
this.$store.dispatch('device/querySubChannels', [
{
page: this.currentPage,
count: this.count,
query: this.searchSrt,
online: this.online,
channelType: this.channelType
},
this.deviceId,
this.parentChannelId
])
.then(data => {
this.total = data.total
this.deviceChannelList = data.list
this.deviceChannelList.forEach(e => {
e.ptzType = e.ptzType + ''
})
// 防止出现表格错位
this.$nextTick(() => {
this.$refs.channelListTable.doLayout()
})
})
},
search: function() {
this.currentPage = 1
this.total = 0
this.initData()
},
updateChannel: function(row) {
this.$store.dispatch('device/changeChannelAudio', {
channelId: row.id,
audio: row.hasAudio
})
},
subStreamChange: function() {
this.$confirm('确定重置所有通道的码流类型?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$store.dispatch('device/updateChannelStreamIdentification', {
deviceDbId: this.device.id,
streamIdentification: this.subStream
})
.then(data => {
this.initData()
})
.finally(() => {
this.subStream = ''
})
}).catch(() => {
this.subStream = ''
})
},
channelSubStreamChange: function(row) {
this.$store.dispatch('device/updateChannelStreamIdentification', {
deviceDbId: row.deviceDbId,
id: row.id,
streamIdentification: row.streamIdentification
})
.then(data => {
this.initData()
})
.finally(() => {
this.subStream = ''
})
},
refresh: function() {
this.initData()
},
// 编辑
handleEdit(row) {
this.editId = row.id
},
// 结束编辑
closeEdit: function() {
this.editId = null
this.getDeviceChannelList()
}
}
}
</script>

View File

@@ -0,0 +1,625 @@
<template>
<div id="DeviceRecord" class="app-container">
<div :style="boxStyle">
<div>
<div v-if="this.$route.query.mediaServerId" class="page-header-btn" style="padding-right: 1rem">
<b>节点</b> {{ mediaServerId }}
</div>
<div v-if="this.$route.params.mediaServerId">
<span>流媒体{{ this.$route.params.mediaServerId }}</span>
</div>
<div class="record-list-box-box">
<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">
<ul v-if="detailFiles.length >0" class="infinite-list record-list">
<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)"
>
<i class="el-icon-video-camera" />
{{ getFileShowName(item) }}
</el-tag>
<el-tag v-if="chooseFileIndex === index" type="danger">
<i class="el-icon-video-camera" />
{{ getFileShowName(item) }}
</el-tag>
<a
class="el-icon-download"
style="color: #409EFF;font-weight: 600;margin-left: 10px;"
target="_blank"
@click="downloadFile(item)"
/>
</li>
</ul>
<div v-if="detailFiles.length === 0" class="record-list-no-val">暂无数据</div>
</div>
</div>
</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
ref="recordVideoPlayer"
:video-url="videoUrl"
:height="'calc(100vh - 250px)'"
:show-button="false"
:has-audio="true"
@playStatusChange="playingChange"
@playTimeChange="showPlayTimeChange"
/>
</div>
<div class="player-option-box">
<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()"
/>
<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="倍速播放"
>{{ playSpeed }}X</a>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="item in playSpeedRange"
:key="item"
:command="item"
>{{ item }}X
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
<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>
</div>
</div>
</div>
</div>
<record-download ref="recordDownload" />
<chooseTimeRange ref="chooseTimeRange" />
</div>
</template>
<script>
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'
import moment from 'moment'
import screenfull from 'screenfull'
export default {
name: 'DeviceRecord',
components: {
h265web, VideoTimeline, recordDownload, ChooseTimeRange
},
data() {
return {
showSidebar: false,
deviceId: this.$route.params.deviceId,
channelId: this.$route.params.channelDeviceId,
mediaServerId: null,
dateFilesObj: [],
mediaServerList: [],
detailFiles: [],
videoUrl: null,
streamInfo: null,
loading: false,
chooseDate: null,
playTime: null,
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'
}
}
},
playSpeedRange: [0.25, 0.5, 1, 2, 4]
}
},
computed: {
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'
}
},
mounted() {
// 查询当年有视频的日期
this.chooseDate = moment().format('YYYY-MM-DD')
this.dateChange()
this.getDownloadSpeedArray()
window.addEventListener('beforeunload', this.stopPlayRecord)
},
destroyed() {
this.$destroy('recordVideoPlayer')
window.removeEventListener('beforeunload', this.stopPlayRecord)
},
methods: {
sidebarControl() {
this.showSidebar = !this.showSidebar
},
snap() {
this.$refs.recordVideoPlayer.screenshot()
},
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
})
})
},
playLast() {
// 播放上一个
if (this.chooseFileIndex === 0) {
return
}
this.chooseFile(this.chooseFileIndex - 1)
},
playNext() {
// 播放上一个
if (this.chooseFileIndex === this.detailFiles.length - 1) {
return
}
this.chooseFile(this.chooseFileIndex + 1)
},
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)
})
.catch((err) => {
console.log(err)
})
},
seekBackward() {
// 快退五秒
this.playSeekValue -= 5 * 1000
this.play()
},
seekForward() {
// 快进五秒
this.playSeekValue += 5 * 1000
this.play()
},
stopPLay() {
// 停止
this.$refs.recordVideoPlayer.destroy()
},
pausePlay() {
// 暂停
this.$refs.recordVideoPlayer.pause()
},
play() {
if (this.$refs.recordVideoPlayer.loaded) {
this.$refs.recordVideoPlayer.unPause()
} else {
this.playRecord(this.showTimeValue, this.endTime)
}
},
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
})
this.isFullScreen = true
},
dateChange() {
this.detailFiles = []
this.$store.dispatch('gbRecord/query', [this.deviceId, this.channelId, this.startTime, this.endTime])
.then(data => {
// 处理时间信息
if (data.recordList.length === 0) {
return
}
this.detailFiles = data.recordList
this.initTime = new Date(this.detailFiles[0].startTime).getTime()
console.log(this.initTime)
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
})
}
})
.finally(() => {
this.recordsLoading = false
})
},
getDownloadSpeedArray() {
this.$store.dispatch('device/queryChannelOne', {
deviceId: this.deviceId,
channelDeviceId: this.channelId
})
.then(data => {
if (data.downloadSpeed) {
const speedArray = data.downloadSpeed.split('/')
speedArray.forEach(item => {
if (parseInt(item) > 4) {
this.playSpeedRange.push(parseInt(item))
}
})
}
})
},
stopPlayRecord(callback) {
console.log('停止录像回放')
if (this.streamInfo !== null) {
this.$refs['recordVideoPlayer'].pause()
this.videoUrl = ''
this.$store.dispatch('playback/stop', [this.deviceId, this.channelId, this.streamInfo.stream])
.then((data) => {
this.streamInfo = null
if (callback) callback()
})
} else {
if (callback) callback()
}
},
chooseFile(index) {
this.chooseFileIndex = index
const chooseFile = this.detailFiles[this.chooseFileIndex]
this.playTime = new Date(chooseFile.startTime).getTime()
this.playRecord(chooseFile.startTime, this.endTime)
},
playRecord(startTime, endTime) {
if (this.streamInfo !== null) {
this.stopPlayRecord(() => {
this.playRecord(startTime, endTime)
})
} else {
this.playerTime = 0
this.$store.dispatch('playback/play', [this.deviceId, this.channelId, startTime, endTime])
.then(data => {
this.streamInfo = data
this.videoUrl = this.getUrlByStreamInfo()
this.hasAudio = this.streamInfo.tracks && this.streamInfo.tracks.length > 1
})
}
},
getUrlByStreamInfo() {
if (location.protocol === 'https:') {
this.videoUrl = this.streamInfo['wss_flv']
} else {
this.videoUrl = this.streamInfo['ws_flv']
}
return this.videoUrl
},
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
}
}
if (this.streamInfo !== null) {
this.stopPlayRecord(() => {
this.downloadFile(row)
})
} else {
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()
})
}
},
getFileShowName(item) {
return moment(item.startTime).format('HH:mm:ss') + '-' + moment(item.endTime).format('HH:mm:ss')
},
showPlayTimeChange(val) {
this.playTime += (val * 1000 - this.playerTime)
this.playerTime = val * 1000
},
playingChange(val) {
this.playing = val
},
playTimeChange(val) {
if (val === this.playTime) {
return
}
this.playTime = val
},
timelineMouseDown() {
this.timelineControl = true
},
mouseupTimeline(event) {
if (!this.timelineControl) {
this.timelineControl = false
return
}
this.timelineControl = false
this.playRecord(this.showTimeValue, this.endTime)
}
}
}
</script>
<style>
.record-list-box-box {
width: fit-content;
float: left;
}
.record-list-box {
width: 100%;
overflow: auto;
list-style: none;
padding: 0;
margin: 0;
background-color: #FFF;
margin-top: 10px;
}
.record-list {
list-style: none;
padding: 0;
margin: 0;
background-color: #FFF;
}
.record-list-no-val {
width: fit-content;
position: relative;
color: #9f9f9f;
top: 50%;
left: calc(50% - 2rem);
}
.record-list-item {
padding: 0;
margin: 0;
margin: 0.5rem 0;
cursor: pointer;
}
.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;
}
.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;
}
</style>

32
web/src/views/device/index.vue Executable file
View File

@@ -0,0 +1,32 @@
<template>
<div id="device" class="app-container">
<deviceList v-show="deviceId === null" @show-channel="showChannelList" />
<channelList v-if="deviceId !== null" :device-id="deviceId" @show-device="showDevice" />
</div>
</template>
<script>
import deviceList from './list.vue'
import channelList from './channel/index.vue'
export default {
name: 'Device',
components: {
deviceList,
channelList
},
data() {
return {
deviceId: null
}
},
methods: {
showChannelList: function(deviceId) {
this.deviceId = deviceId
},
showDevice: function() {
this.deviceId = null
}
}
}
</script>

427
web/src/views/device/list.vue Executable file
View File

@@ -0,0 +1,427 @@
<template>
<div id="app" style="height: calc(100vh - 124px);">
<el-form :inline="true" size="mini">
<el-form-item label="搜索">
<el-input
v-model="searchSrt"
style="margin-right: 1rem; width: auto;"
placeholder="关键字"
prefix-icon="el-icon-search"
clearable
@input="initData"
/>
</el-form-item>
<el-form-item label="在线状态">
<el-select
v-model="online"
style="width: 8rem; margin-right: 1rem;"
placeholder="请选择"
default-first-option
@change="initData"
>
<el-option label="全部" value="" />
<el-option label="在线" value="true" />
<el-option label="离线" value="false" />
</el-select>
</el-form-item>
<el-form-item>
<el-button icon="el-icon-plus" style="margin-right: 1rem;" type="primary" @click="add">添加设备</el-button>
<el-button icon="el-icon-info" style="margin-right: 1rem;" @click="showInfo()">接入信息
</el-button>
</el-form-item>
<el-form-item style="float: right;">
<el-button
icon="el-icon-refresh-right"
circle
:loading="getDeviceListLoading"
@click="getDeviceList()"
/>
</el-form-item>
</el-form>
<!--设备列表-->
<el-table
size="small"
:data="deviceList"
height="calc(100% - 64px)"
header-row-class-name="table-header"
>
<el-table-column prop="name" label="名称" min-width="160" />
<el-table-column prop="deviceId" label="设备编号" min-width="160" />
<el-table-column label="地址" min-width="180">
<template v-slot:default="scope">
<div slot="reference" class="name-wrapper">
<el-tag v-if="scope.row.hostAddress" size="medium">{{ scope.row.transport.toLowerCase() }}://{{ scope.row.hostAddress }}</el-tag>
<el-tag v-if="!scope.row.hostAddress" size="medium">未知</el-tag>
</div>
</template>
</el-table-column>
<el-table-column prop="manufacturer" label="厂家" min-width="100" />
<el-table-column label="流传输模式" min-width="160">
<template v-slot:default="scope">
<el-select
v-model="scope.row.streamMode"
size="mini"
placeholder="请选择"
style="width: 120px"
@change="transportChange(scope.row)"
>
<el-option key="UDP" label="UDP" value="UDP" />
<el-option key="TCP-ACTIVE" label="TCP主动模式" value="TCP-ACTIVE" />
<el-option key="TCP-PASSIVE" label="TCP被动模式" value="TCP-PASSIVE" />
</el-select>
</template>
</el-table-column>
<el-table-column label="通道数" min-width="80">
<template v-slot:default="scope">
<span style="font-size: 1rem">{{ scope.row.channelCount }}</span>
</template>
</el-table-column>
<el-table-column label="状态" min-width="80">
<template v-slot:default="scope">
<div slot="reference" class="name-wrapper">
<el-tag
v-if="scope.row.onLine && myServerId !== scope.row.serverId"
size="medium"
style="border-color: #ecf1af"
>在线
</el-tag>
<el-tag v-if="scope.row.onLine && myServerId === scope.row.serverId" size="medium">在线
</el-tag>
<el-tag v-if="!scope.row.onLine" size="medium" type="info">离线</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="订阅" min-width="160">
<template v-slot:default="scope">
<el-checkbox
label="目录"
:checked="scope.row.subscribeCycleForCatalog > 0"
@change="(e)=>subscribeForCatalog(scope.row.id, e)"
/>
<el-checkbox
label="位置"
:checked="scope.row.subscribeCycleForMobilePosition > 0"
@change="(e)=>subscribeForMobilePosition(scope.row.id, e)"
/>
<!-- <el-checkbox label="报警" disabled :checked="scope.row.subscribeCycleForAlarm > 0"></el-checkbox>-->
</template>
</el-table-column>
<el-table-column prop="keepaliveTime" label="最近心跳" min-width="140" />
<el-table-column prop="registerTime" label="最近注册" min-width="140" />
<el-table-column label="操作" min-width="300" fixed="right">
<template v-slot:default="scope">
<el-button
type="text"
size="medium"
:disabled="scope.row.online===0"
icon="el-icon-refresh"
@click="refDevice(scope.row)"
@mouseover="getTooltipContent(scope.row.deviceId)"
>刷新
</el-button>
<el-divider direction="vertical" />
<el-button
type="text"
size="medium"
icon="el-icon-video-camera"
@click="showChannelList(scope.row)"
>通道
</el-button>
<el-divider direction="vertical" />
<el-button size="medium" icon="el-icon-edit" type="text" @click="edit(scope.row)">编辑</el-button>
<el-divider direction="vertical" />
<el-dropdown @command="(command)=>{moreClick(command, scope.row)}">
<el-button size="medium" type="text">
操作<i class="el-icon-arrow-down el-icon--right" />
</el-button>
<el-dropdown-menu>
<el-dropdown-item command="delete" style="color: #f56c6c">
删除
</el-dropdown-item>
<el-dropdown-item command="setGuard" :disabled="!scope.row.onLine">
布防
</el-dropdown-item>
<el-dropdown-item command="resetGuard" :disabled="!scope.row.onLine">
撤防
</el-dropdown-item>
<el-dropdown-item command="syncBasicParam" :disabled="!scope.row.onLine">
基础配置同步
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-pagination
style="text-align: right"
:current-page="currentPage"
:page-size="count"
:page-sizes="[15, 25, 35, 50]"
layout="total, sizes, prev, pager, next"
:total="total"
@size-change="handleSizeChange"
@current-change="currentChange"
/>
<deviceEdit ref="deviceEdit" />
<syncChannelProgress ref="syncChannelProgress" />
<configInfo ref="configInfo" />
</div>
</template>
<script>
import deviceEdit from '../dialog/deviceEdit.vue'
import syncChannelProgress from '../dialog/SyncChannelProgress.vue'
import configInfo from '../dialog/configInfo.vue'
import Vue from 'vue'
export default {
name: 'App',
components: {
configInfo,
deviceEdit,
syncChannelProgress
},
data() {
return {
deviceList: [], // 设备列表
currentDevice: {}, // 当前操作设备对象
searchSrt: '',
online: null,
videoComponentList: [],
updateLooper: 0, // 数据刷新轮训标志
currentDeviceChannelsLength: 0,
currentPage: 1,
count: 15,
total: 0,
getDeviceListLoading: false
}
},
computed: {
Vue() {
return Vue
},
myServerId() {
return this.$store.getters.serverId
}
},
mounted() {
this.initData()
this.updateLooper = setInterval(this.getDeviceList, 10000)
},
destroyed() {
this.$destroy('videojs')
clearTimeout(this.updateLooper)
},
methods: {
initData: function() {
this.currentPage = 1
this.total = 0
this.getDeviceList()
},
currentChange: function(val) {
this.currentPage = val
this.getDeviceList()
},
handleSizeChange: function(val) {
this.count = val
this.getDeviceList()
},
getDeviceList: function() {
this.getDeviceListLoading = true
this.$store.dispatch('device/queryDevices', {
page: this.currentPage,
count: this.count,
query: this.searchSrt,
status: this.online
}).then((data) => {
this.total = data.total
this.deviceList = data.list
}).finally(() => {
this.getDeviceListLoading = false
})
},
deleteDevice: function(row) {
let msg = '确定删除此设备?'
if (row.online !== 0) {
msg = '在线设备删除后仍可通过注册再次上线。<br/>如需彻底删除请先将设备离线。<br/><strong>确定删除此设备?</strong>'
}
this.$confirm(msg, '提示', {
dangerouslyUseHTMLString: true,
confirmButtonText: '确定',
cancelButtonText: '取消',
center: true,
type: 'warning'
}).then(() => {
this.$store.dispatch('device/deleteDevice', row.deviceId)
.then((data) => {
this.getDeviceList()
})
})
},
showChannelList: function(row) {
this.$emit('show-channel', row.deviceId)
// this.$router.push(`/device/?deviceId=${row.deviceId}`)
},
showDevicePosition: function(row) {
this.$router.push(`/map?deviceId=${row.deviceId}`)
},
// gb28181平台对接
// 刷新设备信息
refDevice: function(itemData) {
console.log('刷新对应设备:' + itemData.deviceId)
this.$store.dispatch('device/sync', itemData.deviceId)
.then(data => {
if (data && data.errorMsg) {
this.$message({
showClose: true,
message: data.errorMsg,
type: 'error'
})
return
}
this.$refs.syncChannelProgress.openDialog(itemData.deviceId, () => {
this.getDeviceList()
})
}).finally(() => {
this.getDeviceList()
})
},
getTooltipContent: async function(deviceId) {
let result = ''
await this.$store.dispatch('device/queryDeviceSyncStatus', deviceId)
.then((data) => {
if (data.errorMsg !== null) {
result = data.errorMsg
}
result = `同步中...[${data.current}/${data.total}]`
}).catch(error => {
result = error
})
return result
},
transportChange: function(row) {
console.log(`修改传输方式为 ${row.streamMode}${row.deviceId} `)
console.log(row.streamMode)
this.$store.dispatch('device/updateDeviceTransport', [row.deviceId, row.streamMode])
},
edit: function(row) {
this.$refs.deviceEdit.openDialog(row, () => {
this.$refs.deviceEdit.close()
this.$message({
showClose: true,
message: '设备修改成功,通道字符集将在下次更新生效',
type: 'success'
})
setTimeout(this.getDeviceList, 200)
})
},
add: function() {
this.$refs.deviceEdit.openDialog(null, () => {
this.$refs.deviceEdit.close()
this.$message({
showClose: true,
message: '添加成功',
type: 'success'
})
setTimeout(this.getDeviceList, 200)
})
},
showInfo: function() {
this.$store.dispatch('server/getSystemConfig')
.then((data) => {
this.serverId = data.addOn.serverId
this.$refs.configInfo.openDialog(data)
})
},
moreClick: function(command, itemData) {
if (command === 'setGuard') {
this.setGuard(itemData)
} else if (command === 'resetGuard') {
this.resetGuard(itemData)
} else if (command === 'delete') {
this.deleteDevice(itemData)
} else if (command === 'syncBasicParam') {
this.syncBasicParam(itemData)
}
},
setGuard: function(itemData) {
this.$store.dispatch('device/setGuard', itemData.deviceId)
.then((data) => {
this.$message.success({
showClose: true,
message: '布防成功'
})
}).catch((error) => {
this.$message.error({
showClose: true,
message: error.message
})
})
},
resetGuard: function(itemData) {
this.$store.dispatch('device/ResetGuard', itemData.deviceId)
.then((data) => {
this.$message.success({
showClose: true,
message: '撤防成功'
})
}).catch((error) => {
this.$message.error({
showClose: true,
message: error.message
})
})
},
subscribeForCatalog: function(data, value) {
this.$store.dispatch('device/subscribeCatalog', {
id: data,
cycle: value ? 60 : 0
}).then((data) => {
this.$message.success({
showClose: true,
message: value ? '订阅成功' : '取消订阅成功'
})
}).catch((error) => {
this.$message.error({
showClose: true,
message: error.message
})
})
},
subscribeForMobilePosition: function(data, value) {
this.$store.dispatch('device/subscribeMobilePosition', {
id: data,
cycle: value ? 60 : 0,
interval: value ? 5 : 0
}).then((data) => {
this.$message.success({
showClose: true,
message: value ? '订阅成功' : '取消订阅成功'
})
}).catch((error) => {
this.$message.error({
showClose: true,
message: error.message
})
})
},
syncBasicParam: function(data) {
this.$store.dispatch('device/queryBasicParam')
.then((data) => {
this.$message.success({
showClose: true,
message: `配置已同步,当前心跳间隔: ${data.BasicParam.HeartBeatInterval} 心跳间隔:${res.data.data.BasicParam.HeartBeatCount}`
})
}).catch((error) => {
this.$message.error({
showClose: true,
message: error.message
})
})
}
}
}
</script>