particulars.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <!-- 仓库、车辆详情页面 -->
  3. <view>
  4. <u-navbar :title="detailTitle" autoBack placeholder></u-navbar>
  5. <view class="card_time">
  6. <uni-datetime-picker v-model="datetimeRange" type="datetimerange" rangeSeparator="至" @change="changeTime" />
  7. </view>
  8. <view class="sub_card" v-if="probeList.length > 0">
  9. <u-subsection :list="probeList" :current="current" keyName="T_name" @change="sectionChange"></u-subsection>
  10. </view>
  11. <view class="card_particulars">
  12. <view class="humiture_line"></view>
  13. <view class="card_humiture border_humiture">
  14. <view class="headline_item w_wsd">温度(°C)</view>
  15. <view class="headline_item w_wsd">湿度(Rh)</view>
  16. <view class="headline_item w_time">时间</view>
  17. </view>
  18. <view style="width: 100%;" v-if="humitureList.length > 0">
  19. <view class="card_humiture" v-for="(item,index) in humitureList" :key="index">
  20. <view class="title_item w_wsd">{{item.T_t || ''}}</view>
  21. <view class="title_item w_wsd">{{item.T_rh || ''}}</view>
  22. <view class="title_item w_time">{{item.T_time || ''}}</view>
  23. </view>
  24. <view class="center_in">
  25. <view v-if="loadingMore" style="width: 60%;"><u-divider :text="loading"></u-divider></view>
  26. </view>
  27. </view>
  28. <view v-else style="padding: 30rpx 0rpx;">
  29. <u-empty mode="data" text="暂无温湿度记录"></u-empty>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. current: 0,
  39. detailTitle: '',
  40. probeList: [],
  41. humitureList: [],
  42. datetimeRange: [],
  43. defaultItem: {},
  44. pageSize: 15,
  45. currentPage: 1,
  46. loadingMore: false,
  47. loading: '加载中'
  48. }
  49. },
  50. onReachBottom() {
  51. if (!this.loadingMore) {
  52. this.getDeviceData(this.defaultItem)
  53. }
  54. },
  55. onLoad(value) {
  56. if (value.title == 'true' || value.title === true) {
  57. this.detailTitle = '仓库信息'
  58. } else if (value.title == 'false' || value.title === false) {
  59. this.detailTitle = '车辆信息'
  60. }
  61. this.getSensor()
  62. },
  63. methods: {
  64. getSensor() {
  65. this.$api.get('/api/device/sensor-list').then(res => {
  66. if (res.code == 200) {
  67. if (res.data.list) {
  68. this.probeList = res.data.list
  69. }
  70. if (this.probeList.length > 0) {
  71. this.defaultItem = this.probeList[0]
  72. }
  73. this.getDeviceData(this.defaultItem)
  74. }
  75. })
  76. },
  77. getDeviceData(value) {
  78. this.loadingMore = true;
  79. let params = {
  80. t_sn: value.T_sn,
  81. t_id: value.T_id,
  82. startTime: '',
  83. endTime: '',
  84. page: this.currentPage,
  85. pageSize: this.pageSize,
  86. }
  87. if (this.datetimeRange.length > 0) {
  88. params.startTime = this.datetimeRange[0]
  89. params.endTime = this.datetimeRange[1]
  90. }
  91. this.$api.get('/api/device/data', params).then(res => {
  92. if (res.code == 200) {
  93. const data = res.data.list
  94. if (this.loadingMore == true && data) {
  95. this.humitureList = this.humitureList.concat(data);
  96. }
  97. if (data.length < this.pageSize) {
  98. this.loadingMore = true
  99. this.loading = '没有更多了'
  100. } else {
  101. this.loading = '加载中'
  102. this.loadingMore = false
  103. this.currentPage++
  104. }
  105. }
  106. })
  107. },
  108. // 日期选择
  109. changeTime(value) {
  110. this.datetimeRange = value
  111. this.currentPage = 1
  112. this.humitureList = []
  113. this.getDeviceData(this.defaultItem)
  114. },
  115. // 选择探头
  116. sectionChange(numIndex) {
  117. this.currentPage = 1
  118. this.humitureList = []
  119. this.current = numIndex
  120. const arrList = this.probeList[numIndex]
  121. this.defaultItem = arrList
  122. this.getDeviceData(arrList)
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss">
  128. page {
  129. background-color: #fff !important;
  130. }
  131. .card_time {
  132. display: flex;
  133. margin: 20rpx;
  134. }
  135. .sub_card {
  136. margin: 20rpx;
  137. }
  138. .card_particulars {
  139. display: flex;
  140. flex-direction: column;
  141. align-items: center;
  142. padding: 20rpx 0rpx;
  143. margin: 30rpx 20rpx 20rpx 20rpx;
  144. border-radius: 40rpx;
  145. background-color: #fff;
  146. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  147. }
  148. .humiture_line {
  149. width: 80rpx;
  150. height: 10rpx;
  151. border-radius: 20rpx;
  152. background-color: #C0C4CC;
  153. margin: 20rpx;
  154. }
  155. .card_humiture {
  156. width: 100%;
  157. display: flex;
  158. align-items: center;
  159. padding: 20rpx 0rpx;
  160. margin-bottom: 10rpx;
  161. }
  162. .border_humiture {
  163. border-bottom: 1rpx solid #EBEEF5;
  164. }
  165. .headline_item {
  166. font-size: 30rpx;
  167. font-weight: 600;
  168. }
  169. .title_item {
  170. font-size: 28rpx
  171. }
  172. .w_wsd {
  173. text-align: center;
  174. width: 27%;
  175. }
  176. .w_time {
  177. text-align: center;
  178. width: 46%;
  179. }
  180. </style>