wszhyWx/src/views/index.vue
2025-06-20 17:28:16 +08:00

789 lines
38 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="index">
<div class="header">
<div class="header-left">
<img class="logo-img" src="../assets/image/logo-img.png" alt="">
<img class="logo-bg" src="../assets/image/logo.png" alt="">
<div class="logo-title" v-if="mainData">
{{mainData.projectName}}
</div>
</div>
<div class="header-center">
<div class="header-warning" v-if="statusData[1114]">
<img src="../assets/img/warning.gif" alt="">
</div>
<div @click="toRouter(item)" :class="item.routerList.indexOf(routerNow) != -1 ? 'active' : ''"
v-for="item, index in headerList" :key="index">
<div class="img"> <img :src="item.img" alt=""></div>
<div class="name">{{ item.name }}</div>
</div>
</div>
<div class="header-right" v-if="userInfo">
<img src="../assets/image/avatar.png" alt="">
<div class="user-data">
<div class="name">{{$t('index.welcome')}}{{ userInfo.nickName }}
</div>
<div class="time" v-if="time"> {{ time.year.year }}-{{ time.year.month }}-{{ time.year.date }}</div>
</div>
<!-- <el-button
@click="changeLanguage()"
>
{{ currentLanguage === 'zh' ? 'EN' : '中' }}
</el-button> -->
<div class="login-out" @click="loginOut"></div>
</div>
</div>
<div class="index-content">
<div class="left collapse" v-if="manageList.indexOf(routerNow)==-1">
<el-collapse v-model="activeNames">
<template v-for="item, index in leftList">
<el-collapse-item :name="index + 1" :key="index" v-if="!item.isRouter&&item.list.length">
<template slot="title" class="collapse-title">
<div class="img"><img style="width: 16px;" :src="item.img" alt=""></div> {{ item.name }}
</template>
<ul class="table-ul">
<li class="table-li" @click="toRouter1(item1)"
:class="item.routerList.indexOf(routerNow) != -1 && routerIndex == item1.index ? 'active' : ''"
v-for="item1, index1 in item.list" :key="index1">{{ item1.deviceTypeName }} <div
class="status" :class="item1.deviceState == 0 ? 'outline' : 'online'"
v-if="item1.deviceState >= 0 && item1.deviceState">{{
item1.deviceState == 0 ? $t('index.offline') : $t('index.online') }}</div>
</li>
</ul>
</el-collapse-item>
<div @click="toRouter1(item)" :class="routerNow == item.router ? 'active' : ''" class="no-list"
v-else-if="item.isRouter">
<div class="img"><img :src="item.img" alt=""></div>{{ item.name }}
</div>
</template>
</el-collapse>
</div>
<!-- 管理的左侧 -->
<div class="left collapse" v-else>
<el-collapse v-model="activeNames1">
<template v-for="item, index in leftList1">
<el-collapse-item :name="index + 1" :key="index" v-if="!item.isRouter">
<template slot="title" class="collapse-title">
<div class="img"><img :src="item.img" alt=""></div> {{ item.name }}
</template>
<ul class="table-ul">
<li class="table-li" @click="toRouter2(item1)"
:class="routerNow == item1.router? 'active' : ''"
v-for="item1, index1 in item.list" :key="index1">{{ item1.deviceTypeName }}
</li>
</ul>
</el-collapse-item>
<div @click="toRouter2(item)" :class="routerNow == item.router ? 'active' : ''" class="no-list"
v-else>
<div class="img"><img :src="item.img" alt=""></div>{{ item.name }}
</div>
</template>
</el-collapse>
</div>
<div class="right">
<router-view v-if="!loading"></router-view>
</div>
</div>
</div>
</template>
<script>
import { getnowtime } from '../assets/js/nowTime'
//切换中英文
import { changeLanguage, getLanguage } from '@/utils/language'
import axios from "axios";
export default {
data() {
return {
currentLanguage: getLanguage(),//切换中英文
time: null,//当前时间
headerActive: 0,
leftList: [],
activeNames: [3],
manageList:['deviceStatusSet',
'deviceSet',
'deviceInfoManage',
'weatherData',
'dataDevice',
'mobileControl',
'userInfoControl',
'officialWebsiteCase',
'officialWebsiteNews',
'officialWebsiteDetail',
'officialWebsiteProduct',
'officialWebsiteBanner',
'deviceManage',
'videoManage',],
activeNames1: [3,2],
routerNow: 'realTime',
deviceName: 1,
routerIndex: 1,
equipmentList: [],
userInfo: null,
loading: true,//页面加载
IDTimer: null,
deviceId: '',
limitUserId: [],
statusData: [],
roleId:2,
mainData:null,
}
},
computed:{
headerList(){
var topMenu=[
{ name: this.$t('index.realTimeData'), router: 'realTime', routerList: ['realTime'], img: require('../assets/image/header-img1.png') },
// { name: '设定值参数', router: 'status', index: 1, routerList: ['formula', 'irrigateSet', 'PIDSet', 'systemSet', 'upload', 'sensorSet'], img: require('../assets/image/header-img0.png') },
{ name:this.$t('index.setParams') , router: 'status', index: 1, routerList: ['formula', 'status', 'exitSettings', 'skylight', 'systemSet-con', 'fan', 'upload-con', 'sensorSet-con', 'alarmSettings', 'synthesis-con', 'waterPump', 'geothermalFan', 'uptake', 'downtake', 'rollByRoll', 'snowRemoval', "targetTemperature", "targetHumidity", "targetCo2", "sunroofControl", "outsizeSunshade", "insizeSunshade", "wetFan", "LED", 'electromagneticControl', "coercionMist", "circulationCan", "internalInsulation", "forceOutput", "intrinsicParameter", "parameterSet",], img: require('../assets/image/header-img0.png') },
{ name:this.$t('index.galleryData'), router: 'imageData', routerList: ['imageData'], img: require('../assets/image/header-img1.png') },
{ name:this.$t('index.videoMonitor'), router: 'videoMonitoring', routerList: ['videoMonitoring'], img: require('../assets/image/header-img2.png') },
// history history
{ name:this.$t('index.historyData'), router: 'historyData', index: 1, routerList: ['historyData'], img: require('../assets/image/header-img3.png') },
//dataAnalysis dataAnalysis
{ name:this.$t('index.dataAnalysis'), router: 'dataAnalysis', index: 1, routerList: ['dataAnalysis'], img: require('../assets/image/header-img4.png') },
// { name: '设备菜单', router: '', routerList: [], img: require('../assets/image/header-img5.png') },
//systemManage systemManage
// manage
{ name:this.$t('index.management'), router: 'manage', routerList: ['manage','dataDevice','deviceStatusSet','officialWebsiteBanner','officialWebsiteProduct','officialWebsiteCase','officialWebsiteDetail','officialWebsiteNews','deviceSet','deviceInfoManage','weatherData','mobileControl','userInfoControl','deviceManage','videoManage'], img: require('../assets/image/header-img6.png') },
{ name:this.$t('index.bigData') , router: 'largeScreen', routerList: ['largeScreen'], img: require('../assets/image/header-img8.png') }
]
const foundObject = this.limitUserId.find(item => item.id == 3);
const foundName =topMenu.findIndex(item => item.name == this.$t('index.qrTrace'));
if (foundObject) {
if (foundName == -1) {
topMenu.push({ name: this.$t('index.qrTrace'), router: 'setsuyuan', index: 1, routerList: ['setsuyuan'], img: require('../assets/image/header-img4.png') })
}
} else {
if (foundName != -1) {
topMenu.splice(foundName, 1)
}
}
return topMenu
},
leftList1(){
// 普通管理左侧
var baseMenu= [
{ name: this.$t('index.mgmt'), img: require('../assets/image/index-icon.png'), list: [], router: 'manage', isRouter: true, },
{ name: this.$t('index.userMgmt'), routerList: [''], img: require('../assets/image/left-img0.png'), list: [
{deviceTypeName:this.$t('index.deviceStatusConfig'),router:'deviceStatusSet',index:0},
{deviceTypeName:this.$t('index.deviceSetConfig'),router:'deviceSet',index:1},
{deviceTypeName:this.$t('index.deviceInfoMgmt'),router:'deviceInfoManage',index:2},
{deviceTypeName:this.$t('index.weatherBinding'),router:'weatherData',index:3},
{deviceTypeName:this.$t('index.bigDataDevice'),router:'dataDevice',index:4},
{deviceTypeName:this.$t('index.mobileControl'),router:'mobileControl',index:5},
] },]
// 管理员的管理页面左侧
var adminMenu=[
{ name: this.$t('index.adminMgmt'), routerList: [''], img: require('../assets/image/left-img0.png'), list: [
{deviceTypeName:this.$t('index.userControl'),router:'userInfoControl',index:6},
{deviceTypeName:this.$t('index.deviceControl'),router:'deviceManage',index:7},
{deviceTypeName:this.$t('index.websiteBanner'),router:'officialWebsiteBanner',index:8},
{deviceTypeName:this.$t('index.websiteProducts'),router:'officialWebsiteProduct',index:11},
{deviceTypeName:this.$t('index.websiteCases'),router:'officialWebsiteCase',index:9},
{deviceTypeName:this.$t('index.companyProfile'),router:'officialWebsiteDetail',index:12},
{deviceTypeName:this.$t('index.websiteNews'),router:'officialWebsiteNews',index:10},
// {deviceTypeName:'摄像头信息管理',router:'videoManage',index:8},
] },
]
if (this.roleId === 1) {
return [...baseMenu, ...adminMenu];
}else{
return baseMenu
}
}
},
watch: {
"$route"(newName, oldName) {
this.gerRouter();
var store = this.$store.state
if (!store.equipmentName) {
this.getByid()
}
},
'$i18n.locale'() {
this.initLeftList()
}
},
mounted() {
const that = this
this.getTime()
var router = this.$route.query
if (router.token && router.userid) {
this.deviceId = router.deviceId ? router.deviceId : ''
localStorage.setItem('token', router.token)
this.api.getUser({ userId: router.userid }).then(res => {
var data = res.data.data
data.userid = router.userid
localStorage.setItem('userInfo', JSON.stringify(data))
this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
this.gerRouter();
this.getEqbyid(true)
})
return
} else {
if (localStorage.getItem('token')) {
this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
}
this.gerRouter();
this.getEqbyid(true)
}
this.IDTimer && clearInterval(this.IDTimer)
this.IDTimer = setInterval(() => {
that.getEqbyid(false)
}, 120000);
// 获取用户id权限
this.get_user_getjurisdiction()
//获取用户身份
this.getRole()
},
created(){
this.initLeftList()
},
beforeDestroy() {
this.IDTimer && clearInterval(this.IDTimer)
},
methods: {
initLeftList() {
this.leftList = [
{ name: this.$t('index.home'), img: require('../assets/image/index-icon.png'), list: [], router: 'realTime', isRouter: true, },
{ name: this.$t('index.greenhouse'), routerList: ['realTime', 'dataAnalysis', 'historyData','air-conditioning', 'exitSettings', 'videoMonitoring','imageData', 'skylight', 'control', 'systemSet-con', 'fan', 'upload-con', 'sensorSet-con', 'synthesis-con', 'alarmSettings', 'waterPump', 'geothermalFan', 'uptake', 'downtake', 'rollByRoll', 'snowRemoval', "targetTemperature", "targetHumidity", "targetCo2", "sunroofControl", "outsizeSunshade", "insizeSunshade", "wetFan", "LED", 'electromagneticControl', "coercionMist", "circulationCan", "internalInsulation", "forceOutput", "intrinsicParameter", "parameterSet"], img: require('../assets/image/left-img0.png'), list: [] },
// { name: '二号温室', img: require('../assets/image/left-img1.png'), list: [] },
{ name: this.$t('index.fertigation'), routerList: ['status-soil','formula', 'dataAnalysis', 'historyData', 'irrigateSet', 'videoMonitoring','imageData', 'PIDSet', 'systemSet', 'upload', 'sensorSet', 'realTime', 'history', 'dataAnalysis'], img: require('../assets/image/left-img2.png'), list: [] },
{ name:this.$t('index.smartIrrigation') , routerList: ['realTime', 'dataAnalysis', 'historyData','irrigateSet-soil', 'videoMonitoring','imageData','PIDSet-soil', 'systemSet-soil', 'upload-soil', 'sensorSet-soil', 'realTime', 'history', 'dataAnalysis'], img: require('../assets/image/irrigateSet-icon1-act.png'), list: [] },
{ name:this.$t('index.dataCollector') , routerList: ['realTime', 'historyData', 'exitSettings', 'skylight', 'control', 'systemSet-con','imageData', 'fan', 'upload-con', 'sensorSet-con', 'synthesis-con', 'alarmSettings', 'waterPump', 'geothermalFan', 'uptake', 'downtake', 'rollByRoll', 'snowRemoval', "targetTemperature", "targetHumidity", "targetCo2", "sunroofControl", "outsizeSunshade", "insizeSunshade", "wetFan", "LED", 'electromagneticControl', "coercionMist", "circulationCan", "internalInsulation", "forceOutput", "intrinsicParameter", "parameterSet"], img: require('../assets/image/left-img3.png'), list: [] },
{ name:this.$t('index.weatherStation') , routerList: ['realTime', 'historyData', 'exitSettings', 'skylight', 'control', 'systemSet-con','imageData', 'fan', 'upload-con', 'sensorSet-con', 'synthesis-con', 'alarmSettings', 'waterPump', 'geothermalFan', 'uptake', 'downtake', 'rollByRoll', 'snowRemoval', "targetTemperature", "targetHumidity", "targetCo2", "sunroofControl", "outsizeSunshade", "insizeSunshade", "wetFan", "LED", 'electromagneticControl', "coercionMist", "circulationCan", "internalInsulation", "forceOutput", "intrinsicParameter", "parameterSet"], img: require('../assets/image/left-img3.png'), list: [] },
{ name:this.$t('index.pestMonitor') , routerList: ['insectPestDetail'], img: require('../assets/image/index-icon1.png'), list: [] },
]
setTimeout(() => {
this.leftListInit1()
this.leftListInit2()
}, 0);
},
getRole(){
// var user= JSON.parse(localStorage.getItem('userInfo'))
// this.api.selUserbyid(user.userid).then(res=>{
// if(res.data.code==200){
// }
// })
},
// 获取用户id权限
get_user_getjurisdiction() {
let userInfo = localStorage.getItem("userInfo") ? JSON.parse(localStorage.getItem("userInfo")) : { userid: -1 };
let userId = userInfo.userid
this.api.user_getjurisdiction(userId).then(res => {
if (res.data.code == 200) {
this.limitUserId = res.data.data;
const foundObject = this.limitUserId.find(item => item.id == 3);
const foundName = this.headerList.findIndex(item => item.name == this.$t('index.qrTrace'));
if (foundObject) {
if (foundName == -1) {
this.headerList.push({ name: this.$t('index.qrTrace'), router: 'setsuyuan', index: 1, routerList: ['setsuyuan'], img: require('../assets/image/header-img4.png') })
}
} else {
if (foundName != -1) {
this.headerList.splice(foundName, 1)
}
}
// 是长兴前卫柑桔新优品种扩繁基地 有虫情页面
const foundObject13 = this.limitUserId.find(item => item.id == 13);
if (foundObject13) {
this.getbugzhaodi_login()
}
}
})
},
// 虫情登录
getbugzhaodi_login(){
var userInfo = localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : { userid: -1 }
// this.api.bugzhaodi_login().then(res=>{
// console.log(res,11);
// if(res.data.data.code==200&&res.data){
// localStorage.setItem("CQtoken", res.data.data.data.token);
// localStorage.setItem("CQuserName", JSON.stringify(res.data.data.data.userName));
// }
// })
var data={"pageNum": 1,
"pageSize": 10,
"imei":""}
this.api.getDeviceList(data).then(res1=>{
if(res1.data.code==200){
console.log(res1.data.data.data.list);
var list= res1.data.data.data.list.map(item => {
return {
...item,
deviceId: item.id,
userId: userInfo.userid,
deviceTypeName: item.deviceName,
index: 99,
router: 'insectPest',
deviceName: '99',
deviceState:item.isOnline,
isRouter:true
};
})
this.leftList[6].list =list
}
})
},
//获取设备名称/配方名称
getByid() {
var store = this.$store.state
var data = {
deviceId: store.equipmentList[store.equipmentIndex - 1].deviceId,
};
this.api.getByid(data).then((res) => {
if (res.data.code == 200) {
store.equipmentName = res.data.data
} else {
this.$message.error(res.data.msg);
}
this.loading = false
});
},
//排序
compare(property) {
return function (a, b) {
let value1 = a[property];
let value2 = b[property];
return value1 - value2;
};
},
// 根据deviceName获取router
deviceNameRouter(deviceName){
if(deviceName==1){
return 'formula'
}else if(deviceName==10){
return 'control'
}else if(deviceName==20){
return 'soil'
}else{
return 'formula'
}
},
getQibenGeticcid(){
const store = this.$store.state
var data=this.devicesList.map(device => ({
deviceId: device.deviceId,
iccid: device.iccidcode,
deviceName: device.deviceTypeName
}));
var iccidList=[]
var userInfo = localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : { userid: -1 }
this.api.popupwindow({userId:userInfo.userid}).then(res1=>{
data.forEach((el,index)=>{
if(this.validateIccid(el.iccid)){
this.api.qibenGeticcid(el).then(res=>{
if(res.data.code==200&&res.data.data){
iccidList.push(res.data.data)
this.$store.state.iccidList=iccidList
if(res1.data.data&&res.data.data.expired){
setTimeout(() => {
this.$notify({
title: this.$t('index.notification'),
dangerouslyUseHTMLString: true,
message: this.$t('index.cardExpiryWarning', {
deviceName: res.data.data.deviceName,
iccid: res.data.data.iccid,
daysDifference: res.data.data.daysDifference
}),
duration:60000,//10s自动关闭
});
}, 10);
}
}
})
}
})
})
},
// 判断iccid是否显示
validateIccid(iccidcode) {
// 如果 iccidcode 是 false严格判断排除 0、"" 等情况)
if (!iccidcode) {
return false;
}
// 如果 iccidcode 不是字符串,先转为字符串(防止数字 0 等情况)
const str = String(iccidcode);
// 检测是否全为 0
const isAllZeros = /^0+$/.test(str);
// 检测是否包含中文Unicode 范围:\u4e00-\u9fa5
const hasChinese = /[\u4e00-\u9fa5]/.test(str);
// 如果全为 0 或包含中文,返回 false
if (isAllZeros || hasChinese) {
return false;
}
// 其他情况返回 true表示有效
return true;
},
leftListInit1(){
this.leftList[1].list = []
this.leftList[2].list = []
this.leftList[3].list = []
this.leftList[4].list = []
this.leftList[5].list = []
this.$store.state.equipmentList.forEach((el, index) => {
//链接中的deviceId
if (this.deviceId && this.deviceId == el.deviceId) {
this.$store.state.equipmentIndex = index + 1
}
if (el.deviceName == 1) {
this.leftList.forEach((el1, index1) => {
if (el1.name ==this.$t('index.fertigation') ) {
this.leftList[index1].list.push(el)
}
})
} else if (el.deviceName == 10) {
this.leftList.forEach((el1, index1) => {
if (el1.name ==this.$t('index.greenhouse') ) {
this.leftList[index1].list.push(el)
}
})
} else if (el.deviceName == 20) {
this.leftList.forEach((el1, index1) => {
if (el1.name == this.$t('index.smartIrrigation')) {
this.leftList[index1].list.push(el)
}
})
}else if (el.deviceName == 40) {
this.leftList.forEach((el1, index1) => {
if (el1.name == this.$t('index.dataCollector')) {
this.leftList[index1].list.push(el)
}
})
}
// else if (el.deviceName == 30) {
// this.leftList.forEach((el1, index1) => {
// if (el1.name == '生态气象站') {
// this.leftList[index1].list.push(el)
// }
// })
// }
})
},
leftListInit2(){
this.$store.state.equipmentList.forEach((el, index) => {
if (el.deviceName == '30') {
this.leftList.forEach((el1, index1) => {
if (el1.name ==this.$t('index.weatherStation') ) {
this.leftList[index1].list.push(el)
}
})
}
})
this.leftList.forEach((el1, index1) => {
if (el1.name ==this.$t('index.greenhouse') ) {
this.leftList[index1].list.sort(this.compare('equipmentStatu'))
}
if (el1.name ==this.$t('index.fertigation') ) {
this.leftList[index1].list.sort(this.compare('equipmentStatu'))
}
if (el1.name == this.$t('index.smartIrrigation')) {
this.leftList[index1].list.sort(this.compare('equipmentStatu'))
}
if (el1.name ==this.$t('index.weatherStation') ) {
this.leftList[index1].list.sort(this.compare('equipmentStatu'))
}
if (el1.name == this.$t('index.dataCollector')) {
this.leftList[index1].list.sort(this.compare('equipmentStatu'))
}
})
},
//获取设备
getEqbyid(selTrue) {
const that = this
var userInfo = localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : { userid: -1 }
var store = this.$store.state
this.api.selUserbyid(userInfo.userid).then((res) => {
if (res.data.code == 200) {
var data=res.data.data.devices
this.devicesList=res.data.data.devices
if(selTrue){
this.getQibenGeticcid(data)
}
this.$store.state.equipmentList =data.map((item, index) => {
return {
...item,
router: that.deviceNameRouter(item.deviceName),
index: index + 1,
};
});
if (!localStorage.getItem('equipmentSelList')) {
localStorage.setItem('equipmentSelList', JSON.stringify(data))
// this.$store.state.equipmentSelList=res.data.data
}
this.leftListInit1()
this.api.geteqetdata(userInfo.userid).then((res) => {
if (res.data.code == 200) {
var list = this.$store.state.equipmentList
this.$store.state.equipmentList = list.concat(res.data.data.map(function (item, index) {
return {
deviceId: item.deviceId,
userId: item.userId,
deviceTypeName: item.deviceName,
index: list[list.length - 1].index + index + 1,
router: that.deviceNameRouter(item.deviceName),
deviceName: '30'
};
}))
this.leftListInit2()
this.gerRouter()
this.getByid()
var data = {
deviceId: store.equipmentList[store.equipmentIndex - 1].deviceId,
};
this.api.getControlGetState(data).then(res => {
if (res.data.code == 200) {
this.statusData = res.data.data;
}
})
}
})
this.roleId=res.data.data.roleId
this.mainData=res.data.data.project
}
})
},
gerRouter() {
var store = this.$store.state
this.routerIndex = this.$route.query.index ? this.$route.query.index : store.equipmentIndex
this.routerNow = this.$route.name;
if (store.equipmentList.length) {
this.deviceName = store.equipmentList[this.routerIndex - 1].deviceName
} else {
}
},
loginOut() {
this.api.loginOut().then((res) => {
if (res.data.code == 200) {
this.$message({
message:this.$t('index.logoutSuccess'),
type: "success",
});
localStorage.removeItem('token')
localStorage.removeItem('userInfo')
localStorage.removeItem('equipmentSelList')
this.$router.push({ name: 'login' })
} else {
this.$message.error(this.$t('index.requestError'));
}
})
},
toHome() {
this.$router.push({ name: 'home' })
},
toRouter(item) {
if (item.router) {
// 是虫情
if(this.routerNow == 'insectPestDetail'||this.routerNow == 'insectPestImageList'){
this.$message(this.$t('index.noPageForDevice', {device: this.$t('index.pestDevice')}));
return
}
if (item.http) {
window.location.href = item.http;
} else if (item.router == 'formula' && this.$route.query.index != item.index) {
this.$store.state.equipmentIndex = item.index
this.$router.push({ path: `/${item.router}?id=${item.index ? item.index : 1}` })
} else if (item.router == 'history' && this.$route.query.index != item.index) {
this.$router.push({ path: `/history?index=${item.index ? item.index : 1}` })
} else if (item.router == 'dataAnalysis' && this.$route.query.index != item.index) {
this.$router.push({ path: `/dataAnalysis` })
} else if (item.router == 'status') {
if (this.deviceName == '30') {
this.$message(this.$t('index.noPageForDevice', {device: this.$t('index.weatherStation')}));
return
}
if (this.deviceName == '40') {
this.$message(this.$t('index.noPageForDevice', {device: this.$t('index.dataCollector')}));
return
}
if (this.deviceName == '10') {
this.$router.push({ path: `/control` })
} else if(this.deviceName == '20'){
this.$router.push({ path: `/soil` })
} else {
this.$router.push({ path: `/formula` })
}
} else if (item.router == 'realTime') {
this.$router.push({ path: `/realTime` })
} else if (item.router == 'videoMonitoring') {
if (this.deviceName == '30') {
this.$message(this.$t('index.noPageForDevice', {device: this.$t('index.weatherStation')}));
return
}
this.$router.push({ path: `/videoMonitoring` })
} else if (item.router == 'status' && item.routerList.indexOf(this.routerNow) != -1) {
return
} else if (item.router == 'largeScreen') {
// item.id == 2 东北;
// item.id == 1 丽水;
// item.id == 5 石门;
// 进入大屏的权限目前是写死的 等于几能进 反之显示没权限
const foundObject = this.limitUserId.find(item => item.id == 2 || item.id == 1 || item.id == 5|| item.id == 7|| item.id == 8|| item.id == 9|| item.id == 10|| item.id == 11 || item.id == 12|| item.id == 13);
if (!foundObject) {
this.$message(this.$t('index.noPermission'));
return
} else {
this.$router.push({ name: item.router })
}
} else if (item.router != this.routerNow && !item.http) {
this.$router.push({ name: item.router })
}
} else {
this.$message(this.$t('index.pageDeveloping'));
}
},
toRouter1(item) {
if (item.router) {
if (item.http) {
window.location.href = item.http;
}else if(item.isRouter){
// 虫情页面逻辑
if(item.deviceName=='99'){
this.$router.push({ path: item.router,query:{id:item.deviceId} })
}else{
this.$router.push({ path: item.router })
}
} else if ( this.$route.query.index != item.index) {
if (this.routerNow == 'realTime'||item.router=='realTime') {
this.$store.state.equipmentIndex = item.index
this.$router.push({ path: `/realTime?index=${item.index ? item.index : 1}&name=${item.deviceName? item.deviceName : 1}` })
} else if (this.routerNow == 'history'||this.routerNow == 'dataAnalysis'||this.routerNow == 'historyData'||this.routerNow == 'imageData') {
this.$store.state.equipmentIndex = item.index
this.$router.push({ path: `/${this.routerNow}?index=${item.index ? item.index : 1}` })
}
else if (this.routerNow == 'videoMonitoring') {
this.$store.state.equipmentIndex = item.index
this.routerIndex = item.index
// this.$router.push({ path: `/videoMonitoring?index=${item.index ? item.index : 1}` })
} else {
if (item.deviceName == 10) {
// 控制器跳转
// 限制页面随意跳转
this.$store.state.equipmentIndex = item.index
this.routerIndex = item.index
if (this.routerNow != 'skylight' && this.leftList[1].routerList.indexOf(this.$route.name) != -1) {
return
}
this.$router.push({ path: `/control?change=${item.index}` })
} else if (item.deviceName == 1 ) {
// 施肥机跳转
if(this.routerNow == 'irrigateSet'){
this.$store.state.equipmentIndex = item.index
this.routerIndex = item.index
}else{
this.$store.state.equipmentIndex = item.index
this.routerIndex = item.index
this.$router.push({ path: `/irrigateSet?change=${item.index}` })
}
} else if (item.deviceName == 20 ) {
// 智能灌溉s
if(this.routerNow == 'irrigateSet-soil'){
this.$store.state.equipmentIndex = item.index
this.routerIndex = item.index
}else{
this.$store.state.equipmentIndex = item.index
this.routerIndex = item.index
this.$router.push({ path: `/irrigateSet-soil?change=${item.index}` })
}
}
else if (item.deviceName == 30) {
this.$message(this.$t('index.noPageForDevice', {device: this.$t('index.weatherStation')}));
} else if (item.deviceName == 40) {
this.$message(this.$t('index.noPageForDevice', {device: this.$t('index.dataCollector')}));
}
}
} else if ( this.$route.query.index == item.index) {
return
} else if (item.router != this.routerNow && !item.http) {
this.$router.push({ name: item.router })
}
} else {
this.$message(this.$t('index.pageDeveloping'));
}
},
toRouter2(item){
if (item.router != this.routerNow && !item.http) {
this.$router.push({ name: item.router })
}
},
getTime() {
this.time = getnowtime()
const that = this
setInterval(() => {
that.time = getnowtime()
}, 1000);
},
changeLanguage() {
const newLang = this.currentLanguage === 'zh' ? 'en' : 'zh'
changeLanguage(newLang, this)
this.$forceUpdate()
this.currentLanguage = newLang
},
},
}
</script>
<style lang="scss"></style>