<template> <div class="video"> <div ref="tree"> <el-col :span="6"> <video-tree @click="handleCameraClicked" /> </el-col> </div> <el-col :span="18"> <el-card class="box-card" style="margin-top: 14px; height: calc(100vh - 170px);"> <div style="z-index: 9999999;margin-left: 20px"> <el-form ref="dataForm" :inline="true" :model="listQuery" :rules="rules" class="form-container"> <el-form-item class="selectForm-container-item" prop="startTime"> <el-date-picker v-model="timeRange" type="datetimerange" range-separator="至" value-format="yyyy-MM-dd HH:mm:ss" start-placeholder="搜索起始时间" end-placeholder="搜索截止时间" arrow-control="true" @focus="startTimeFocus" @blur="startTimeBlur" /> </el-form-item> <el-button class="filter-item" type="primary" icon="el-icon-search" @click="search"> 搜索 </el-button> </el-form> </div> <div id="tabDiv"> <div id="divPlugin" class="iframe-body" /> </div> </el-card> </el-col> </div> </template> <script> import VideoTree from './videoTree' import { formatToString, getDate, oneDayTime } from '@/utils/calendarUtil' import { initPlugin, login, logout } from '@/utils/HKVideo' export default { name: 'VideoHistory', components: { VideoTree }, data() { const validTime = (rule, value, callback) => { if (value !== '' && value.length > 0) { if (this.timeRange[1] === '') { callback(new Error('请选择搜索起止时间')) } else { callback() } } else { callback(new Error('请选择搜索起止时间')) } } return { activeName: 'hk', videoShow: true, timeRange: [], pre: null, listQuery: { indexCode: '', startTime: '', endTime: '' }, rules: { startTime: [{ required: true, validator: validTime, trigger: ['blur'] }] }, isPlaying: false } }, watch: { timeRange(val) { if (val && val.length > 0) { this.listQuery.startTime = val[0] this.listQuery.endTime = val[1] } else { this.listQuery.startTime = '' this.listQuery.endTime = '' } } }, mounted() { this.listQuery.startTime = getDate(0, 'DATE') + ' 00:00:00' this.listQuery.endTime = getDate(0, 'SECOND') this.timeRange = [this.listQuery.startTime, this.listQuery.endTime] console.log(this.timeRange) setTimeout(() => { initPlugin(1, '', false, null, null) window.addEventListener('resize', resize) }, 100) }, beforeDestroy() { if (this.pre !== null) { logout(this.pre.ip) } WebVideoCtrl.I_Resize(0, 0) window.location.reload() window.removeEventListener('resize', resize) }, methods: { search() { if (this.pre === null) { this.$message.warning('请选择摄像头') return } if (!this.isPlaying) { this.play() } else { var that = this WebVideoCtrl.I_Stop({ success() { that.play() }, error(oErr) { this.$message.error(`开始回放失败:${oErr.errorCode}!`) } }) } }, play() { var that = this const ip = `${that.pre.nvrIp}_8989` const szStartTime = that.listQuery.startTime const szEndTime = that.listQuery.endTime const iChannelID = parseInt(that.pre.nvrChannel, 10) WebVideoCtrl.I_StartPlayback(ip, { iRtspPort: 29729, iHttpPort: 57114, iStreamType: 1, iChannelID: iChannelID, szStartTime: szStartTime, szEndTime: szEndTime, success() { this.$message.success('开始回放成功!') }, error(oError) { console.log('开始回放失败!') console.log(oError) } }) this.isPlaying = true }, resize() { WebVideoCtrl.I_Resize(document.getElementById('divPlugin').clientWidth, document.getElementById('divPlugin').clientHeight) }, handleCameraClicked(camera) { if (this.pre !== null) { logout(this.pre.nvrIp) } this.pre = camera console.log('this.pre', this.pre) login( this.pre.nvrIp, '8989', this.pre.nvrUser, this.pre.nvrPassword, 0, true, this.pre.nvrChannel, this.search ) }, startTimeFocus() { if (WebVideoCtrl) { WebVideoCtrl.JS_CuttingPartWindow(0, 0, 3000, 2000) } }, startTimeBlur() { if (WebVideoCtrl) { // WebVideoCtrl.JS_RepairPartWindow(divLeft, divTop, iframeWndWidth, 600) WebVideoCtrl.JS_RepairPartWindow(0, 0, 3000, 2000) } } } } </script> <style scoped> .iframe-body{ height: calc(100vh - 250px); width: 100%; frameBorder: 0; scrolling: no; border: 0; vspale: 0; z-index: -1; padding:0 !important; } .playWnd { margin: 10px 0 0 20px; width: 1px; height: 1px; border: 1px solid white; z-index: -1; } .video{ background: white; } </style>