Forráskód Böngészése

refactor: adjust some apis

ai timing and ai function switch
Casper Dai 3 éve
szülő
commit
f012220e1a

+ 27 - 0
src/api/device.js

@@ -418,3 +418,30 @@ export function getShadow (deviceId) {
   })
 }
 
+export function getRecordConfig (deviceId, config) {
+  return request({
+    url: '/deviceStream/config',
+    method: 'GET',
+    params: { deviceId },
+    ...config
+  })
+}
+
+export function addRecordConfig (data, config) {
+  return request({
+    url: '/deviceStream/config',
+    method: 'POST',
+    data,
+    ...config
+  })
+}
+
+export function updateRecordConfig (data, config) {
+  return request({
+    url: '/deviceStream/config',
+    method: 'PUT',
+    data,
+    ...config
+  })
+}
+

+ 7 - 7
src/views/realm/ai-timing/api.js

@@ -7,7 +7,7 @@ import {
 
 export function getTenantStratConfig (tenant) {
   return send({
-    url: '/device/deviceAuditConfig/deviceAuditConfig',
+    url: '/device/deviceAudit/tenant/deviceAuditConfig',
     method: 'GET',
     params: { tenant }
   })
@@ -15,7 +15,7 @@ export function getTenantStratConfig (tenant) {
 
 export function addTenantStratConfig (data) {
   return add({
-    url: '/device/deviceAuditConfig/deviceAuditConfig',
+    url: '/device/deviceAudit/tenant/deviceAuditConfig',
     method: 'POST',
     data
   })
@@ -23,7 +23,7 @@ export function addTenantStratConfig (data) {
 
 export function updateTenantStratConfig (data) {
   return update({
-    url: '/device/deviceAuditConfig/deviceAuditConfig',
+    url: '/device/deviceAudit/tenant/deviceAuditConfig',
     method: 'PUT',
     data
   })
@@ -31,15 +31,15 @@ export function updateTenantStratConfig (data) {
 
 export function getDeviceServiceConfig (deviceId) {
   return send({
-    url: '/device/deviceAuditConfig/deviceServiceConfig',
+    url: '/device/deviceAudit/deviceAuditConfig',
     method: 'GET',
-    params: { deviceId, service: 1 }
+    params: { deviceId }
   })
 }
 
 export function addDeviceServiceConfig (data) {
   return add({
-    url: '/device/deviceAuditConfig/deviceServiceConfig',
+    url: '/device/deviceAudit/deviceAuditConfig',
     method: 'POST',
     data
   })
@@ -47,7 +47,7 @@ export function addDeviceServiceConfig (data) {
 
 export function updateDeviceServiceConfig (data) {
   return update({
-    url: '/device/deviceAuditConfig/deviceServiceConfig',
+    url: '/device/deviceAudit/deviceAuditConfig',
     method: 'PUT',
     data
   })

+ 58 - 2
src/views/realm/ai-timing/components/DeviceServiceConfigDialog.vue

@@ -13,6 +13,35 @@
           inactive-color="#ff4949"
         />
       </div>
+      <span class="c-grid-form__label u-bold">回采设备:</span>
+      <div class="l-flex--row c-grid-form__option">
+        <schema-select
+          v-model="deviceServiceConfig.collectDevice"
+          :schema="collectDeviceSelectSchema"
+        />
+      </div>
+      <span class="c-grid-form__label">抽帧间隔:</span>
+      <div class="c-grid-form__option">
+        <el-input-number
+          v-model="deviceServiceConfig.offset"
+          :min="10"
+          :max="3600"
+          step-strictly
+        />
+        秒(10~3600)
+      </div>
+      <span class="c-grid-form__label required">开始时间:</span>
+      <el-time-picker
+        v-model="deviceServiceConfig.startTime"
+        value-format="HH:mm:ss"
+        :clearable="false"
+      />
+      <span class="c-grid-form__label required">结束时间:</span>
+      <el-time-picker
+        v-model="deviceServiceConfig.endTime"
+        value-format="HH:mm:ss"
+        :clearable="false"
+      />
     </div>
   </confirm-dialog>
 </template>
@@ -24,11 +53,20 @@ import {
   updateDeviceServiceConfig
 } from '../api'
 
+const CollectDevice = {
+  BOX: 1,
+  CARD: 2
+}
+
 export default {
   name: 'DeviceServiceConfigDialog',
   data () {
     return {
       title: '',
+      collectDeviceSelectSchema: { options: [
+        { value: CollectDevice.BOX, label: '播放器' },
+        { value: CollectDevice.CARD, label: '采集卡' }
+      ] },
       deviceServiceConfig: {}
     }
   },
@@ -38,13 +76,31 @@ export default {
       getDeviceServiceConfig(deviceId).then(({ data }) => {
         this.deviceServiceConfig = data || {
           deviceId,
-          service: 1,
-          enabled: false
+          enabled: false,
+          collectDevice: CollectDevice.BOX,
+          offset: 10,
+          startTime: '08:00:00',
+          endTime: '23:59:59'
         }
         this.$refs.configDialog.show()
       })
     },
     onSave (done) {
+      const { startTime, endTime } = this.deviceServiceConfig
+      if (!startTime) {
+        this.$message({
+          type: 'warning',
+          message: '请选择开始时间'
+        })
+        return
+      }
+      if (!endTime) {
+        this.$message({
+          type: 'warning',
+          message: '请选择结束时间'
+        })
+        return
+      }
       (this.deviceServiceConfig.id ? updateDeviceServiceConfig : addDeviceServiceConfig)(this.deviceServiceConfig).then(done)
     }
   }

+ 24 - 40
src/views/realm/ai-timing/components/StratConfigDialog.vue

@@ -13,28 +13,6 @@
           inactive-color="#ff4949"
         />
       </div>
-      <span class="c-grid-form__label">抽帧间隔:</span>
-      <div class="c-grid-form__option">
-        <el-input-number
-          v-model="tenantStratConfig.offset"
-          :min="10"
-          :max="3600"
-          step-strictly
-        />
-        秒(10~3600)
-      </div>
-      <span class="c-grid-form__label required">开始时间:</span>
-      <el-time-picker
-        v-model="tenantStratConfig.startTime"
-        value-format="HH:mm:ss"
-        :clearable="false"
-      />
-      <span class="c-grid-form__label required">结束时间:</span>
-      <el-time-picker
-        v-model="tenantStratConfig.endTime"
-        value-format="HH:mm:ss"
-        :clearable="false"
-      />
       <span class="c-grid-form__label">图片保存:</span>
       <div
         class="l-flex--row c-grid-form__option c-grid-form__info"
@@ -58,6 +36,20 @@
           step-strictly
         />
       </div>
+      <span class="c-grid-form__label u-bold">疑似处理:</span>
+      <div class="l-flex--row c-grid-form__option">
+        <schema-select
+          v-model="tenantStratConfig.suspectedStrategy"
+          :schema="suspectedStrategySelectSchema"
+        />
+      </div>
+      <span class="c-grid-form__label u-bold">不合规处理:</span>
+      <div class="l-flex--row c-grid-form__option">
+        <schema-select
+          v-model="tenantStratConfig.nonComplianceStrategy"
+          :schema="nonComplianceStrategySelectSchema"
+        />
+      </div>
     </div>
   </confirm-dialog>
 </template>
@@ -73,6 +65,16 @@ export default {
   name: 'StratConfigDialog',
   data () {
     return {
+      suspectedStrategySelectSchema: { options: [
+        { value: 0, label: '预警' },
+        { value: 1, label: '关机' },
+        { value: 2, label: '预警+关机' }
+      ] },
+      nonComplianceStrategySelectSchema: { options: [
+        { value: 0, label: '预警' },
+        { value: 1, label: '关机' },
+        { value: 2, label: '预警+关机' }
+      ] },
       tenantStratConfig: {}
     }
   },
@@ -82,9 +84,6 @@ export default {
         this.tenantStratConfig = data || {
           tenant,
           enabled: false,
-          offset: 10,
-          startTime: '08:00:00',
-          endTime: '23:59:59',
           storePic: true,
           suspectedStrategy: 0,
           nonComplianceStrategy: 2,
@@ -94,21 +93,6 @@ export default {
       })
     },
     onSave (done) {
-      const { startTime, endTime } = this.tenantStratConfig
-      if (!startTime) {
-        this.$message({
-          type: 'warning',
-          message: '请选择开始时间'
-        })
-        return
-      }
-      if (!endTime) {
-        this.$message({
-          type: 'warning',
-          message: '请选择结束时间'
-        })
-        return
-      }
       (this.tenantStratConfig.id ? updateTenantStratConfig : addTenantStratConfig)(this.tenantStratConfig).then(done)
     }
   }

+ 0 - 29
src/views/realm/device/settings/api.js

@@ -1,29 +0,0 @@
-import {
-  add,
-  update,
-  send
-} from '@/api/base'
-
-export function getRecordConfig (deviceId) {
-  return send({
-    url: '/deviceStream/config',
-    method: 'GET',
-    params: { deviceId }
-  })
-}
-
-export function addRecordConfig (data) {
-  return add({
-    url: '/deviceStream/config',
-    method: 'POST',
-    data
-  })
-}
-
-export function updateRecordConfig (data) {
-  return update({
-    url: '/deviceStream/config',
-    method: 'PUT',
-    data
-  })
-}

+ 11 - 2
src/views/realm/device/settings/components/RecordConfigDialog.vue

@@ -48,7 +48,7 @@ import {
   getRecordConfig,
   addRecordConfig,
   updateRecordConfig
-} from '../api'
+} from '@/api/device'
 
 export default {
   name: 'RecordConfigDialog',
@@ -61,6 +61,7 @@ export default {
   methods: {
     show ({ id, name }) {
       this.title = `${name}推流配置`
+      const loading = this.$showLoading()
       getRecordConfig(id).then(({ data }) => {
         if (data) {
           this.$has = true
@@ -83,6 +84,8 @@ export default {
           }
         }
         this.$refs.configDialog.show()
+      }).finally(() => {
+        this.$closeLoading(loading)
       })
     },
     onSave (done) {
@@ -93,7 +96,13 @@ export default {
         videoHeight,
         videoBitRate: videoBitRate * 1024,
         frameRate
-      }).then(done)
+      }).then(() => {
+        done()
+        this.$message({
+          type: 'success',
+          message: '设置成功'
+        })
+      })
     }
   }
 }

+ 3 - 3
src/views/realm/settings/api.js

@@ -51,7 +51,7 @@ export function updateInformStrategy (tenant, strategy) {
 
 export function getTenantServiceConfig (tenant, type) {
   return send({
-    url: '/device/deviceAuditConfig/tenantServiceConfig',
+    url: '/device/deviceAudit/tenant/serviceConfig',
     method: 'GET',
     params: { tenant, type }
   })
@@ -59,7 +59,7 @@ export function getTenantServiceConfig (tenant, type) {
 
 export function addTenantServiceConfig (data) {
   return add({
-    url: '/device/deviceAuditConfig/tenantServiceConfig',
+    url: '/device/deviceAudit/tenant/serviceConfig',
     method: 'POST',
     data
   })
@@ -67,7 +67,7 @@ export function addTenantServiceConfig (data) {
 
 export function updateTenantServiceConfig (data) {
   return update({
-    url: '/device/deviceAuditConfig/tenantServiceConfig',
+    url: '/device/deviceAudit/tenant/serviceConfig',
     method: 'PUT',
     data
   })

+ 3 - 6
src/views/realm/settings/components/ServiceConfigDialog.vue

@@ -37,19 +37,16 @@ export default {
       getTenantServiceConfig(tenant, type).then(({ data }) => {
         this.title = type === 1 ? 'AI抽帧检测服务配置' : '媒资AI审核服务配置'
         this.$has = !!data
-        this.tenantServiceConfig = {
+        this.tenantServiceConfig = data || {
           tenant,
           type,
-          enabled: data ? data.enabled : false
-        }
-        if (type === 1) {
-          this.tenantServiceConfig.collectDevice = 1
+          enabled: false
         }
         this.$refs.configDialog.show()
       })
     },
     onSave (done) {
-      (this.$has ? updateTenantServiceConfig : addTenantServiceConfig)(this.tenantServiceConfig).then(done)
+      (this.tenantServiceConfig.id ? updateTenantServiceConfig : addTenantServiceConfig)(this.tenantServiceConfig).then(done)
     }
   }
 }