feat(organization): add performance salary sidebar views

This commit is contained in:
江林铖 2026-10-23 14:43:47 +08:00
parent bba59fc926
commit df90e6f479
4 changed files with 79 additions and 4 deletions

View File

@ -25,6 +25,7 @@ web
- “自动化工作流”作为“资产与AI自动化”下的业务入口,集中链接现有的绩效考核调研与作品过稿看板。
- “组织架构”统一品牌中心与全公司范围,默认品牌中心,复用真实组织树、人员明细和原管理员权限。
- “绩效薪资”沿用 `/workspaces/organization/performance-review`,仅启用中的超级管理员及明确授权的无邪、清云、伯言、元泽账号可查看;指定账号按固定用户 ID 校验,普通系统/部门管理员不自动获得权限。导航默认隐藏,服务端页面独立核验当前账号权限。
- “绩效薪资”页内左侧栏提供“薪资明细”和“后台配置”,默认薪资明细,`?view=configuration` 切换配置;窄屏改为顶部两列菜单。业务内容尚未接入时显示空状态,不展示示例薪资或无效配置操作。
- 品牌中心工作台访问范围以权威人员绑定和 HR 组织路径为准;品牌中心以外的普通用户登录后只进入 `/assets/material-library`,不显示品牌中心侧栏、返回入口,也不能直接访问 `/` 或 `/workspaces/*`。系统管理员保留维护通行能力。
- “权限管理”统一权限组与人员权限视图;组织数据归组织管理,不再保留数据口径的独立入口。旧链接跳转至对应的新视图。
- “进行中项目”只同步两个已确认的钉钉流程类型,并只统计北京时间 2026 年 4 月 1 日起发起且尚未完结的流程;总览和所有下钻维度共用这一口径。

View File

@ -16,6 +16,7 @@ import TeamFunctionsDashboard from '@/components/department-dashboard/TeamFuncti
import ValueMetricsDashboard from '@/components/department-dashboard/ValueMetricsDashboard'
import BrandKnowledgeDashboard from '@/components/department-dashboard/BrandKnowledgeDashboard'
import PerformanceConversionDashboard from '@/components/department-dashboard/PerformanceConversionDashboard'
import PerformanceSalaryDashboard from '@/components/department-dashboard/PerformanceSalaryDashboard'
import WorkspacePlaceholder from '@/components/department-dashboard/WorkspacePlaceholder'
import {
getFrameworkWorkspaceParams,
@ -85,6 +86,13 @@ export function generateMetadata({ params }: WorkspaceItemPageProps): Metadata {
}
}
if (workspace.section.key === 'organization' && workspace.item.key === 'performance-review') {
return {
title: '绩效薪资 | 组织管理 | 品牌中心部门看板',
description: '查看薪资明细与后台配置。',
}
}
if (workspace.section.key === 'assets' && workspace.item.key === 'value-metrics') {
return {
title: '价值指标 | 资产与AI自动化 | 品牌中心部门看板',
@ -134,6 +142,7 @@ export default async function WorkspaceItemPage({ params, searchParams }: Worksp
if (!session?.user) redirect('/login')
if (session.user.canAccessBrandCenter !== true) redirect('/assets/material-library')
if (!(await canViewPerformanceSalary(session.user.id))) redirect('/workspaces/dashboard/core-metrics')
return <PerformanceSalaryDashboard view={searchParams?.view === 'configuration' ? 'configuration' : 'details'} />
}
if (workspace.section.key === 'assets' && workspace.item.key === 'automation-workflows') {

View File

@ -0,0 +1,49 @@
import Link from 'next/link'
import { ListChecks, Settings2 } from 'lucide-react'
import DepartmentShell from './DepartmentShell'
// Operate: inherit the existing split workbench; two URL-backed views, no sample salary data.
const VIEWS = [
{ key: 'details', title: '薪资明细', href: '/workspaces/organization/performance-review', icon: ListChecks },
{ key: 'configuration', title: '后台配置', href: '/workspaces/organization/performance-review?view=configuration', icon: Settings2 },
] as const
export default function PerformanceSalaryDashboard({ view = 'details' }: { view?: 'details' | 'configuration' }) {
const activeView = VIEWS.find((item) => item.key === view)!
return (
<DepartmentShell>
<main className="flex min-h-[calc(100dvh-72px)] flex-col bg-white lg:grid lg:grid-cols-[232px_minmax(0,1fr)]" aria-label="绩效薪资">
<aside className="shrink-0 border-b border-[#e2e8f0] bg-[#f8fafc] px-4 py-4 lg:border-b-0 lg:border-r lg:py-6">
<nav aria-label="绩效薪资二级导航" className="grid grid-cols-2 gap-2 lg:grid-cols-1 lg:gap-1">
{VIEWS.map((item) => {
const Icon = item.icon
const active = item.key === view
return (
<Link
key={item.key}
href={item.href}
scroll={false}
aria-current={active ? 'page' : undefined}
className={`flex min-h-11 min-w-0 items-center gap-3 rounded-lg px-3 py-3 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#5a9ce6] ${active ? 'bg-[#e6f4ff] text-[#0050cb]' : 'text-[#4f6077] hover:bg-[#eef2f6] hover:text-[#101828]'}`}
>
<Icon className="h-4 w-4 shrink-0" aria-hidden="true" />
{item.title}
</Link>
)
})}
</nav>
</aside>
<section aria-labelledby="salary-view-title" className="min-w-0">
<header className="border-b border-[#e2e8f0] px-5 py-5 sm:px-6">
<h1 id="salary-view-title" className="text-xl font-bold text-[#101828]">{activeView.title}</h1>
</header>
<div className="px-5 py-16 text-center sm:px-6 sm:py-24">
<h2 className="text-base font-semibold text-[#101828]">{view === 'details' ? '暂无薪资明细' : '暂无后台配置'}</h2>
<p className="mt-2 text-sm leading-6 text-[#66758b]">{view === 'details' ? '薪资数据尚未接入。' : '配置内容尚未设置。'}</p>
</div>
</section>
</main>
</DepartmentShell>
)
}

View File

@ -2,7 +2,7 @@ import { getServerSession } from 'next-auth'
import { redirect } from 'next/navigation'
import { prisma } from '@/lib/prisma'
import WorkspaceItemPage, { generateMetadata } from '@/app/workspaces/[section]/[item]/page'
import WorkspacePlaceholder from './WorkspacePlaceholder'
import PerformanceSalaryDashboard from './PerformanceSalaryDashboard'
jest.mock('next-auth', () => ({ getServerSession: jest.fn() }))
jest.mock('next/navigation', () => ({ redirect: jest.fn(), notFound: jest.fn() }))
@ -55,12 +55,28 @@ test.each([
getSession.mockResolvedValue({ user: { id: identity.id, canAccessBrandCenter: true } })
findUser.mockResolvedValue({ ...identity, isActive: true, status: 'active', archivedAt: null })
const page = await WorkspaceItemPage(props)
expect(page.type).toBe(WorkspacePlaceholder)
expect(page.props.title).toBe('绩效薪资')
expect(page.props.description).toContain('绩效薪资')
expect(page.type).toBe(PerformanceSalaryDashboard)
expect(page.props.view).toBe('details')
expect(generateMetadata(props).title).toBe('绩效薪资 | 组织管理 | 品牌中心部门看板')
})
test.each([
['configuration', 'configuration'],
['unknown', 'details'],
])('授权访问按 URL 选择视图:%s', async (view, expectedView) => {
getSession.mockResolvedValue({ user: { id: 'super-admin', canAccessBrandCenter: true } })
findUser.mockResolvedValue({ id: 'super-admin', isSuperAdmin: true, isActive: true, status: 'active', archivedAt: null })
const page = await WorkspaceItemPage({ ...props, searchParams: { view } })
expect(page.type).toBe(PerformanceSalaryDashboard)
expect(page.props.view).toBe(expectedView)
})
test('后台配置链接同样经过薪资权限门禁', async () => {
getSession.mockResolvedValue({ user: { id: 'ordinary', canAccessBrandCenter: true } })
findUser.mockResolvedValue({ id: 'ordinary', isSuperAdmin: false, isActive: true, status: 'active', archivedAt: null })
await expect(WorkspaceItemPage({ ...props, searchParams: { view: 'configuration' } })).rejects.toThrow('redirect:/workspaces/dashboard/core-metrics')
})
test('其他组织管理板块不受薪资专属权限限制', async () => {
await WorkspaceItemPage({ params: { section: 'organization', item: 'team-functions' } })
expect(getSession).not.toHaveBeenCalled()