From 3fd7594de051120e0f9ba5df7c4518112d3f61eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E8=90=8C?= <525441437@qq.com> Date: Fri, 22 Dec 2023 15:42:29 +0800 Subject: [PATCH] 1 --- src/views/HomeView.vue | 1 + src/views/index.vue | 93 ++++++++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 96391ba..2ba9257 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -40,6 +40,7 @@ export default { }, watch: { "$route.name"(newName, oldName) { + console.log(newName,oldName); this.gerRouter(); }, }, diff --git a/src/views/index.vue b/src/views/index.vue index 73aa793..8b8da2a 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -62,7 +62,7 @@ export default { headerList: [ { name: '实时数据', 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: '设定值参数', router: 'status', index: 1, routerList: ['status','skylight', 'fan','upload-con','sensorSet-con','waterPump','geothermalFan','uptake','downtake','rollByRoll','snowRemoval'], img: require('../assets/image/header-img0.png') }, + { name: '设定值参数', router: 'status', index: 1, routerList: ['status', 'skylight', 'fan', 'upload-con', 'sensorSet-con', 'waterPump', 'geothermalFan', 'uptake', 'downtake', 'rollByRoll', 'snowRemoval'], img: require('../assets/image/header-img0.png') }, { name: '设备菜单', router: '', routerList: [], img: require('../assets/image/header-img1.png') }, { name: '视频监控', router: '', routerList: [], img: require('../assets/image/header-img2.png') }, // history history @@ -72,14 +72,14 @@ export default { { name: '设备菜单', router: '', routerList: [], img: require('../assets/image/header-img5.png') }, //systemManage systemManage { name: '管理', router: '', routerList: [''], img: require('../assets/image/header-img6.png') }, - + { name: '大数据', router: 'largeScreen', routerList: ['largeScreen'], img: require('../assets/image/header-img8.png') } ], - + activeNames: [3], leftList: [ { name: '首页', img: require('../assets/image/index-icon.png'), list: [], router: 'realTime', isRouter: true, }, - { name: '温室', routerList: ['realTime', 'skylight', 'control','fan','upload-con','sensorSet-con','synthesis-con','waterPump','geothermalFan','uptake','downtake','rollByRoll','snowRemoval'], img: require('../assets/image/left-img0.png'), list: [] }, + { name: '温室', routerList: ['realTime', 'skylight', 'control', 'fan', 'upload-con', 'sensorSet-con', 'synthesis-con', 'waterPump', 'geothermalFan', 'uptake', 'downtake', 'rollByRoll', 'snowRemoval'], img: require('../assets/image/left-img0.png'), list: [] }, // { name: '二号温室', img: require('../assets/image/left-img1.png'), list: [] }, { name: '施肥机', routerList: ['formula', 'irrigateSet', 'PIDSet', 'systemSet', 'upload', 'sensorSet', 'realTime', 'history', 'dataAnalysis'], img: require('../assets/image/left-img2.png'), list: [] },], routerNow: 'realTime', @@ -89,8 +89,8 @@ export default { userInfo: null, loading: true,//页面加载 IDTimer: null, - deviceId:'', - limitUserId:[] + deviceId: '', + limitUserId: [] } }, watch: { @@ -103,7 +103,7 @@ export default { this.getTime() var router = this.$route.query if (router.token && router.userid) { - this.deviceId=router.deviceId?router.deviceId:'' + this.deviceId = router.deviceId ? router.deviceId : '' localStorage.setItem('token', router.token) this.api.getUser({ userId: router.userid }).then(res => { @@ -137,22 +137,22 @@ export default { // 获取用户id权限 get_user_getjurisdiction() { let userInfo = JSON.parse(localStorage.getItem("userInfo")); - let userId = userInfo.userid + 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 == '二维码追溯'); - if(foundObject){ - if(foundName==-1){ + if (foundObject) { + if (foundName == -1) { this.headerList.push({ name: '二维码追溯', router: 'setsuyuan', index: 1, routerList: ['setsuyuan'], img: require('../assets/image/header-img4.png') }) } - }else{ - if(foundName!=-1){ - this.headerList.splice(foundName,1) + } else { + if (foundName != -1) { + this.headerList.splice(foundName, 1) } } - + } }) @@ -176,12 +176,12 @@ export default { }, //排序 compare(property) { - return function (a, b) { - let value1 = a[property]; - let value2 = b[property]; - return value1 - value2; - }; -}, + return function (a, b) { + let value1 = a[property]; + let value2 = b[property]; + return value1 - value2; + }; + }, //获取设备 getEqbyid() { var userInfo = JSON.parse(localStorage.getItem('userInfo')) @@ -198,8 +198,8 @@ export default { this.leftList[2].list = [] this.$store.state.equipmentList.forEach((el, index) => { //链接中的deviceId - if(this.deviceId&&this.deviceId==el.deviceId){ - this.$store.state.equipmentIndex = index+1 + if (this.deviceId && this.deviceId == el.deviceId) { + this.$store.state.equipmentIndex = index + 1 } if (el.deviceName == 1) { this.leftList.forEach((el1, index1) => { @@ -216,12 +216,12 @@ export default { } }) this.leftList.forEach((el1, index1) => { - if (el1.name == '温室') { - this.leftList[index1].list.sort(this.compare('equipmentStatu')) - } - if (el1.name == '施肥机') { - this.leftList[index1].list.sort(this.compare('equipmentStatu')) - } + if (el1.name == '温室') { + this.leftList[index1].list.sort(this.compare('equipmentStatu')) + } + if (el1.name == '施肥机') { + this.leftList[index1].list.sort(this.compare('equipmentStatu')) + } }) this.gerRouter() this.getByid() @@ -230,15 +230,15 @@ export default { }) }, gerRouter() { - var store=this.$store.state + 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{ + if (store.equipmentList.length) { + this.deviceName = store.equipmentList[this.routerIndex - 1].deviceName + } else { } - + }, loginOut() { this.api.loginOut().then((res) => { @@ -276,16 +276,19 @@ export default { } else if (this.routerNow == 'realTime' && item.router == 'status' && this.deviceName == '10') { this.$router.push({ path: `/control` }) } else if (item.router == 'realTime') { - + this.$router.push({ path: `/realTime` }) - } else if (item.router == 'status'&&item.routerList.indexOf(this.routerNow)!=-1) { - - return + } else if (item.router == 'status' && item.routerList.indexOf(this.routerNow) != -1) { + + return + + } else if (item.router == 'largeScreen') { + const foundObject = this.limitUserId.find(item => item.id == 2); + if (!foundObject) return this.$message('您当前没有权限查看!') + + } else if (item.router != this.routerNow && !item.http) { - } else if (item.router != this.routerNow && !item.http) { - const foundObject = this.limitUserId.find(item => item.id == 2); - if( !foundObject) return this.$message('您当前没有权限查看!') this.$router.push({ name: item.router }) } } else { @@ -299,24 +302,24 @@ export default { } else if (item.router == 'formula' && this.$route.query.index != item.index) { if (this.routerNow == 'realTime') { - this.$store.state.equipmentIndex = item.index + this.$store.state.equipmentIndex = item.index this.$router.push({ path: `/realTime?index=${item.index ? item.index : 1}&name=${item.deviceName}` }) } else if (this.routerNow == 'formula') { this.$store.state.equipmentIndex = item.index this.$router.push({ path: `/formula?index=${item.index ? item.index : 1}` }) } else if (this.routerNow == 'history') { - this.$store.state.equipmentIndex = item.index + this.$store.state.equipmentIndex = item.index this.$router.push({ path: `/history?index=${item.index ? item.index : 1}` }) } else if (this.routerNow == 'dataAnalysis') { - this.$store.state.equipmentIndex = item.index + this.$store.state.equipmentIndex = item.index this.$router.push({ path: `/dataAnalysis?index=${item.index ? item.index : 1}` }) } else if (item.router == 'formula') { this.$store.state.equipmentIndex = item.index - this.routerIndex=item.index + this.routerIndex = item.index if (item.deviceName == 10) { this.$router.push({ path: `/skylight?change=${item.index}` }) - } else if (item.deviceName == 1&&this.routerNow!='irrigateSet') { + } else if (item.deviceName == 1 && this.routerNow != 'irrigateSet') { this.$router.push({ path: `/irrigateSet?change=${item.index}` }) } }