index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="home-container">
  3. <el-row :gutter="15" class="home-card-three">
  4. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  5. <div class="home-card-item" style="height: auto">
  6. <div class="home-card-item-title">
  7. <span>告警消息</span>
  8. <el-button size="small" text type="primary" @click="toMore()">更多信息</el-button>
  9. </div>
  10. <el-table :data="tableData.data" style="width: 100%" v-loading="loading">
  11. <el-table-column label="ID" align="center" prop="id" width="100" v-col="'ID'" />
  12. <el-table-column label="告警类型" width="120" prop="type" align="center" show-overflow-tooltip v-col="'type'">
  13. <template #default="scope">
  14. <span v-if="scope.row.type == 1">规则告警</span>
  15. <span v-else-if="scope.row.type == 2">设备自主告警</span>
  16. <span v-else-if="scope.row.type == 3">规侧告警升级</span>
  17. <span v-else>设备自主告警</span>
  18. </template>
  19. </el-table-column>
  20. <el-table-column label="规则级别" width="120" align="center" prop="alarmLevel.name" show-overflow-tooltip v-col="'alarmLevel'" />
  21. <el-table-column label="规则名称" prop="ruleName" show-overflow-tooltip v-col="'ruleName'" />
  22. <el-table-column label="产品标识" prop="productKey" show-overflow-tooltip v-col="'productKey'" />
  23. <el-table-column label="设备标识" prop="deviceKey" show-overflow-tooltip v-col="'deviceKey'" />
  24. <el-table-column prop="status" label="告警状态" width="100" align="center" v-col="'status'">
  25. <template #default="scope">
  26. <el-tag type="success" size="small" v-if="scope.row.status">已处理</el-tag>
  27. <el-tag type="info" size="small" v-else>未处理</el-tag>
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="createdAt" label="告警时间" align="center" width="170" v-col="'createdAt'"></el-table-column>
  31. <el-table-column label="操作" width="130" align="center" fixed="right" v-col="'handle'">
  32. <template #default="scope">
  33. <el-button v-auth="'detail'" size="small" text type="primary" @click="onOpenDetailDic(scope.row)">详情</el-button>
  34. <el-button v-auth="'edit'" size="small" text type="warning" @click="onOpenEditDic(scope.row)" v-if="scope.row.status == 0"
  35. >处理</el-button
  36. >
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. </div>
  41. </el-col>
  42. </el-row>
  43. <EditDic ref="editDicRef" @dataList="getAlarmList" />
  44. <DetailDic ref="detailRef" @dataList="getAlarmList" />
  45. </div>
  46. </template>
  47. <script lang="ts" setup>
  48. import { toRefs, reactive, onMounted, ref } from 'vue'
  49. import { useRouter } from 'vue-router'
  50. import api from '/@/api/datahub'
  51. import EditDic from '../log/component/edit.vue'
  52. import DetailDic from '../log/component/detail.vue'
  53. const editDicRef = ref()
  54. const detailRef = ref()
  55. const router = useRouter()
  56. const state = reactive({
  57. loading: false,
  58. tableData: {
  59. data: [],
  60. total: 0,
  61. loading: false,
  62. param: {
  63. pageNum: 1,
  64. pageSize: 20,
  65. status: '',
  66. dateRange: [],
  67. },
  68. },
  69. })
  70. const { loading, tableData } = toRefs(state)
  71. const getAlarmList = () => {
  72. api.iotManage.getAlarmList(state.tableData.param).then((res: any) => {
  73. state.tableData.data = res.list
  74. state.tableData.total = res.Total
  75. })
  76. }
  77. //打开详情页
  78. const onOpenDetailDic = (row: any) => {
  79. detailRef.value.openDialog(row)
  80. }
  81. // 打开修改产品弹窗
  82. const onOpenEditDic = (row: any) => {
  83. editDicRef.value.openDialog(row)
  84. }
  85. // 告警信息-更多信息
  86. const toMore = () => {
  87. router.push({ path: '/iotmanager/alarm/log' })
  88. }
  89. // 页面加载时
  90. onMounted(() => {
  91. getAlarmList()
  92. })
  93. </script>
  94. <style scoped lang="scss">
  95. .home-container {
  96. overflow: hidden;
  97. .home-card-one,
  98. .home-card-two,
  99. .home-card-three {
  100. .icoimg {
  101. width: 75px;
  102. height: 75px;
  103. }
  104. .title_status {
  105. width: 7px;
  106. height: 7px;
  107. background: #c1bbbb;
  108. border-radius: 50px;
  109. margin-right: 5px;
  110. }
  111. .home-card-item,
  112. .home-card-top {
  113. width: 100%;
  114. border-radius: 8px;
  115. transition: all ease 0.3s;
  116. padding: 10px 20px;
  117. overflow: hidden;
  118. background: var(--el-color-white);
  119. color: var(--el-text-color-primary);
  120. // border: 1px solid var(--next-border-color-light);
  121. &:hover {
  122. // box-shadow: 0 2px 12px var(--next-color-dark-hover);
  123. transition: all ease 0.3s;
  124. }
  125. &-icon {
  126. width: 70px;
  127. height: 70px;
  128. border-radius: 100%;
  129. flex-shrink: 1;
  130. i {
  131. color: var(--el-text-color-placeholder);
  132. }
  133. }
  134. &-title {
  135. font-size: 15px;
  136. font-weight: bold;
  137. height: 30px;
  138. }
  139. }
  140. }
  141. .home-card-three {
  142. .home-card-item-title {
  143. display: flex;
  144. justify-content: space-between;
  145. // span:nth-child(2) {
  146. // color: #409eff;
  147. // }
  148. }
  149. }
  150. }
  151. </style>