From 08d2852c99d71a7d76f1fa330f6b14838b68ee00 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期一, 02 十二月 2024 11:41:30 +0800
Subject: [PATCH] 调整预约小票打印位置

---
 src/permission.ts |  115 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 71 insertions(+), 44 deletions(-)

diff --git a/src/permission.ts b/src/permission.ts
index 748c7d4..d0bfdfd 100644
--- a/src/permission.ts
+++ b/src/permission.ts
@@ -6,8 +6,10 @@
 import { useNProgress } from '@/hooks/web/useNProgress'
 import { usePageLoading } from '@/hooks/web/usePageLoading'
 import { useDictStoreWithOut } from '@/store/modules/dict'
+import { useCheckTypeStoreWithOut } from '@/store/modules/checkType'
 import { useUserStoreWithOut } from '@/store/modules/user'
 import { usePermissionStoreWithOut } from '@/store/modules/permission'
+import { useRoomStoreWithOut } from "@/store/modules/room";
 
 const { start, done } = useNProgress()
 
@@ -53,58 +55,83 @@
   '/auth-redirect',
   '/bind',
   '/register',
-  '/oauthLogin/gitee'
+  '/oauthLogin/gitee',
+  '/calling-screen-big',
+  '/calling-screen-room'
 ]
 
 // 璺敱鍔犺浇鍓�
 router.beforeEach(async (to, from, next) => {
+  console.info("router.beforeEach to: " + to.fullPath + " from: " + from.fullPath)
   start()
   loadStart()
-  if (getAccessToken()) {
-    if (to.path === '/login') {
-      next({ path: '/' })
-    } else {
-      // 鑾峰彇鎵�鏈夊瓧鍏�
-      const dictStore = useDictStoreWithOut()
-      const userStore = useUserStoreWithOut()
-      const permissionStore = usePermissionStoreWithOut()
-      if (!dictStore.getIsSetDict) {
-        await dictStore.setDictMap()
-      }
-      if (!userStore.getIsSetUser) {
-        isRelogin.show = true
-        await userStore.setUserInfoAction()
-        isRelogin.show = false
-        // 鍚庣杩囨护鑿滃崟
-        await permissionStore.generateRoutes()
-        permissionStore.getAddRouters.forEach((route) => {
-          router.addRoute(route as unknown as RouteRecordRaw) // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛�
-        })
 
-        // 鏂板銆愯瘖瀹ら�夋嫨銆戦�昏緫
-        if (userStore.getRoles.includes("doctor") && !userStore.getIsSetRoom ) {
-          next({path: `/roomselect?redirect=${to.fullPath}`})
-        }
-        // <<<銆愯瘖瀹ら�夋嫨銆�<<<
-        else {
-          const redirectPath = from.query.redirect || to.path
-          // 淇璺宠浆鏃朵笉甯﹀弬鏁扮殑闂
-          const redirect = decodeURIComponent(redirectPath as string)
-          const {paramsObject: query} = parseURL(redirect)
-          const nextData = to.path === redirect ? {...to, replace: true} : {path: redirect, query}
-          next(nextData)
-        }
-      } else {
-        next()
-      }
-    }
-  } else {
-    if (whiteList.indexOf(to.path) !== -1) {
-      next()
-    } else {
-      next(`/login?redirect=${to.fullPath}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤�
-    }
+  if (whiteList.indexOf(to.path) !== -1) {
+    next()
+    return
   }
+
+  if (!getAccessToken()) {
+    next(`/login?redirect=${to.fullPath}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤�
+    return
+  }
+
+  if (to.path === '/login') {
+    next({ path: '/' })
+    return
+  }
+
+  // 鑾峰彇鎵�鏈夊瓧鍏�
+  const dictStore = useDictStoreWithOut()
+  const userStore = useUserStoreWithOut()
+  const roomStore = useRoomStoreWithOut()
+  const checkTypeStore = useCheckTypeStoreWithOut()
+  const permissionStore = usePermissionStoreWithOut()
+  if (!dictStore.getIsSetDict) {
+    await dictStore.setDictMap()
+  }
+  if (!checkTypeStore.getIsSetCheckType) {
+    await checkTypeStore.setCheckTypeMap()
+  }
+
+  if (userStore.getIsSetUser ) {
+
+      // <<<銆愯瘖瀹ら�夋嫨銆�<<<
+      if ( to.path !== '/roomselect' &&
+          userStore.getRoles.includes("doctor") && !userStore.getRoles.includes("super_admin")
+          && !roomStore.getIsSetRoom ) {
+          next({path: `/roomselect?redirect=${to.fullPath}`})
+          return
+      }
+
+      next()
+      return
+  }
+
+  isRelogin.show = true
+  await userStore.setUserInfoAction()
+  isRelogin.show = false
+
+  // 鍚庣杩囨护鑿滃崟
+  await permissionStore.generateRoutes()
+  permissionStore.getAddRouters.forEach((route) => {
+    router.addRoute(route as unknown as RouteRecordRaw) // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛�
+  })
+
+  // <<<銆愯瘖瀹ら�夋嫨銆�<<<
+  if ( to.path !== '/roomselect' &&
+      userStore.getRoles.includes("doctor") && !userStore.getRoles.includes("super_admin")
+      && !roomStore.getIsSetRoom ) {
+    next({path: `/roomselect?redirect=${to.fullPath}`})
+    return
+  }
+
+  const redirectPath = from.query.redirect || to.path
+  // 淇璺宠浆鏃朵笉甯﹀弬鏁扮殑闂
+  const redirect = decodeURIComponent(redirectPath as string)
+  const {paramsObject: query} = parseURL(redirect)
+  const nextData = to.path === redirect ? {...to, replace: true} : {path: redirect, query}
+  next(nextData)
 })
 
 router.afterEach((to) => {

--
Gitblit v1.9.3