Merge pull request '1' (#100) from pc-master into portal

Reviewed-on: #100
portal
xiaomeng 2024-01-24 00:37:42 +00:00
commit 8b282a468d
4 changed files with 49 additions and 13 deletions

View File

@ -1,9 +1,10 @@
import * as echarts from "echarts"; 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 chartDom = document.getElementById(id);
var myChart = echarts.init(chartDom); var myChart = echarts.init(chartDom);
chartDom.removeAttribute('_echarts_instance_')//解决切换页面echarts不显示的问题
var Xdata = [] var Xdata = []
var colorList1 = ['rgba(0, 187, 136, 1)', 'rgba(252, 125, 106, 1)', 'rgba(252, 223, 39, 1)', 'rgba(68, 214, 232, 1)', 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)'] '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 list = []
var selList={} var selList={}
var selTure=false
var dataList = [] 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) => { data.forEach((el, index) => {
Xdata.push(el.time) 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) => { dataList.forEach((el, index) => {
list.push({ list.push({
name: el.name, name: el.name,
@ -217,7 +240,6 @@ export function realTimeLine(id, data) {
}, },
}, },
}) })
selList[el.name]=(index==0?true:false)
}) })
var option = { var option = {
tooltip: { tooltip: {
@ -331,6 +353,16 @@ export function realTimeLine(id, data) {
}; };
option && myChart.setOption(option); option && myChart.setOption(option);
myChart.resize(); myChart.resize();
myChart.on('legendselectchanged', function (params) {
equipmentList.forEach((obj,index) => {
if (obj.deviceId== pageId) {
// 在找到的对象中添加参数
obj.selList=params.selected
}
});
});
window.addEventListener("resize", function () { window.addEventListener("resize", function () {
myChart.resize(); myChart.resize();
}); });

View File

@ -9,6 +9,7 @@ export default new Vuex.Store({
lateSend: 100,//写入停止后 *100毫秒进行发送 例如10*100就是1000毫秒(1s) lateSend: 100,//写入停止后 *100毫秒进行发送 例如10*100就是1000毫秒(1s)
lateSendBtn: 10,//写入停止后 *100毫秒进行发送 例如10*100就是1000毫秒(1s) lateSendBtn: 10,//写入停止后 *100毫秒进行发送 例如10*100就是1000毫秒(1s)
equipmentList: [],//当前账户施肥设备 equipmentList: [],//当前账户施肥设备
equipmentSelList:[],//存储当前echarts的sel数组
equipmentIndex: 1,//当前在第几个设备 equipmentIndex: 1,//当前在第几个设备
equipmentName: null,//当前设备 小设备的各个名字 equipmentName: null,//当前设备 小设备的各个名字
nameList: ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Elven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen'], 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)) localStorage.setItem('userInfo', JSON.stringify(data))
this.userInfo = JSON.parse(localStorage.getItem('userInfo')) this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
this.gerRouter(); this.gerRouter();
this.getEqbyid() this.getEqbyid(true)
}) })
return return
} else { } else {
@ -123,11 +123,11 @@ export default {
this.userInfo = JSON.parse(localStorage.getItem('userInfo')) this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
} }
this.gerRouter(); this.gerRouter();
this.getEqbyid() this.getEqbyid(true)
} }
this.IDTimer && clearInterval(this.IDTimer) this.IDTimer && clearInterval(this.IDTimer)
this.IDTimer = setInterval(() => { this.IDTimer = setInterval(() => {
that.getEqbyid() that.getEqbyid(false)
}, 120000); }, 120000);
// id // id
@ -186,7 +186,7 @@ export default {
}; };
}, },
// //
getEqbyid() { getEqbyid(selTrue) {
var userInfo =localStorage.getItem('userInfo')? JSON.parse(localStorage.getItem('userInfo')):{userid:-1} var userInfo =localStorage.getItem('userInfo')? JSON.parse(localStorage.getItem('userInfo')):{userid:-1}
this.api.getEqbyid(userInfo.userid).then((res) => { this.api.getEqbyid(userInfo.userid).then((res) => {
if (res.data.code == 200) { if (res.data.code == 200) {
@ -197,6 +197,9 @@ export default {
index: index + 1, index: index + 1,
}; };
}); });
if(selTrue){
this.$store.state.equipmentSelList=res.data.data
}
this.leftList[1].list = [] this.leftList[1].list = []
this.leftList[2].list = [] this.leftList[2].list = []
this.leftList[3].list = [] this.leftList[3].list = []

View File

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