From 78e27b469fdf3894fb1c74ff750288f6e9a228ac Mon Sep 17 00:00:00 2001 From: dai <851733175@qq.com> Date: Fri, 5 Nov 2021 11:22:51 +0800 Subject: [PATCH] dfds --- src/assets/scss/main-shuju.scss | 1 + src/router/index.js | 525 ++++++++++----------- src/views/main-shuju/main.vue | 2 +- src/views/modules/visual/warning/index.vue | 525 +++++++++++++++++++++ 4 files changed, 788 insertions(+), 265 deletions(-) create mode 100644 src/views/modules/visual/warning/index.vue diff --git a/src/assets/scss/main-shuju.scss b/src/assets/scss/main-shuju.scss index 07f64577..7fbd5c19 100644 --- a/src/assets/scss/main-shuju.scss +++ b/src/assets/scss/main-shuju.scss @@ -346,6 +346,7 @@ body { } &:focus, &:hover { + color: #fff; background-color: transparent !important; .navbar__icon-menu { diff --git a/src/router/index.js b/src/router/index.js index 67824687..5f6e7ab7 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,115 +1,116 @@ -import Vue from 'vue' -import Router from 'vue-router' -import http from '@/utils/request' -import { - isURL -} from '@/utils/validate' -import store from '@/js/store' +import Vue from "vue"; +import Router from "vue-router"; +import http from "@/utils/request"; +import { isURL } from "@/utils/validate"; +import store from "@/js/store"; -Vue.use(Router) +Vue.use(Router); // 页面路由(独立页面) -export const pageRoutes = [{ - path: '/404', - component: () => import('@/views/pages/404'), - name: '404', +export const pageRoutes = [ + { + path: "/404", + component: () => import("@/views/pages/404"), + name: "404", meta: { - title: '404未找到' + title: "404未找到", }, beforeEnter(to, from, next) { // 拦截处理特殊业务场景 // 如果, 重定向路由包含__双下划线, 为临时添加路由 if (/__.*/.test(to.redirectedFrom)) { - return next(to.redirectedFrom.replace(/__.*/, '')) + return next(to.redirectedFrom.replace(/__.*/, "")); } - next() - } + next(); + }, }, { - path: '/login', - component: () => import('@/views/pages/login'), - name: 'login', + path: "/login", + component: () => import("@/views/pages/login"), + name: "login", meta: { - title: '登录' - } + title: "登录", + }, }, { - path: '/', - name: 'index', + path: "/", + name: "index", redirect: { - name: 'indexWork' + name: "indexWork", }, meta: { - title: '首页' - } + title: "首页", + }, }, { - path: '/indexWork', - component: () => import('@/views/pages/indexWork'), - name: 'indexWork', + path: "/indexWork", + component: () => import("@/views/pages/indexWork"), + name: "indexWork", meta: { - title: '工作端首页' - } - } -] + title: "工作端首页", + }, + }, +]; // 模块路由(基于主入口布局页面) export const moduleRoutes = { - path: '/main', - component: () => import('@/views/main'), - name: 'main', + path: "/main", + component: () => import("@/views/main"), + name: "main", redirect: { - name: 'home' + name: "home", }, meta: { - title: '主入口布局' + title: "主入口布局", }, - children: [{ - path: '/home', - component: () => import('@/views/modules/home'), - name: 'home', + children: [ + { + path: "/home", + component: () => import("@/views/modules/home"), + name: "home", meta: { - title: '主页', - isTab: true - } - } - ] -} + title: "主页", + isTab: true, + }, + }, + ], +}; // 模块路由(基于主入口布局页面) 可视化数据 export const moduleShujuRoutes = { - path: '/main-shuju', - component: () => import('@/views/main-shuju/main'), - name: 'main-shuju', + path: "/main-shuju", + component: () => import("@/views/main-shuju/main"), + name: "main-shuju", redirect: { - name: 'home2' + name: "home2", }, meta: { - title: '主入口布局' + title: "主入口布局", }, - children: [{ - path: '/home2', - component: () => import('@/views/modules/home'), - name: 'home2', + children: [ + { + path: "/home2", + component: () => import("@/views/modules/home"), + name: "home2", meta: { - title: '主页2', - isTab: true - } - } - ] -} + title: "主页2", + isTab: true, + }, + }, + ], +}; export function addDynamicRoute(routeParams, router) { // 组装路由名称, 并判断是否已添加, 如是: 则直接跳转 - var routeName = routeParams.routeName - var dynamicRoute = window.SITE_CONFIG['dynamicRoutes'].filter( + var routeName = routeParams.routeName; + var dynamicRoute = window.SITE_CONFIG["dynamicRoutes"].filter( (item) => item.name === routeName - )[0] + )[0]; if (dynamicRoute) { return router.push({ name: routeName, - params: routeParams.params - }) + params: routeParams.params, + }); } // 否则: 添加并全局变量保存, 再跳转 dynamicRoute = { @@ -117,161 +118,155 @@ export function addDynamicRoute(routeParams, router) { component: () => import(`@/views/modules/${routeParams.path}`), name: routeName, meta: { - ...window.SITE_CONFIG['contentTabDefault'], + ...window.SITE_CONFIG["contentTabDefault"], menuId: routeParams.menuId, - title: `${routeParams.title}` - } - } - router.addRoutes([{ - ...moduleRoutes, - name: `main-dynamic__${dynamicRoute.name}`, - children: [dynamicRoute] - }]) - window.SITE_CONFIG['dynamicRoutes'].push(dynamicRoute) + title: `${routeParams.title}`, + }, + }; + router.addRoutes([ + { + ...moduleRoutes, + name: `main-dynamic__${dynamicRoute.name}`, + children: [dynamicRoute], + }, + ]); + window.SITE_CONFIG["dynamicRoutes"].push(dynamicRoute); router.push({ name: dynamicRoute.name, - params: routeParams.params - }) + params: routeParams.params, + }); } const router = new Router({ - mode: 'hash', + mode: "hash", scrollBehavior: () => ({ - y: 0 + y: 0, }), - routes: pageRoutes.concat(moduleRoutes, moduleShujuRoutes) -}) + routes: pageRoutes.concat(moduleRoutes, moduleShujuRoutes), +}); router.beforeEach((to, from, next) => { // 添加动态(菜单)路由 // 已添加或者当前路由为页面路由, 可直接访问 if ( - window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || + window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] || fnCurrentRouteIsPageRoute(to, pageRoutes) ) { - return next() + return next(); } - const customerId = localStorage.getItem('customerId') - console.log('customerId:', customerId) - // if(customerId==='1e68188b8f7e9ab15658c164bd5b3676'){ - // // if(customerId==='45687aa479955f9d06204d415238f7cc'){ - // const menuList=[ - // { - // children: [], - // createdBy: "a76fc711807ac9827d7611b0f94ec220", - // createdTime: "2020-08-26 16:38", - // delFlag: null, - // icon: "icon-database", - // id: "abe812eb350f6b5eda575e268e50ac1c", - // name: "定制功能配置", - // parentName: null, - // permissions: "", - // pid: "0", - // resourceList: null, - // revision: 0, - // showFlag: 1, - // sort: 2, - // type: 0, - // updatedBy: "a76fc711807ac9827d7611b0f94ec220", - // updatedTime: "2020-09-02 14:49", - // url: "customer/customize/ConfigItem", - // }, - // { - // children: [], - // createdBy: "a76fc711807ac9827d7611b0f94ec220", - // createdTime: "2020-08-26 16:38", - // delFlag: null, - // icon: "icon-file-text", - // id: "8e55eba74c920c00c44c125e3bc73ddc", - // name: "居民端首页配置", - // parentName: null, - // permissions: "", - // pid: "0", - // resourceList: null, - // revision: 0, - // showFlag: 1, - // sort: 3, - // type: 0, - // updatedBy: "a76fc711807ac9827d7611b0f94ec220", - // updatedTime: "2020-09-02 14:49", - // url: "customer/customize/MiniHome", - // } - // ] - - // window.SITE_CONFIG['menuList'] = menuList - // fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList']) - // // next({ ...to, replace: true }) - // next({ ...to, replace: true }) - // }else{ - http - .get('/gov/access/menu/nav') - .then(({ - data: res - }) => { - if (res.code !== 0) { - // Vue.prototype.$message.error(res.msg) - return next({ - name: 'login' - }) - } - window.SITE_CONFIG['menuList'] = res.data - fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList']) - // next({ ...to, replace: true }) - next({ - ...to, - replace: true - }) - }) - .catch(() => { - next({ - name: 'login' - }) - }) - // } + const customerId = localStorage.getItem("customerId"); + console.log("customerId:", customerId); + // if(customerId==='1e68188b8f7e9ab15658c164bd5b3676'){ + // // if(customerId==='45687aa479955f9d06204d415238f7cc'){ + // const menuList=[ + // { + // children: [], + // createdBy: "a76fc711807ac9827d7611b0f94ec220", + // createdTime: "2020-08-26 16:38", + // delFlag: null, + // icon: "icon-database", + // id: "abe812eb350f6b5eda575e268e50ac1c", + // name: "定制功能配置", + // parentName: null, + // permissions: "", + // pid: "0", + // resourceList: null, + // revision: 0, + // showFlag: 1, + // sort: 2, + // type: 0, + // updatedBy: "a76fc711807ac9827d7611b0f94ec220", + // updatedTime: "2020-09-02 14:49", + // url: "customer/customize/ConfigItem", + // }, + // { + // children: [], + // createdBy: "a76fc711807ac9827d7611b0f94ec220", + // createdTime: "2020-08-26 16:38", + // delFlag: null, + // icon: "icon-file-text", + // id: "8e55eba74c920c00c44c125e3bc73ddc", + // name: "居民端首页配置", + // parentName: null, + // permissions: "", + // pid: "0", + // resourceList: null, + // revision: 0, + // showFlag: 1, + // sort: 3, + // type: 0, + // updatedBy: "a76fc711807ac9827d7611b0f94ec220", + // updatedTime: "2020-09-02 14:49", + // url: "customer/customize/MiniHome", + // } + // ] - // localStorage.getItem('customerId') - // 1e68188b8f7e9ab15658c164bd5b3676 + // window.SITE_CONFIG['menuList'] = menuList + // fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList']) + // // next({ ...to, replace: true }) + // next({ ...to, replace: true }) + // }else{ + http + .get("/oper/access/menu/nav") + .then(({ data: res }) => { + if (res.code !== 0) { + // Vue.prototype.$message.error(res.msg) + return next({ + name: "login", + }); + } + window.SITE_CONFIG["menuShujuList"] = [ + { + icon: "icon-setting", + id: "2", + name: "基础信息", + url: "visual/basicinfo/basicInfoMain", + }, + { + icon: "icon-setting", + id: "3", + name: "人员预警", + url: "visual/warning/index", + }, + ]; + fnAddDynamicMenuRoutes2(window.SITE_CONFIG["menuShujuList"]); + // next({ ...to, replace: true }) + next({ + ...to, + replace: true, + }); + }) + .catch(() => { + next({ + name: "login", + }); + }); - http - .get('/oper/access/menu/nav') - .then(({ - data: res - }) => { - if (res.code !== 0) { - // Vue.prototype.$message.error(res.msg) - return next({ - name: 'login' - }) - } - window.SITE_CONFIG['menuShujuList'] = [ - { - icon: "icon-setting", - id: "2", - name: "基础信息", - url: "shequ/index" - }, - { - icon: "icon-setting", - id: "3", - name: "人员预警", - url: "base/resi" - } - ] - fnAddDynamicMenuRoutes2(window.SITE_CONFIG['menuShujuList']) - // next({ ...to, replace: true }) - next({ - ...to, - replace: true - }) - }) - .catch(() => { - next({ - name: 'login' - }) - }) -}) + http + .get("/gov/access/menu/nav") + .then(({ data: res }) => { + if (res.code !== 0) { + // Vue.prototype.$message.error(res.msg) + return next({ + name: "login", + }); + } + window.SITE_CONFIG["menuList"] = res.data; + fnAddDynamicMenuRoutes(window.SITE_CONFIG["menuList"]); + // next({ ...to, replace: true }) + next({ + ...to, + replace: true, + }); + }) + .catch(() => { + next({ + name: "login", + }); + }); +}); /** * 判断当前路由是否为页面路由 @@ -279,16 +274,16 @@ router.beforeEach((to, from, next) => { * @param {*} pageRoutes 页面路由 */ function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { - var temp = [] + var temp = []; for (var i = 0; i < pageRoutes.length; i++) { if (route.path === pageRoutes[i].path) { - return true + return true; } if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) { - temp = temp.concat(pageRoutes[i].children) + temp = temp.concat(pageRoutes[i].children); } } - return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false + return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false; } /** @@ -297,107 +292,109 @@ function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { * @param {*} routes 递归创建的动态(菜单)路由 */ function fnAddDynamicMenuRoutes(menuList = [], routes = []) { - var temp = [] + var temp = []; for (var i = 0; i < menuList.length; i++) { if (menuList[i].children && menuList[i].children.length >= 1) { - temp = temp.concat(menuList[i].children) - continue + temp = temp.concat(menuList[i].children); + continue; } // 组装路由 var route = { - path: '', + path: "", component: null, - name: '', + name: "", meta: { - ...window.SITE_CONFIG['contentTabDefault'], + ...window.SITE_CONFIG["contentTabDefault"], menuId: menuList[i].id, - title: menuList[i].name - } - } + title: menuList[i].name, + }, + }; // eslint-disable-next-line - let URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => + let URL = (menuList[i].url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) => eval(s2) - ) // URL支持{{ window.xxx }}占位符变量 + ); // URL支持{{ window.xxx }}占位符变量 if (isURL(URL)) { - route['path'] = route['name'] = `i-${menuList[i].id}` - route['meta']['iframeURL'] = URL + route["path"] = route["name"] = `i-${menuList[i].id}`; + route["meta"]["iframeURL"] = URL; } else { - URL = URL.replace(/^\//, '').replace(/_/g, '-') - route['path'] = route['name'] = URL.replace(/\//g, '-') - route['component'] = () => import(`@/views/modules/${URL}`) + URL = URL.replace(/^\//, "").replace(/_/g, "-"); + route["path"] = route["name"] = URL.replace(/\//g, "-"); + route["component"] = () => import(`@/views/modules/${URL}`); } - routes.push(route) + routes.push(route); } if (temp.length >= 1) { - return fnAddDynamicMenuRoutes(temp, routes) + return fnAddDynamicMenuRoutes(temp, routes); } // 添加路由 - router.addRoutes([{ + router.addRoutes([ + { ...moduleRoutes, - name: 'main-dynamic-menu', - children: routes + name: "main-dynamic-menu", + children: routes, }, { - path: '*', + path: "*", redirect: { - name: '404' - } - } - ]) - window.SITE_CONFIG['dynamicMenuRoutes'] = routes - window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = true + name: "404", + }, + }, + ]); + window.SITE_CONFIG["dynamicMenuRoutes"] = routes; + window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] = true; } function fnAddDynamicMenuRoutes2(menuList = [], routes = []) { - var temp = [] + var temp = []; for (var i = 0; i < menuList.length; i++) { if (menuList[i].children && menuList[i].children.length >= 1) { - temp = temp.concat(menuList[i].children) - continue + temp = temp.concat(menuList[i].children); + continue; } // 组装路由 var route = { - path: '', + path: "", component: null, - name: '', + name: "", meta: { - ...window.SITE_CONFIG['contentTabDefault'], + ...window.SITE_CONFIG["contentTabDefault"], menuId: menuList[i].id, - title: menuList[i].name - } - } + title: menuList[i].name, + }, + }; // eslint-disable-next-line - let URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => + let URL = (menuList[i].url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) => eval(s2) - ) // URL支持{{ window.xxx }}占位符变量 + ); // URL支持{{ window.xxx }}占位符变量 if (isURL(URL)) { - route['path'] = route['name'] = `i-${menuList[i].id}` - route['meta']['iframeURL'] = URL + route["path"] = route["name"] = `i-${menuList[i].id}`; + route["meta"]["iframeURL"] = URL; } else { - URL = URL.replace(/^\//, '').replace(/_/g, '-') - route['path'] = route['name'] = URL.replace(/\//g, '-') - route['component'] = () => import(`@/views/modules/${URL}`) + URL = URL.replace(/^\//, "").replace(/_/g, "-"); + route["path"] = route["name"] = URL.replace(/\//g, "-"); + route["component"] = () => import(`@/views/modules/${URL}`); } - routes.push(route) + routes.push(route); } if (temp.length >= 1) { - return fnAddDynamicMenuRoutes2(temp, routes) + return fnAddDynamicMenuRoutes2(temp, routes); } // 添加路由 - router.addRoutes([{ + router.addRoutes([ + { ...moduleShujuRoutes, - name: 'main-dynamic-menu-shuju', - children: routes + name: "main-dynamic-menu-shuju", + children: routes, }, { - path: '*', + path: "*", redirect: { - name: '404' - } - } - ]) - window.SITE_CONFIG['dynamicMenuRoutesShuju'] = routes - window.SITE_CONFIG['dynamicMenuRoutesShujuHasAdded'] = true + name: "404", + }, + }, + ]); + window.SITE_CONFIG["dynamicMenuRoutesShuju"] = routes; + window.SITE_CONFIG["dynamicMenuRoutesShujuHasAdded"] = true; } -export default router \ No newline at end of file +export default router; diff --git a/src/views/main-shuju/main.vue b/src/views/main-shuju/main.vue index 731629bd..16bb29f3 100644 --- a/src/views/main-shuju/main.vue +++ b/src/views/main-shuju/main.vue @@ -154,4 +154,4 @@ export default { } - + diff --git a/src/views/modules/visual/warning/index.vue b/src/views/modules/visual/warning/index.vue new file mode 100644 index 00000000..4836d7ab --- /dev/null +++ b/src/views/modules/visual/warning/index.vue @@ -0,0 +1,525 @@ + + + + + + \ No newline at end of file