detail.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. </van-cell>
  7. <van-cell title="上报时间" :value="stateUpdateTimeText" />
  8. <van-cell title="持续时长" :value="durationText" />
  9. <van-cell title="设备采集值" :value="gatherText" title-style="max-width:100px" :value-class="info.state==1?'cell-gather-alarm-value':''"/>
  10. <van-cell title="动环类型" :value="info.deviceTypeText" />
  11. <van-cell title="所属机构" :value="info.orgName" />
  12. </van-cell-group>
  13. </div>
  14. </template>
  15. <script>
  16. import { detail } from '@/api/iot/donghuan.js'
  17. import NavBar from '@/components/NavBar'
  18. import dayjs from 'dayjs'
  19. import {durationText} from "@/utils/date.js"
  20. export default {
  21. data() {
  22. return {
  23. info: {},
  24. search: {
  25. sensorId: this.$route.query.id
  26. }
  27. }
  28. },
  29. components: { NavBar },
  30. computed: {
  31. stateUpdateTimeText() {
  32. if (this.info.stateUpdateTime == null) {
  33. return '未上报'
  34. }
  35. return dayjs(this.info.stateUpdateTime).format('YYYY年M月D日H时m分')
  36. },
  37. gatherText() {
  38. if (!this.info.infos) {
  39. return '未上报'
  40. }
  41. let array = JSON.parse(this.info.infos)
  42. if (array.length === 0) {
  43. return '未上报'
  44. }
  45. let text;
  46. switch (this.info.deviceType) {
  47. case '4183': //温湿度
  48. let temporary = array.find(i => i.name === '环境温度')
  49. if (temporary) {
  50. text = `温度:${temporary.val }${temporary.unit};`
  51. }
  52. let humidity = array.find(i => i.name === '环境湿度')
  53. if (humidity) {
  54. text += `湿度:${humidity.val}${humidity.unit};`
  55. }
  56. break
  57. case '4181': //红外
  58. text = `红外${(array[0].val == 0 ? '正常' : '告警')}`
  59. break
  60. case '4182': //烟感
  61. text = `烟感${array[0].val == 0 ? '正常' : '告警'}`
  62. break
  63. case '4184': //水浸,
  64. text = `水浸${array[0].val == 0 ? '正常' : '告警'}`
  65. break
  66. case '4160': //智能电表
  67. text = `智能电表${array[0].val == 0 ? '正常' : '告警'}`
  68. break
  69. case '41885': //燃气报警器
  70. text = `燃气${array[0].val == 0 ? '正常' : '告警'}`
  71. break
  72. case '4188': //门窗磁
  73. text = `门窗磁${array[0].val == 0 ? '关门' : '开门'}`
  74. break
  75. case '41881': //防盗
  76. text = `防盗${array[0].val == 0 ? '正常' : '告警'}`
  77. break
  78. }
  79. return text;
  80. },
  81. durationText() {
  82. if (!this.info.stateStartTime) {
  83. return '未上报'
  84. }
  85. let minutes =dayjs().diff(this.info.stateStartTime,'minute')
  86. return durationText(minutes);
  87. }
  88. },
  89. mounted() {
  90. this.getInfo()
  91. },
  92. methods: {
  93. getInfo() {
  94. detail(this.search.sensorId).then(r => {
  95. this.info = r.data
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .cell-title-value {
  103. display: none;
  104. }
  105. .detail {
  106. margin: 15px;
  107. }
  108. .cell-gather-alarm-value{
  109. color:#ee0a24;
  110. }
  111. </style>