forecastResult.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="bigBox">
  3. <u-card :show-head="false" margin="0rpx 20rpx" :show-foot="false">
  4. <view class="cardBox" slot="body">
  5. <view class="selecttimes" @click="tiemshow = !tiemshow">
  6. <view class="timesbox">
  7. <image
  8. :src="$imageURL+'/bigdata_app/image/prevention/1acfe2751c01d3786cdc49b83d7e505.png'"
  9. mode=""
  10. ></image>
  11. <p>{{ initTime ? '出苗期' : begintime }}</p>
  12. <p class="or">~</p>
  13. <p>{{ initTime ? '收获期' : end }}</p>
  14. <u-icon
  15. name="rili"
  16. custom-prefix="custom-icon"
  17. class="icon"
  18. ></u-icon>
  19. </view>
  20. <u-calendar
  21. v-model="tiemshow"
  22. mode="range"
  23. @change="tiemchange"
  24. ></u-calendar>
  25. </view>
  26. <view class="empty" v-if="initTime"> 请先选择出苗期和收获期 </view>
  27. <view class="empty" v-else-if="list.length == 0"> 数据为空 </view>
  28. <scroll-view scroll-top="0" scroll-x="true" class="scroll-X" v-else>
  29. <table class="table">
  30. <tr class="tr">
  31. <th class="th" v-for="(value, key) in param" :key="'a' + key">
  32. {{ value }}
  33. </th>
  34. </tr>
  35. <tr class="tr" v-for="(items, indexs) in list" :key="'b' + indexs">
  36. <td class="td" v-for="(value, key) in param">{{ items[key] }}</td>
  37. </tr>
  38. </table>
  39. </scroll-view>
  40. </view>
  41. <view class="" slot="foot"
  42. ><u-icon name="chat-fill" size="34" color="" label="30评论"></u-icon
  43. ></view>
  44. </u-card>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. tiemshow: false,
  52. initTime: true,
  53. forecastId: '',
  54. end: '',
  55. begintime: '',
  56. list: [],
  57. param: {
  58. ciDai: '代/次',
  59. sTime: '本次侵染开始时间',
  60. eTime: '本次侵染结束时间',
  61. awsDeg: '本次侵染程度',
  62. awsFen: '本次侵染的分值',
  63. awsYao: '是否使用预报数据',
  64. },
  65. };
  66. },
  67. onLoad(option) {
  68. this.forecastId = option.id;
  69. this.end = parseInt(+new Date() / 1000);
  70. this.begintime = parseInt(this.end - 24 * 60 * 60);
  71. },
  72. methods: {
  73. async histprydatas() {
  74. //表格历史数据
  75. const res = await this.$myRequest({
  76. url: '/api/api_gateway?method=wheat.potato.potato_time',
  77. data: {
  78. device_id: this.forecastId,
  79. start: this.begintime,
  80. end: this.end,
  81. },
  82. });
  83. console.log(res);
  84. this.list = res.data.list;
  85. },
  86. tiemchange(e) {
  87. console.log(e);
  88. this.initTime = false;
  89. //切换时间
  90. // this.begintime = parseInt(+new Date(e.startDate) / 1000);
  91. this.begintime = e.startDate;
  92. this.end = e.endDate;
  93. this.histprydatas();
  94. },
  95. },
  96. };
  97. </script>
  98. <style scoped lang="less">
  99. .bigBox {
  100. width: 100vw;
  101. height: calc(100vh - 80rpx);
  102. background: #eee;
  103. box-sizing: border-box;
  104. padding-top: 20rpx;
  105. overflow: hidden;
  106. .cardBox {
  107. height: 75vh;
  108. overflow-y: auto;
  109. padding-top: 20rpx;
  110. .empty {
  111. display: flex;
  112. justify-content: center;
  113. align-items: center;
  114. height: calc(100% - 60rpx);
  115. }
  116. .selecttimes {
  117. width: 90%;
  118. box-shadow: 0 0 10rpx #bcb9ca;
  119. padding: 10rpx 20rpx;
  120. box-sizing: border-box;
  121. margin: 0 auto;
  122. font-size: 28rpx;
  123. .timesbox {
  124. display: flex;
  125. justify-content: space-around;
  126. image {
  127. width: 30rpx;
  128. height: 30rpx;
  129. margin-top: 6rpx;
  130. }
  131. .icon {
  132. color: #949494;
  133. text-align: right;
  134. margin-left: 30rpx;
  135. }
  136. }
  137. ::v-deep .u-calendar__action {
  138. display: flex;
  139. justify-content: space-around;
  140. .u-calendar__action__text {
  141. line-height: 25px;
  142. }
  143. }
  144. }
  145. .scroll-X {
  146. width: 100%;
  147. margin: 20rpx auto;
  148. height: calc(100% - 120rpx);
  149. overflow-y: auto;
  150. .tr {
  151. display: flex;
  152. overflow: hidden;
  153. .th,
  154. .td {
  155. display: inline-block;
  156. padding: 5rpx;
  157. width: 300rpx;
  158. text-align: center;
  159. height: 52rpx;
  160. line-height: 52rpx;
  161. border: 2rpx solid #f1f1f1;
  162. }
  163. }
  164. .tr:nth-child(2n-1) {
  165. background-color: #f5fff8;
  166. }
  167. .tr:first-child {
  168. background-color: #57c878;
  169. color: #fff;
  170. }
  171. }
  172. }
  173. }
  174. </style>