Просмотр исходного кода

refactor(device): alarm display

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

+ 14 - 26
src/api/device.js

@@ -59,6 +59,18 @@ export function getTimeline (deviceId, options) {
   }).then(({ data }) => JSON.parse(data.eventDetail) || [])
 }
 
+export function getTimelineByRange (deviceId, startTime, endTime, options) {
+  return request({
+    url: `/content/deviceCalender/${deviceId}`,
+    method: 'GET',
+    params: {
+      startTime,
+      endTime
+    },
+    ...options
+  }).then(({ data }) => JSON.parse(data.eventDetail) || [])
+}
+
 export function addDevice (data) {
   return add({
     url: '/device',
@@ -347,7 +359,7 @@ export function getDeviceAlarms (query) {
     }
   }).then(({ data, totalCount }) => {
     return {
-      data: data.map(({ id, deviceName, level, pic, picUrl, type, handle, status, happenTime, ...item }) => {
+      data: data.map(({ id, deviceName, level, pic, picUrl, type, handle, status, happenTime, bugMessage, ...item }) => {
         const alarm = {
           id, deviceName, level, happenTime,
           file: pic && picUrl
@@ -358,7 +370,7 @@ export function getDeviceAlarms (query) {
               origin: true
             }
             : null,
-          type: getType(type),
+          type: bugMessage || `预警码【${type}】`,
           handle: ['应用重启', '设备重启', '恢复出厂', '未干预'][handle] || '-',
           status: handle <= 2 && status <= 2
             ? {
@@ -377,30 +389,6 @@ export function getDeviceAlarms (query) {
   })
 }
 
-const AlarmType = {
-  0: '疑似黑屏',
-  1: '设备离线',
-  2: '屏幕拓扑结构异常',
-  3: '播放非法视频',
-  4: '接收卡离线',
-  5: '发送控制设备离线',
-  6: '浪潮智能网关离线',
-  7: '屏幕监控摄像头离线',
-  8: '人流监测摄像头离线',
-  9: '设备上线',
-  10: '回采疑似',
-  11: '回采不合规',
-  12: '空档期',
-  1000: '分割器异常'
-}
-
-function getType (type) {
-  if (type >= 1101 && type <= 1116) {
-    type = 1000
-  }
-  return AlarmType[type] || '-'
-}
-
 function getTag (value) {
   switch (value) {
     case 0:

+ 6 - 0
src/constant.js

@@ -285,6 +285,12 @@ export const RoleAccess = {
   ]
 }
 
+export const AlarmLevelInfo = {
+  0: '提示性预警',
+  1: '中级预警',
+  2: '紧急预警'
+}
+
 export const AlarmStrategies = [
   { key: 'note', label: '短信', support: true },
   { key: 'email', label: '邮件', support: true },

+ 1 - 0
src/layout/components/Sidebar/index.vue

@@ -109,6 +109,7 @@ export default {
       .c-page-sidebar__wrapper {
         margin-right: -7px !important;
         overflow-x: hidden;
+        scrollbar-width: none;
       }
 
       .el-scrollbar__bar {

+ 1 - 0
src/scss/base/_reset.scss

@@ -1,6 +1,7 @@
 * {
   margin: 0;
   padding: 0;
+  scrollbar-width: thin;
 }
 
 html,

+ 14 - 7
src/views/device/detail/components/DeviceAlarm.vue

@@ -9,9 +9,12 @@
 </template>
 
 <script>
-import { getDeviceAlarms } from '@/api/device'
+import {
+  AlarmLevelInfo,
+  SupportedAlarmStrategies
+} from '@/constant'
 import { createListOptions } from '@/utils'
-import { SupportedAlarmStrategies } from '@/constant'
+import { getDeviceAlarms } from '@/api/device'
 
 export default {
   name: 'DeviceAlarm',
@@ -25,12 +28,17 @@ export default {
     return {
       options: createListOptions({ deviceId: this.device.id }),
       schema: {
-        condition: { deviceId: this.device.id },
         list: getDeviceAlarms,
+        condition: { deviceId: this.device.id },
         cols: [
           { prop: 'file', label: '截图', type: 'asset', refresh: true, on: this.onView },
-          { prop: 'type', label: '类型', 'min-width': 120 },
-          { prop: 'handle', label: '处理方式' },
+          { label: '预警级别', type: 'tag', render: ({ level }) => AlarmLevelInfo[level] && {
+            type: ['primary', 'wraning', 'danger'],
+            label: AlarmLevelInfo[level]
+          }, width: 108, align: 'center' },
+          { prop: 'happenTime', label: '预警时间', width: 180, align: 'center' },
+          { prop: 'type', label: '预警类型' },
+          { prop: 'handle', label: '处理方式', width: 100, align: 'center' },
           { prop: 'status', label: '处理结果', type: 'tag' },
           ...SupportedAlarmStrategies.map(({ key, label }) => {
             return {
@@ -38,8 +46,7 @@ export default {
               label: `${label}通知`,
               type: 'tag'
             }
-          }),
-          { prop: 'happenTime', label: '时间', 'min-width': 120 }
+          })
         ]
       }
     }

+ 5 - 8
src/views/realm/settings/api.js

@@ -1,16 +1,13 @@
-import { SupportedAlarmStrategies } from '@/constant'
+import {
+  AlarmLevelInfo,
+  SupportedAlarmStrategies
+} from '@/constant'
 import {
   update,
   send,
   addTenant
 } from '@/api/base'
 
-const AlarmLevel = {
-  0: '提示性预警',
-  1: '中级预警',
-  2: '紧急预警'
-}
-
 export function getInformStrategy () {
   return send({
     url: '/tenant/informStrategy',
@@ -19,7 +16,7 @@ export function getInformStrategy () {
   }).then(({ data: { strategy } }) => Object.keys(strategy).sort().map(key => {
     return {
       level: key,
-      name: AlarmLevel[key],
+      name: AlarmLevelInfo[key],
       options: getStrategyOptions(strategy[key])
     }
   }))

+ 0 - 6
src/views/realm/settings/components/AlarmStratConfigDialog.vue

@@ -70,9 +70,3 @@ export default {
   }
 }
 </script>
-
-<style lang="scss" scoped>
-.o-strategy-name {
-  width: 60px;
-}
-</style>