recordTime.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div>
  3. <top-header></top-header>
  4. <div class="mainbox">
  5. <div class="gas-container">
  6. <return-back></return-back>
  7. <!-- <div style="max-width:1920px"> -->
  8. <div class="timeList">
  9. <div
  10. class="timeItem"
  11. v-for="(item, index) in recordData.slice(
  12. (currentPage - 1) * Count,
  13. currentPage * Count
  14. )"
  15. :key="index"
  16. @click="goInspectDetail(item)"
  17. >
  18. {{ item.Time }}
  19. <!-- </div> -->
  20. </div>
  21. </div>
  22. <div
  23. style="
  24. position: fixed;
  25. bottom: 0.3rem;
  26. text-align: center;
  27. display: block;
  28. width: 100%;
  29. "
  30. >
  31. <el-pagination
  32. background
  33. @size-change="handleSizeChange"
  34. @current-change="handleCurrentChange"
  35. :current-page="currentPage"
  36. :page-size="Count"
  37. layout=" prev, pager, next, jumper"
  38. :total="TotalCount"
  39. >
  40. </el-pagination>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import topHeader from "@/components/topHeader";
  48. import returnBack from "@/components/returnBack";
  49. export default {
  50. name: "index",
  51. components: {
  52. topHeader,
  53. returnBack,
  54. },
  55. data() {
  56. return {
  57. StationID: "",
  58. // 总数据
  59. recordData: [],
  60. // 默认显示第几页
  61. currentPage: 1,
  62. // 总条数,根据接口获取数据长度(注意:这里不能为空)
  63. TotalCount: 1,
  64. // 默认每页显示的条数(可修改)
  65. Count: 10,
  66. };
  67. },
  68. watch: {
  69. "$store.state.wsInfo"(val) {
  70. this.messageHandle(val);
  71. },
  72. },
  73. created() {
  74. this.StationID = this.$store.state.StationID;
  75. (this.recordData = [
  76. {
  77. Time: "2021-06-15 13:01:14",
  78. },
  79. {
  80. Time: "2021-06-15 13:01:09",
  81. },
  82. {
  83. Time: "2021-06-15 13:01:04",
  84. },
  85. {
  86. Time: "2021-06-15 13:00:59",
  87. },
  88. {
  89. Time: "2021-06-15 13:00:54",
  90. },
  91. {
  92. Time: "2021-06-15 15:01:14",
  93. },
  94. {
  95. Time: "2021-06-15 16:01:09",
  96. },
  97. {
  98. Time: "2021-06-15 17:01:04",
  99. },
  100. {
  101. Time: "2021-06-15 18:00:59",
  102. },
  103. {
  104. Time: "2021-06-15 19:00:54",
  105. },
  106. {
  107. Time: "2021-06-15 13:00:59",
  108. },
  109. {
  110. Time: "2021-06-15 13:00:54",
  111. },
  112. {
  113. Time: "2021-06-15 15:01:14",
  114. },
  115. {
  116. Time: "2021-06-15 16:01:09",
  117. },
  118. ]),
  119. // 将数据的长度赋值给TotalCount
  120. (this.TotalCount = this.recordData.length);
  121. },
  122. mounted() {
  123. document.getElementsByClassName(
  124. "el-pagination__jump"
  125. )[0].childNodes[0].nodeValue = "跳转到: ";
  126. },
  127. methods: {
  128. messageHandle(e) {
  129. if (e.data.search("{") != -1) {
  130. const redata = JSON.parse(e.data);
  131. // 初始化获取站点下拉数据
  132. if (redata.CMD == "getStationInfo" && redata.RESULT[0].StationID) {
  133. var json = {};
  134. json.CMD = "getPatrolRecord";
  135. json.StationID = this.StationID;
  136. (json.Start = 0), (json.Limit = 2), (json.Order = "DESC");
  137. // this.global.sendWs(json);
  138. setInterval(() => {
  139. console.log("每隔30秒请求一次getPatrolRecord");
  140. this.global.sendWs(json);
  141. }, 30000);
  142. }
  143. if (redata.CMD == "getPatrolRecord") {
  144. this.recordData = redata.RESULT.LIST;
  145. console.log("this.recordData");
  146. console.log(this.recordData);
  147. }
  148. }
  149. },
  150. goInspectDetail(item) {
  151. this.$router.push({
  152. path: "/inspectRecord",
  153. query: { Time: item.Time },
  154. });
  155. },
  156. // 分页
  157. // 每页显示的条数
  158. handleSizeChange(val) {
  159. // 改变每页显示的条数
  160. this.Count = val;
  161. // 注意:在改变每页显示的条数时,要将页码显示到第一页
  162. this.currentPage = 1;
  163. },
  164. // 显示第几页
  165. handleCurrentChange(val) {
  166. // 改变默认的页数
  167. this.currentPage = val;
  168. },
  169. },
  170. };
  171. </script>
  172. <!-- Add "scoped" attribute to limit CSS to this component only -->
  173. <style >
  174. </style>