新增财务角色与财务报表并完善后台权限

This commit is contained in:
yml2213
2026-09-02 13:58:03 +08:00
parent de63daf1ac
commit bf167d98ed
29 changed files with 1242 additions and 69 deletions
+9 -5
View File
@@ -5,10 +5,11 @@ const ADMIN_USERNAME_KEY = 'order-site-admin-username'
const ADMIN_ROLE_KEY = 'order-site-admin-role'
const ADMIN_PERMISSIONS_KEY = 'order-site-admin-permissions'
const ADMIN_ROLE_LEVEL: Record<'support' | 'operator' | 'admin', number> = {
const ADMIN_ROLE_LEVEL: Record<'support' | 'operator' | 'admin' | 'finance', number> = {
support: 1,
operator: 2,
admin: 3,
finance: 0,
}
export function getAdminToken() {
@@ -30,7 +31,7 @@ export function getAdminUsername() {
export function getAdminRole() {
const role = localStorage.getItem(ADMIN_ROLE_KEY)
if (role === 'admin' || role === 'operator' || role === 'support') {
if (role === 'admin' || role === 'operator' || role === 'support' || role === 'finance') {
return role
}
@@ -57,12 +58,15 @@ export function hasAdminPermission(permission: string) {
return getAdminPermissions().includes(String(permission || '').trim())
}
export function hasAdminRole(role: 'admin' | 'operator' | 'support') {
export function hasAdminRole(role: 'admin' | 'operator' | 'support' | 'finance') {
if (!hasAdminSession()) {
return false
}
return ADMIN_ROLE_LEVEL[getAdminRole()] >= ADMIN_ROLE_LEVEL[role]
const currentRole = getAdminRole()
if (role === 'finance') return currentRole === 'finance'
if (currentRole === 'finance') return false
return ADMIN_ROLE_LEVEL[currentRole] >= ADMIN_ROLE_LEVEL[role]
}
export function setAdminSession(
@@ -71,7 +75,7 @@ export function setAdminSession(
user?: {
userId: number
username: string
role: 'admin' | 'operator' | 'support'
role: 'admin' | 'operator' | 'support' | 'finance'
permissions?: string[]
},
) {
+1
View File
@@ -39,6 +39,7 @@ export const adminUserRoleOptions = [
{ label: '管理员', value: 'admin' },
{ label: '普通运营', value: 'operator' },
{ label: '客服', value: 'support' },
{ label: '财务', value: 'finance' },
]
export const adminUserStatusOptions = [