<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: 9999;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="dateClick"
@change="dateSelected"/>
</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>
<div id="tabDiv">
<!--<el-tabs v-model="activeName" type="card" @tab-click.once="handleClick">-->
<!--<el-tab-pane label="海康" name="hk" >-->
<!--<iframe v-if="activeName==='hk'" zIndex="-1" name="playHK" class="iframe-body" src="/static/webCtrl/hk/demo_embedded_for_iframe.html?wmode=opaque"/>-->
<iframe name="playHK" class="iframe-body" src="/static/webCtrl/hk/demo_embedded_for_iframe.html?wmode=opaque"/>
<!--</el-tab-pane>-->
<!--<el-tab-pane label="NVR" name="nvr">-->
<!--<iframe v-if="activeName==='nvr'" zIndex="-1" name="playNVR" class="iframe-body" src="/static/webCtrl/nvr/demo-easy.html?wmode=opaque"/>-->
<!--</el-tab-pane>-->
<!--</el-tabs>-->
</div>
</el-card>
</el-col>
</div>
</template>
<script>
import VideoTree from './videoTree'
import { formatToString, getDate, oneDayTime } from '@/utils/calendarUtil'
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: [],
listQuery: {
indexCode: '',
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() {
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(() => {
// console.log('treewidth: ' + this.$refs.tree.$el.offsetWidth.toString())
window.frames['playHK'].initPlugin('back',document.getElementById('tabDiv').getBoundingClientRect().left + 20)
}, 100)
},
methods: {
handleClick(tab, event) {
if (tab.name === 'hk') {
this.activeName = 'hk'
console.log('hk')
window.frames['playHK'].initPlugin('back',document.getElementById('tabDiv').getBoundingClientRect().left + 20)
} else if (tab.name === 'nvr') {
this.activeName = 'nvr'
// window.frames['playNVR'].stopPlayReal(null)
}
},
search() {
window.frames['playHK'].show()
if (this.listQuery. indexCode === '') {
this.$message.warning('请先选中一个监控点')
return
}
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') {
console.log(this.listQuery. indexCode, this.listQuery.startTime, this.listQuery.endTime)
window.frames['playHK'].search(this.listQuery. indexCode, this.listQuery.startTime, this.listQuery.endTime)
}
}
})
},
handleCameraClicked(camera) {
console.log(camera)
if (typeof camera.indexCode === 'undefined' || camera.indexCode === '') {
return false
} else {
this.listQuery.indexCode = camera.indexCode
window.frames['playHK'].search(this.listQuery.indexCode, this.listQuery.startTime, this.listQuery.endTime)
}
},
dateClick() {
this.videoShow = false
window.frames['playHK'].hide()
},
dateSelected() {
window.frames['playHK'].show()
}
}
}
</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>