index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div
  3. class="ele-body"
  4. :style="
  5. $route.query.isDrawer
  6. ? {
  7. position: 'fixed',
  8. height: '100vh',
  9. top: '0',
  10. bottom: '0',
  11. left: '0',
  12. right: '0',
  13. zIndex: 1000,
  14. background: '#fff'
  15. }
  16. : {}
  17. "
  18. >
  19. <el-card shadow="never" v-loading="loading">
  20. <message-search @search="reload"> </message-search>
  21. <!-- 数据表格 -->
  22. <ele-pro-table
  23. ref="table"
  24. :pageSizes="tablePageSizes"
  25. :columns="columns"
  26. :datasource="datasource"
  27. cache-key="systemRoleTable"
  28. >
  29. <template v-slot:action="{ row }">
  30. <el-link
  31. type="primary"
  32. :underline="false"
  33. icon="el-icon-edit"
  34. @click="openEdit(row)"
  35. v-if="
  36. !row.handleStatus && $hasPermission('eam:alarmlogsheet:update')
  37. "
  38. >
  39. 处理
  40. </el-link>
  41. </template>
  42. <template v-slot:triggerCount="{ row }">
  43. <el-link type="primary" :underline="false" @click="triggerCount(row)">
  44. {{ row.triggerCount }}
  45. </el-link>
  46. </template>
  47. <template v-slot:deviceName="{ row }">
  48. <el-link
  49. type="primary"
  50. :underline="false"
  51. @click="openEdit(row, 'view')"
  52. >
  53. {{ row.deviceName }}
  54. </el-link>
  55. </template>
  56. </ele-pro-table>
  57. </el-card>
  58. <processDialog ref="processDialogRef" @reload="reload"></processDialog>
  59. <!-- 告警次数详情弹窗 -->
  60. <el-dialog
  61. title="告警详情"
  62. :visible.sync="triggerDialogVisible"
  63. width="70%"
  64. append-to-body
  65. >
  66. <el-table :data="triggerList" border style="width: 100%">
  67. <el-table-column type="index" label="序号" width="55" align="center" />
  68. <el-table-column
  69. prop="description"
  70. label="告警描述"
  71. align="center"
  72. show-overflow-tooltip
  73. min-width="180"
  74. />
  75. <el-table-column
  76. prop="triggerTime"
  77. label="告警时间"
  78. align="center"
  79. show-overflow-tooltip
  80. min-width="160"
  81. />
  82. <el-table-column
  83. label="告警内容"
  84. align="center"
  85. show-overflow-tooltip
  86. min-width="200"
  87. >
  88. <template slot-scope="{ row }">
  89. <div v-if="row._deviceData && row._deviceData.length">
  90. <div v-for="(item, index) in row._deviceData" :key="index">
  91. 点位:{{ item.attributeName}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 告警值:{{ item.thresholdValue }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当前值: {{ item.value }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 差值:{{
  92. parseFloat((item.value - item.thresholdValue).toFixed(3))
  93. }}
  94. </div>
  95. </div>
  96. <span v-else>-</span>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. </el-dialog>
  101. </div>
  102. </template>
  103. <script>
  104. import MessageSearch from './components/message-search.vue';
  105. import processDialog from './components/processDialog.vue';
  106. import { alarmlogsheetPage, getDetail } from '@/api/warning/index.js';
  107. import dictMixins from '@/mixins/dictMixins';
  108. export default {
  109. mixins: [dictMixins],
  110. components: {
  111. MessageSearch,
  112. processDialog
  113. },
  114. data() {
  115. return {
  116. // 表格列配置
  117. columns: [
  118. {
  119. columnKey: 'index',
  120. label: '序号',
  121. type: 'index',
  122. width: 55,
  123. align: 'center',
  124. showOverflowTooltip: true,
  125. fixed: 'left'
  126. },
  127. {
  128. prop: 'alarmLevel',
  129. label: '告警级别',
  130. align: 'center',
  131. showOverflowTooltip: true,
  132. minWidth: 80,
  133. formatter: (_row, _column, cellValue) => {
  134. const map = {
  135. 1: '轻微',
  136. 2: '中等',
  137. 3: '严重',
  138. 4: '紧急',
  139. 5: '致命'
  140. };
  141. return map[cellValue] || '-';
  142. }
  143. },
  144. {
  145. prop: 'deviceCode',
  146. label: '设备编号',
  147. align: 'center',
  148. showOverflowTooltip: true,
  149. minWidth: 110
  150. },
  151. {
  152. prop: 'deviceName',
  153. label: '设备名称',
  154. slot: 'deviceName',
  155. align: 'center',
  156. showOverflowTooltip: true,
  157. minWidth: 200
  158. },
  159. {
  160. prop: 'description',
  161. label: '告警描述',
  162. align: 'center',
  163. showOverflowTooltip: true,
  164. minWidth: 180
  165. },
  166. {
  167. prop: 'generateDocumentType',
  168. label: '生成单据类型',
  169. formatter: (_row, _column, cellValue) => {
  170. let message =
  171. cellValue == 1
  172. ? '巡点检'
  173. : cellValue == 2
  174. ? '保养'
  175. : cellValue == 3
  176. ? '维修'
  177. : cellValue == 5
  178. ? '量具送检'
  179. : '';
  180. if (_row.orderStatusName) {
  181. message += ' (' + _row.orderStatusName + ')';
  182. } else if (message) {
  183. message += ' (待派单)';
  184. }
  185. return message;
  186. },
  187. align: 'center',
  188. showOverflowTooltip: true,
  189. minWidth: 110
  190. },
  191. {
  192. prop: 'generateDocumentCode',
  193. label: '生成单据编码',
  194. align: 'center',
  195. showOverflowTooltip: true,
  196. minWidth: 110
  197. },
  198. {
  199. prop: 'triggerCount',
  200. slot: 'triggerCount',
  201. label: '告警次数',
  202. align: 'center',
  203. showOverflowTooltip: true,
  204. minWidth: 110
  205. },
  206. {
  207. prop: 'alarmTime',
  208. label: '首次告警时间',
  209. align: 'center',
  210. showOverflowTooltip: true,
  211. minWidth: 160,
  212. formatter: (_row, _column, cellValue) => {
  213. return this.$util.toDateString(cellValue);
  214. }
  215. },
  216. {
  217. prop: 'lastTriggerTime',
  218. label: '最近告警时间',
  219. align: 'center',
  220. showOverflowTooltip: true,
  221. minWidth: 160,
  222. formatter: (_row, _column, cellValue) => {
  223. return this.$util.toDateString(cellValue);
  224. }
  225. },
  226. {
  227. prop: 'handleStatus',
  228. label: '处理状态',
  229. align: 'center',
  230. formatter: (_row, _column, cellValue) => {
  231. return { 0: '未处理', 1: '处理中', 2: '已处理' }[cellValue];
  232. },
  233. showOverflowTooltip: true,
  234. minWidth: 110
  235. },
  236. {
  237. prop: 'handleUserName',
  238. label: '处理人',
  239. align: 'center',
  240. showOverflowTooltip: true,
  241. minWidth: 110
  242. },
  243. {
  244. prop: 'remark',
  245. label: '处理意见',
  246. align: 'center',
  247. showOverflowTooltip: true,
  248. minWidth: 110
  249. },
  250. {
  251. columnKey: 'action',
  252. label: '操作',
  253. width: 150,
  254. align: 'center',
  255. resizable: false,
  256. slot: 'action',
  257. showOverflowTooltip: true
  258. }
  259. ],
  260. // 加载状态
  261. loading: false,
  262. triggerDialogVisible: false,
  263. triggerList: []
  264. };
  265. },
  266. computed: {},
  267. created() {
  268. this.requestDict('规则状态');
  269. },
  270. methods: {
  271. /* 表格数据源 */
  272. datasource({ page, limit, where, order }) {
  273. return alarmlogsheetPage({
  274. pageNum: page,
  275. size: limit,
  276. ...where
  277. });
  278. },
  279. openEdit(row, type) {
  280. this.$refs.processDialogRef.open(row, type);
  281. },
  282. triggerCount(row) {
  283. getDetail(row.id).then((res) => {
  284. let list = Array.isArray(res) ? res : [];
  285. list = list.map((item) => {
  286. let deviceDataArr = [];
  287. if (item.deviceData) {
  288. try {
  289. const parsed = JSON.parse(item.deviceData);
  290. deviceDataArr = Array.isArray(parsed) ? parsed : [];
  291. } catch (e) {
  292. deviceDataArr = [];
  293. }
  294. }
  295. return {
  296. ...item,
  297. _deviceData: deviceDataArr
  298. };
  299. });
  300. this.triggerList = list;
  301. this.triggerDialogVisible = true;
  302. });
  303. },
  304. /* 刷新表格 */
  305. reload(where) {
  306. this.$refs.table.reload({ page: 1, where, ruleType: 2 });
  307. }
  308. }
  309. };
  310. </script>
  311. <style lang="scss" scoped></style>