From 95b6a6388e4cc4e6ed0f54cc04212a86cd8cf829 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期五, 23 五月 2025 13:37:09 +0800 Subject: [PATCH] 1、用户管理新增和编辑用户时设置工单为必填项 2、新增终端登录、首页、设备点检、故障上报、上下班打卡、停机原因维护页面(未与后端联调且客户未确定页面设计)并调整全局路由守卫相关逻辑 3、调整设备结构树设备层级和车间层级区分的判断条件 4、调整电子样板检索与部件借用弹窗列表与搜索区域样式 --- src/permission.js | 90 +++++++++++++++++++++++++++------------------ 1 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/permission.js b/src/permission.js index fe8d825..ddd93e2 100644 --- a/src/permission.js +++ b/src/permission.js @@ -4,12 +4,12 @@ import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style import notification from 'ant-design-vue/es/notification' -import { ACCESS_TOKEN,INDEX_MAIN_PAGE_PATH, OAUTH2_LOGIN_PAGE_PATH } from '@/store/mutation-types' +import { ACCESS_TOKEN, INDEX_MAIN_PAGE_PATH, OAUTH2_LOGIN_PAGE_PATH } from '@/store/mutation-types' import { generateIndexRouter, isOAuth2AppEnv } from '@/utils/util' NProgress.configure({ showSpinner: false }) // NProgress Configuration -const whiteList = ['/user/login', '/user/register', '/user/register-result','/user/alteration'] // no redirect whitelist +const whiteList = ['/user/login', '/user/register', '/user/register-result', '/user/alteration', '/terminal/login'] // no redirect whitelist whiteList.push(OAUTH2_LOGIN_PAGE_PATH) router.beforeEach((to, from, next) => { @@ -21,8 +21,8 @@ to.matched.splice(2, to.matched.length - 3) } //update-end---author:scott ---date::2022-10-13 for锛歔jeecg-boot/issues/4091]澶氱骇璺敱缂撳瓨闂 #4091-------------- - - + + NProgress.start() // start progress bar if (Vue.ls.get(ACCESS_TOKEN)) { @@ -30,57 +30,75 @@ if (to.path === '/user/login' || to.path === OAUTH2_LOGIN_PAGE_PATH) { next({ path: INDEX_MAIN_PAGE_PATH }) NProgress.done() - } else { + } + else { if (store.getters.permissionList.length === 0) { store.dispatch('GetPermissionList').then(res => { - const menuData = res.result.menu; - //console.log(res.message) - if (menuData === null || menuData === "" || menuData === undefined) { - return; + const menuData = res.result.menu + //console.log(res.message) + if (menuData === null || menuData === '' || menuData === undefined) { + return + } + let constRoutes = [] + constRoutes = generateIndexRouter(menuData) + // 娣诲姞涓荤晫闈㈣矾鐢� + store.dispatch('UpdateAppRouter', { constRoutes }).then(() => { + // 鏍规嵁roles鏉冮檺鐢熸垚鍙闂殑璺敱琛� + // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛� + router.addRoutes(store.getters.addRouters) + const redirect = decodeURIComponent(from.query.redirect || to.path) + if (to.path === redirect) { + // hack鏂规硶 纭繚addRoutes宸插畬鎴� ,set the replace: true so the navigation will not leave a history record + next({ ...to, replace: true }) + } else { + // 璺宠浆鍒扮洰鐨勮矾鐢� + if (to.path !== '/terminal/login' && from.path !== '/terminal/login' && redirect.split('/')[1] === 'terminal') { + next({ path: '/terminal/login' }) + } else { + next({ path: redirect }) } - let constRoutes = []; - constRoutes = generateIndexRouter(menuData); - // 娣诲姞涓荤晫闈㈣矾鐢� - store.dispatch('UpdateAppRouter', { constRoutes }).then(() => { - // 鏍规嵁roles鏉冮檺鐢熸垚鍙闂殑璺敱琛� - // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛� - router.addRoutes(store.getters.addRouters) - const redirect = decodeURIComponent(from.query.redirect || to.path) - if (to.path === redirect) { - // hack鏂规硶 纭繚addRoutes宸插畬鎴� ,set the replace: true so the navigation will not leave a history record - next({ ...to, replace: true }) - } else { - // 璺宠浆鍒扮洰鐨勮矾鐢� - next({ path: redirect }) - } - }) - }) + } + }) + }) .catch(() => { - /* notification.error({ - message: '绯荤粺鎻愮ず', - description: '璇锋眰鐢ㄦ埛淇℃伅澶辫触锛岃閲嶈瘯锛�' - })*/ + /* notification.error({ + message: '绯荤粺鎻愮ず', + description: '璇锋眰鐢ㄦ埛淇℃伅澶辫触锛岃閲嶈瘯锛�' + })*/ store.dispatch('Logout').then(() => { next({ path: '/user/login', query: { redirect: to.fullPath } }) }) }) - } else { - next() + } + else { + // 璺宠浆鍒扮洰鐨勮矾鐢� + if (to.path !== '/terminal/login' && from.path !== '/' && from.path.split('/') [1] !== 'terminal' && to.path.split('/')[1] === 'terminal') { + next({ path: '/terminal/login' }) + } else { + next() + } } } - } else { + } + else { if (whiteList.indexOf(to.path) !== -1) { // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝濡傛灉杩涘叆鐨勯〉闈㈡槸login椤甸潰骞朵笖褰撳墠鏄疧Auth2app鐜锛屽氨杩涘叆OAuth2鐧诲綍椤甸潰 if (to.path === '/user/login' && isOAuth2AppEnv()) { - next({path: OAUTH2_LOGIN_PAGE_PATH}) + next({ path: OAUTH2_LOGIN_PAGE_PATH }) } else { // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆 next() } NProgress.done() - } else { + } + else { // 濡傛灉褰撳墠鏄湪OAuth2APP鐜锛屽氨璺宠浆鍒癘Auth2鐧诲綍椤甸潰 - let path = isOAuth2AppEnv() ? OAUTH2_LOGIN_PAGE_PATH : '/user/login' + let path + if (isOAuth2AppEnv()) path = OAUTH2_LOGIN_PAGE_PATH + else { + if (to.path.split('/')[1] !== 'terminal') path = '/user/login' + else path = '/terminal/login' + } next({ path: path, query: { redirect: to.fullPath } }) NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it } -- Gitblit v1.9.3