| | |
| | | |
| | | const { loadStart, loadDone } = usePageLoading() |
| | | |
| | | /** |
| | | * 「选择工位模式」的跳转判定(0/1/2/3)。 |
| | | * |
| | | * - 0 按需要强制选择工位:未入座 → 强制去选工位页 |
| | | * - 1 登录IP匹配工位:先按本机IP自动匹配并自动入座;匹配不到 → 按 0(去选工位页,带原因) |
| | | * - 2 登录时手动选择工位:强制去选工位页,并在确认时把本机IP写入所选工位(写IP在选工位页里做) |
| | | * - 3 按系统默认处理:该IP未绑定过工位 → 按 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') { |
| | | // 现场排查用:说明"为什么这次没有自动入座"(admin 等非医生角色按设计不自动入座, |
| | | // 需要点顶栏的「未入座」标签进选工位页手动选一次) |
| | | if (!isDoctor) { |
| | | console.info('[room] 当前角色非医生(roles=' + userStore.getRoles.join(',') + '),跳过按IP自动入座') |
| | | } |
| | | return true |
| | | } |
| | | |
| | | const mode = await roomStore.loadRoomSelectMode() |
| | | |
| | | // 模式 1 / 3:先尝试按本机IP自动匹配并自动入座(成功就直接进) |
| | | 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 } } => { |
| | |
| | | // 获取所有字典 |
| | | const dictStore = useDictStoreWithOut() |
| | | const userStore = useUserStoreWithOut() |
| | | const roomStore = useRoomStoreWithOut() |
| | | const checkTypeStore = useCheckTypeStoreWithOut() |
| | | const permissionStore = usePermissionStoreWithOut() |
| | | if (!dictStore.getIsSetDict) { |
| | |
| | | |
| | | 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 |
| | | } |
| | | |
| | |
| | | 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 |
| | | } |
| | | |