analyse.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <!-- 虫害分析 -->
  3. <view>
  4. <!-- 时期卡片 -->
  5. <raise-card :deviceId="deviceId"></raise-card>
  6. <!-- 时期卡片end -->
  7. <!-- 虫害统计图 -->
  8. <view class="ui-card px-13">
  9. <!-- 选择时间范围 -->
  10. <view class="mb">
  11. <uni-datetime-picker v-model="searchTime" type="daterange" rangeSeparator="-"
  12. @change="changeSearchTime" />
  13. </view>
  14. <!-- 区域统计图 -->
  15. <area-charts :chartData="pestLineData"></area-charts>
  16. <view style="height: 20rpx;"></view>
  17. <!-- 环形统计图 -->
  18. <pie-charts :chartData="pestPieData"></pie-charts>
  19. <!-- 统计列表 -->
  20. <view class="mt-12">
  21. <view class="progress-item" v-for="(val,key,i) in pestTotal" :key="i">
  22. <view class="label">{{i+1}}、{{key}}</view>
  23. <view class="progress">
  24. <progress :percent="pestTotal[key]" backgroundColor="#F3F5F9" activeColor="#10AEFF" :stroke-width="9" />
  25. </view>
  26. <view class="percent">{{val}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 虫害统计图end -->
  31. <!-- 虫害表格数据 -->
  32. <view class="ui-card worm-table">
  33. <ui-tabs :list="pestTabs" :active="pestTabValue" @clickTab="clickPestTabs"></ui-tabs>
  34. <!-- 害虫图片溯源 -->
  35. <view v-show="pestTabValue==1">
  36. <uni-table class="table-style mt-12" ref="table" border emptyText="暂无更多数据">
  37. <uni-tr>
  38. <uni-th width="150" align="center">设备号</uni-th>
  39. <uni-th width="150" align="center">设备名称</uni-th>
  40. <uni-th width="250" align="center">害虫名称</uni-th>
  41. <uni-th width="200" align="center">添加时间</uni-th>
  42. <uni-th width="200" align="center">地址</uni-th>
  43. </uni-tr>
  44. <uni-tr v-for="(item, index) in pestImageSourceTable" :key="index">
  45. <uni-td>{{ item.deviceId }}</uni-td>
  46. <uni-td>{{ item.deviceName }}</uni-td>
  47. <uni-td>
  48. <view class="name">{{ item.pestName }}</view>
  49. </uni-td>
  50. <uni-td align="center">{{ item.addtime | timeFrom }}</uni-td>
  51. <uni-td align="center">{{ item.location }}</uni-td>
  52. </uni-tr>
  53. </uni-table>
  54. <!-- 页码 -->
  55. <uni-pagination :total="imageSourceTotal" @change="getPestImageSourceList" />
  56. <!-- 页码end -->
  57. </view>
  58. <!-- 害虫基础信息溯源 -->
  59. <view v-show="pestTabValue==2">
  60. <uni-table class="table-style mt-12" ref="table" border emptyText="暂无更多数据">
  61. <uni-tr>
  62. <uni-th width="150" align="center">害虫名称</uni-th>
  63. <uni-th width="150" align="center">害虫数量</uni-th>
  64. <uni-th width="180" align="center">添加时间</uni-th>
  65. </uni-tr>
  66. <uni-tr v-for="(item, index) in pestBaseTable" :key="index">
  67. <uni-td align="center">{{ item.pest_name }}</uni-td>
  68. <uni-td align="center">{{ item.pest_num }}</uni-td>
  69. <uni-td align="center">{{ item.addtime | timeFrom }}</uni-td>
  70. </uni-tr>
  71. </uni-table>
  72. <!-- 页码 -->
  73. <uni-pagination :total="baseTotal" @change="getPestBaseDataList" />
  74. <!-- 页码end -->
  75. </view>
  76. </view>
  77. <view style="height: 100rpx;"></view>
  78. <!-- 返回顶部按钮 -->
  79. <ui-back-top :scroll-top="scrollTop" />
  80. </view>
  81. </template>
  82. <script>
  83. import {
  84. getPestStatisticsChart,
  85. getPestImageSource,
  86. getPestBaseData
  87. } from '@/api/worm.js'
  88. import {
  89. timeFrame,
  90. dateToUnix
  91. } from '@/utils/utils.js'
  92. import areaCharts from './components/w-area-charts.vue'
  93. import pieCharts from './components/w-pie-charts.vue'
  94. import raiseCard from './components/analyse/raise-card.vue' // 始见期卡片组件
  95. export default {
  96. data() {
  97. return {
  98. deviceId: '', // 设备id
  99. // 检索时间 折线图,虫害图片溯源,虫害基础数据通用
  100. timeParams: {
  101. start_time: timeFrame('start'), // 开始时间
  102. end_time: timeFrame('end'), // 结束时间
  103. },
  104. // === 虫害统计信息参数
  105. searchTime: ['', ''],
  106. chartLoading: false,
  107. // 饼状图数据
  108. pestPieData: null,
  109. // 折线图数据
  110. pestLineData: null,
  111. pestTotal: null, // 虫害统计信息
  112. // === 虫害统计信息参数 end
  113. // === 虫害表格数据
  114. pestTabs: [{
  115. text: '图像溯源',
  116. value: 1
  117. }, {
  118. text: '虫害基础数据',
  119. value: 2
  120. }],
  121. pestTabValue: 1, // 当前虫害选项
  122. pestImageSourceTable: [], // 害虫图片溯源表格数据,
  123. imageSourcePage: 1, // 害虫图片溯源页码
  124. imageSourceTotal: 0, // 害虫图片溯源总数
  125. pestBaseTable: [], // 害虫基础表格数据
  126. basePage: 1, // 害虫基础页码
  127. baseTotal: 0, // 害虫基础总数
  128. // === 虫害表格数据 end
  129. scrollTop: 0,
  130. };
  131. },
  132. components: {
  133. areaCharts,
  134. pieCharts,
  135. raiseCard
  136. },
  137. onLoad(options) {
  138. this.deviceId = options.id;// '15';
  139. this.getPestStatisticsChart();
  140. this.getPestImageSourceList();
  141. this.getPestBaseDataList();
  142. },
  143. onPageScroll(e) {
  144. this.scrollTop = e.scrollTop;
  145. },
  146. methods: {
  147. // 获取折线图统计信息
  148. async getPestStatisticsChart() {
  149. this.chartLoading = false;
  150. const {
  151. lineChart,
  152. pieChart,
  153. pestTotal,
  154. } = await getPestStatisticsChart({
  155. d_ids: this.deviceId,
  156. amend: 0,
  157. ...this.timeParams
  158. });
  159. this.pestPieData = pieChart; // 饼状图
  160. this.pestLineData = lineChart; // 折线图数据
  161. this.pestTotal = pestTotal; // 虫害统计信息
  162. this.chartLoading = true;
  163. },
  164. // 折线图时间切换
  165. changeSearchTime(time) {
  166. this.timeParams.start_time = time[0] ? dateToUnix(time[0]) : timeFrame('start');
  167. this.timeParams.end_time = time[0] ? dateToUnix(time[1]) : timeFrame('end');
  168. this.searchTime = time;
  169. this.getPestStatisticsChart();
  170. this.getPestImageSourceList();
  171. this.getPestBaseDataList();
  172. },
  173. clickPestTabs(value){
  174. this.pestTabValue=value;
  175. },
  176. /**
  177. * 获取虫害图片溯源列表
  178. * @param {Object} e 获取当前页数 e.current
  179. */
  180. async getPestImageSourceList(e) {
  181. this.imageSourcePage = e?.current ?? 1;
  182. const res = await getPestImageSource({
  183. d_ids: this.deviceId,
  184. page: this.imageSourcePage,
  185. ...this.timeParams
  186. });
  187. this.pestImageSourceTable = res.pest_image_data;
  188. this.imageSourceTotal = res.total_count;
  189. this.imageSourcePage = res.current_count
  190. },
  191. /**
  192. * 获取虫害基础数据列表
  193. * @param {Object} e 获取当前页数 e.current
  194. */
  195. async getPestBaseDataList(e) {
  196. this.basePage = e?.current ?? 1;
  197. const res = await getPestBaseData({
  198. d_ids: this.deviceId,
  199. page: this.basePage,
  200. ...this.timeParams
  201. });
  202. this.pestBaseTable = res.pest_image_data;
  203. this.baseTotal = res.total_count;
  204. this.basePage = res.current_count
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. // 时期样式
  211. .period-navs {
  212. display: flex;
  213. justify-content: space-between;
  214. }
  215. .period-item {
  216. width: 200rpx;
  217. height: 264rpx;
  218. padding: 122rpx 24rpx 24rpx;
  219. background: url('/static/img/startTime.png') center center no-repeat;
  220. background-size: 200rpx 264rpx;
  221. &.high-time {
  222. background-image: url('/static/img/highTime.png');
  223. }
  224. &.end-time {
  225. background-image: url('/static/img/endTime.png');
  226. }
  227. .title {
  228. font-size: 32rpx;
  229. font-weight: normal;
  230. color: #333333;
  231. line-height: 44rpx;
  232. }
  233. .text {
  234. margin-top: 10rpx;
  235. font-size: 24rpx;
  236. font-weight: normal;
  237. color: #999999;
  238. line-height: 34rpx;
  239. }
  240. }
  241. .progress-item {
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. margin-top: 12rpx;
  246. .label,
  247. .percent {
  248. font-size: 24rpx;
  249. color: #333;
  250. }
  251. .label {
  252. width: 200rpx;
  253. }
  254. .percent {
  255. width: 80rpx;
  256. text-align: right;
  257. }
  258. .progress {
  259. flex: 1;
  260. height: 18rpx;
  261. overflow: hidden;
  262. border-radius: 30rpx;
  263. }
  264. }
  265. // 虫害表格数据
  266. .worm-table {
  267. padding: 10rpx 24rpx 30rpx;
  268. border-radius: 0;
  269. }
  270. </style>