Commit 0bb327f5 authored by 纪泽龙's avatar 纪泽龙

大路由调整

parent a3303844
......@@ -37,6 +37,7 @@
<script>
import { constantRoutes } from "@/router";
import "../../common/font/font.css";
export default {
data() {
......@@ -47,6 +48,7 @@ export default {
isFrist: false,
// 当前激活菜单的 index
currentIndex: undefined,
myRouter: [],
};
},
computed: {
......@@ -133,7 +135,9 @@ export default {
},
// 菜单选择事件
handleSelect(key, keyPath) {
console.log(key)
console.log("key", key);
console.log("keypath", keyPath);
let path;
this.currentIndex = key;
if (this.ishttp(key)) {
// http(s):// 路径新窗口打开
......@@ -143,7 +147,18 @@ export default {
this.$router.push({ path: key.replace("/redirect", "") });
} else {
// 显示左侧联动菜单
this.activeRoutes(key);
path = this.activeRoutes(key);
if (this.$route.path != path[0].path) {
this.$router.push(path[0].path);
}
// if (key == "/enterprise") {
// // this.$store.commit("TOGGLE_DEVICE","mobile");
// this.$store.dispatch("app/toggleDevice", "mobile");
// } else {
// this.$store.dispatch("app/toggleDevice", "desktop");
// }
// TOGGLE_DEVICE
}
},
// 当前激活的路由
......@@ -156,9 +171,14 @@ export default {
}
});
}
// console.log(this.myRouter)
// console.log(this.myRouter)
if (routes.length > 0) {
this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
}
return routes;
},
ishttp(url) {
......
import store from '@/store'
import store from "@/store";
const { body } = document
const WIDTH = 992 // refer to Bootstrap's responsive design
const { body } = document;
const WIDTH = 992; // refer to Bootstrap's responsive design
export default {
watch: {
$route(route) {
if (this.device === 'mobile' && this.sidebar.opened) {
store.dispatch('app/closeSideBar', { withoutAnimation: false })
if (this.device === "mobile" && this.sidebar.opened) {
store.dispatch("app/closeSideBar", { withoutAnimation: false });
}
}
},
beforeMount() {
window.addEventListener('resize', this.$_resizeHandler)
window.addEventListener("resize", this.$_resizeHandler);
},
beforeDestroy() {
window.removeEventListener('resize', this.$_resizeHandler)
window.removeEventListener("resize", this.$_resizeHandler);
},
mounted() {
const isMobile = this.$_isMobile()
const isMobile = this.$_isMobile();
if (isMobile) {
store.dispatch('app/toggleDevice', 'mobile')
store.dispatch('app/closeSideBar', { withoutAnimation: true })
store.dispatch("app/toggleDevice", "mobile");
store.dispatch("app/closeSideBar", { withoutAnimation: true });
}
},
methods: {
// use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
$_isMobile() {
const rect = body.getBoundingClientRect()
return rect.width - 1 < WIDTH
const rect = body.getBoundingClientRect();
return rect.width - 1 < WIDTH;
},
$_resizeHandler() {
if (!document.hidden) {
const isMobile = this.$_isMobile()
store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop')
const isMobile = this.$_isMobile();
// console.log(this.$route.path)
// 当是gis地图的时候左边隐藏
if (this.$route.path == "/enterprise/mapView") {
store.dispatch("app/toggleDevice", "mobile");
} else {
store.dispatch("app/toggleDevice", isMobile ? "mobile" : "desktop");
}
if (isMobile) {
store.dispatch('app/closeSideBar', { withoutAnimation: true })
store.dispatch("app/closeSideBar", { withoutAnimation: true });
}
}
}
}
}
};
import router from './router'
import store from './store'
import { Message } from 'element-ui'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { getToken } from '@/utils/auth'
import router from "./router";
import store from "./store";
import { Message } from "element-ui";
import NProgress from "nprogress";
import "nprogress/nprogress.css";
import { getToken } from "@/utils/auth";
NProgress.configure({ showSpinner: false })
NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
const whiteList = ["/login", "/auth-redirect", "/bind", "/register"];
router.beforeEach((to, from, next) => {
NProgress.start()
NProgress.start();
if (getToken()) {
/* has token*/
if (to.path === '/login') {
next({ path: '/' })
NProgress.done()
if (to.path === "/login") {
next({ path: "/" });
NProgress.done();
} else {
if (store.getters.roles.length === 0) {
// 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(() => {
store.dispatch('GenerateRoutes').then(accessRoutes => {
store
.dispatch("GetInfo")
.then(() => {
store.dispatch("GenerateRoutes").then(accessRoutes => {
// 根据roles权限生成可访问的路由表
router.addRoutes(accessRoutes) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
})
}).catch(err => {
store.dispatch('LogOut').then(() => {
Message.error(err)
next({ path: '/' })
})
router.addRoutes(accessRoutes); // 动态添加可访问路由表
next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
});
})
.catch(err => {
store.dispatch("LogOut").then(() => {
Message.error(err);
next({ path: "/" });
});
});
} else {
next()
next();
}
}
} else {
// 没有token
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
next();
} else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
NProgress.done()
next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
NProgress.done();
}
}
})
});
router.afterEach(() => {
NProgress.done()
})
router.afterEach((to, from) => {
// console.log('全局后置钩子',to, from)
if (to.path == "/enterprise/mapView") {
store.dispatch("app/toggleDevice", "mobile");
} else {
store.dispatch("app/toggleDevice", "desktop");
}
NProgress.done();
});
......@@ -26,6 +26,7 @@ const mutations = {
},
TOGGLE_DEVICE: (state, device) => {
state.device = device
console.log(123)
},
SET_SIZE: (state, size) => {
state.size = size
......
......@@ -9,7 +9,8 @@ const permission = {
addRoutes: [],
defaultRoutes: [],
topbarRouters: [],
sidebarRouters: []
sidebarRouters: [],
mySidebarRouters:[],
},
mutations: {
SET_ROUTES: (state, routes) => {
......@@ -28,8 +29,10 @@ const permission = {
state.topbarRouters = routes.concat(index);
},
SET_SIDEBAR_ROUTERS: (state, routes) => {
state.sidebarRouters = routes
state.sidebarRouters = routes;
state.mySidebarRouters = routes;
},
},
actions: {
// 生成路由
......
......@@ -3,7 +3,7 @@
<div class="left">
<div class="top">
<span>设备报警最新记录</span>
<span class="repeat">刷新</span>
<span @click="repeatClick" class="repeat">刷新</span>
<span @click="moreClick" class="more">更多</span>
</div>
......@@ -23,15 +23,15 @@
style="width: 100%"
height="170"
>
<el-table-column prop="deviceCode" label="编号" width="120">
<el-table-column prop="deviceCode" label="编号" width="100">
</el-table-column>
<el-table-column prop="deviceName" label="名称" width="">
</el-table-column>
<el-table-column prop="alarmType" label="报警类型" width="">
<el-table-column prop="alarmType" label="报警类型" width="80">
</el-table-column>
<el-table-column prop="createTime" label="报警开始时间" width="">
<el-table-column prop="createTime" label="报警开始时间" width="170">
</el-table-column>
<el-table-column prop="alarmValue" label="报警内容" width="">
<el-table-column prop="alarmValue" label="报警内容" width="100">
</el-table-column>
</el-table>
</div>
......@@ -153,6 +153,9 @@ export default {
this.$router.push("/dataMonitoring/deviceAlarm");
// route.push(`dataMonitoring/deviceAlarm`)
},
repeatClick(){
this.getList();
},
getList() {
this.loading = true;
listDeviceAlarm({ pageNum: 1, pageSize: 10 }).then((res) => {
......@@ -196,7 +199,7 @@ export default {
& > div {
}
.left {
width: 778px;
width: 680px;
margin-right: 12px;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.16);
// background-color: #fff;
......
......@@ -94,7 +94,12 @@
</div>
</div>
<RightBototmData v-show="bottomDataShow" :class="{classShow:!bottomDataShow}" ref="RightBototmData" :list="rightBototmData" />
<RightBototmData
v-show="bottomDataShow"
:class="{ classShow: !bottomDataShow }"
ref="RightBototmData"
:list="rightBototmData"
/>
</div>
</template>
<script>
......@@ -168,9 +173,13 @@ export default {
keyWord: "",
// 右下角的数据data
rightBototmData: [],
bottomDataShow:true,
bottomDataShow: true,
};
},
created() {
// 让左边的框隐藏
this.$store.dispatch("app/toggleDevice", "mobile");
},
mounted() {
this.initMap();
},
......@@ -185,7 +194,6 @@ export default {
this.getPipeList();
// 右下角数据
this.rightBottomData();
},
// 右下角数据
async rightBottomData() {
......@@ -447,7 +455,7 @@ export default {
// 新建下拉列表关闭 window点击事件
barClose() {
// 一点windowbottomData显示
this.bottomDataShow=true;
this.bottomDataShow = true;
// return;
console.log("window");
this.deviceType = false;
......@@ -730,7 +738,7 @@ input[type="radio"] {
color: white;
background-color: #053b6a;
}
.classShow{
.classShow {
opacity: 0;
}
</style>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment