feature: Digitization Workstation UI

This commit is contained in:
voltsrage
2026-06-27 12:15:43 +08:00
parent 88e70b3dbe
commit e22d33b654
55 changed files with 6411 additions and 143 deletions
+92
View File
@@ -0,0 +1,92 @@
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import { useAuthStore, getDefaultRouteForRole } from '../stores/auth'
const routes: RouteRecordRaw[] = [
{
path: '/login',
name: 'Login',
component: () => import('../views/LoginView.vue'),
meta: { requiresAuth: false },
},
{
path: '/intake',
name: 'Intake',
component: () => import('../views/IntakeView.vue'),
meta: { requiresAuth: true, roles: ['INTAKE_CLERK', 'ADMINISTRATOR'] },
},
{
path: '/entry',
name: 'EntryQueue',
component: () => import('../views/EntryView.vue'),
meta: { requiresAuth: true, roles: ['DATA_ENTRY_CLERK', 'ADMINISTRATOR'] },
},
{
path: '/entry/:batchId',
name: 'EntryBatch',
component: () => import('../views/EntryView.vue'),
meta: { requiresAuth: true, roles: ['DATA_ENTRY_CLERK', 'ADMINISTRATOR'] },
props: true,
},
{
path: '/verification',
name: 'VerificationQueue',
component: () => import('../views/VerificationView.vue'),
meta: {
requiresAuth: true,
roles: ['VERIFIER', 'CLINICAL_APPROVER', 'ADMINISTRATOR'],
},
},
{
path: '/verification/:batchId',
name: 'VerificationBatch',
component: () => import('../views/VerificationView.vue'),
meta: {
requiresAuth: true,
roles: ['VERIFIER', 'CLINICAL_APPROVER', 'ADMINISTRATOR'],
},
props: true,
},
{
path: '/dashboard',
name: 'Dashboard',
component: () => import('../views/QueueDashboardView.vue'),
meta: { requiresAuth: true, roles: ['ADMINISTRATOR'] },
},
{
path: '/',
redirect: '/login',
},
]
const router = createRouter({
history: createWebHistory(),
routes,
})
// Navigation guard: check auth and role
router.beforeEach((to, _from, next) => {
const auth = useAuthStore()
if (to.path === '/login' && auth.isAuthenticated) {
return next(getDefaultRouteForRole(auth.userRole))
}
if (to.meta.requiresAuth && !auth.isAuthenticated) {
return next('/login')
}
if (to.meta.roles && Array.isArray(to.meta.roles)) {
const allowedRoles = to.meta.roles as string[]
if (!allowedRoles.includes(auth.userRole)) {
const fallback = getDefaultRouteForRole(auth.userRole)
if (fallback !== '/login' && fallback !== to.path) {
return next(fallback)
}
return next('/login')
}
}
next()
})
export default router