Historymodel.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="container">
  3. <!-- 建议放在外层 -->
  4. <u-navbar
  5. title="历史数据"
  6. @leftClick="devicemenuShow"
  7. :safeAreaInsetTop="false"
  8. >
  9. <view class="u-nav-slot" slot="left">
  10. <u-icon name="list" size="20"> </u-icon>
  11. </view>
  12. </u-navbar>
  13. <!-- 侧边栏 -->
  14. <view v-show="menushow" class="menupage">
  15. <DeviceMenu @menuClick="menuClick"></DeviceMenu>
  16. </view>
  17. <!-- 历史数据列表页 -->
  18. <view v-show="!menushow" class="main">
  19. <view class="u-page">
  20. <div class="btns">
  21. <u-button type="primary" shape="circle" text="选择设备"></u-button>
  22. <u-button
  23. type="primary"
  24. shape="circle"
  25. text="选择间隔时间"
  26. @click="show = true"
  27. ></u-button>
  28. </div>
  29. <u-picker :show="show" :columns="columns" title="请选择设备"></u-picker>
  30. <u-picker
  31. :show="show"
  32. :columns="timeColumns"
  33. title="间隔时间"
  34. ></u-picker>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import DeviceMenu from "./devicemenu/devicemenu.vue";
  41. import api from "@/api/api";
  42. export default {
  43. data() {
  44. return {
  45. menushow: false,
  46. TabCur: "gate",
  47. curlist: [],
  48. deviceList: {},
  49. scrollLeft: 0,
  50. currentTab: 0,
  51. startDate: null,
  52. endDate: null,
  53. show: false,
  54. columns: [["中国", "美国", "日本"]],
  55. timeColumns: [
  56. ["1s", "5s", "10s", "30s", "1分钟", "10分钟", "30分钟", "1小时"],
  57. ],
  58. };
  59. },
  60. components: {
  61. DeviceMenu,
  62. },
  63. props: ["showColum"],
  64. watch: {
  65. showColum(data) {
  66. this.colums = data;
  67. console.log(this.colums);
  68. },
  69. },
  70. created() {},
  71. mounted() {
  72. this.startTimer();
  73. },
  74. methods: {
  75. startTimer() {
  76. // 每隔一段时间执行某个操作
  77. this.timer = setInterval(() => {
  78. // 执行定时任务
  79. console.log("定时任务执行中...");
  80. }, 5000);
  81. },
  82. stopTimer() {
  83. // 停止定时器
  84. clearInterval(this.timer);
  85. },
  86. tabSelect(e) {
  87. this.currentTab = e.currentTarget.dataset.id;
  88. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
  89. },
  90. devicemenuShow(e) {
  91. this.menushow = true;
  92. },
  93. menuClick(id) {
  94. // 显示该分类的数据
  95. this.menushow = false;
  96. },
  97. },
  98. destroyed() {
  99. // 停止定时器
  100. },
  101. };
  102. </script>
  103. <style>
  104. .top-nav {
  105. height: 100rpx;
  106. line-height: 100rpx;
  107. background-color: #2aa9f3;
  108. color: #daaaa;
  109. }
  110. .top-nav2 {
  111. background-color: #ffffff;
  112. }
  113. .main {
  114. margin-top: 100rpx;
  115. display: flex;
  116. flex-direction: column;
  117. }
  118. .menupage {
  119. position: absolute;
  120. z-index: 2;
  121. top: 40rpx;
  122. height: calc(100% - 40rpx);
  123. width: 100%;
  124. }
  125. .btns {
  126. display: flex;
  127. }
  128. </style>