This commit is contained in:
shijing 2022-07-15 17:16:14 +08:00
commit 90f9fcc2ca
3 changed files with 148 additions and 95 deletions

View File

@ -277,7 +277,6 @@ export default {
// delete reqData[config.request.pageSize]
}
Object.assign(reqData, this.tableParams);
debugger;
try {
var res = await this.apiObj.req(reqData);
if (this.hidePagination) {

View File

@ -32,8 +32,8 @@ const routes = [
"path": "/home",
"meta": {
"title": "首页",
"icon": "el-icon-house",
"type": "menu"
"icon": "el-icon-home-filled",
"type": "menu",
},
"children": [
{
@ -41,8 +41,8 @@ const routes = [
"path": "/dashboard",
"meta": {
"title": "控制台",
"icon": "el-icon-menu",
"affix": true
"icon": "el-icon-monitor",
"affix": true,
},
"component": "home"
},
@ -51,7 +51,7 @@ const routes = [
"path": "/bigScreen",
"meta": {
"title": "驾驶舱",
"icon": "el-icon-platform",
"icon": "el-icon-position",
"fullpage": true
},
"component": "bigScreen"
@ -72,8 +72,8 @@ const routes = [
"path": "/ecm",
"meta": {
"title": "事件",
"icon": "el-icon-goods",
"type": "menu"
"icon": "el-icon-goods-filled",
"type": "menu",
},
"children": [
{
@ -81,9 +81,10 @@ const routes = [
"path": "/ecm/event",
"meta": {
"title": "事件列表",
"icon": "el-icon-menu",
"icon": "el-icon-document",
"perms": ["event"]
},
"component": "ecm/event"
"component": "ecm/event",
}
,
{
@ -112,7 +113,7 @@ const routes = [
"path": "/ecm/myevent",
"meta": {
"title": "我的事件",
"icon": "el-icon-menu",
"icon": "el-icon-document-remove",
},
"component": "ecm/myevent"
},
@ -121,7 +122,7 @@ const routes = [
"path": "/ecm/notify_setting",
"meta": {
"title": "提醒配置",
"icon": "el-icon-menu",
"icon": "el-icon-setting",
},
"component": "ecm/notify_setting"
},
@ -131,7 +132,7 @@ const routes = [
"path": "/ecm/algo",
"meta": {
"title": "算法配置",
"icon": "el-icon-menu",
"icon": "el-icon-setting",
},
"component": "ecm/algo"
}
@ -142,7 +143,7 @@ const routes = [
"path": "/wf",
"meta": {
"title": "工单",
"icon": "el-icon-goods",
"icon": "el-icon-circle-check-filled",
"type": "menu"
},
"children": [
@ -151,7 +152,7 @@ const routes = [
"path": "/wf/workflow",
"meta": {
"title": "工作流",
"icon": "el-icon-menu",
"icon": "el-icon-guide",
},
"component": "wf/workflow"
},
@ -171,7 +172,7 @@ const routes = [
"path": "/wf/allwork",
"meta": {
"title": "全部工单",
"icon": "el-icon-menu",
"icon": "el-icon-folder",
},
"component": "wf/allwork"
@ -181,7 +182,7 @@ const routes = [
"path": "/wf/ownerwork",
"meta": {
"title": "我创建的",
"icon": "el-icon-menu",
"icon": "el-icon-folder-add",
},
"component": "wf/ownerwork"
@ -193,7 +194,7 @@ const routes = [
"path": "/wf/dutywork",
"meta": {
"title": "待办工单",
"icon": "el-icon-menu",
"icon": "el-icon-folder-opened",
},
"component": "wf/dutywork"
@ -203,7 +204,7 @@ const routes = [
"path": "/wf/worked",
"meta": {
"title": "我处理的",
"icon": "el-icon-menu",
"icon": "el-icon-expand",
},
"component": "wf/worked"
@ -213,7 +214,7 @@ const routes = [
"path": "/wf/ccwork",
"meta": {
"title": "抄送我的",
"icon": "el-icon-menu",
"icon": "el-icon-edit-pen",
},
"component": "wf/ccwork"
@ -238,7 +239,7 @@ const routes = [
"path": "/opm",
"meta": {
"title": "作业",
"icon": "el-icon-goods",
"icon": "el-icon-list",
"type": "menu"
},
"children": [
@ -247,7 +248,7 @@ const routes = [
"path": "/opm/operation",
"meta": {
"title": "作业列表",
"icon": "el-icon-menu",
"icon": "el-icon-tickets",
},
"component": "opm/operation"
},
@ -256,11 +257,10 @@ const routes = [
"path": "/opm/oplcate",
"meta": {
"title": "许可证分类",
"icon": "el-icon-menu",
"icon": "el-icon-ticket",
},
"component": "opm/oplcate"
},
,
{
"name": "opl",
"path": "/opm/opl",
@ -271,7 +271,6 @@ const routes = [
},
"component": "opm/opl"
},
,
{
"name": "fire",
"path": "/opm/fire",
@ -282,7 +281,6 @@ const routes = [
},
"component": "opm/fire"
},
,
{
"name": "space",
"path": "/opm/space",
@ -293,7 +291,6 @@ const routes = [
},
"component": "opm/space"
},
,
{
"name": "clear",
"path": "/opm/clear",
@ -344,7 +341,6 @@ const routes = [
},
"component": "opm/cooler"
},
,
{
"name": "soil",
"path": "/opm/soil",
@ -372,7 +368,7 @@ const routes = [
"path": "/rpm",
"meta": {
"title": "相关方",
"icon": "el-icon-goods",
"icon": "el-icon-avatar",
"type": "menu"
},
"children": [
@ -381,7 +377,7 @@ const routes = [
"path": "/rpm/rparty",
"meta": {
"title": "相关方列表",
"icon": "el-icon-menu",
"icon": "el-icon-tickets",
},
"component": "rpm/rparty"
},
@ -390,7 +386,7 @@ const routes = [
"path": "/rpm/remployee",
"meta": {
"title": "相关方人员",
"icon": "el-icon-menu",
"icon": "el-icon-user",
},
"component": "rpm/remployee"
},
@ -399,7 +395,7 @@ const routes = [
"path": "/rpm/rcertificate",
"meta": {
"title": "人员证书",
"icon": "el-icon-menu",
"icon": "el-icon-postcard",
},
"component": "rpm/rcertificate"
},
@ -408,7 +404,7 @@ const routes = [
"path": "/rpm/rfile",
"meta": {
"title": "资料库",
"icon": "el-icon-menu",
"icon": "el-icon-shopping-bag",
},
"component": "rpm/rfile"
},
@ -417,7 +413,7 @@ const routes = [
"path": "/rpm/rpj",
"meta": {
"title": "入厂项目",
"icon": "el-icon-menu",
"icon": "el-icon-calendar",
},
"component": "rpm/rpj"
},
@ -439,7 +435,7 @@ const routes = [
"path": "/vm",
"meta": {
"title": "访客",
"icon": "el-icon-goods",
"icon": "el-icon-user-filled",
"type": "menu"
},
"children": [
@ -448,7 +444,7 @@ const routes = [
"path": "/vm/visit",
"meta": {
"title": "来访项目",
"icon": "el-icon-menu",
"icon": "el-icon-tickets",
},
"component": "vm/visit"
},
@ -457,7 +453,7 @@ const routes = [
"path": "/vm/visitor",
"meta": {
"title": "来访人员",
"icon": "el-icon-menu",
"icon": "el-icon-user",
},
"component": "vm/visitor"
},{
@ -489,7 +485,7 @@ const routes = [
"path": "/am",
"meta": {
"title": "区域",
"icon": "el-icon-goods",
"icon": "el-icon-location-filled",
"type": "menu"
},
"children": [
@ -498,7 +494,7 @@ const routes = [
"path": "/am/area",
"meta": {
"title": "区域列表",
"icon": "el-icon-menu",
"icon": "el-icon-tickets",
},
"component": "am/area"
},
@ -507,7 +503,7 @@ const routes = [
"path": "/am/eqm",
"meta": {
"title": "门禁通道",
"icon": "el-icon-menu",
"icon": "el-icon-phone",
},
"component": "am/em1"
},
@ -516,7 +512,7 @@ const routes = [
"path": "/am/monitor",
"meta": {
"title": "视频通道",
"icon": "el-icon-menu",
"icon": "el-icon-video-camera",
},
"component": "am/monitor"
},
@ -525,7 +521,7 @@ const routes = [
"path": "/am/audio",
"meta": {
"title": "喇叭通道",
"icon": "el-icon-menu",
"icon": "el-icon-mic",
},
"component": "am/audio"
},{
@ -533,7 +529,7 @@ const routes = [
"path": "/am/blt",
"meta": {
"title": "定位标签",
"icon": "el-icon-menu",
"icon": "el-icon-map-location",
},
"component": "am/blt"
},
@ -544,7 +540,7 @@ const routes = [
"path": "/hrm",
"meta": {
"title": "人事",
"icon": "el-icon-user",
"icon": "el-icon-platform",
"type": "menu"
},
"children": [
@ -554,7 +550,7 @@ const routes = [
"path": "/hrm/employee",
"meta": {
"title": "企业员工",
"icon": "el-icon-menu",
"icon": "el-icon-user",
},
"component": "hrm/employee"
}
@ -564,7 +560,7 @@ const routes = [
"path": "/hrm/certificates",
"meta": {
"title": "证书列表",
"icon": "el-icon-menu",
"icon": "el-icon-tickets",
},
"component": "hrm/certificates"
}
@ -587,7 +583,7 @@ const routes = [
"path": "/sys",
"meta": {
"title": "系统",
"icon": "el-icon-setting",
"icon": "el-icon-tools",
"type": "menu"
},
"children": [
@ -658,8 +654,9 @@ const routes = [
"path": "/ops",
"meta": {
"title": "运维",
"icon": "el-icon-user",
"type": "menu"
"icon": "el-icon-wallet-filled",
"type": "menu",
"perms": ["ops"]
},
"children": [
{
@ -668,6 +665,7 @@ const routes = [
"meta": {
"title": "菜单管理",
"icon": "el-icon-fold",
"perms": ["menu"]
},
"component": "ops/menu"
},
@ -677,6 +675,7 @@ const routes = [
"meta": {
"title": "请求日志",
"icon": "el-icon-fold",
"perms": ["log"]
},
"component": "ops/log_request"
},
@ -686,6 +685,7 @@ const routes = [
"meta": {
"title": "第三方日志",
"icon": "el-icon-fold",
"perms": ["third_log"]
},
"component": "ops/thirdLogs"
},
@ -695,6 +695,7 @@ const routes = [
"meta": {
"title": "文件日志",
"icon": "el-icon-fold",
"perms": ["file_log"]
},
"component": "ops/files"
},

View File

@ -1,4 +1,4 @@
import {createRouter, createWebHashHistory} from 'vue-router';
import { createRouter, createWebHashHistory } from 'vue-router';
import { ElNotification } from 'element-plus';
import config from "@/config"
import NProgress from 'nprogress'
@ -6,7 +6,7 @@ import 'nprogress/nprogress.css'
import tool from '@/utils/tool';
import systemRouter from './systemRouter';
import userRoutes from '@/config/route';
import {beforeEach, afterEach} from './scrollBehavior';
import { beforeEach, afterEach } from './scrollBehavior';
//系统路由
const routes = systemRouter
@ -17,7 +17,7 @@ const routes_404 = {
hidden: true,
component: () => import(/* webpackChunkName: "404" */ '@/layout/other/404'),
}
let routes_404_r = ()=>{}
let routes_404_r = () => { }
const router = createRouter({
history: createWebHashHistory(),
@ -38,7 +38,7 @@ router.beforeEach(async (to, from, next) => {
let token = tool.cookie.get("TOKEN");
if(to.path === "/login"){
if (to.path === "/login") {
//删除路由(替换当前layout路由)
router.addRoute(routes[0])
//删除路由(404)
@ -48,12 +48,12 @@ router.beforeEach(async (to, from, next) => {
return false;
}
if(routes.findIndex(r => r.path === to.path) >= 0){
if (routes.findIndex(r => r.path === to.path) >= 0) {
next();
return false;
}
if(!token){
if (!token) {
next({
path: '/login'
});
@ -61,18 +61,20 @@ router.beforeEach(async (to, from, next) => {
}
//整页路由处理
if(to.meta.fullpage){
to.matched = [to.matched[to.matched.length-1]]
if (to.meta.fullpage) {
to.matched = [to.matched[to.matched.length - 1]]
}
//加载动态/静态路由
if(!isGetRouter){
if (!isGetRouter) {
// let apiMenu = tool.data.get("MENU") || []
debugger;
let userInfo = tool.data.get("USER_INFO");
let permissions = tool.data.get("PERMISSIONS");
let userMenu = treeFilter(userRoutes, node => {
return node.meta.perms ? node.meta.perms.filter(item=>userInfo.perms.indexOf(item)>-1).length > 0 : true
});
let userMenu = userRoutes;
if (permissions.indexOf('superuser') == -1) {
userMenu = treeFilter(userRoutes, node => {
return node.meta.perms ? node.meta.perms.filter(item => permissions.indexOf(item) > -1).length > 0 : true
});
}
// let userMenu = checkRoute(userRoutes, permissions)
// let menu = [...userMenu, ...apiMenu]
var menuRouter = filterAsyncRouter(userMenu);
menuRouter = flatAsyncRoutes(menuRouter);
@ -80,8 +82,7 @@ router.beforeEach(async (to, from, next) => {
router.addRoute("layout", item)
});
routes_404_r = router.addRoute(routes_404);
debugger;
if (to.matched.length ==0||permissions[0]==='superuser') {
if (to.matched.length == 0) {
router.push(to.fullPath);
}
isGetRouter = true;
@ -106,10 +107,14 @@ router.onError((error) => {
//入侵追加自定义方法、对象
router.sc_getMenu = () => {
// var apiMenu = tool.data.get("MENU") || []
let userInfo = tool.data.get("USER_INFO")
let userMenu = treeFilter(userRoutes, node => {
return node.meta.perms ? node.meta.perms.filter(item=>userInfo.perms.indexOf(item)>-1).length > 0 : true
})
let permissions = tool.data.get("PERMISSIONS");
let userMenu = userRoutes;
if (permissions.indexOf('superuser') == -1) {
userMenu = treeFilter(userRoutes, node => {
return node.meta.perms ? node.meta.perms.filter(item => permissions.indexOf(item) > -1).length > 0 : true
});
}
// let userMenu = checkRoute(userRoutes, permissions)
// var menu = [...userMenu, ...apiMenu]
return userMenu
}
@ -118,9 +123,9 @@ router.sc_getMenu = () => {
function filterAsyncRouter(routerMap) {
const accessedRouters = []
routerMap.forEach(item => {
item.meta = item.meta?item.meta:{};
item.meta = item.meta ? item.meta : {};
//处理外部链接特殊路由
if(item.meta.type=='iframe'){
if (item.meta.type == 'iframe') {
item.meta.url = item.path;
item.path = `/i/${item.name}`;
}
@ -137,39 +142,39 @@ function filterAsyncRouter(routerMap) {
})
return accessedRouters
}
function loadComponent(component){
if(component){
function loadComponent(component) {
if (component) {
return () => import(/* webpackChunkName: "[request]" */ `@/views/${component}`)
}else{
} else {
return () => import(`@/layout/other/empty`)
}
}
//路由扁平化
function flatAsyncRoutes(routes, breadcrumb=[]) {
function flatAsyncRoutes(routes, breadcrumb = []) {
let res = []
routes.forEach(route => {
const tmp = {...route}
if (tmp.children) {
let childrenBreadcrumb = [...breadcrumb]
childrenBreadcrumb.push(route)
let tmpRoute = { ...route }
tmpRoute.meta.breadcrumb = childrenBreadcrumb
delete tmpRoute.children
res.push(tmpRoute)
let childrenRoutes = flatAsyncRoutes(tmp.children, childrenBreadcrumb)
childrenRoutes.map(item => {
res.push(item)
})
} else {
let tmpBreadcrumb = [...breadcrumb]
tmpBreadcrumb.push(tmp)
tmp.meta.breadcrumb = tmpBreadcrumb
res.push(tmp)
}
})
return res
const tmp = { ...route }
if (tmp.children) {
let childrenBreadcrumb = [...breadcrumb]
childrenBreadcrumb.push(route)
let tmpRoute = { ...route }
tmpRoute.meta.breadcrumb = childrenBreadcrumb
delete tmpRoute.children
res.push(tmpRoute)
let childrenRoutes = flatAsyncRoutes(tmp.children, childrenBreadcrumb)
childrenRoutes.map(item => {
res.push(item)
})
} else {
let tmpBreadcrumb = [...breadcrumb]
tmpBreadcrumb.push(tmp)
tmp.meta.breadcrumb = tmpBreadcrumb
res.push(tmp)
}
})
return res
}
//过滤树
@ -180,4 +185,52 @@ function treeFilter(tree, func) {
})
}
function hasPerm(perms_need, perms_have) {
let has = false
for (var m = 0; m < perms_need.length; m++) {
if (perms_have.indexOf(perms_need[m]) > -1) {
has = true
}
}
return has
}
function checkRoute(routes, perms) {
if (perms.indexOf('superuser') > -1) {
return routes
}
for (var i = 0; i < routes.length; i++) {
if (routes[i].meta && routes[i].meta.perms) {
let has = hasPerm(routes[i].meta.perms, perms)
if (!has) {
routes.splice(i, 1)
}
else if (routes[i].children) {
for (var m = 0; m < routes[i].children.length; m++) {
let child = routes[i].children[m]
if (child.meta && child.meta.perms) {
let has = hasPerm(child.meta.perms, perms)
if (!has) {
routes[i].children.splice(m, 1)
}
}
}
}
}
else if (routes[i].children) {
for (var m = 0; m < routes[i].children.length; m++) {
let child = routes[i].children[m]
console.log(m, child)
if (child.meta && child.meta.perms) {
let has = hasPerm(child.meta.perms, perms)
if (!has) {
routes[i].children.splice(m, 1)
}
}
}
}
}
return routes
}
export default router