|
|
@@ -2,125 +2,136 @@
|
|
|
<!-- 虫害分析 -->
|
|
|
<view>
|
|
|
<!-- 时期卡片 -->
|
|
|
- <raise-card :deviceId="dId"></raise-card>
|
|
|
+ <raise-card :deviceId="deviceId"></raise-card>
|
|
|
<!-- 时期卡片end -->
|
|
|
<!-- 虫害统计图 -->
|
|
|
<view class="ui-card px-13">
|
|
|
<!-- 选择时间范围 -->
|
|
|
<view class="mb">
|
|
|
- <uni-datetime-picker v-model="range" type="daterange" rangeSeparator="至" @maskClick="maskClick" />
|
|
|
+ <uni-datetime-picker v-model="searchTime" type="daterange" rangeSeparator="-"
|
|
|
+ @change="changeSearchTime" />
|
|
|
</view>
|
|
|
<!-- 区域统计图 -->
|
|
|
- <area-charts :chartData="areaData"></area-charts>
|
|
|
+ <area-charts :chartData="pestLineData"></area-charts>
|
|
|
<view style="height: 20rpx;"></view>
|
|
|
<!-- 环形统计图 -->
|
|
|
- <pie-charts :chartData="pieData"></pie-charts>
|
|
|
+ <pie-charts :chartData="pestPieData"></pie-charts>
|
|
|
<!-- 统计列表 -->
|
|
|
<view class="mt-12">
|
|
|
- <view class="progress-item">
|
|
|
- <view class="label">1、贪夜蛾</view>
|
|
|
+ <view class="progress-item" v-for="(val,key,i) in pestTotal" :key="i">
|
|
|
+ <view class="label">{{i+1}}、{{key}}</view>
|
|
|
<view class="progress">
|
|
|
- <progress :percent="10" backgroundColor="#F3F5F9" activeColor="#10AEFF" :stroke-width="9" />
|
|
|
+ <progress :percent="pestTotal[key]" backgroundColor="#F3F5F9" activeColor="#10AEFF" :stroke-width="9" />
|
|
|
</view>
|
|
|
- <view class="percent">52%</view>
|
|
|
+ <view class="percent">{{val}}</view>
|
|
|
</view>
|
|
|
-
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
+ <!-- 虫害统计图end -->
|
|
|
<!-- 虫害表格数据 -->
|
|
|
<view class="ui-card worm-table">
|
|
|
- <ui-tabs :list="tabs" :active="1"></ui-tabs>
|
|
|
- <!-- <uni-table class="table-style mt-12" ref="table" :loading="loading" border emptyText="暂无更多数据">
|
|
|
- <uni-tr>
|
|
|
- <uni-th width="150" align="center">日期</uni-th>
|
|
|
- <uni-th width="150" align="center">姓名</uni-th>
|
|
|
- <uni-th align="center">地址</uni-th>
|
|
|
- <uni-th width="204" align="center">设置</uni-th>
|
|
|
- </uni-tr>
|
|
|
- <uni-tr v-for="(item, index) in tableData" :key="index">
|
|
|
- <uni-td>{{ item.date }}</uni-td>
|
|
|
- <uni-td>{{ item.date }}</uni-td>
|
|
|
- <uni-td>
|
|
|
- <view class="name">{{ item.name }}</view>
|
|
|
- </uni-td>
|
|
|
- <uni-td align="center">{{ item.address }}</uni-td>
|
|
|
- </uni-tr>
|
|
|
- </uni-table> -->
|
|
|
- <!-- 页码 -->
|
|
|
- <uni-pagination :total="50" title="标题文字" />
|
|
|
- <!-- 页码end -->
|
|
|
+ <ui-tabs :list="pestTabs" :active="pestTabValue" @clickTab="clickPestTabs"></ui-tabs>
|
|
|
+ <!-- 害虫图片溯源 -->
|
|
|
+ <view v-show="pestTabValue==1">
|
|
|
+ <uni-table class="table-style mt-12" ref="table" border emptyText="暂无更多数据">
|
|
|
+ <uni-tr>
|
|
|
+ <uni-th width="150" align="center">设备号</uni-th>
|
|
|
+ <uni-th width="150" align="center">设备名称</uni-th>
|
|
|
+ <uni-th width="250" align="center">害虫名称</uni-th>
|
|
|
+ <uni-th width="200" align="center">添加时间</uni-th>
|
|
|
+ <uni-th width="200" align="center">地址</uni-th>
|
|
|
+ </uni-tr>
|
|
|
+ <uni-tr v-for="(item, index) in pestImageSourceTable" :key="index">
|
|
|
+ <uni-td>{{ item.deviceId }}</uni-td>
|
|
|
+ <uni-td>{{ item.deviceName }}</uni-td>
|
|
|
+ <uni-td>
|
|
|
+ <view class="name">{{ item.pestName }}</view>
|
|
|
+ </uni-td>
|
|
|
+ <uni-td align="center">{{ item.addtime | timeFrom }}</uni-td>
|
|
|
+ <uni-td align="center">{{ item.location }}</uni-td>
|
|
|
+ </uni-tr>
|
|
|
+ </uni-table>
|
|
|
+ <!-- 页码 -->
|
|
|
+ <uni-pagination :total="imageSourceTotal" @change="getPestImageSourceList" />
|
|
|
+ <!-- 页码end -->
|
|
|
+ </view>
|
|
|
+ <!-- 害虫基础信息溯源 -->
|
|
|
+ <view v-show="pestTabValue==2">
|
|
|
+ <uni-table class="table-style mt-12" ref="table" border emptyText="暂无更多数据">
|
|
|
+ <uni-tr>
|
|
|
+ <uni-th width="150" align="center">害虫名称</uni-th>
|
|
|
+ <uni-th width="150" align="center">害虫数量</uni-th>
|
|
|
+ <uni-th width="180" align="center">添加时间</uni-th>
|
|
|
+ </uni-tr>
|
|
|
+ <uni-tr v-for="(item, index) in pestBaseTable" :key="index">
|
|
|
+ <uni-td align="center">{{ item.pest_name }}</uni-td>
|
|
|
+ <uni-td align="center">{{ item.pest_num }}</uni-td>
|
|
|
+ <uni-td align="center">{{ item.addtime | timeFrom }}</uni-td>
|
|
|
+ </uni-tr>
|
|
|
+ </uni-table>
|
|
|
+ <!-- 页码 -->
|
|
|
+ <uni-pagination :total="baseTotal" @change="getPestBaseDataList" />
|
|
|
+ <!-- 页码end -->
|
|
|
+ </view>
|
|
|
</view>
|
|
|
+ <view style="height: 100rpx;"></view>
|
|
|
+
|
|
|
+ <!-- 返回顶部按钮 -->
|
|
|
+ <ui-back-top :scroll-top="scrollTop" />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
getPestStatisticsChart,
|
|
|
- getPestRaiseInfo,
|
|
|
getPestImageSource,
|
|
|
getPestBaseData
|
|
|
} from '@/api/worm.js'
|
|
|
+ import {
|
|
|
+ timeFrame,
|
|
|
+ dateToUnix
|
|
|
+ } from '@/utils/utils.js'
|
|
|
import areaCharts from './components/w-area-charts.vue'
|
|
|
import pieCharts from './components/w-pie-charts.vue'
|
|
|
import raiseCard from './components/analyse/raise-card.vue' // 始见期卡片组件
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- dId: '', // 设备id
|
|
|
- pieData: {
|
|
|
- series: [{
|
|
|
- data: [{
|
|
|
- "name": "一班",
|
|
|
- "value": 50
|
|
|
- }, {
|
|
|
- "name": "二班",
|
|
|
- "value": 30
|
|
|
- }, {
|
|
|
- "name": "三班",
|
|
|
- "value": 20
|
|
|
- }]
|
|
|
- }]
|
|
|
- },
|
|
|
- areaData: {
|
|
|
- categories: ["2016", "2017", "2018", "2019", "2020", "2021"],
|
|
|
- series: [{
|
|
|
- name: "成交量A",
|
|
|
- data: [35, 8, 25, 37, 4, 20]
|
|
|
- },
|
|
|
- {
|
|
|
- name: "成交量B",
|
|
|
- data: [70, 40, 65, 100, 44, 68]
|
|
|
- }
|
|
|
- ]
|
|
|
+ deviceId: '', // 设备id
|
|
|
+ // 检索时间 折线图,虫害图片溯源,虫害基础数据通用
|
|
|
+ timeParams: {
|
|
|
+ start_time: timeFrame('start'), // 开始时间
|
|
|
+ end_time: timeFrame('end'), // 结束时间
|
|
|
},
|
|
|
- // 日期列表
|
|
|
- periodList: [{
|
|
|
- url: '',
|
|
|
- title: '始见期',
|
|
|
- time: '2022-08-22',
|
|
|
- num: 536
|
|
|
- },
|
|
|
- {
|
|
|
- url: '',
|
|
|
- title: '高峰期',
|
|
|
- time: '2022-08-22',
|
|
|
- num: 132
|
|
|
- }, {
|
|
|
- url: '',
|
|
|
- title: '终见期',
|
|
|
- time: '2022-08-22',
|
|
|
- num: 0
|
|
|
- }
|
|
|
- ],
|
|
|
- range: ['2021-02-1', '2021-3-28'],
|
|
|
- tabs: [{
|
|
|
+ // === 虫害统计信息参数
|
|
|
+ searchTime: ['', ''],
|
|
|
+ chartLoading: false,
|
|
|
+ // 饼状图数据
|
|
|
+ pestPieData: null,
|
|
|
+ // 折线图数据
|
|
|
+ pestLineData: null,
|
|
|
+ pestTotal: null, // 虫害统计信息
|
|
|
+ // === 虫害统计信息参数 end
|
|
|
+
|
|
|
+ // === 虫害表格数据
|
|
|
+ pestTabs: [{
|
|
|
text: '图像溯源',
|
|
|
value: 1
|
|
|
}, {
|
|
|
text: '虫害基础数据',
|
|
|
value: 2
|
|
|
- }, ]
|
|
|
+ }],
|
|
|
+ pestTabValue: 1, // 当前虫害选项
|
|
|
+
|
|
|
+ pestImageSourceTable: [], // 害虫图片溯源表格数据,
|
|
|
+ imageSourcePage: 1, // 害虫图片溯源页码
|
|
|
+ imageSourceTotal: 0, // 害虫图片溯源总数
|
|
|
+
|
|
|
+ pestBaseTable: [], // 害虫基础表格数据
|
|
|
+ basePage: 1, // 害虫基础页码
|
|
|
+ baseTotal: 0, // 害虫基础总数
|
|
|
+ // === 虫害表格数据 end
|
|
|
+ scrollTop: 0,
|
|
|
};
|
|
|
},
|
|
|
components: {
|
|
|
@@ -129,11 +140,75 @@
|
|
|
raiseCard
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- this.dId = '15'; //options.id
|
|
|
+ this.deviceId = '15'; //options.id
|
|
|
+ this.getPestStatisticsChart();
|
|
|
+ this.getPestImageSourceList();
|
|
|
+ this.getPestBaseDataList();
|
|
|
+ },
|
|
|
+ onPageScroll(e) {
|
|
|
+ this.scrollTop = e.scrollTop;
|
|
|
},
|
|
|
methods: {
|
|
|
- maskClick(e) {
|
|
|
- console.log('----maskClick事件:', e);
|
|
|
+ // 获取折线图统计信息
|
|
|
+ async getPestStatisticsChart() {
|
|
|
+ this.chartLoading = false;
|
|
|
+
|
|
|
+ const {
|
|
|
+ lineChart,
|
|
|
+ pieChart,
|
|
|
+ pestTotal,
|
|
|
+ } = await getPestStatisticsChart({
|
|
|
+ d_ids: this.deviceId,
|
|
|
+ amend: 0,
|
|
|
+ ...this.timeParams
|
|
|
+ });
|
|
|
+ this.pestPieData = pieChart; // 饼状图
|
|
|
+ this.pestLineData = lineChart; // 折线图数据
|
|
|
+ this.pestTotal = pestTotal; // 虫害统计信息
|
|
|
+ this.chartLoading = true;
|
|
|
+ },
|
|
|
+ // 折线图时间切换
|
|
|
+ changeSearchTime(time) {
|
|
|
+ this.timeParams.start_time = time[0] ? dateToUnix(time[0]) : timeFrame('start');
|
|
|
+ this.timeParams.end_time = time[0] ? dateToUnix(time[1]) : timeFrame('end');
|
|
|
+ this.searchTime = time;
|
|
|
+ this.getPestStatisticsChart();
|
|
|
+ this.getPestImageSourceList();
|
|
|
+ this.getPestBaseDataList();
|
|
|
+ },
|
|
|
+
|
|
|
+ clickPestTabs(value){
|
|
|
+ this.pestTabValue=value;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取虫害图片溯源列表
|
|
|
+ * @param {Object} e 获取当前页数 e.current
|
|
|
+ */
|
|
|
+ async getPestImageSourceList(e) {
|
|
|
+ this.imageSourcePage = e?.current ?? 1;
|
|
|
+ const res = await getPestImageSource({
|
|
|
+ d_ids: this.deviceId,
|
|
|
+ page: this.imageSourcePage,
|
|
|
+ ...this.timeParams
|
|
|
+ });
|
|
|
+ this.pestImageSourceTable = res.pest_image_data;
|
|
|
+ this.imageSourceTotal = res.total_count;
|
|
|
+ this.imageSourcePage = res.current_count
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取虫害基础数据列表
|
|
|
+ * @param {Object} e 获取当前页数 e.current
|
|
|
+ */
|
|
|
+ async getPestBaseDataList(e) {
|
|
|
+ this.basePage = e?.current ?? 1;
|
|
|
+ const res = await getPestBaseData({
|
|
|
+ d_ids: this.deviceId,
|
|
|
+ page: this.basePage,
|
|
|
+ ...this.timeParams
|
|
|
+ });
|
|
|
+ this.pestBaseTable = res.pest_image_data;
|
|
|
+ this.baseTotal = res.total_count;
|
|
|
+ this.basePage = res.current_count
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -178,11 +253,11 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
.progress-item {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: space-between;
|
|
|
+ margin-top: 12rpx;
|
|
|
|
|
|
.label,
|
|
|
.percent {
|
|
|
@@ -191,7 +266,7 @@
|
|
|
}
|
|
|
|
|
|
.label {
|
|
|
- width: 160rpx;
|
|
|
+ width: 200rpx;
|
|
|
}
|
|
|
|
|
|
.percent {
|
|
|
@@ -204,15 +279,12 @@
|
|
|
height: 18rpx;
|
|
|
overflow: hidden;
|
|
|
border-radius: 30rpx;
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 虫害表格数据
|
|
|
.worm-table {
|
|
|
padding: 10rpx 24rpx 30rpx;
|
|
|
- margin-bottom: 100rpx;
|
|
|
border-radius: 0;
|
|
|
}
|
|
|
</style>
|