Newer
Older
securityFront / src / views / video / history.vue
wangxitong on 3 Feb 2021 4 KB 电子围栏
<template>
  <div class="container">
    <div>
      <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;">
            <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"
                  @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>
            <!--<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 zIndex="-1" 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>
  </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,
      timeRange: [],
      listQuery: {
        monitorPoint: '',
        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() {
    setTimeout(() => {
      // console.log('treewidth: ' + this.$refs.tree.$el.offsetWidth.toString())
      window.frames['playHK'].initPlugin('back')
    }, 1500)
  },
  methods: {
    handleClick(tab, event) {
      if (tab.name === 'hk') {
        this.activeName = 'hk'
        console.log('hk')
        window.frames['playHK'].initPlugin('back')
      } else if (tab.name === 'nvr') {
        this.activeName = 'nvr'
        // window.frames['playNVR'].stopPlayReal(null)
      }
    },
    search() {
      window.frames['playHK'].show()
      if (this.listQuery.monitorPoint === '') {
        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') {
            window.frames['playHK'].search(this.listQuery.monitorPoint, this.listQuery.startTime, this.listQuery.endTime)
          }
        }
      })
    },
    handleCameraClicked(camera) {
      console.log(camera)
      if (typeof camera.monitorPoint === 'undefined' || camera.monitorPoint === '') {
        console.log('ip is null')
        return false
      } else {
        this.listQuery.monitorPoint = camera.monitorPoint
      }
    },
    dateClick() {
      this.videoShow = false
      window.frames['playHK'].hide()
    },
    dateSelected() {
      window.frames['playHK'].show()
    }
  }
}
</script>

<style scoped>
.iframe-body{
  height: calc(100vh - 305px);
  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;
}
</style>