Casper Dai 2 лет назад
Родитель
Сommit
aab0b53e47

+ 3 - 2
src/api/device.js

@@ -534,10 +534,11 @@ export function updateRecordConfig (data, config) {
   })
 }
 
-export function authCode (stream) {
+export function authCode (stream, options) {
   return request({
     url: `/deviceStream/${stream}/authCode`,
-    method: 'GET'
+    method: 'GET',
+    ...options
   })
 }
 

+ 26 - 5
src/views/device/detail/components/DeviceInvoke/MultifunctionCardPowerSwitch.vue

@@ -117,7 +117,10 @@ import {
   SET_RELAY_POWER_TIMING
 } from '@/utils/adapter/nova'
 import { toDate } from '@/utils/event'
-import { savePowerLogger } from '@/api/platform'
+import {
+  savePowerLogger,
+  sendDeviceAlarm
+} from '@/api/platform'
 import {
   addListener,
   removeListener
@@ -229,7 +232,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['isSuperAdmin']),
+    ...mapGetters(['isSuperAdmin', 'account']),
     powerStatusTip () {
       switch (this.powerStatus) {
         case Status.OK:
@@ -577,11 +580,17 @@ export default {
           type: 'warning'
         }
       ).then(() => {
+        const target = `手动${this.actionInfo[targetAction]} ${type} 电源端口${powerIndex}`
         savePowerLogger({
-          description: `${this.actionInfo[targetAction]} ${powerIndex} ${type} 电源`,
+          description: target,
           method: `power ${targetAction ? 'on' : 'off'}`,
           params: this.device.name
         })
+        sendDeviceAlarm({
+          deviceId: this.device.id,
+          errorEnumId: targetAction ? 36 : 37,
+          message: `用户: ${this.account} ${target}`
+        })
         this.onSwitchPowerSingle(power)
       })
     },
@@ -596,11 +605,17 @@ export default {
           type: 'warning'
         }
       ).then(() => {
+        const target = `手动${this.actionInfo[targetAction]}电源 ${type}`
         savePowerLogger({
-          description: `${this.actionInfo[targetAction]} 所有 ${type} 电源`,
+          description: target,
           method: `power ${targetAction ? 'on' : 'off'}`,
           params: this.device.name
         })
+        sendDeviceAlarm({
+          deviceId: this.device.id,
+          errorEnumId: targetAction ? 36 : 37,
+          message: `用户: ${this.account} ${target}`
+        })
         if (portIndex === RELAY_KEY) {
           this.onSwitchPowerSingle(power)
         } else {
@@ -684,11 +699,17 @@ export default {
           type: 'warning'
         }
       ).then(() => {
+        const target = `手动${this.actionInfo[action]}电源`
         savePowerLogger({
-          description: `${this.actionInfo[action]}所有电源`,
+          description: target,
           method: `power ${action ? 'on' : 'off'}`,
           params: this.device.name
         })
+        sendDeviceAlarm({
+          deviceId: this.device.id,
+          errorEnumId: action ? 36 : 37,
+          message: `用户: ${this.account} ${target}`
+        })
         if (!this.$useUnified && this.$hasRelay) {
           this.onSwitchPowerSingle(this.$powers[0].powers[0])
           return