<template> <div class="container"> <div> <el-col :span="6"> <video-tree @click="handleCameraClicked"/> </el-col> <el-col :span="18"> <el-card class="box-card" style="margin-top: 14px; height: calc(100vh - 170px);"> <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="搜索截止时间" @focus="dateClick"/> </el-form-item> <el-button class="filter-item" type="primary" icon="el-icon-search" @click="search">搜索</el-button> <!--<el-button class="filter-item" type="primary" @click="live">实时预览</el-button>--> </el-form> <div class="body-right"> <el-tabs v-model="activeName" type="card" @tab-click="handleClick"> <el-tab-pane label="海康" name="hk"> <iframe v-if="activeName === 'hk'" name="playHK" class="iframe-body" src="/static/webCtrl/hk/demo_window_simple_playback.html"/> </el-tab-pane> <el-tab-pane label="NVR" name="nvr"> <iframe v-if="activeName==='nvr'" name="playNVR" class="iframe-body" src="/static/webCtrl/nvr/demo-easy.html"/> </el-tab-pane> </el-tabs> </div> </el-card> </el-col> </div> </div> </template> <script> import VideoTree from './videoTree' 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, listQuery: { code: '', startTime: '', endTime: '' }, rules: { startTime: [{ required: true, validator: validTime, trigger: ['blur'] }] } } }, 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() { }, methods: { handleClick(tab, event) { if (tab.name === 'hk') { this.activeName = 'hk' window.frames['playHK'].initPlugin() } else if (tab.name === 'nvr') { window.frames['playHK'].close() this.activeName = 'nvr' window.frames['playNVR'].stopPlayReal(null) } }, search() { this.videoShow = true this.$refs['dataForm'].validate((valid) => { if (valid) { if (this.activeName === 'nvr') { window.frames['playNVR'].search(0, this.listQuery.startTime, this.listQuery.endTime) } else if (this.activeName === 'hk') { window.frames['playHK'].stop() window.frames['playHK'].search(this.listQuery.code, this.listQuery.startTime, this.listQuery.endTime) } } }) }, handleCameraClicked(camera) { console.log(camera) if (typeof camera.ip === 'undefined' || camera.ip === '') { console.log('ip is null') return false } if (typeof camera.username === 'undefined' || camera.username === '') { console.log('username is null') return false } if (typeof camera.password === 'undefined' || camera.password === '') { console.log('password is null') return false } // 开始预览 // this.$refs.webCtrl.$refs.play.contentWindow.startPlayReal(camera) } } } </script> <style scoped> .iframe-body{ height: calc(100vh - 305px); width: 100%; frameBorder: 0; scrolling: no; border: 0; vspale: 0; } </style>