Browse Source

feat(camera): support tenant

a new column to display the binding status (camera and gateway)
Casper Dai 2 years ago
parent
commit
3052d61f72

+ 6 - 5
src/api/camera.js

@@ -2,7 +2,8 @@ import request from '@/utils/request'
 import {
   add,
   update,
-  del
+  del,
+  addTenant
 } from './base'
 
 // 查询摄像头
@@ -11,10 +12,10 @@ export function getCameras (query) {
   return request({
     url: '/camera/list',
     method: 'GET',
-    params: {
+    params: addTenant({
       pageIndex, pageSize,
       ...params
-    }
+    })
   })
 }
 
@@ -23,7 +24,7 @@ export function addCamera (data) {
   return add({
     url: '/camera',
     method: 'POST',
-    data
+    data: addTenant(data)
   })
 }
 
@@ -54,7 +55,7 @@ export function getStatistic (params) {
 }
 
 // 获取摄像头当前的视频参数
-export function getVideoinfo (deviceId) {
+export function getVideoInfo (deviceId) {
   return request({
     url: `/camera/${deviceId}/video/param`,
     method: 'GET'

+ 12 - 15
src/components/service/external/camera/CameraDetail/index.vue

@@ -127,7 +127,7 @@ import { mapGetters } from 'vuex'
 import * as echarts from 'echarts'
 import {
   getStatistic,
-  getVideoinfo,
+  getVideoInfo,
   getAvailableParam,
   setCamera
 } from '@/api/camera'
@@ -192,15 +192,11 @@ export default {
   },
   beforeDestroy () {
     if (this.isTraffic) {
+      this.hideSettingsMenu()
       window.removeEventListener('resize', this.onResize)
     }
   },
   methods: {
-    onVideoReset () {
-      this.videoSettings = null
-      this.infoData = null
-      this.getAvailableParam()
-    },
     close () {
       this.destroyPlayer()
       this.$emit('close')
@@ -232,7 +228,9 @@ export default {
         return
       }
       this.$videoPramsLoading = true
-      getAvailableParam().then(({ data }) => {
+      getAvailableParam().finally(() => {
+        this.$videoPramsLoading = false
+      }).then(({ data }) => {
         this.videoSettings = {
           items: data.itemList.map(item => {
             // maxBitRateOptions: 20480
@@ -251,9 +249,7 @@ export default {
           bitRates: [],
           streamRateType: data.streamRateTypeList
         }
-        this.getVideoinfo()
-      }).finally(() => {
-        this.$videoPramsLoading = false
+        this.getVideoInfo()
       })
     },
     onSettings () {
@@ -262,7 +258,7 @@ export default {
         return
       }
       if (!this.infoData) {
-        this.getVideoinfo()
+        this.getVideoInfo()
         return
       }
       this.settingTab = false
@@ -290,7 +286,8 @@ export default {
     onCloseSettingTab () {
       this.settingTab = false
     },
-    getVideoinfo () {
+    getVideoInfo () {
+      console.log('getVideoInfo', this.$videoInfoLoading)
       if (this.$videoInfoLoading) {
         this.$message({
           type: 'warning',
@@ -299,12 +296,12 @@ export default {
         return
       }
       this.$videoInfoLoading = true
-      getVideoinfo(this.camera.identifier).then(({ data }) => {
+      getVideoInfo(this.camera.identifier).finally(() => {
+        this.$videoInfoLoading = false
+      }).then(({ data }) => {
         const { width, hight, frameRate, bitRate } = data
         this.infoData = { width, hight, frameRate, bitRate }
         this.dataInit()
-      }).finally(() => {
-        this.$videoInfoLoading = false
       })
     },
     dataInit () {

+ 3 - 0
src/views/external/camera/index.vue

@@ -96,6 +96,9 @@ export default {
           { type: 'tag', render: ({ onlineStatus }) => onlineStatus === 1
             ? { type: 'success', label: '在线' }
             : { type: 'danger', label: '离线' } },
+          { type: 'tag', render: ({ bound }) => bound
+            ? { type: 'success', label: '已绑定' }
+            : { type: 'primary', label: '未绑定' } },
           { prop: 'remark', label: '备注' },
           { type: 'invoke', width: 160, render: [
             { label: '编辑', on: this.onEdit },

+ 3 - 0
src/views/external/gateway/index.vue

@@ -112,6 +112,9 @@ export default {
           { type: 'tag', render: ({ status }) => status === 1
             ? { type: 'success', label: '在线' }
             : { type: 'danger', label: '离线' } },
+          { type: 'tag', render: ({ bound }) => bound
+            ? { type: 'success', label: '已绑定' }
+            : { type: 'primary', label: '未绑定' } },
           { prop: 'remark', label: '备注' },
           { type: 'invoke', width: 200, render: [
             { label: '编辑', on: this.onEdit },