index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div>
  3. <!-- 头部区域 -->
  4. <top-header></top-header>
  5. <!-- 首页主体start -->
  6. <div class="mainbox">
  7. <div style="margin: 0rem auto; width: 15rem">
  8. <div class="column" v-for="item in homeData" :key="item.StationID">
  9. <div
  10. class="panel"
  11. @click="goInnerCard(item)"
  12. :class="{
  13. alarm: Number(item.DeviceStatus) === 1,
  14. fault: Number(item.DeviceStatus) === 2,
  15. }"
  16. >
  17. <div>
  18. <p>
  19. 状态:
  20. <span v-if="item.DeviceStatus==0">正常</span>
  21. <span v-if="item.DeviceStatus==1">告警</span>
  22. <span v-if="item.DeviceStatus==2">故障</span>
  23. </p>
  24. <p class="light-color">{{ item.DeviceType }}</p>
  25. <!-- 电气火灾渲染start -->
  26. <p
  27. v-if="item.DeviceType == '电气火灾监测装置'"
  28. class="light-color"
  29. >
  30. {{ item.KeyPoints[0].PointName }}:
  31. <span v-if="item.KeyPoints[0].ValueList.length>0">
  32. {{item.KeyPoints[0].ValueList[0].Value == 0 ? "正常" : "告警"}}
  33. </span>
  34. <span v-else>
  35. 默认值
  36. </span>
  37. </p>
  38. <!-- 电气火灾渲染end -->
  39. <!-- 可燃气体渲染start -->
  40. <p v-else class="light-color">
  41. {{ item.KeyPoints[0].PointName }}:
  42. <span v-if="item.KeyPoints[0].ValueList.length>0">
  43. {{ item.KeyPoints[0].ValueList[0].Value }}
  44. </span>
  45. <span v-else>默认值</span>
  46. </p>
  47. <!-- 可燃气体渲染end -->
  48. </div>
  49. </div>
  50. </div>
  51. <!-- <div class="column">
  52. <div class="panel alarm" @click="goInnerCard">
  53. <div>
  54. <img src="@/assets/images/panel-icon.png" alt="" />
  55. <p>状态:<span>告警</span></p>
  56. <p class="light-color">电气火灾</p>
  57. <p class="light-color">电缆温度:51℃</p>
  58. </div>
  59. </div>
  60. </div>
  61. -->
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import topHeader from "@/components/topHeader";
  68. export default {
  69. name: "index",
  70. components: {
  71. topHeader,
  72. },
  73. data() {
  74. return {
  75. StationID: "",
  76. homeData: [],
  77. };
  78. },
  79. watch: {
  80. "$store.state.wsInfo"(val) {
  81. this.messageHandle(val);
  82. },
  83. },
  84. created() {
  85. // 如果有站点选项,发送请求获取站点信息页数据
  86. this.StationID = this.$store.state.StationID;
  87. // console.log(1212121212);
  88. // console.log(this.StationID);
  89. },
  90. methods: {
  91. messageHandle(e) {
  92. if (e.data.search("{") != -1) {
  93. const redata = JSON.parse(e.data);
  94. if (redata.CMD == "getStationInfo" && redata.RESULT[0].StationID) {
  95. var json = {};
  96. json.CMD = "getStationDetail";
  97. json.StationID = this.StationID;
  98. this.global.sendWs(json);
  99. // setInterval(() => {
  100. // console.log("每隔30秒请求一次getStationDetail");
  101. // this.global.sendWs(json);
  102. // }, 30000);
  103. }
  104. if (redata.CMD == "getStationDetail") {
  105. this.homeData = redata.RESULT.LIST;
  106. // console.log('首页数据')
  107. // console.log(redata)
  108. // console.log(this.homeData);
  109. }
  110. }
  111. },
  112. goInnerCard(item) {
  113. if (item.DeviceType == "电气火灾监测装置") {
  114. this.$router.push({
  115. path: "/eleFireCard",
  116. query: { DeviceID: item.DeviceID },
  117. });
  118. } else {
  119. this.$router.push({
  120. path: "/gasCard?",
  121. query: { DeviceID: item.DeviceID },
  122. });
  123. }
  124. },
  125. goGasCard() {},
  126. },
  127. };
  128. </script>
  129. <!-- Add "scoped" attribute to limit CSS to this component only -->
  130. <style scoped>
  131. </style>