forecastResult.vue 4.0 KB

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