diff --git a/src/components/header.vue b/src/components/header.vue index 5e291153..0635519b 100644 --- a/src/components/header.vue +++ b/src/components/header.vue @@ -65,6 +65,7 @@ export default { message: "退出成功", type: "success", }); + localStorage.clear(); //this.$store.commit("REMOVE_INFO"); this.$router.push("/login"); // console.log(this.$cookies.get("Admin-Token")); diff --git a/src/main.js b/src/main.js index 5c574c43..93452ead 100644 --- a/src/main.js +++ b/src/main.js @@ -33,15 +33,15 @@ Vue.config.productionTip = false; //使用钩子函数对路由进行权限跳转 router.beforeEach((to, from, next) => { document.title = `${to.meta.title} | 状态监测数据汇集系统`; - next(); - // const token = localStorage.getItem("token"); - // if (!token && to.path !== "/login") { - // next({ - // path: "/login", - // }); - // } else { - // next(); - // } + //next(); + const token = localStorage.getItem("token"); + if (!token && to.path !== "/login") { + next({ + path: "/login", + }); + } else { + next(); + } }); new Vue({ diff --git a/src/views/dataReport/index.vue b/src/views/dataReport/index.vue index 126235c6..71590d7e 100644 --- a/src/views/dataReport/index.vue +++ b/src/views/dataReport/index.vue @@ -395,7 +395,7 @@ export default { this.currentId = data.id; this.page = 1; this.pageSize = 20; - // this.handleSearch(); + //this.handleSearch(); //获取数据时间 this.getAllTimeTable(); }, @@ -547,14 +547,20 @@ export default { getDetailTable(id, dayval, stime, eTime) { console.log(id, stime, eTime); this.tableLoading = true; - getDetailApi({ + // 创建一个空对象来存储API的参数 + const apiParams = { id: id, - numPerDay: dayval, startTime: stime, endTime: eTime, pageNum: this.page, pageSize: this.pageSize, - }) + }; + + // 如果dayval不等于-1,则添加numPerDay参数 + if (dayval !== -1) { + apiParams.numPerDay = dayval; + } + getDetailApi(apiParams) .then((res) => { console.log(res); if (res.success) { @@ -583,6 +589,7 @@ export default { } }) .catch((err) => { + this.tableLoading = false; console.log(err); //代码错误、请求失败捕获 }); }, diff --git a/src/views/equipment/monitoring/index.vue b/src/views/equipment/monitoring/index.vue index 86d861aa..025687c6 100644 --- a/src/views/equipment/monitoring/index.vue +++ b/src/views/equipment/monitoring/index.vue @@ -223,7 +223,7 @@ export default { }, getmonitoringAllList() { this.monitoringLoading = true; - monitoringListApi({ pageNum: this.page - 1, pageSize: this.pageSize }) + monitoringListApi({ pageNum: this.page, pageSize: this.pageSize }) .then((res) => { console.log(res); this.monitoringTableData = res.data.content; diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 7eecf6ae..83fe70ad 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -99,6 +99,7 @@ export default { if (res.success) { console.log(res.data); //this.$router.push("/weather"); + localStorage.setItem("token", "13747c96ff9f434cb09ecf78e4b9a8bc"); this.$message({ duration: 1500, showClose: true,