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

大路由调整

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