qa-prevention-gwj-vue/src/views/keyprojects/videomanager/components/video-list.vue

753 lines
25 KiB
Vue

<template>
<div class="app-container">
<div class="filter-container">
<el-form label-width="100px">
<el-row>
<el-col :span="5">
<el-form-item label="关键字搜索">
<el-input v-model="KEYWORDS" placeholder="搜索关键字" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label-width="10px">
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="getQuery">
搜索
</el-button>
<el-button v-waves class="filter-item" type="success" icon="el-icon-refresh" @click="goKeyReset">
重置
</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<el-table
v-loading="listLoading"
ref="multipleTable"
:data="varList"
:row-key="getRowKey"
:header-cell-style="{
'font-weight': 'bold',
'color': '#000'
}"
tooltip-effect="dark"
border
fit
highlight-current-row
>
<el-table-column
:reserve-selection="true"
type="selection"
width="55"
align="center"/>
<el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column prop="VIDEONAME" label="视频名称" />
<!-- <el-table-column prop="CODE" label="视频编码" />-->
<el-table-column prop="VIDEOURL" label="播放地址" />
<el-table-column prop="POSITION" label="状态" width="100">
<template slot-scope="{row}">
<span v-if="row.LATITUDE && row.LONGITUDE">已定位</span>
<span v-else>未定位</span>
</template>
</el-table-column>
<el-table-column label="操作" align="left" width="500">
<template slot-scope="{row}">
<el-button :disabled="STATE == 2" type="success" icon="el-icon-caret-right" size="mini" @click="showVideo(row)">播放</el-button>
<el-button type="info" icon="el-icon-location-information" size="mini" @click="handleMap(row)">定位</el-button>
<el-button v-show="!row.PLATFORMVIDEOMANAGEMENT_ID" :disabled="STATE == 2" type="warning" icon="el-icon-caret-right" size="mini" @click="showVideoBack(row.VIDEOURL)">回放</el-button>
<el-button v-show="row.PLATFORMVIDEOMANAGEMENT_ID" :disabled="STATE == 2" type="warning" size="mini" @click="getRTSP(row)">获取rtsp地址</el-button>
<el-button v-show="edit" :disabled="STATE == 2" type="primary" icon="el-icon-edit" size="mini" @click="handleEdit(row.VIDEOMANAGER_ID)">编辑</el-button>
<el-button v-show="del" :disabled="STATE == 2" type="danger" icon="el-icon-delete" plain @click="handleDelete(row.VIDEOMANAGER_ID)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="page-btn-group" style="margin-bottom: 50px;">
<div>
<el-button v-show="add" :disabled="STATE == 2" type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
<el-button :disabled="STATE == 2" type="success" icon="el-icon-caret-right" @click="showAll">播放全部</el-button>
</div>
<pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
</div>
<div class="ui-foot">
<el-button plain type="info" @click="goBack">返 回</el-button>
</div>
<el-dialog :visible.sync="dialogFormMap" title="定位" width="1050px" class="dy-dialog">
<div id="map" />
<div slot="footer" class="dialog-footer">
<span>经度:</span>
<el-input v-model="form.LONGITUDE" style="width: 200px" placeholder="请输入内容" disabled />
<span>纬度:</span>
<el-input v-model="form.LATITUDE" style="width: 200px" placeholder="请输入内容" disabled />
<el-button @click="dialogFormMap = false">取 消</el-button>
<el-button type="primary" @click="setPosition">确 定</el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogForm" :title="msg==='add'?'新增':'编辑'" width="600px">
<el-form ref="form" :model="form" :rules="rules" label-width="110px" style="width: 500px;">
<el-form-item label="视频类型">
<el-radio-group v-model="form.VIDEO_TYPE" @change="changeType($event)">
<el-radio :label="0">移动摄像头</el-radio>
<el-radio :label="1"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="form.VIDEO_TYPE===0" label="视频监控信息" prop="VIDEO_RESOURCES_ID">
<el-button type="success" icon="el-icon-caret-right" size="mini" @click="selectBobileVideo()">选择</el-button>
</el-form-item>
<el-form-item v-if="form.VIDEO_TYPE===1" label="视频选择">
<el-button type="success" icon="el-icon-caret-right" size="mini" @click="selectVideo()">选择</el-button>
</el-form-item>
<el-form-item label="视频名称" prop="VIDEONAME">
<el-input :disabled="true" v-model="form.VIDEONAME" placeholder="这里输入视频名称..." />
</el-form-item>
<el-form-item v-if="form.VIDEO_TYPE===0" label="播放地址" prop="VIDEOURL">
<el-input :disabled="true" v-model="form.VIDEOURL" placeholder="这里输入播放地址..." />
</el-form-item>
<el-form-item label="摄像头编号" prop="CODE">
<el-input :disabled="true" v-model="form.CODE" placeholder="这里输入摄像头编号..." />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="back">取 消</el-button>
<el-button type="primary" @click="upload">确 定</el-button>
</div>
</el-dialog>
<el-dialog v-if="dialogVideo" :visible.sync="dialogVideo" title="视频" width="600px">
<iframe :src="VIDEOURL" width="100%" height="380" allowfullscreen allow="autoplay; fullscreen;microphone" style="position: relative;border:none"/>
<div slot="footer" class="dialog-footer">
<el-button @click="back">取 消</el-button>
</div>
</el-dialog>
<el-dialog v-if="dialogVideoHLS" :visible.sync="dialogVideoHLS" :before-close="handleBack" title="视频" width="600px">
<div id="aLiVideoPlayer" class="prism-player"/>
<div slot="footer" class="dialog-footer">
<el-button @click="back">取 消</el-button>
</div>
</el-dialog>
<el-dialog v-if="dialogVideoBack" :visible.sync="dialogVideoBack" title="视频回放" width="800px">
<iframe :src="VIDEOURL" width="100%" height="620" allowfullscreen allow="autoplay; fullscreen;microphone" style="position: relative;border:none"/>
<div slot="footer" class="dialog-footer">
<el-button @click="back">取 消</el-button>
</div>
</el-dialog>
<el-dialog v-if="dialogVideoAll" :visible.sync="dialogVideoAll" :before-close="handleBack" title="视频" width="1200px">
<!-- <iframe src="http://192.168.192.121:10800/?menu=no/#/screen" width="100%" height="500px" allowfullscreen allow="autoplay; fullscreen" style="position: relative;border:none"/>-->
<div style="display: flex;flex-wrap: wrap;justify-content: space-between">
<div v-for="(video,index) in videoList" :key="index" style="margin-bottom: 10px;width: 45%">
<iframe v-if="video.GBSVIDEOURL" :src="video.GBSVIDEOURL" width="100%" height="380" allowfullscreen allow="autoplay; fullscreen;microphone" style="position: relative;border:none"/>
<div v-if="video.HLSVIDEOURL" :id="'aLiVideoPlayer'+index" class="prism-player"/>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="back"> </el-button>
</div>
</el-dialog>
<platformvideo ref="platformvideo" @handleSelected="handleSelected"/>
<BobileCamer ref="bobileCamer" @bobilehandleSelected="bobilehandleSelected"/>
</div>
</template>
<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves'
import Platformvideo from './platformvideo.vue'
import BobileCamer from './bobileCamer.vue'
import TiandiMap from '../../../../components/TianMap/TiandiMap'
export default {
components: { Platformvideo, Pagination, TiandiMap, BobileCamer },
directives: { waves },
data() {
return {
map: null,
marker: null,
BMap: '',
clientHeight: 500,
inputLocation: '',
msg: 'add',
config: config,
listLoading: true,
dialogForm: false,
dialogImageUrl: '',
dialogVisible: false,
dialogSelect: false,
add: true,
del: true,
edit: true,
dialogFormMap: false,
listQuery: {
page: 1,
limit: 20
},
total: 0,
KEYWORDS: '',
STATE: this.$parent.STATE,
dates: [],
videoList: [],
videoResourcesList: [],
varList: [],
LATITUDE: '',
LONGITUDE: '',
disabledForm: true,
form: {
VIDEOMANAGER_ID: '',
VIDEO_RESOURCES_ID: '',
VIDEO_TYPE: 0,
VIDEONAME: '', //
VIDEOURL: '',
CODE: '',
PLATFORMVIDEOMANAGEMENT_ID: '',
LATITUDE: '',
LONGITUDE: ''
},
zoom: 10,
rules: {
VIDEONAME: [{ required: true, message: '视频名称不能为空', trigger: 'blur' }],
VIDEOURL: [{ required: true, message: '播放地址不能为空', trigger: 'blur' }],
VIDEO_RESOURCES_ID: [{ required: true, message: '不能为空', trigger: 'change' }],
CODE: [{ required: true, message: '摄像头编号不能为空', trigger: 'blur' }]
},
dialogVideo: false,
timer: '',
dialogVideoHLS: false,
dialogVideoBack: false,
dialogVideoAll: false,
VIDEOURL: '',
player: {},
playerList: []
}
},
created() {
this.getList()
this.getVideoResourcesSelect()
},
beforeDestroy() {
this.map && this.map.removeEventListener('click', this.MapClick)
console.log('定时器关闭')
clearInterval(this.timer)
},
methods: {
getVideoResourcesSelect() {
requestFN(
'/videoResources/listAll', {
UNITS_ID: this.$parent.UNITS_ID
}
).then((res) => {
this.videoResourcesList = res.varList
})
},
/**
* 初始化天地图对象
*/
initTDT() {
return new Promise((resolve, reject) => {
if (window.T) {
console.log('天地图初始化成功...')
resolve(window.T)
reject('error')
}
}).then(T => {
window.T = T
})
},
/**
* 初始化地图
* @param {*} lng 经度
* @param {*} lat 纬度
* @param {*} zoom 缩放比例(1~18)
*/
initMap(lng, lat, zoom) {
this.initTDT().then((T) => {
const imageURL = 'http://t0.tianditu.gov.cn/img_w/wmts?' + 'SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles' + '&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=e8a16137fd226a62a23cc7ba5c9c78ce'
// 创建自定义图层对象
this.lay = new window.T.TileLayer(imageURL, { minZoom: 1, maxZoom: 18 })
// 初始化地图对象
this.map = new window.T.Map('map')
this.initCenter(lng, lat, zoom)
})
},
initCenter(lng, lat, zoom) {
// 设置显示地图的中心点和级别
if (!this.form.LONGITUDE && !this.form.LATITUDE) {
this.map.centerAndZoom(new window.T.LngLat(119.58, 39.94), zoom)
this.marker && this.map.removeOverLay(this.marker)
} else {
this.map.centerAndZoom(new window.T.LngLat(lng, lat), zoom)
this.marker && this.map.removeOverLay(this.marker)
this.form.LONGITUDE = lng
this.form.LATITUDE = lat
this.marker = new window.T.Marker(new window.T.LngLat(lng, lat))
// 向地图上添加标注
this.map.addOverLay(this.marker)
}
// 创建卫星和路网的混合视图
this.map.setMapType(window.TMAP_HYBRID_MAP)
// 允许鼠标滚轮缩放地图
this.map.enableScrollWheelZoom()
// 允许鼠标移动地图
this.map.enableInertia()
// 向地图上添加标注
this.map.addEventListener('click', this.MapClick)
},
MapClick(event) {
this.marker && this.map.removeOverLay(this.marker)
this.form.LONGITUDE = event.lnglat.getLng()
this.form.LATITUDE = event.lnglat.getLat()
this.marker = new window.T.Marker(new window.T.LngLat(event.lnglat.getLng(), event.lnglat.getLat()))
// 向地图上添加标注
this.map.addOverLay(this.marker)
},
handleMap(row) {
this.dialogFormMap = true
this.VIDEOMANAGER_ID = row.VIDEOMANAGER_ID
this.form = {
...this.form,
LATITUDE: row.LATITUDE,
LONGITUDE: row.LONGITUDE
}
this.$nextTick(() => {
if (!this.map) this.initMap(this.form.LONGITUDE, this.form.LATITUDE, 16)
else this.initCenter(this.form.LONGITUDE, this.form.LATITUDE, 16)
})
},
getRowKey(row) {
return row.VIDEOMANAGER_ID
},
// 搜索
getQuery() {
this.$refs.multipleTable.clearSelection()
this.getList()
},
// 五分钟关闭视频播放页面定时任务
start() {
console.log('定时器开启')
this.timer = setInterval(this.closeVideoStart, (5 * 60 * 1000)) // 5分钟;
},
over() {
// 定时器手动关闭
console.log('定时器手动关闭')
clearInterval(this.timer)
},
closeVideoStart() {
this.dialogVideo = false
this.dialogVideoHLS = false
this.dialogVideoBack = false
this.dialogVideoAll = false
this.over()
},
// 播放
showVideo(row) {
this.$message.warning('单次播放最多五分钟')
this.start()
if (!row.PLATFORMVIDEOMANAGEMENT_ID) {
this.VIDEOURL = row.VIDEOURL
this.dialogVideo = true
} else {
requestFN(
'/platformvideomanagement/getHlsPath',
{
INDEXCODE: row.INDEXCODE
}
).then((res) => {
this.dialogVideoHLS = true
this.$nextTick(() => {
// eslint-disable-next-line no-undef
this.player = new Aliplayer({
'id': 'aLiVideoPlayer',
'source': res.data.url,
'width': '100%',
'height': '500px',
'autoplay': true,
'isLive': true,
'rePlay': false,
'playsinline': true,
'preload': true,
'controlBarVisibility': 'hover',
'useH5Prism': true
}, function(player) {
console.log('The player is created')
})
})
}).catch((e) => {
this.listLoading = false
})
}
},
setPosition() {
this.dialogFormMap = false
this.listLoading = true
console.log(132)
requestFN(
'/videomanager/savePosition',
{
LATITUDE: this.form.LATITUDE,
LONGITUDE: this.form.LONGITUDE,
VIDEOMANAGER_ID: this.VIDEOMANAGER_ID
}
).then((data) => {
this.listLoading = false
this.dialogForm = false
this.getList()
}).catch((e) => {
this.listLoading = false
})
},
getRTSP(row) {
requestFN(
'/platformvideomanagement/getRtspPath',
{
INDEXCODE: row.INDEXCODE
}
).then((res) => {
this.notify(res.data.url)
}).catch((e) => {
this.listLoading = false
})
},
// 回放
showVideoBack(path) {
this.VIDEOURL = path.replace('play.html', 'playback.html')
this.dialogVideoBack = true
},
showAll() {
const _selectData = this.$refs.multipleTable.selection
if (_selectData == null || _selectData.length == 0) {
this.$message({
message: '请选中要播放的视频...',
type: 'error'
})
return false
}
const ids = _selectData.map((item, index) => {
return item.VIDEOMANAGER_ID
}).join(',')
this.videoList = []
this.listLoading = true
requestFN(
'/videomanager/goAllVideo',
{
DATA_IDS: ids
}
).then((data) => {
this.videoList = data.videoList
this.listLoading = false
this.dialogVideoAll = true
this.playerList = []
this.$nextTick(() => {
for (let i = 0; i < this.videoList.length; i++) {
if (!this.videoList[i].HLSVIDEOURL) continue
console.log(this.videoList[i].HLSVIDEOURL.data.url)
// eslint-disable-next-line no-undef
const player = new Aliplayer({
'id': 'aLiVideoPlayer' + i,
'source': this.videoList[i].HLSVIDEOURL.data.url,
'width': '100%',
'height': '500px',
'autoplay': true,
'isLive': true,
'rePlay': false,
'playsinline': true,
'preload': true,
'controlBarVisibility': 'hover',
'useH5Prism': true
}, function(player) {
console.log('The player is created')
})
this.playerList.push(player)
console.log(this.playerList)
}
})
}).catch((e) => {
this.listLoading = false
})
},
// 获取列表
getList() {
this.listLoading = true
requestFN(
'/videomanager/list?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
{
KEYWORDS: this.KEYWORDS,
OUTSOURCED_ID: this.$parent.OUTSOURCED_ID
}
).then((data) => {
this.listLoading = false
this.varList = data.varList
this.total = data.page.totalResult
this.hasButton()
}).catch((e) => {
this.listLoading = false
})
},
// 添加
handleAdd() {
this.msg = 'add'
this.resetForm()
this.dialogForm = true
},
// 修改
handleEdit(id) {
this.msg = 'edit'
this.form.VIDEOMANAGER_ID = id
this.getData()
this.dialogForm = true
},
selectBobileVideo() {
this.$refs.bobileCamer.init(this.$parent.UNITS_ID)
},
selectVideo(row) {
this.$refs.platformvideo.init()
},
bobilehandleSelected(row) {
this.$set(this.form, 'VIDEOURL', row.VIDEOURL)
this.$set(this.form, 'VIDEONAME', row.VIDEONAME)
this.$set(this.form, 'CODE', row.CODE)
this.$set(this.form, 'VIDEO_RESOURCES_ID', row.VIDEO_RESOURCES_ID)
},
handleSelected(row) {
this.$set(this.form, 'VIDEONAME', row.NAME)
this.$set(this.form, 'CODE', row.INDEXCODE)
this.$set(this.form, 'LATITUDE', row.LATITUDE)
this.$set(this.form, 'LONGITUDE', row.LONGITUDE)
this.$set(this.form, 'PLATFORMVIDEOMANAGEMENT_ID', row.PLATFORMVIDEOMANAGEMENT_ID)
},
// 获取详情
getData() {
this.listLoading = true
requestFN(
'/videomanager/goEdit',
{
VIDEOMANAGER_ID: this.form.VIDEOMANAGER_ID
}
).then((data) => {
Object.assign(this.form, data.pd)
if (this.form.PLATFORMVIDEOMANAGEMENT_ID) {
this.form.VIDEO_TYPE = 1
} else {
if (this.form.VIDEO_RESOURCES_ID) {
this.form.VIDEO_TYPE = 0
} else {
this.form.VIDEO_TYPE = 1
}
}
this.VIDEOURL = data.pd.VIDEOURL + '&aspect=600x380'
this.listLoading = false
}).catch((e) => {
this.listLoading = false
})
},
// 保存
upload() {
this.$refs.form.validate(valid => {
if (valid) {
this.listLoading = true
requestFN(
'/videomanager/' + this.msg,
{
VIDEOMANAGER_ID: this.form.VIDEOMANAGER_ID,
VIDEO_RESOURCES_ID: this.form.VIDEO_TYPE === 0 ? this.form.VIDEO_RESOURCES_ID : '',
VIDEONAME: this.form.VIDEONAME,
VIDEOURL: this.form.VIDEO_TYPE === 0 ? this.form.VIDEOURL : '',
CODE: this.form.CODE,
LONGITUDE: this.form.LONGITUDE,
LATITUDE: this.form.LATITUDE,
OUTSOURCED_ID: this.$parent.OUTSOURCED_ID,
PLATFORMVIDEOMANAGEMENT_ID: this.form.VIDEO_TYPE === 1 ? this.form.PLATFORMVIDEOMANAGEMENT_ID : ''
}
).then((data) => {
this.listLoading = false
this.dialogForm = false
this.getList()
}).catch((e) => {
this.listLoading = false
})
} else {
return false
}
})
},
handleDelete(id) {
this.$confirm('确定要删除吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.listLoading = true
console.log(this.VIDEOMANAGER_ID)
requestFN(
'/videomanager/delete',
{
VIDEOMANAGER_ID: id
}
).then(() => {
this.$message({
message: '删除成功',
type: 'success'
})
this.listLoading = false
this.varList = []
this.listQuery.page = 1
this.getList()
}).catch((e) => {
this.listLoading = false
})
}).catch(() => {
})
},
batchDel() {
const _selectData = this.$refs.multipleTable.selection
if (_selectData == null || _selectData.length == 0) {
this.$message({
message: '请选中要删除的项...',
type: 'error'
})
return false
}
const ids = _selectData.map((item, index) => {
return item.VIDEOMANAGER_ID
}).join(',')
this.$confirm('确定要删除选中的数据吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.listLoading = true
requestFN(
'/videomanager/deleteAll',
{
DATA_IDS: ids
}
).then(() => {
this.listLoading = false
this.varList = []
this.listQuery.page = 1
this.$refs.multipleTable.clearSelection()
this.getList()
}).catch((e) => {
this.listLoading = false
})
}).catch(() => {
})
},
// 判断按钮权限,用于是否显示按钮
hasButton: function() {
var keys = 'videomanager:add,videomanager:del,videomanager:edit,toExcel'
requestFN(
'/head/hasButton',
{
keys: keys
}
).then((data) => {
this.add = data.videomanagerfhadminadd // 新增权限
this.del = data.videomanagerfhadmindel // 删除权限
this.edit = data.videomanagerfhadminedit // 修改权限
}).catch((e) => {
this.listLoading = false
})
},
goKeyReset() {
this.KEYWORDS = ''
this.getList()
},
changeType(e) {
if (e === 1) {
this.form.VIDEO_TYPE = 1
} else {
this.form.VIDEO_TYPE = 0
}
this.form.VIDEO_RESOURCES_ID = ''
this.form.VIDEONAME = ''
this.form.VIDEOURL = ''
this.form.CODE = ''
},
changeRid(e) {
console.log(e)
this.disabledForm = true
requestFN(
'/videoResources/findById',
{
VIDEO_RESOURCES_ID: e
}
).then((data) => {
this.form.VIDEOURL = data.pd.VIDEOURL
this.form.VIDEONAME = data.pd.VIDEONAME
this.form.CODE = data.pd.CODE
}).catch((e) => {
})
},
back() {
if (this.dialogVideo) this.dialogVideo = false
if (this.dialogVideoBack) this.dialogVideoBack = false
if (this.dialogVideoAll) {
this.dialogVideoAll = false
for (let i = 0; i < this.playerList.length; i++) {
this.playerList[i].dispose()
}
}
if (this.dialogForm) this.dialogForm = false
if (this.dialogVideoHLS) {
this.dialogVideoHLS = false
this.player.dispose()
}
},
handleBack() {
if (this.dialogVideoAll) {
for (let i = 0; i < this.playerList.length; i++) {
this.playerList[i].dispose()
}
this.dialogVideoAll = false
}
if (this.dialogVideoHLS) {
this.player.dispose()
this.dialogVideoHLS = false
}
},
resetForm() {
this.form = {
VIDEOMANAGER_ID: '',
VIDEO_TYPE: 0,
VIDEONAME: '', //
VIDEOURL: '',
CODE: '',
PLATFORMVIDEOMANAGEMENT_ID: ''
}
},
goBack() {
this.$parent.activeName = 'List'
this.$parent.OUTSOURCED_ID = ''
}
}
}
</script>
<style>
.hide .el-upload--picture-card {
display: none;
}
#map{
width: 1000px;
height: 500px;
}
</style>