Pārlūkot izejas kodu

Merge branch 'dev' of http://192.168.2.241:3000/tengmingxue/dcWaterService into dev

xiangyiyong 10 mēneši atpakaļ
vecāks
revīzija
0fa71b05d9

+ 146 - 0
src/components/hikVideo/VideoPlayer.vue

@@ -0,0 +1,146 @@
+<!--
+ * @Author: zjz
+ * @Date: 2024-05-16 14:19:50
+ * @LastEditors: zjz
+ * @LastEditTime: 2024-05-16 17:05:09
+ * @FilePath: \WebGIS\src\components\hikVideo\VideoPlayer.vue
+ * @Description:
+-->
+<template>
+  <div id="videoDom" class="videoBox">
+    <!-- <video
+      :id="videoId"
+      style="width: 100%; height: 100%"
+      class="video-js"
+    /> -->
+  </div>
+</template>
+
+<script>
+import videojs from 'video.js'
+import 'video.js/dist/video-js.css'
+import 'videojs-flvjs-es6'
+
+export default {
+  props: {
+    // 视频地址、video的id值
+    vData: {
+      type: Object,
+      default: () => {
+        return {
+          hlsurl: '', // 视频url地址
+          cameraId: '' // id
+        }
+      }
+    },
+    // 视频宽度
+    videoWidth: {
+      type: String,
+      default: '100%'
+    },
+    // 视频高度
+    videoHeight: {
+      type: String,
+      default: '100%'
+    }
+  },
+  data() {
+    return {
+      options: {
+        autoplay: true, // 设置自动播放
+        muted: true, // 设置了它为true,才可实现自动播放,同时视频也被静音 (Chrome66及以上版本,禁止音视频的自动播放)
+        preload: 'auto', // 预加载
+        controls: false // 显示播放的控件
+      },
+      player: null,
+      videoId: ''
+    }
+  },
+  watch: {
+    // 监听视频地址、video的id值
+    vData: {
+      deep: true,
+      immediate: true,
+      handler(val) {
+        this.videoId = val.cameraId
+        this.$nextTick(() => {
+          this.getVideo(val.hlsurl, val.cameraId)
+        })
+      }
+    }
+  },
+  beforeDestroy() {
+    //  组件销毁时,清除播放器
+    if (this.player) {
+      this.player.dispose() // 该方法会重置videojs的内部状态并移除dom
+    }
+  },
+  methods: {
+    getVideo(nowPlayVideoUrl, nowPlayVideoId) {
+      // this.player = videojs(nowPlayVideoId, this.options)
+      // // 关键代码, 动态设置src,才可实现换台操作
+      // // 不动态设置依然也可以这样写
+      // this.player.src([
+      //   {
+      //     src: nowPlayVideoUrl,
+      //     type: 'application/x-mpegURL' // 告诉videojs,这是一个hls流
+      //   }
+      // ])
+      this.createDom()
+      this.player = videojs(
+        // videoPlayerEl.value, // 挂载容器
+        document.getElementById('videoPlayer' + nowPlayVideoId),
+        // videoPlayerEl.value,
+        // refs[`videoPlayerEl${this.videoId}`],
+        {
+          autoplay: 'muted', // 自动播放
+          controls: true, // 用户可以与之交互的控件
+          loop: true, // 视频一结束就重新开始
+          muted: false, // 默认情况下将使所有音频静音
+          // fill: true, //铺满
+          // aspectRatio: '16:9', //显示比率
+          fullscreen: {
+            options: { navigationUI: 'hide' }
+          },
+          techOrder: ['html5', 'flvjs'], // 兼容顺序
+          html5: {
+            hls: {
+              withCredentials: true
+            }
+          },
+          sources: [{ src: nowPlayVideoUrl, type: 'application/x-mpegURL' }] // 视频地址 类型
+        }
+      )
+
+      // 开启响应模式
+      this.player.responsive(true)
+      // 开启填充模式
+      this.player.fill(true)
+    },
+
+    createDom() {
+      const id = 'videoPlayer' + this.vData.cameraId
+      if (this.vData.cameraId) {
+        const newVideoElement = document.createElement('video')
+        newVideoElement.id = id
+        newVideoElement.style.width = '100%'
+        newVideoElement.style.height = '100%'
+        newVideoElement.className = 'video-js vjs-big-play-centered vjs-fluid'
+        newVideoElement.preload = 'auto'
+        const oldVideoElement = document.getElementById('videoDom')
+        oldVideoElement.innerHTML = ''
+        oldVideoElement.appendChild(newVideoElement)
+      }
+    }
+
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.videoBox {
+  width: 100%;
+  height: 100%;
+  border: solid 1px #ccc;
+}
+</style>

+ 3 - 3
src/views/dcSystem/storeManage/storageManage/repertoryReport/index.vue

@@ -232,7 +232,7 @@ export default {
     var y = new Date().getFullYear() // 获取年份
     var m = new Date().getMonth() + 1 // 获取月份
     if (m < 10) m = '0' + m
-    this.monthTime = `${y}-${m}`
+    this.searchParams.monthTime = `${y}-${m}`
   },
   mounted() {
     this.getRecords()
@@ -306,8 +306,8 @@ export default {
     upload() {
       const form = new FormData()
       // 增加类型
-      form.append('time', this.monthTime + '-01 00:00:00')
-      form.append('templateServiceType', this.templateServiceType)
+      form.append('time', this.reportForm.time + '-01 00:00:00')
+      form.append('templateServiceType', this.searchParams.templateServiceType)
 
       for (const item of this.fileList) {
         debugger

+ 8 - 3
src/views/zhpt/scada/cameraManage/WaterDetail.vue

@@ -16,7 +16,12 @@
       <div class="flexDiv">
         <span class="flexTitle">所属权属状态:</span>
         <div class="flexInfo">
-          <el-select v-model="reportForm.belongStatus" size="small" placeholder="请输入所属权属状态" disabled>
+          <el-select
+            v-model="reportForm.belongStatus"
+            size="small"
+            placeholder="请输入所属权属状态"
+            :disabled="isLook"
+          >
             <el-option v-for="item in stateStatus" :key="item.id" :label="item.name" :value="item.id" />
           </el-select>
         </div>
@@ -36,7 +41,7 @@
       <div class="flexDiv">
         <span class="flexTitle">类别:</span>
         <div class="flexInfo select-tree">
-          <el-select ref="selectTree" v-model="searchForms.id" placeholder="请选择类别" size="small" :popper-append-to-body="false" :disabled="isLook">
+          <el-select ref="selectTree" v-model="searchForms.id" style="width:100%;" placeholder="请选择类别" size="small" :popper-append-to-body="false" :disabled="isLook">
             <el-option :value="searchForms.id" :label="searchForms.name">
               <el-tree node-key="id" :data="treeData" :props="defaultProps" default-expand-all @node-click="handleNodeClick" />
             </el-option>
@@ -58,7 +63,7 @@
       <div class="flexDiv">
         <span class="flexTitle">安装时间:</span>
         <div class="flexInfo">
-          <el-date-picker v-model="reportForm.installationTime" :disabled="isLook" type="date" placeholder="选择安装日期" format="yyyy/MM/dd" value-format="yyyy-MM-dd" size="small" />
+          <el-date-picker v-model="reportForm.installationTime" style="width:100%;" :disabled="isLook" type="date" placeholder="选择安装日期" format="yyyy/MM/dd" value-format="yyyy-MM-dd" size="small" />
         </div>
       </div>
       <div v-show="reportForm.belongStatus == 1" class="flexDiv">

+ 88 - 2
src/views/zhpt/scada/cameraManage/widget.vue

@@ -15,6 +15,14 @@
       <el-button class="search" style="margin-left: 10px" type="success" size="small" @click="reportClick()">新增</el-button>
       <el-button class="search" style="margin-left: 10px" type="warning" size="small" :disabled="multipleSelection.length!==1" @click="editClick()">修改</el-button>
       <el-button class="search" style="margin-left: 10px" type="danger" size="small" :disabled="multipleSelection.length==0" @click="deleteClick()">删除</el-button>
+      <el-button
+        class="search"
+        style="margin-left: 10px"
+        type="info"
+        size="small"
+        :disabled="multipleSelection.length !== 1"
+        @click="videoPlayClick()"
+      >视频预览</el-button>
     </div>
     <div class="tableheight">
       <table-item :table-data="buildsiteData" :column="column" :for-id="true" :pagination="true" :pagesize="pageInfo.size" :currentpage="pageInfo.current" :border="true" :multiple="true" :total="pageInfo.tableTotal" :fixed="true" :isdelete="false" :is-select="false" :stripe="true" @handleCurrentChange="handleCurrentChange" @handleSelectionChange="handleSelectionChange" @handleSizeChange="handleSizeChange" @rowClick="rowBuildData" @rowDblclick="showBuild" @detail="showBuild" />
@@ -41,6 +49,18 @@
         <el-button type="primary" size="small" @click="editItem">确定</el-button>
       </template>
     </el-dialog>
+
+    <el-dialog
+      :visible.sync="videoDialog"
+      title="实时视频查看"
+      width="70%"
+      top="5vh"
+    >
+      <div class="videoPlay"><VideoPlayer :v-data="vData" /></div>
+      <template slot="footer">
+        <el-button size="small" @click="cancelVideo">关闭</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 <script>
@@ -48,16 +68,18 @@ import TableItem from '@/components/TableAuto'
 import WaterDetail from './WaterDetail'
 import { esriConfig } from 'staticPub/config'
 import { loadModules } from 'esri-loader'
+import VideoPlayer from '@/components/hikVideo/VideoPlayer.vue'
 import {
   addCamera,
   editCamera,
   deleteCamera,
   queryCamera,
-  getTfcameratypeTree
+  getTfcameratypeTree,
+  getPreviewURLs
 } from '@/api/scadaApi'
 export default {
   name: 'CameraManage',
-  components: { TableItem, WaterDetail },
+  components: { TableItem, WaterDetail, VideoPlayer },
   props: ['data'],
   data() {
     return {
@@ -169,6 +191,13 @@ export default {
       defaultProps: {
         children: 'children',
         label: 'name'
+      },
+
+      // 视频预览
+      videoDialog: false, // 视频预览弹窗
+      vData: {
+        hlsurl: 'http://183.255.30.6:83/openUrl/oTPzNNC/live.m3u8', // 视频url地址
+        cameraId: 'fid0' // id
       }
     }
   },
@@ -466,6 +495,63 @@ export default {
       this.clearPageInfo()
     },
 
+    /**
+     * @description 打开视频
+     */
+    videoPlayClick() {
+      var activeItem = this.multipleSelection[0]
+
+      // this.camera.push({
+      //   code: activeItem.code.replace('\t', ''),
+      //   name: activeItem.name.replace('\t', '')
+      // })
+
+      this.getPreviewURLsToType({
+        type: 'hls',
+        cameraIndexCode: activeItem.code
+      })
+    },
+
+    /**
+     * @description 获取视频格式
+     */
+    getPreviewURLsToType(params) {
+      const that = this
+      var previceUrl = ''
+      var hikDto = {}
+      if (params.type == 'hls') {
+        hikDto = {
+          cameraIndexCode: params.cameraIndexCode, // 'ace5bef19901445aa3eb3dcebe06909c',//
+          streamType: 0,
+          protocol: 'hls',
+          transmode: 1,
+          expand: 'transcode=1&videotype=h264'
+        }
+      } else if (params.type == 'rtsp') {
+        hikDto = {
+          cameraIndexCode: params.cameraIndexCode,
+          streamType: 0,
+          protocol: 'rtsp',
+          transmode: 1
+        }
+      }
+
+      getPreviewURLs(hikDto).then((res) => {
+        console.log('海康参数:' + JSON.stringify(res))
+        if (res.code == '1') {
+          var jsonEntity = JSON.parse(res.result)
+          if (jsonEntity.code == '0') {
+            previceUrl = jsonEntity.data.url
+
+            that.vData.hlsurl = previceUrl
+            console.log('海康流URL:' + previceUrl)
+
+            this.videoDialog = true
+          }
+        }
+      })
+    },
+
     /**
      * @description 判断字符串是否为空
      */