Pārlūkot izejas kodu

feat: optimize

remove some useless code and adjust some code processing
Casper Dai 2 gadi atpakaļ
vecāks
revīzija
1d92b95657

+ 3 - 2
src/api/device.js

@@ -557,10 +557,11 @@ export function cancelDeviceAttention (deviceId) {
   }, '取关')
 }
 
-export function getDeviceAttentionList () {
+export function getDeviceAttentionList (options) {
   return request({
     url: '/device/user/attention/list',
-    method: 'GET'
+    method: 'GET',
+    ...options
   })
 }
 

+ 11 - 9
src/components/service/FullLink/index.vue

@@ -395,17 +395,19 @@ export default {
       const linkDeviceMap = this.linkDeviceMap
       const by = this.led.by
       const mutliStatus = this.linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD]
-      const isError = mutliStatus > Status.NONE && mutliStatus === Status.ERROR || by.some(key => linkDeviceMap[key] === Status.ERROR)
+      const linkError = by.some(key => linkDeviceMap[key] === Status.ERROR)
       const isOK = (mutliStatus === Status.NONE || mutliStatus === Status.OK) && !by.some(key => linkDeviceMap[key] !== Status.OK)
+      this.linkDeviceMap.led = mutliStatus === Status.ERROR || linkError ? Status.ERROR : isOK ? Status.OK : Status.WARNING
       this.led.onlineStatus = isOK ? 1 : 0
-      this.led.powerStatus = mutliStatus === Status.LOADING
-        ? 'el-icon-loading'
-        : mutliStatus === Status.ERROR
-          ? 'off'
-          : mutliStatus === Status.WARNING
-            ? 'power el-icon-warning u-color--warning'
-            : ''
-      this.linkDeviceMap.led = isError ? Status.ERROR : isOK ? Status.OK : Status.WARNING
+      this.led.powerStatus = linkError
+        ? ''
+        : mutliStatus === Status.LOADING
+          ? 'el-icon-loading'
+          : mutliStatus === Status.ERROR
+            ? 'off'
+            : mutliStatus === Status.WARNING
+              ? 'power el-icon-warning u-color--warning'
+              : ''
     },
     onClick (item) {
       if (!item.canClick) {

+ 2 - 8
src/views/dashboard/v1/MessageNotice.vue

@@ -178,9 +178,7 @@ export default {
           pageSize: 20
         })
       ).then(({ data }) => {
-        console.log(data)
         this.listData = data
-        // this.newAlarmList = data.filter(i => i.level === 2)
       })
     },
     closeNewAlarm (alarm) {
@@ -196,7 +194,6 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-
 .c-messageNotice {
   position: relative;
   &__header {
@@ -274,12 +271,9 @@ export default {
       opacity: 0.8;
       filter: blur(4px);
     }
-    &:hover {
-      // animation: none;
-    }
   }
-    --color1: #fc6076;
-    --color2: #f40606;
+  --color1: #fc6076;
+  --color2: #f40606;
   @keyframes liuguang {
     0% {
       background: linear-gradient(

+ 0 - 1
src/views/dashboard/v1/Record.vue

@@ -149,7 +149,6 @@ export default {
         case ThirdPartyDevice.FLOODING_SENSOR:
           return value ? '是' : '否'
         case ThirdPartyDevice.TRANSLOCATION_SENSOR:
-          console.log(data)
           return `x ${data.xvalue?.toFixed(3)}  y ${data.yvalue?.toFixed(
             3
           )}  z ${data.zvalue?.toFixed(3)}`

+ 15 - 11
src/views/device/detail/components/DeviceInvoke/MultifunctionCardPowerSwitch.vue

@@ -235,10 +235,8 @@ export default {
       switch (this.powerStatus) {
         case Status.OK:
           return '开关电源'
-        case Status.LOADING:
-          return '检测电源中'
         default:
-          return '检测电源'
+          return '检测电源中'
       }
     },
     iconClass () {
@@ -377,6 +375,7 @@ export default {
     },
     invoke () {
       if (this.powerStatus !== Status.OK) {
+        this.fetchPowerStatus()
         return
       }
       this.active = GET_POWER_STATUS
@@ -385,14 +384,23 @@ export default {
     },
     onCacheMessage (value) {
       const multiCard = value[ThirdPartyDevice.MULTI_FUNCTION_CARD]
-      if (multiCard.status > Status.LOADING) {
+      if (multiCard.status > Status.LOADING && Date.now() - multiCard.timestamp < 30000) {
         this.powerStatus = multiCard.status
         this.$multiCard = multiCard
-        if (this.active === GET_POWER_STATUS && Date.now() - this.$multiCard.timestamp < 5000) {
+        if (this.$openDialog && this.active === GET_POWER_STATUS) {
           this.getPowerStatus()
         }
+      } else {
+        this.powerStatus = Status.LOADING
       }
     },
+    fetchPowerStatus () {
+      this.sendTopic(
+        GET_POWER_STATUS,
+        JSON.stringify({ sn: this.device.serialNumber }),
+        true
+      )
+    },
     onMessage (message) {
       if (!this.$messageId) {
         return
@@ -461,17 +469,13 @@ export default {
     getPowerStatus () {
       this.$powers = []
       this.hasChanged = false
-      if (this.$multiCard && Date.now() - this.$multiCard.timestamp < 10000) {
+      if (this.$multiCard && Date.now() - this.$multiCard.timestamp < 30000) {
         this.setCachePowerStatus(this.$multiCard)
         if (this.$openDialog) {
           this.$refs.dialog?.show()
         }
       } else {
-        this.sendTopic(
-          GET_POWER_STATUS,
-          JSON.stringify({ sn: this.device.serialNumber }),
-          ErrorMessage[this.$refs.dialog?.dialogVisible ? 'TIMEOUT_RETRY' : GET_POWER_STATUS]
-        )
+        this.fetchPowerStatus()
       }
       this.$refs.table?.pageTo(1)
     },

+ 2 - 2
src/views/realm/assign/Device.vue

@@ -68,8 +68,8 @@ export default {
         condition: { isFullDisplay: 0 },
         filters: [
           { key: 'isFullDisplay', type: 'select', options: [
-            { value: 0, label: '未绑定' },
-            { value: 1, label: '未绑定自身' }
+            { value: 0, label: '未分配' },
+            { value: 1, label: '全部' }
           ] },
           { key: 'name', type: 'search', placeholder: '设备名称' }
         ],