forecastResult.vue 4.7 KB

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