analyse.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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 :current="imageSourcePage" :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 :current="basePage" :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. timeFrameText,
  90. timeFrame,
  91. dateToUnix
  92. } from '@/utils/utils.js'
  93. import areaCharts from './components/w-area-charts.vue'
  94. import pieCharts from './components/w-pie-charts.vue'
  95. import raiseCard from './components/analyse/raise-card.vue' // 始见期卡片组件
  96. export default {
  97. data() {
  98. return {
  99. deviceId: '', // 设备id
  100. // 检索时间 折线图,虫害图片溯源,虫害基础数据通用
  101. timeParams: {
  102. start_time: timeFrame('start'), // 开始时间
  103. end_time: timeFrame('end'), // 结束时间
  104. },
  105. // === 虫害统计信息参数
  106. searchTime: [timeFrameText('start'), timeFrameText('end')],
  107. chartLoading: false,
  108. // 饼状图数据
  109. pestPieData: null,
  110. // 折线图数据
  111. pestLineData: null,
  112. pestTotal: null, // 虫害统计信息
  113. // === 虫害统计信息参数 end
  114. // === 虫害表格数据
  115. pestTabs: [{
  116. text: '图像溯源',
  117. value: 1
  118. }, {
  119. text: '虫害基础数据',
  120. value: 2
  121. }],
  122. pestTabValue: 1, // 当前虫害选项
  123. pestImageSourceTable: [], // 害虫图片溯源表格数据,
  124. imageSourcePage: 1, // 害虫图片溯源页码
  125. imageSourceTotal: 0, // 害虫图片溯源总数
  126. pestBaseTable: [], // 害虫基础表格数据
  127. basePage: 1, // 害虫基础页码
  128. baseTotal: 0, // 害虫基础总数
  129. // === 虫害表格数据 end
  130. scrollTop: 0,
  131. };
  132. },
  133. components: {
  134. areaCharts,
  135. pieCharts,
  136. raiseCard
  137. },
  138. onLoad(options) {
  139. this.deviceId = options.id;// '15';
  140. this.getPestStatisticsChart();
  141. this.getPestImageSourceList();
  142. this.getPestBaseDataList();
  143. },
  144. onPageScroll(e) {
  145. this.scrollTop = e.scrollTop;
  146. },
  147. methods: {
  148. // 获取折线图统计信息
  149. async getPestStatisticsChart() {
  150. this.chartLoading = false;
  151. const {
  152. lineChart,
  153. pieChart,
  154. pestTotal,
  155. } = await getPestStatisticsChart({
  156. d_ids: this.deviceId,
  157. amend: 0,
  158. ...this.timeParams
  159. });
  160. this.pestPieData = pieChart; // 饼状图
  161. this.pestLineData = lineChart; // 折线图数据
  162. this.pestTotal = pestTotal; // 虫害统计信息
  163. this.chartLoading = true;
  164. },
  165. // 折线图时间切换
  166. changeSearchTime(time) {
  167. this.timeParams.start_time = time[0] ? dateToUnix(time[0]) : timeFrame('start');
  168. this.timeParams.end_time = time[0] ? dateToUnix(time[1]) : timeFrame('end');
  169. this.searchTime = time;
  170. this.getPestStatisticsChart();
  171. this.getPestImageSourceList();
  172. this.getPestBaseDataList();
  173. },
  174. clickPestTabs(value){
  175. this.pestTabValue=value;
  176. },
  177. /**
  178. * 获取虫害图片溯源列表
  179. * @param {Object} e 获取当前页数 e.current
  180. */
  181. async getPestImageSourceList(e) {
  182. this.imageSourcePage = e?.current ?? 1;
  183. const res = await getPestImageSource({
  184. d_ids: this.deviceId,
  185. page: this.imageSourcePage,
  186. ...this.timeParams
  187. });
  188. this.pestImageSourceTable = res.pest_image_data;
  189. this.imageSourceTotal = res.total_count;
  190. this.imageSourcePage = res.current_count
  191. },
  192. /**
  193. * 获取虫害基础数据列表
  194. * @param {Object} e 获取当前页数 e.current
  195. */
  196. async getPestBaseDataList(e) {
  197. this.basePage = e?.current ?? 1;
  198. const res = await getPestBaseData({
  199. d_ids: this.deviceId,
  200. page: this.basePage,
  201. ...this.timeParams
  202. });
  203. this.pestBaseTable = res.pest_image_data;
  204. this.baseTotal = res.total_count;
  205. this.basePage = res.current_count
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss">
  211. // 时期样式
  212. .period-navs {
  213. display: flex;
  214. justify-content: space-between;
  215. }
  216. .period-item {
  217. width: 200rpx;
  218. height: 264rpx;
  219. padding: 122rpx 24rpx 24rpx;
  220. background: url('/static/img/startTime.png') center center no-repeat;
  221. background-size: 200rpx 264rpx;
  222. &.high-time {
  223. background-image: url('/static/img/highTime.png');
  224. }
  225. &.end-time {
  226. background-image: url('/static/img/endTime.png');
  227. }
  228. .title {
  229. font-size: 32rpx;
  230. font-weight: normal;
  231. color: #333333;
  232. line-height: 44rpx;
  233. }
  234. .text {
  235. margin-top: 10rpx;
  236. font-size: 24rpx;
  237. font-weight: normal;
  238. color: #999999;
  239. line-height: 34rpx;
  240. }
  241. }
  242. .progress-item {
  243. display: flex;
  244. align-items: center;
  245. justify-content: space-between;
  246. margin-top: 12rpx;
  247. .label,
  248. .percent {
  249. font-size: 24rpx;
  250. color: #333;
  251. }
  252. .label {
  253. width: 200rpx;
  254. }
  255. .percent {
  256. width: 80rpx;
  257. text-align: right;
  258. }
  259. .progress {
  260. flex: 1;
  261. height: 18rpx;
  262. overflow: hidden;
  263. border-radius: 30rpx;
  264. }
  265. }
  266. // 虫害表格数据
  267. .worm-table {
  268. padding: 10rpx 24rpx 30rpx;
  269. border-radius: 0;
  270. }
  271. </style>