pull/100/head
孙萌 2024-01-23 17:49:43 +08:00
parent cbd53e4cea
commit 4c71562686
4 changed files with 49 additions and 13 deletions

View File

@ -1,9 +1,10 @@
import * as echarts from "echarts";
import { h } from "vue";
import store from '../../store/index'
export function realTimeLine(id, data) {
export function realTimeLine(id, data,pageId) {
var chartDom = document.getElementById(id);
var myChart = echarts.init(chartDom);
chartDom.removeAttribute('_echarts_instance_')//解决切换页面echarts不显示的问题
var Xdata = []
var colorList1 = ['rgba(0, 187, 136, 1)', 'rgba(252, 125, 106, 1)', 'rgba(252, 223, 39, 1)', 'rgba(68, 214, 232, 1)',
'rgba(69, 224, 155, 1)', 'rgba(82, 188, 255, 1)', 'rgba(214, 162, 255, 1)', 'rgba(255, 192, 111, 1)', 'rgba(255, 156, 154, 1)', 'rgba(255, 156, 154, 1)']
@ -171,9 +172,25 @@ export function realTimeLine(id, data) {
),
]
var equipmentList=store.state.equipmentSelList
var list = []
var selList={}
var selTure=false
var dataList = []
equipmentList.forEach(obj => {
if (obj.deviceId == pageId) {
// 在找到的对象中添加参数
if(obj.selList){
selList = obj.selList;
selTure=true
}else{
selList ={}
selTure=false
}
}
});
data.forEach((el, index) => {
Xdata.push(el.time)
@ -190,6 +207,12 @@ export function realTimeLine(id, data) {
})
if(!selTure){
dataList.forEach((el, index) => {
selList[el.name]=(index==0?true:false)
})
}
dataList.forEach((el, index) => {
list.push({
name: el.name,
@ -217,7 +240,6 @@ export function realTimeLine(id, data) {
},
},
})
selList[el.name]=(index==0?true:false)
})
var option = {
tooltip: {
@ -331,6 +353,16 @@ export function realTimeLine(id, data) {
};
option && myChart.setOption(option);
myChart.resize();
myChart.on('legendselectchanged', function (params) {
equipmentList.forEach((obj,index) => {
if (obj.deviceId== pageId) {
// 在找到的对象中添加参数
obj.selList=params.selected
}
});
});
window.addEventListener("resize", function () {
myChart.resize();
});

View File

@ -9,6 +9,7 @@ export default new Vuex.Store({
lateSend: 100,//写入停止后 *100毫秒进行发送 例如10*100就是1000毫秒(1s)
lateSendBtn: 10,//写入停止后 *100毫秒进行发送 例如10*100就是1000毫秒(1s)
equipmentList: [],//当前账户施肥设备
equipmentSelList:[],//存储当前echarts的sel数组
equipmentIndex: 1,//当前在第几个设备
equipmentName: null,//当前设备 小设备的各个名字
nameList: ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Elven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen'],

View File

@ -115,7 +115,7 @@ export default {
localStorage.setItem('userInfo', JSON.stringify(data))
this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
this.gerRouter();
this.getEqbyid()
this.getEqbyid(true)
})
return
} else {
@ -123,11 +123,11 @@ export default {
this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
}
this.gerRouter();
this.getEqbyid()
this.getEqbyid(true)
}
this.IDTimer && clearInterval(this.IDTimer)
this.IDTimer = setInterval(() => {
that.getEqbyid()
that.getEqbyid(false)
}, 120000);
// id
@ -186,7 +186,7 @@ export default {
};
},
//
getEqbyid() {
getEqbyid(selTrue) {
var userInfo =localStorage.getItem('userInfo')? JSON.parse(localStorage.getItem('userInfo')):{userid:-1}
this.api.getEqbyid(userInfo.userid).then((res) => {
if (res.data.code == 200) {
@ -197,6 +197,9 @@ export default {
index: index + 1,
};
});
if(selTrue){
this.$store.state.equipmentSelList=res.data.data
}
this.leftList[1].list = []
this.leftList[2].list = []
this.leftList[3].list = []

View File

@ -895,7 +895,7 @@ export default {
this.api.postFsdata(data1).then(res => {
if (res.data.code == 200) {
var chartsData = res.data.data
realTimeLine('realTime-line', chartsData)
realTimeLine('realTime-line', chartsData,data1)
} else {
// this.$message.error(res.data.msg);
}
@ -1008,7 +1008,7 @@ export default {
this.api.getControlFsdata(data1).then(res => {
if (res.data.code == 200) {
var chartsData = res.data.data
realTimeLine('realTime-line', chartsData)
realTimeLine('realTime-line', chartsData,data1)
} else {
// this.$message.error(res.data.msg);
}
@ -1071,7 +1071,7 @@ export default {
if (res.data.code == 200) {
res.data.data.forEach((el, index) => {
var chartsData = res.data.data
realTimeLine('realTime-line', chartsData)
realTimeLine('realTime-line', chartsData,equipmentId)
})
}
})
@ -1185,7 +1185,7 @@ export default {
fandata.type = 1
fandata.name = el.name
fandata.status = []
var num = res.data.data['1024']
var num = res.data.data['1024']?res.data.data['1024']:0
var num1 = this.padString(num.toString(2), 5)
var openListNew = []
openListNew = num1.split("")
@ -1199,7 +1199,7 @@ export default {
fandata.type = 1
fandata.name = el.name
fandata.status = []
var num = res.data.data['1079']
var num = res.data.data['1079']?res.data.data['1079']:0
var num1 = this.padString(num.toString(2), 5)
var openListNew = []
openListNew = num1.split("")
@ -1213,7 +1213,7 @@ export default {
fandata.type = 8
fandata.name = el.name
fandata.status = []
var num = res.data.data['1069']
var num = res.data.data['1069']?res.data.data['1069']:0
var num1 = this.padString(num.toString(2), 8)
var openListNew = []
openListNew = num1.split("")