history.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <view class="realtime">
  4. <scroll-view scroll-top="0" scroll-x="true" class="scroll-X">
  5. <table class="table">
  6. <tr class="tr">
  7. <th class="th" v-for="(item, index) in thdata" :key="'a' + index">
  8. {{ item }}
  9. </th>
  10. </tr>
  11. <tr
  12. class="tr"
  13. v-for="(items, indexs) in statusList"
  14. :key="'b' + indexs"
  15. v-if="statusList.length > 0"
  16. >
  17. <td class="td">{{ items.device_name }}</td>
  18. <td class="td">{{ items.device_id }}</td>
  19. <td class="td">{{ items.name }}</td>
  20. <td class="td">{{ items.slave_index }}</td>
  21. <td class="td">{{ items.slave_name }}</td>
  22. <td class="td">{{ items.upltime | timeFormat() }}</td>
  23. <td class="td">
  24. <view v-if="type == 1">
  25. {{ items.values == 1 ? '开' : '关' }}
  26. </view>
  27. <view v-else>
  28. {{ items.values }}
  29. </view>
  30. </td>
  31. </tr>
  32. <tr class="tr" v-else>
  33. <td class="td" v-for="item in 7">暂无数据</td>
  34. </tr>
  35. </table>
  36. </scroll-view>
  37. <view class="pagenumber">
  38. <button @click="prev">上一页</button>
  39. <view class="pagenumber_page"> 第 {{ page }} 页 </view>
  40. <view class="pagenumber_page"> 共 {{ pagesum }} 页 </view>
  41. <button @click="next" :disabled="forbidden">下一页</button>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. device_id: {},
  51. pagesum: 1,
  52. page: 1,
  53. type: '',
  54. statusList: [],
  55. thdata: [
  56. '设备名称',
  57. '设备ID',
  58. '变量名称',
  59. '从机序号',
  60. '从机名称',
  61. '时间',
  62. '值',
  63. ],
  64. };
  65. },
  66. methods: {
  67. prev() {
  68. //上一页
  69. if (this.page > 1) {
  70. this.page--;
  71. this.geDetail();
  72. }
  73. },
  74. next() {
  75. //下一页
  76. if (this.page < this.pagesum) {
  77. this.page++;
  78. this.geDetail();
  79. }
  80. },
  81. async geDetail() {
  82. const res = await this.$myRequest({
  83. url: '/api/api_gateway?method=irrigation_system.waterfertilizer.water_fer_history_data',
  84. data: {
  85. dataPointId: this.device_id,
  86. page: this.page,
  87. page_size: 10,
  88. },
  89. });
  90. this.pagesum = Math.ceil(res.data.nums / 10) || 1;
  91. if (res.data.length > 0) {
  92. this.statusList = res.data;
  93. }
  94. },
  95. },
  96. onLoad(option) {
  97. this.device_id = option.device_id;
  98. this.type = option.type;
  99. this.geDetail();
  100. },
  101. };
  102. </script>
  103. <style lang="less">
  104. page {
  105. padding: 20rpx;
  106. box-sizing: border-box;
  107. .realtime {
  108. display: flex;
  109. flex-wrap: wrap;
  110. width: 100%;
  111. box-shadow: 0 0 10rpx #bcb9ca;
  112. margin: 20rpx auto 30rpx;
  113. .scroll-X {
  114. width: 95%;
  115. margin: 20rpx auto;
  116. .tr {
  117. display: flex;
  118. overflow: hidden;
  119. .th,
  120. .td {
  121. display: inline-block;
  122. padding: 5rpx;
  123. width: 300rpx;
  124. text-align: center;
  125. height: 52rpx;
  126. line-height: 52rpx;
  127. border: 2rpx solid #f1f1f1;
  128. }
  129. }
  130. .tr:nth-child(2n-1) {
  131. background-color: #f5fff8;
  132. }
  133. .tr:first-child {
  134. background-color: #57c878;
  135. color: #fff;
  136. }
  137. }
  138. .pagenumber {
  139. display: flex;
  140. margin: 20rpx auto;
  141. width: 100%;
  142. justify-content: space-around;
  143. button {
  144. width: 150rpx;
  145. height: 50rpx;
  146. line-height: 50rpx;
  147. font-size: 26rpx;
  148. text-align: center;
  149. background-color: #57c878;
  150. color: #ffffff;
  151. }
  152. .pagenumber_page {
  153. // width: 100rpx;
  154. height: 50rpx;
  155. line-height: 50rpx;
  156. font-size: 26rpx;
  157. text-align: center;
  158. }
  159. }
  160. }
  161. }
  162. .btn-box {
  163. text-align: center;
  164. padding: 20rpx 30rpx;
  165. }
  166. ::v-deep .u-calendar__action {
  167. display: flex;
  168. justify-content: space-around;
  169. .u-calendar__action__text {
  170. line-height: 25px;
  171. }
  172. }
  173. </style>