AlarmMonitor.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div class="alarm-monitor">
  3. <div class="alarm-top">
  4. <div class="time-range">
  5. <a-range-picker
  6. v-model:value="timeRange"
  7. class="alarm-range-picker"
  8. show-time
  9. value-format="YYYY-MM-DD HH:mm:ss"
  10. format="YYYY-MM-DD HH:mm:ss"
  11. :placeholder="['开始时间', '结束时间']"
  12. :allow-clear="false"
  13. @change="getDscAlarmLogList"
  14. />
  15. </div>
  16. </div>
  17. <div class="alarm-bot">
  18. <CommonTable :columns="alarmColumns" :table-data="tableData"></CommonTable>
  19. </div>
  20. </div>
  21. </template>
  22. <script setup lang="ts">
  23. import { onMounted, onUnmounted, ref } from 'vue';
  24. import dayjs from 'dayjs';
  25. import CommonTable from './CommonTable.vue';
  26. import { autoLogList, dscAlarmLogList } from '../hsqHome.api';
  27. import {alarmColumns} from '../hsqHome.data'
  28. const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss'
  29. let props = defineProps({
  30. /**
  31. * 卡片数据对象
  32. * key 对应 option 中每项的 value,value 为实际展示数值
  33. */
  34. cardData: {
  35. type: Object as any,
  36. default: () => {
  37. return {}
  38. }
  39. }
  40. })
  41. /** 时间范围:[开始时间, 结束时间],默认当天 0 点至当前时间 */
  42. const timeRange = ref<[string, string]>([
  43. dayjs().startOf('day').format(DATE_FORMAT),
  44. dayjs().format(DATE_FORMAT),
  45. ])
  46. // 表格数据源:从后端获取报警日志列表数据
  47. let tableData = ref<any[]>([])
  48. /** 定时获取监测数据定时器 */
  49. let timer: null | NodeJS.Timeout = null;
  50. /**
  51. * 定时获取监测数据
  52. * 通过定时器循环调用数据获取方法,更新表格数据
  53. *
  54. * @param flag - 是否立即执行(首次调用时传true跳过延时)
  55. */
  56. function getMonitor(flag?: boolean) {
  57. timer = setTimeout(async () => {
  58. await getDscAlarmLogList();
  59. if (timer) {
  60. timer = null;
  61. }
  62. getMonitor();
  63. }, flag ? 0 : 10000);
  64. }
  65. /**
  66. * 获取双光谱摄像机报警记录-分页列表查询
  67. * 调用 dscAlarmLogList 接口获取双光谱摄像机报警记录分页列表,
  68. * 并将返回数据赋值给 warnList
  69. */
  70. async function getDscAlarmLogList() {
  71. const res = await dscAlarmLogList({ pageNo: 1, pageSize: 1000, startTime: timeRange.value?.[0], endTime: timeRange.value?.[1] });
  72. if (res && res.records) {
  73. tableData.value = res.records
  74. .map(el => ({
  75. ...el,
  76. // 将数字类型的报警等级映射为中文描述
  77. eventTypeC: el.eventType == '10001' ? '热源报警' : el.eventType == '10002' ? '闯入报警' : '-',
  78. }))
  79. .sort((a, b) => dayjs(b.createTime).valueOf() - dayjs(a.createTime).valueOf())
  80. }
  81. }
  82. // 组件挂载后立即获取报警日志数据
  83. onMounted(() => {
  84. getMonitor(true);
  85. })
  86. /**
  87. * 组件卸载前
  88. * 清理定时器,停止轮询获取监测数据
  89. */
  90. onUnmounted(() => {
  91. timer = null
  92. clearTimeout(timer);
  93. });
  94. </script>
  95. <style lang="less" scoped>
  96. @import '/@/design/theme.less';
  97. .alarm-monitor {
  98. --image-card-bg: url('@/assets/images/home-container/configurable/hsq/1-7.png');
  99. --image-card-bg1: url('@/assets/images/home-container/configurable/hsq/1-8.png');
  100. position: relative;
  101. width: 100%;
  102. height: 100%;
  103. padding: 10px;
  104. box-sizing: border-box;
  105. .alarm-top {
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. width: calc(100% - 14px);
  110. height: 30px;
  111. // background: var(--image-card-bg) no-repeat bottom;
  112. // background-size: 100% auto;
  113. margin: 5px 7px;
  114. // padding: 0 8px;
  115. // box-sizing: border-box;
  116. }
  117. .time-range {
  118. width: 100%;
  119. }
  120. .alarm-range-picker {
  121. width: 100%;
  122. }
  123. :deep(.zxm-picker) {
  124. width: 100%;
  125. height: 28px;
  126. border: 1px solid #3ae1ff !important;
  127. background-color: rgba(16, 64, 100, 0.85) !important;
  128. box-shadow: 0 0 6px rgba(58, 225, 255, 0.25);
  129. }
  130. :deep(.zxm-picker-input > input) {
  131. color: #fff !important;
  132. font-size: 14px;
  133. text-align: center;
  134. }
  135. :deep(.zxm-picker-input > input::placeholder) {
  136. color: rgba(200, 236, 255, 0.45) !important;
  137. }
  138. :deep(.zxm-picker-separator),
  139. :deep(.zxm-picker-suffix),
  140. :deep(.zxm-picker-clear) {
  141. color: #3ae1ff !important;
  142. }
  143. .alarm-bot {
  144. width: 100%;
  145. height: calc(100% - 40px);
  146. }
  147. }
  148. </style>