|
|
@@ -3,7 +3,7 @@
|
|
|
* @Autor: lin
|
|
|
* @Date: 2024-04-09 14:26:43
|
|
|
* @LastEditors: lin
|
|
|
- * @LastEditTime: 2024-04-18 16:55:05
|
|
|
+ * @LastEditTime: 2024-04-19 16:35:19
|
|
|
-->
|
|
|
<template>
|
|
|
<div class="bigBg">
|
|
|
@@ -131,13 +131,14 @@
|
|
|
<div class="card">
|
|
|
<div class="titleBox">
|
|
|
<Title text="虫害折线图"></Title>
|
|
|
- <div class="rightBox">
|
|
|
- <el-select size="mini">
|
|
|
+ <div class="rightBox" v-if="pestLineDate.length > 0">
|
|
|
+ <el-select size="mini" v-model="pestLineCheck[index].value" @change="e => changePestSelect(e, pestLineCheck[index], pestLineDate[index], `pestDateChar${item.id}`)">
|
|
|
+ <el-option v-for="(pest, pestIndex) in (pestLineDate[index])[((pestLineCheck[index]).type)].pestName" :key="`${index}${pest}${pestIndex}`" :value="pest" :label="pest"></el-option>
|
|
|
</el-select>
|
|
|
<div class="rightType">
|
|
|
- <div class="active" @click="changePestType(index, 'date', `pestDateChar${item.id}`)">日</div>
|
|
|
- <div @click="changePestType(index, 'month', `pestDateChar${item.id}`)">月</div>
|
|
|
- <div @click="changePestType(index, 'year', `pestDateChar${item.id}`)">年</div>
|
|
|
+ <div :class="`${(pestLineCheck[index]).type == 'day' ? 'active' : ''}`" @click="changePestType(`pestDateChar${item.id}`, 'day', pestLineCheck[index], pestLineDate[index])">日</div>
|
|
|
+ <div :class="`${(pestLineCheck[index]).type == 'months' ? 'active' : ''}`" @click="changePestType(`pestDateChar${item.id}`, 'months', pestLineCheck[index], pestLineDate[index])">月</div>
|
|
|
+ <div :class="`${(pestLineCheck[index]).type == 'year' ? 'active' : ''}`" @click="changePestType(`pestDateChar${item.id}`, 'year', pestLineCheck[index], pestLineDate[index])">年</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -166,6 +167,7 @@ export default {
|
|
|
pestNowList: [], // 实时数据
|
|
|
pestImgList: [], //设备图片
|
|
|
videoList: [], //监控列表 跳出页面要停止
|
|
|
+ pestLineCheck:[]
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -183,6 +185,47 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
methods: {
|
|
|
+ /**
|
|
|
+ * @description: 虫害折线图 切换年月日 由于虫子不一样 所以会默认展示第一种
|
|
|
+ * @param {*} char 需要渲染的echars dom id
|
|
|
+ * @param {*} type 当前统计类型 日、月、年
|
|
|
+ * @param {*} typeObj 记录统计类型及统计害虫名称的对象
|
|
|
+ * @param {*} data 当前统计数据对象
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ changePestType(charID, type, typeObj, data) {
|
|
|
+ typeObj.type = type;
|
|
|
+ typeObj.value = data[type].pestName[0];
|
|
|
+ let xData = [];
|
|
|
+ let yData = [];
|
|
|
+ data[type].countInfo.forEach(pest => {
|
|
|
+ xData.push(pest.date);
|
|
|
+ yData.push(pest.data[0])
|
|
|
+ })
|
|
|
+ let char = echarts.init(document.getElementById(charID));
|
|
|
+ this.setLineOption(char, [typeObj.value], xData, [yData], [['#0066ff59', '#0066ff00']], ['#1588F2'], true)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @description: 虫害折线图 切换虫害下拉框
|
|
|
+ * @param {*} pest 当前选中害虫名称
|
|
|
+ * @param {*} typeObj 记录统计类型及统计害虫名称的对象
|
|
|
+ * @param {*} data 当前统计数据对象
|
|
|
+ * @param {*} charId 需要渲染的echars dom id
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ changePestSelect(pest, typeObj, data, charId) {
|
|
|
+ console.log(pest, typeObj, data, charId);
|
|
|
+ typeObj.value = pest;
|
|
|
+ let pestIndex = data[typeObj.type].pestName.indexOf(pest);
|
|
|
+ let xData = [];
|
|
|
+ let yData = [];
|
|
|
+ data[typeObj.type].countInfo.forEach(pest => {
|
|
|
+ xData.push(pest.date);
|
|
|
+ yData.push(pest.data[pestIndex])
|
|
|
+ })
|
|
|
+ let char = echarts.init(document.getElementById(charId));
|
|
|
+ this.setLineOption(char, [pest], xData, [yData], [['#0066ff59', '#0066ff00']], ['#1588F2'], true);
|
|
|
+ },
|
|
|
// 获取有测报灯列表
|
|
|
getDeviceList(date) {
|
|
|
this.$axios({
|
|
|
@@ -227,7 +270,7 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
// 折线图带渐变配置
|
|
|
- setLineOption(char, name, xData, yData, color, lineColor) {
|
|
|
+ setLineOption(char, name, xData, yData, color, lineColor, showAxisLabel=false) {
|
|
|
let series = [];
|
|
|
yData.forEach((item, index) => {
|
|
|
let pre = {
|
|
|
@@ -265,7 +308,7 @@ export default {
|
|
|
},
|
|
|
grid: {
|
|
|
top: '5%',
|
|
|
- left: '0',
|
|
|
+ left: '5%',
|
|
|
bottom: '5%',
|
|
|
right: '0%',
|
|
|
containLabel: true
|
|
|
@@ -282,7 +325,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
axisLabel: {
|
|
|
- show: false
|
|
|
+ show: showAxisLabel
|
|
|
},
|
|
|
splitLine: {
|
|
|
show: false // 不显示 x 轴分隔线
|
|
|
@@ -445,7 +488,20 @@ export default {
|
|
|
this.$message.error('网络连接出错或服务报错,请刷新页面重试');
|
|
|
return
|
|
|
}
|
|
|
- this.pestLineDate.push(res.data.data)
|
|
|
+ this.pestLineDate.push(res.data.data);
|
|
|
+ this.pestLineCheck.push({
|
|
|
+ type: 'day',
|
|
|
+ value:res.data.data.day.pestName[0]
|
|
|
+ });
|
|
|
+ let xData = [];
|
|
|
+ let yData = [];
|
|
|
+ res.data.data.day.countInfo.forEach(pest => {
|
|
|
+ xData.push(pest.date);
|
|
|
+ yData.push(pest.data[0])
|
|
|
+ })
|
|
|
+ let char = echarts.init(document.getElementById(`pestDateChar${id}`));
|
|
|
+ this.setLineOption(char, [res.data.data.day.pestName[0]], xData, [yData], [['#0066ff59', '#0066ff00']], ['#1588F2'], true)
|
|
|
+ console.log(this.pestLineDate)
|
|
|
})
|
|
|
},
|
|
|
},
|