detail.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div class="detail">
  3. <nav-bar></nav-bar>
  4. <van-cell-group>
  5. <van-cell :title="info.deviceName" value-class="cell-title-value" title-style="width:100%;">
  6. <template #right-icon v-if="info.time">
  7. <van-tag v-if="info.endTime">告警结束</van-tag>
  8. <van-tag v-else type="danger">正在告警</van-tag>
  9. </template>
  10. </van-cell>
  11. <van-cell title="所属机构" :value="info.orgName" />
  12. <van-cell title="告警分类" :value="dataTypeText"></van-cell>
  13. <van-cell title="告警类型" :value="info.sourceTypeDes"></van-cell>
  14. <van-cell title="告警开始时间" :value="renderTime(info.time)"></van-cell>
  15. <van-cell title="告警结束时间" :value="renderTime(info.endTime)"></van-cell>
  16. <van-cell title="持续时长" :value="durationText" />
  17. <van-cell title="告警值" :value="valueText" />
  18. <van-cell title="告警内容" :value="info.content" />
  19. <van-cell title="处置时间" :value="renderTime(info.doTime)" />
  20. <van-cell title="处置人" :value="info.doByUser" />
  21. <van-cell title="处置内容" :value="info.doContent" />
  22. </van-cell-group>
  23. </div>
  24. </template>
  25. <script>
  26. import { detail } from '@/api/iot/alarmCenter.js'
  27. import NavBar from '@/components/NavBar'
  28. import dayjs from 'dayjs'
  29. import { durationText } from '@/utils/date.js'
  30. export default {
  31. data() {
  32. return {
  33. info: {},
  34. search: {
  35. sensorId: this.$route.query.id
  36. }
  37. }
  38. },
  39. components: { NavBar },
  40. computed: {
  41. stateUpdateTimeText() {
  42. if (this.info.stateUpdateTime == null) {
  43. return '未上报'
  44. }
  45. return dayjs(this.info.stateUpdateTime).format('YYYY年M月D日H时m分')
  46. },
  47. dataTypeText() {
  48. if (!this.info || this.info.dataType == null) {
  49. return ''
  50. }
  51. if (this.info.dataType == '0') {
  52. return '动环类告警'
  53. } else if (this.info.dataType == '1') {
  54. return '视频类告警'
  55. } else {
  56. return '未知'
  57. }
  58. },
  59. durationText() {
  60. let endTime = this.info.endTime ? this.info.endTime : new Date()
  61. let minutes = dayjs(endTime).diff(this.info.time, 'minute')
  62. if (minutes < 1) {
  63. return dayjs(endTime).diff(this.info.time, 'second') + '秒'
  64. } else {
  65. return durationText(minutes)
  66. }
  67. },
  68. valueText() {
  69. if (!this.info || this.info.valueText == null) {
  70. return ''
  71. }
  72. if(this.info.alarmValue && (this.info.alarmValue.includes("°C") || this.info.alarmValue.includes("%RH") ))
  73. {
  74. return this.info.alarmValue;
  75. }
  76. else{
  77. return this.info.valueText
  78. }
  79. }
  80. },
  81. mounted() {
  82. this.getInfo()
  83. },
  84. methods: {
  85. getInfo() {
  86. detail(this.search.sensorId).then(r => {
  87. this.info = r.data
  88. })
  89. },
  90. renderTime(dateTime) {
  91. if (!dateTime) {
  92. return ''
  93. }
  94. return dayjs(dateTime).format('YYYY年M月D日H时m分')
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .cell-title-value {
  101. display: none;
  102. }
  103. .detail {
  104. margin: 15px;
  105. }
  106. .cell-gather-alarm-value {
  107. color: #ee0a24;
  108. }
  109. </style>