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

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
+31 -9
View File
@@ -1,5 +1,6 @@
import {
AuditOutlined,
AccountBookOutlined,
BellOutlined,
BugOutlined,
DashboardOutlined,
@@ -87,12 +88,14 @@ export default function AdminLayout() {
const devMockStatusQuery = useQuery({
queryKey: ['admin-dev-mock-status'],
queryFn: () => fetchDevMockStatus(),
enabled: role !== 'finance',
retry: false,
})
const devMockEnabled = Boolean(devMockStatusQuery.data?.data?.enabled)
const notificationsQuery = useQuery({
queryKey: ['admin-notifications'],
queryFn: fetchAdminNotifications,
enabled: role !== 'finance',
retry: false,
})
const notifications = notificationsQuery.data?.data.items || []
@@ -100,7 +103,7 @@ export default function AdminLayout() {
useRealtimeEvents({
url: '/api/v1/admin/realtime',
token: getAdminToken(),
token: role === 'finance' ? '' : getAdminToken(),
onEvent: (event) => applyAdminRealtimeEvent(event, queryClient),
// 会话过期时清登录态回登录页,避免 SSE 带着失效 token 无限重连刷 401。
onAuthExpired: () => {
@@ -110,14 +113,31 @@ export default function AdminLayout() {
})
const menuItems = useMemo<MenuProps['items']>(() => {
const operationItems: MenuProps['items'] = [
{ key: '/admin/dashboard', icon: <DashboardOutlined />, label: '概览' },
{ key: '/admin/orders', icon: <OrderedListOutlined />, label: '订单' },
{ key: '/admin/tasks', icon: <UnorderedListOutlined />, label: '务' },
{ key: '/admin/worker-platform', icon: <TrophyOutlined />, label: '接单平台' },
{ key: '/admin/kuaishou-industry', icon: <SafetyCertificateOutlined />, label: '电子凭证' },
{ key: '/admin/cloudtentacles-records', icon: <FileSearchOutlined />, label: '发货记录' },
]
const operationItems: MenuProps['items'] =
role === 'finance'
? [
{ key: '/admin/finance', icon: <AccountBookOutlined />, label: '务' },
{ key: '/admin/worker-platform', icon: <TrophyOutlined />, label: '资金审核' },
]
: [
{ key: '/admin/dashboard', icon: <DashboardOutlined />, label: '概览' },
{ key: '/admin/orders', icon: <OrderedListOutlined />, label: '订单' },
...(role === 'support'
? []
: [{ key: '/admin/finance', icon: <AccountBookOutlined />, label: '财务' }]),
{ key: '/admin/tasks', icon: <UnorderedListOutlined />, label: '任务' },
{ key: '/admin/worker-platform', icon: <TrophyOutlined />, label: '接单平台' },
{
key: '/admin/kuaishou-industry',
icon: <SafetyCertificateOutlined />,
label: '电子凭证',
},
{
key: '/admin/cloudtentacles-records',
icon: <FileSearchOutlined />,
label: '发货记录',
},
]
const items: MenuProps['items'] = [
{
@@ -601,6 +621,7 @@ function playNotificationSound(kind: NotificationAlertKind) {
function resolveSelectedKey(pathname: string) {
if (pathname.startsWith('/admin/orders')) return '/admin/orders'
if (pathname.startsWith('/admin/finance')) return '/admin/finance'
if (pathname.startsWith('/admin/tasks')) return '/admin/tasks'
if (pathname.startsWith('/admin/worker-platform')) return '/admin/worker-platform'
if (pathname.startsWith('/admin/kuaishou-industry')) return '/admin/kuaishou-industry'
@@ -629,5 +650,6 @@ function buildNotificationActionPath(notification: AdminNotification) {
function roleLabel(role: string) {
if (role === 'admin') return '管理员'
if (role === 'operator') return '普通运营'
if (role === 'finance') return '财务'
return '客服'
}