From 1446994d504819c367e1ff667360eadb314f9ac6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 18 十月 2026 16:52:18 +0800
Subject: [PATCH] 修改了诊室工号
---
src/permission.ts | 65 +++++++++++++++++++++++++++-----
1 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/src/permission.ts b/src/permission.ts
index ad7ab58..fcdd1b2 100644
--- a/src/permission.ts
+++ b/src/permission.ts
@@ -19,6 +19,56 @@
const { loadStart, loadDone } = usePageLoading()
+/**
+ * 銆岄�夋嫨宸ヤ綅妯″紡銆嶇殑璺宠浆鍒ゅ畾锛�0/1/2/3锛夈��
+ *
+ * - 0 鎸夐渶瑕佸己鍒堕�夋嫨宸ヤ綅锛氭湭鍏ュ骇 鈫� 寮哄埗鍘婚�夊伐浣嶉〉
+ * - 1 鐧诲綍IP鍖归厤宸ヤ綅锛氬厛鎸夋湰鏈篒P鑷姩鍖归厤骞惰嚜鍔ㄥ叆搴э紱鍖归厤涓嶅埌 鈫� 鎸� 0锛堝幓閫夊伐浣嶉〉锛屽甫鍘熷洜锛�
+ * - 2 鐧诲綍鏃舵墜鍔ㄩ�夋嫨宸ヤ綅锛氬己鍒跺幓閫夊伐浣嶉〉锛屽苟鍦ㄧ‘璁ゆ椂鎶婃湰鏈篒P鍐欏叆鎵�閫夊伐浣嶏紙鍐橧P鍦ㄩ�夊伐浣嶉〉閲屽仛锛�
+ * - 3 鎸夌郴缁熼粯璁ゅ鐞嗭細璇P鏈粦瀹氳繃宸ヤ綅 鈫� 鎸� 2锛堥�変竴娆″苟璁颁綇IP锛夛紱宸茬粦瀹� 鈫� 鎸� 1锛涘尮閰嶄笉鍒� 鈫� 鎸� 0
+ *
+ * @returns true 琛ㄧず宸叉斁琛岋紙鏃犻渶璺宠浆锛夛紝false 琛ㄧず宸茬粡鍙戣捣璺宠浆
+ */
+const checkRoomSelect = async (
+ to: { path: string; fullPath: string },
+ next: (v?: any) => void
+): Promise<boolean> => {
+ const userStore = useUserStoreWithOut()
+ const roomStore = useRoomStoreWithOut()
+
+ // 闈炲尰鐢熻鑹层�佹垨宸插叆搴� 鈫� 涓嶅共棰�
+ const isDoctor =
+ userStore.getRoles.includes('doctor') && !userStore.getRoles.includes('super_admin')
+ if (!isDoctor || roomStore.getIsSetRoom || to.path === '/roomselect') {
+ // 鐜板満鎺掓煡鐢細璇存槑"涓轰粈涔堣繖娆℃病鏈夎嚜鍔ㄥ叆搴�"锛坅dmin 绛夐潪鍖荤敓瑙掕壊鎸夎璁′笉鑷姩鍏ュ骇锛�
+ // 闇�瑕佺偣椤舵爮鐨勩�屾湭鍏ュ骇銆嶆爣绛捐繘閫夊伐浣嶉〉鎵嬪姩閫変竴娆★級
+ if (!isDoctor) {
+ console.info('[room] 褰撳墠瑙掕壊闈炲尰鐢燂紙roles=' + userStore.getRoles.join(',') + '锛夛紝璺宠繃鎸塈P鑷姩鍏ュ骇')
+ }
+ return true
+ }
+
+ const mode = await roomStore.loadRoomSelectMode()
+
+ // 妯″紡 1 / 3锛氬厛灏濊瘯鎸夋湰鏈篒P鑷姩鍖归厤骞惰嚜鍔ㄥ叆搴э紙鎴愬姛灏辩洿鎺ヨ繘锛�
+ if (mode === 1 || mode === 3) {
+ const res = await roomStore.tryAutoSeatByIp()
+ if (res.seated) {
+ return true
+ }
+ // 銆愪富/鍥磋路鏈闇�姹傘�戞病鑷姩鍏ュ骇涔�**涓嶅啀寮哄埗璺�"閫夊伐浣嶉〉"**锛�
+ // 鍏佽浠�"鏈叆搴� / 鍥磋"韬唤杩涘叆宸ヤ綔鍙帮紙鍙锛夛紝鐢卞伐浣滃彴椤堕儴鐨勩�屽伐浣嶃�嶄笅鎷�
+ // 閫夋嫨瑕佹煡鐪嬶紙鍥磋锛夋垨瑕佸叆搴х殑宸ヤ綅銆傝嫢涓�寰嬪脊鍥為�夊伐浣嶉〉锛屽氨姘歌繙鏃犳硶鍥磋鍒汉銆�
+ console.info('[room] 鏈嚜鍔ㄥ叆搴э紙' + (res.reason || 'nomatch') + '锛夛紝鎸�"鍙洿瑙�"鏀捐')
+ return true
+ }
+
+ // 妯″紡 0 / 2锛氬師鏉ュ己鍒跺幓閫夊伐浣嶉〉锛涙湰娆″悓鏍锋斁琛岋紝鐞嗙敱鍚屼笂锛堢敱椤堕儴涓嬫媺閫夋嫨宸ヤ綅锛夈��
+ // 閫夊伐浣嶉〉浠嶅彲浠庨《鏍忓伐浣嶆爣绛� / 椤堕儴涓嬫媺杩涘叆銆�
+ console.info('[room] 閫夋嫨宸ヤ綅妯″紡=' + mode + '锛氫笉寮哄埗璺抽�夊伐浣嶉〉锛屽厑璁歌繘鍏ュ悗鑷閫夋嫨/鍥磋')
+ return true
+}
+
const parseURL = (
url: string | null | undefined
): { basePath: string; paramsObject: { [key: string]: string } } => {
@@ -102,7 +152,6 @@
// 鑾峰彇鎵�鏈夊瓧鍏�
const dictStore = useDictStoreWithOut()
const userStore = useUserStoreWithOut()
- const roomStore = useRoomStoreWithOut()
const checkTypeStore = useCheckTypeStoreWithOut()
const permissionStore = usePermissionStoreWithOut()
if (!dictStore.getIsSetDict) {
@@ -114,11 +163,8 @@
if (userStore.getIsSetUser) {
- // <<<銆愯瘖瀹ら�夋嫨銆�<<<
- if (to.path !== '/roomselect' &&
- userStore.getRoles.includes("doctor") && !userStore.getRoles.includes("super_admin")
- && !roomStore.getIsSetRoom) {
- next({ path: `/roomselect?redirect=${to.fullPath}` })
+ // <<<銆愯瘖瀹ら�夋嫨銆戞寜銆岄�夋嫨宸ヤ綅妯″紡銆嶅弬鏁帮紙0/1/2/3锛夊喅瀹氭槸鍚﹀己鍒堕�夋嫨宸ヤ綅 >>>
+ if (!(await checkRoomSelect(to, next))) {
return
}
@@ -136,11 +182,8 @@
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}` })
+ // <<<銆愯瘖瀹ら�夋嫨銆戞寜銆岄�夋嫨宸ヤ綅妯″紡銆嶅弬鏁帮紙0/1/2/3锛夊喅瀹氭槸鍚﹀己鍒堕�夋嫨宸ヤ綅 >>>
+ if (!(await checkRoomSelect(to, next))) {
return
}
--
Gitblit v1.9.3