history.vue 3.9 KB

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