DeviceAlarm.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div>
  3. <c-table
  4. :curr="options"
  5. @pagination="getList"
  6. >
  7. <el-table-column
  8. align="center"
  9. width="50"
  10. >
  11. <template #header>
  12. <i
  13. class="o-refresh el-icon-refresh"
  14. @click="getList"
  15. />
  16. </template>
  17. </el-table-column>
  18. <el-table-column
  19. label="截图"
  20. align="center"
  21. class-name="c-thumbnail-col"
  22. width="100"
  23. >
  24. <template v-slot="scope">
  25. <i
  26. v-if="scope.row.picUrl"
  27. class="o-thumbnail u-pointer"
  28. :style="{ 'background-image': `url('${scope.row.picUrl}')` }"
  29. @click="toView(scope.row)"
  30. />
  31. </template>
  32. </el-table-column>
  33. <el-table-column
  34. prop="type"
  35. label="告警类型"
  36. align="center"
  37. show-overflow-tooltip
  38. />
  39. <el-table-column
  40. prop="handle"
  41. label="处理方式"
  42. align="center"
  43. show-overflow-tooltip
  44. />
  45. <el-table-column
  46. label="处理结果"
  47. align="center"
  48. show-overflow-tooltip
  49. >
  50. <template v-slot="scope">
  51. <el-tag
  52. class="o-tag"
  53. :type="scope.row.status"
  54. size="medium"
  55. >
  56. {{ scope.row.statusTip }}
  57. </el-tag>
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. label="短信通知"
  62. align="center"
  63. >
  64. <template v-slot="scope">
  65. <el-tag
  66. class="o-tag"
  67. :type="scope.row.note ? 'success' : 'danger'"
  68. size="medium"
  69. >
  70. {{ scope.row.note ? '是' : '否' }}
  71. </el-tag>
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. label="邮件通知"
  76. align="center"
  77. >
  78. <template v-slot="scope">
  79. <el-tag
  80. class="o-tag"
  81. :type="scope.row.email ? 'success' : 'danger'"
  82. size="medium"
  83. >
  84. {{ scope.row.email ? '是' : '否' }}
  85. </el-tag>
  86. </template>
  87. </el-table-column>
  88. <el-table-column
  89. prop="happenTime"
  90. label="告警时间"
  91. align="center"
  92. show-overflow-tooltip
  93. />
  94. </c-table>
  95. <preview ref="preview" />
  96. </div>
  97. </template>
  98. <script>
  99. import { getThumbnailUrl } from '@/api/asset'
  100. import { getDeviceAlarms } from '@/api/device'
  101. import { createListOptions } from '@/utils'
  102. import { AssetType } from '@/constant'
  103. import Preview from '@/components/Preview'
  104. export default {
  105. name: 'DeviceAlarm',
  106. components: {
  107. Preview
  108. },
  109. props: {
  110. device: {
  111. type: Object,
  112. default: null
  113. }
  114. },
  115. data () {
  116. return {
  117. options: createListOptions({ deviceId: this.device.id })
  118. }
  119. },
  120. activated () {
  121. this.getList()
  122. },
  123. methods: {
  124. transform ({ pic, picUrl, type, handle, status, note, email, happenTime }) {
  125. return {
  126. picUrl: pic && picUrl ? getThumbnailUrl(picUrl) : null,
  127. keyName: picUrl,
  128. type: ['疑似黑屏', '设备离线', '屏幕拓扑结构异常'][type],
  129. handle: ['应用重启', '设备重启', '恢复出厂', '未干预'][handle],
  130. status: ['primary', 'success', 'danger', 'primary'][status],
  131. statusTip: ['处理中', '成功', '失败', '无'][status],
  132. note, email, happenTime
  133. }
  134. },
  135. getList () {
  136. const options = this.options
  137. if (!options.loading) {
  138. options.error = false
  139. options.loading = true
  140. getDeviceAlarms(options.params).then(({ data, totalCount }) => {
  141. options.list = data.map(this.transform)
  142. options.totalCount = totalCount
  143. }, () => {
  144. options.error = true
  145. options.list = []
  146. }).finally(() => {
  147. options.loading = false
  148. })
  149. }
  150. },
  151. toView (alarm) {
  152. this.$refs.preview.show({
  153. type: AssetType.IMAGE,
  154. keyName: alarm.keyName
  155. })
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .c-device-status {
  162. display: grid;
  163. grid-template-columns: repeat(4, 1fr);
  164. grid-row-gap: $spacing;
  165. grid-column-gap: $spacing;
  166. align-items: start;
  167. &__block {
  168. height: 180px;
  169. border: 1px solid $info;
  170. border-radius: 2px;
  171. }
  172. }
  173. </style>