feat(organization): add monthly salary templates and Excel export
This commit is contained in:
parent
0a842df1a0
commit
0f2ae24433
@ -154,6 +154,7 @@ components:
|
||||
- 自动化工作流在 Department Shell 内使用 232px 二级业务栏与同源真实操作面,移动端改为顶部两列菜单。
|
||||
- 组织架构复用真实组织树与人员明细,提供“品牌中心 / 全公司”范围切换,沿用原管理员权限。
|
||||
- 权限管理提供“权限组 / 人员权限”两个视图,侧栏只有一个入口。
|
||||
- 绩效薪资使用 232px 二级栏,在“薪资明细”分组下固定展开 AI全案策划岗、摄影中心岗、空间视觉岗、管理岗,后台配置以分隔线区分为独立入口。岗位选中态与 URL、右侧标题同步;手机岗位入口为两列,后台配置独立一行,各项最小高度 44px。四岗按确认的 Excel 结构展示只读空模板,月份选择后查询,当前月份与岗位保存在 URL;四岗整套模板可一次导出。分区表头左对齐,字段表头换行、首列固定,桌面和手机均在表格内部横向滚动;不带入真实工资或预设计算公式。
|
||||
- 素材资产库按权威组织归属选择外壳:品牌中心成员保留 Department Shell,外部普通用户只显示 64px 中性顶栏、素材工作面与退出入口。
|
||||
- 进行中项目明细采用可键盘聚焦的横向滚动数据表:桌面固定“审批单标题”首列并保留 14 项业务字段,移动端转换为同字段的语义化定义列表;节点时间在数值下方标注对应流程节点名称。
|
||||
- 按时交付明细使用紧凑的三项流程筛选条;当前项用浅蓝底和蓝字表达,未选项悬停为灰底,切换时同步更新公式、数量和横向明细表。
|
||||
|
||||
@ -25,7 +25,7 @@ web
|
||||
- “自动化工作流”作为“资产与AI自动化”下的业务入口,集中链接现有的绩效考核调研与作品过稿看板。
|
||||
- “组织架构”统一品牌中心与全公司范围,默认品牌中心,复用真实组织树、人员明细和原管理员权限。
|
||||
- “绩效薪资”沿用 `/workspaces/organization/performance-review`,仅启用中的超级管理员及明确授权的无邪、清云、伯言、元泽账号可查看;指定账号按固定用户 ID 校验,普通系统/部门管理员不自动获得权限。导航默认隐藏,服务端页面独立核验当前账号权限。
|
||||
- “绩效薪资”页内左侧栏提供“薪资明细”和“后台配置”,默认薪资明细,`?view=configuration` 切换配置;窄屏改为顶部两列菜单。“后台配置”提供人员薪资基础部分:姓名、花名、部门、自由文本品牌、基本工资、职级工资、绩效工资,每人一条长期快照,不回写或随 HR 同步覆盖。仅当前启用的超级管理员可增改、软删除,四个指定账号只读。金额精确到分、操作留审计,版本冲突保留草稿并核对最新值;薪资明细仍未接入月度核薪。
|
||||
- “绩效薪资”页内左侧栏在“薪资明细”下固定展开 AI全案策划岗、摄影中心岗、空间视觉岗、管理岗四个入口,分别由 `role=ai-planning/photography/spatial-visual/management` 定位,默认 AI全案策划岗;“后台配置”保持独立入口,`?view=configuration` 切换配置。窄屏岗位入口改为顶部两列菜单,后台配置独立一行。四岗按确认的 Excel 结构提供只读空模板、月份查询和四岗整套 Excel 导出;`month=YYYY-MM` 默认为上海当前月并随岗位切换保留。尚未接入人员、月度核薪、绩效公式或人工编辑。“后台配置”提供人员薪资基础部分:姓名、花名、部门、自由文本品牌、基本工资、职级工资、绩效工资,每人一条长期快照,不回写或随 HR 同步覆盖。仅当前启用的超级管理员可增改、软删除,四个指定账号只读。金额精确到分、操作留审计,版本冲突保留草稿并核对最新值。
|
||||
- 品牌中心工作台访问范围以权威人员绑定和 HR 组织路径为准;品牌中心以外的普通用户登录后只进入 `/assets/material-library`,不显示品牌中心侧栏、返回入口,也不能直接访问 `/` 或 `/workspaces/*`。系统管理员保留维护通行能力。
|
||||
- “权限管理”统一权限组与人员权限视图;组织数据归组织管理,不再保留数据口径的独立入口。旧链接跳转至对应的新视图。
|
||||
- “进行中项目”只同步两个已确认的钉钉流程类型,并只统计北京时间 2026 年 4 月 1 日起发起且尚未完结的流程;总览和所有下钻维度共用这一口径。
|
||||
|
||||
@ -4,6 +4,8 @@ import { notFound, redirect } from 'next/navigation'
|
||||
import { Suspense } from 'react'
|
||||
import { authOptions } from '@/lib/auth'
|
||||
import { canViewPerformanceSalary } from '@/lib/performance-salary-access'
|
||||
import { resolveSalaryRole } from '@/lib/performance-salary-roles'
|
||||
import { resolveSalaryMonth } from '@/lib/performance-salary-templates'
|
||||
import AutomationWorkflowsDashboard from '@/components/department-dashboard/AutomationWorkflowsDashboard'
|
||||
import PermissionsDashboard from '@/components/department-dashboard/PermissionsDashboard'
|
||||
import BrandHealthDashboard from '@/components/department-dashboard/BrandHealthDashboard'
|
||||
@ -29,7 +31,7 @@ type WorkspaceItemPageProps = {
|
||||
section: string
|
||||
item: string
|
||||
}
|
||||
searchParams?: { view?: string; scope?: string }
|
||||
searchParams?: { view?: string; scope?: string; role?: string | string[]; month?: string | string[] }
|
||||
}
|
||||
|
||||
function AutomationWorkflowsFallback() {
|
||||
@ -142,7 +144,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'} />
|
||||
return <PerformanceSalaryDashboard view={searchParams?.view === 'configuration' ? 'configuration' : 'details'} role={resolveSalaryRole(searchParams?.role)} month={resolveSalaryMonth(searchParams?.month)} />
|
||||
}
|
||||
|
||||
if (workspace.section.key === 'assets' && workspace.item.key === 'automation-workflows') {
|
||||
|
||||
@ -1,48 +1,64 @@
|
||||
import Link from 'next/link'
|
||||
import { ListChecks, Settings2 } from 'lucide-react'
|
||||
import { SALARY_ROLES, type SalaryRole } from '@/lib/performance-salary-roles'
|
||||
import { currentSalaryMonth, salaryDetailsHref, SALARY_PATH } from '@/lib/performance-salary-templates'
|
||||
import DepartmentShell from './DepartmentShell'
|
||||
import PersonnelSalaryPanel from './PersonnelSalaryPanel'
|
||||
import PerformanceSalaryDetails from './PerformanceSalaryDetails'
|
||||
|
||||
// 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
|
||||
const navigationItemClass = (active: boolean) => `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]'}`
|
||||
|
||||
export default function PerformanceSalaryDashboard({ view = 'details' }: { view?: 'details' | 'configuration' }) {
|
||||
const activeView = VIEWS.find((item) => item.key === view)!
|
||||
// Operate: URL-backed role navigation within the existing salary workbench.
|
||||
export default function PerformanceSalaryDashboard({ view = 'details', role = 'ai-planning', month = currentSalaryMonth() }: { view?: 'details' | 'configuration'; role?: SalaryRole; month?: string }) {
|
||||
const activeRole = SALARY_ROLES.find((item) => item.key === role)!
|
||||
const title = view === 'configuration' ? '后台配置' : `${activeRole.title} · 薪资明细`
|
||||
|
||||
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 aria-label="绩效薪资二级导航" className="space-y-5">
|
||||
<div>
|
||||
<p id="salary-role-nav-title" className="mb-2 flex items-center gap-3 px-3 py-2 text-sm font-semibold text-[#4f6077]">
|
||||
<ListChecks className="h-4 w-4 shrink-0" aria-hidden="true" />
|
||||
薪资明细
|
||||
</p>
|
||||
<ul aria-labelledby="salary-role-nav-title" className="grid grid-cols-2 gap-2 lg:ml-3 lg:grid-cols-1 lg:gap-1">
|
||||
{SALARY_ROLES.map((item) => {
|
||||
const active = view === 'details' && item.key === role
|
||||
return (
|
||||
<li key={item.key} className="min-w-0">
|
||||
<Link
|
||||
href={salaryDetailsHref(item.key, month)}
|
||||
scroll={false}
|
||||
aria-current={active ? 'page' : undefined}
|
||||
className={navigationItemClass(active)}
|
||||
>
|
||||
{item.title}
|
||||
</Link>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
<div className="border-t border-[#e2e8f0] pt-4">
|
||||
<Link
|
||||
href={`${SALARY_PATH}?${new URLSearchParams({ view: 'configuration', month })}`}
|
||||
scroll={false}
|
||||
aria-current={view === 'configuration' ? 'page' : undefined}
|
||||
className={navigationItemClass(view === 'configuration')}
|
||||
>
|
||||
<Settings2 className="h-4 w-4 shrink-0" aria-hidden="true" />
|
||||
后台配置
|
||||
</Link>
|
||||
</div>
|
||||
</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>
|
||||
<h1 id="salary-view-title" className="text-xl font-bold leading-8 text-[#101828]">{title}</h1>
|
||||
</header>
|
||||
{view === 'configuration' ? <PersonnelSalaryPanel /> : <div className="px-5 py-16 text-center sm:px-6 sm:py-24">
|
||||
<h2 className="text-base font-semibold text-[#101828]">暂无薪资明细</h2>
|
||||
<p className="mt-2 text-sm leading-6 text-[#66758b]">薪资数据尚未接入。</p>
|
||||
</div>}
|
||||
{view === 'configuration' ? <PersonnelSalaryPanel /> : <PerformanceSalaryDetails role={role} month={month} />}
|
||||
</section>
|
||||
</main>
|
||||
</DepartmentShell>
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
|
||||
import PerformanceSalaryDetails from './PerformanceSalaryDetails'
|
||||
import { saveSalaryTemplateWorkbook } from '@/lib/performance-salary-export'
|
||||
|
||||
const push = jest.fn()
|
||||
jest.mock('next/navigation', () => ({ useRouter: () => ({ push }) }))
|
||||
jest.mock('@/lib/performance-salary-export', () => ({
|
||||
saveSalaryTemplateWorkbook: jest.fn(),
|
||||
}))
|
||||
|
||||
beforeEach(() => { jest.clearAllMocks() })
|
||||
|
||||
test('月份切换推入URL,前进后退的新props同步,表格为五行空模板', () => {
|
||||
const { rerender } = render(<PerformanceSalaryDetails role="ai-planning" month="2026-09" />)
|
||||
expect(within(screen.getAllByRole('row')[1]).getAllByRole('columnheader')).toHaveLength(25)
|
||||
expect(screen.getAllByRole('row').slice(2)).toHaveLength(5)
|
||||
expect(screen.getAllByRole('cell').every(cell => cell.textContent === '')).toBe(true)
|
||||
fireEvent.change(screen.getByLabelText('薪资月份'), { target: { value: '2027-01' } })
|
||||
fireEvent.click(screen.getByRole('button', { name: '查询' }))
|
||||
expect(push).toHaveBeenCalledWith('/workspaces/organization/performance-review?role=ai-planning&month=2027-01', { scroll: false })
|
||||
rerender(<PerformanceSalaryDetails role="management" month="2027-01" />)
|
||||
expect(screen.getByLabelText('薪资月份')).toHaveValue('2027-01')
|
||||
expect(within(screen.getAllByRole('row')[1]).getAllByRole('columnheader')).toHaveLength(23)
|
||||
expect(within(screen.getByRole('table')).getByText('2027年1月绩效得分')).toBeInTheDocument()
|
||||
rerender(<PerformanceSalaryDetails role="ai-planning" month="2026-09" />)
|
||||
expect(screen.getByLabelText('薪资月份')).toHaveValue('2026-09')
|
||||
})
|
||||
|
||||
test('导出失败可重试,保存时防止重复点击,月份不受影响', async () => {
|
||||
const save = saveSalaryTemplateWorkbook as jest.Mock
|
||||
let finish!: () => void
|
||||
save.mockRejectedValueOnce(new Error('下载不可用')).mockImplementationOnce(() => new Promise<void>(resolve => { finish = resolve }))
|
||||
render(<PerformanceSalaryDetails role="photography" month="2026-09" />)
|
||||
fireEvent.click(screen.getByRole('button', { name: '导出四岗模板' }))
|
||||
expect(await screen.findByRole('alert')).toHaveTextContent('下载不可用')
|
||||
expect(screen.getByLabelText('薪资月份')).toHaveValue('2026-09')
|
||||
fireEvent.click(screen.getByRole('button', { name: '导出四岗模板' }))
|
||||
await waitFor(() => expect(save).toHaveBeenCalledTimes(2))
|
||||
expect(screen.getByRole('button', { name: '正在生成…' })).toBeDisabled()
|
||||
fireEvent.click(screen.getByRole('button', { name: '正在生成…' }))
|
||||
expect(save).toHaveBeenCalledTimes(2)
|
||||
finish()
|
||||
expect(await screen.findByRole('status')).toHaveTextContent('四岗模板已生成')
|
||||
})
|
||||
42
components/department-dashboard/PerformanceSalaryDetails.tsx
Normal file
42
components/department-dashboard/PerformanceSalaryDetails.tsx
Normal file
@ -0,0 +1,42 @@
|
||||
import type { SalaryRole } from '@/lib/performance-salary-roles'
|
||||
import { getSalaryTemplate, SALARY_TEMPLATE_BLANK_ROWS } from '@/lib/performance-salary-templates'
|
||||
import PerformanceSalaryToolbar from './PerformanceSalaryToolbar'
|
||||
|
||||
export default function PerformanceSalaryDetails({ role, month }: { role: SalaryRole; month: string }) {
|
||||
const template = getSalaryTemplate(role, month)
|
||||
const tableWidth = template.columns.reduce((sum, column) => sum + column.width, 0)
|
||||
return (
|
||||
<>
|
||||
<PerformanceSalaryToolbar role={role} month={month} />
|
||||
<div className="px-5 py-5 sm:px-6">
|
||||
<p id="salary-table-help" className="mb-3 text-sm leading-6 text-[#66758b]">左右滚动查看完整字段,首列保持固定。</p>
|
||||
<div
|
||||
role="region" aria-label={`${template.title}薪资模板表格`} aria-describedby="salary-table-help" tabIndex={0}
|
||||
className="isolate max-h-[560px] max-w-full overflow-auto border border-[#e2e8f0] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#5a9ce6]"
|
||||
>
|
||||
<table className="table-fixed border-separate border-spacing-0 text-sm text-[#344054]" style={{ width: tableWidth }}>
|
||||
<caption className="sr-only">{month} {template.title}薪资明细空白模板,5行待配置</caption>
|
||||
<colgroup>{template.columns.map(column => <col key={column.key} style={{ width: column.width }} />)}</colgroup>
|
||||
<thead className="sticky top-0 z-20">
|
||||
{template.grouped && (
|
||||
<tr>{template.groups.map((group, index) => (
|
||||
<th key={group.key} scope="colgroup" colSpan={group.columns.length} className={`h-11 border-b border-r border-[#e2e8f0] bg-[#e6edf5] px-3 py-2 text-left font-semibold ${index === 0 ? 'text-[#101828]' : ''}`}>
|
||||
{group.label}
|
||||
</th>
|
||||
))}</tr>
|
||||
)}
|
||||
<tr>{template.columns.map((column, index) => (
|
||||
<th key={column.key} scope="col" className={`h-24 border-b border-r border-[#e2e8f0] bg-[#f8fafc] px-3 py-3 text-center align-middle font-semibold leading-6 break-words ${index === 0 ? 'sticky left-0 z-30' : ''}`}>{column.label}</th>
|
||||
))}</tr>
|
||||
</thead>
|
||||
<tbody>{Array.from({ length: SALARY_TEMPLATE_BLANK_ROWS }, (_, row) => (
|
||||
<tr key={row}>{template.columns.map((column, index) => (
|
||||
<td key={column.key} className={`h-14 border-b border-r border-[#e2e8f0] bg-white px-3 ${index === 0 ? 'sticky left-0 z-10' : ''}`} />
|
||||
))}</tr>
|
||||
))}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
70
components/department-dashboard/PerformanceSalaryToolbar.tsx
Normal file
70
components/department-dashboard/PerformanceSalaryToolbar.tsx
Normal file
@ -0,0 +1,70 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useRef, useState, useTransition } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { Download } from 'lucide-react'
|
||||
import type { SalaryRole } from '@/lib/performance-salary-roles'
|
||||
import { isSalaryMonth, salaryDetailsHref, SALARY_PATH } from '@/lib/performance-salary-templates'
|
||||
import { saveSalaryTemplateWorkbook } from '@/lib/performance-salary-export'
|
||||
|
||||
export default function PerformanceSalaryToolbar({ role, month }: { role: SalaryRole; month: string }) {
|
||||
const router = useRouter()
|
||||
const [draft, setDraft] = useState(month)
|
||||
const [pending, startTransition] = useTransition()
|
||||
const [exporting, setExporting] = useState(false)
|
||||
const exportLock = useRef(false)
|
||||
const [feedback, setFeedback] = useState<{ error: boolean; text: string } | null>(null)
|
||||
useEffect(() => { setDraft(month); setFeedback(null) }, [month, role])
|
||||
|
||||
async function exportTemplates() {
|
||||
if (exportLock.current) return
|
||||
exportLock.current = true
|
||||
setExporting(true)
|
||||
setFeedback(null)
|
||||
try {
|
||||
await saveSalaryTemplateWorkbook(month)
|
||||
setFeedback({ error: false, text: '四岗模板已生成,请在下载中查看。' })
|
||||
} catch (error) {
|
||||
setFeedback({ error: true, text: `${error instanceof Error ? error.message : '模板导出失败。'} 请点击导出重试。` })
|
||||
} finally {
|
||||
exportLock.current = false
|
||||
setExporting(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="border-b border-[#e2e8f0] px-5 py-4 sm:px-6">
|
||||
<div className="flex flex-wrap items-end justify-between gap-3">
|
||||
<form action={SALARY_PATH} method="get" className="flex min-w-0 items-end gap-2" onSubmit={event => {
|
||||
event.preventDefault()
|
||||
const value = new FormData(event.currentTarget).get('month')
|
||||
if (isSalaryMonth(value) && value !== month) {
|
||||
setDraft(value)
|
||||
startTransition(() => router.push(salaryDetailsHref(role, value), { scroll: false }))
|
||||
}
|
||||
}}>
|
||||
<input type="hidden" name="role" value={role} />
|
||||
<label className="grid min-w-0 gap-2 text-sm font-semibold text-[#344054]" htmlFor="salary-month">
|
||||
薪资月份
|
||||
<input
|
||||
id="salary-month" name="month" type="month" min="0001-01" max="9999-12" required value={draft} disabled={exporting || pending}
|
||||
className="h-11 w-44 min-w-0 rounded-lg border border-[#cfd8e3] bg-white px-3 text-sm font-normal text-[#101828] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#5a9ce6] disabled:opacity-60"
|
||||
onChange={event => setDraft(event.target.value)}
|
||||
onBlur={() => { if (!isSalaryMonth(draft)) setDraft(month) }}
|
||||
/>
|
||||
</label>
|
||||
<button type="submit" disabled={exporting || pending} className="min-h-11 shrink-0 rounded-lg border border-[#cfd8e3] bg-white px-4 py-2.5 text-sm font-semibold text-[#344054] hover:bg-[#f8fafc] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#5a9ce6] disabled:opacity-60">查询</button>
|
||||
</form>
|
||||
<button
|
||||
type="button" onClick={exportTemplates} disabled={exporting || pending} aria-busy={exporting}
|
||||
className="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg bg-[#0050cb] px-4 py-2.5 text-sm font-semibold text-white hover:bg-[#003da3] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#5a9ce6] focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60"
|
||||
>
|
||||
<Download className="h-4 w-4 shrink-0" aria-hidden="true" />
|
||||
{exporting ? '正在生成…' : '导出四岗模板'}
|
||||
</button>
|
||||
</div>
|
||||
<p className="mt-3 text-sm leading-6 text-[#66758b]">{pending ? '正在切换月份…' : '当前为空白模板,人员数据与计算规则待配置。'}</p>
|
||||
{feedback && <p role={feedback.error ? 'alert' : 'status'} className={`mt-2 text-sm leading-6 ${feedback.error ? 'text-[#b42318]' : 'text-[#344054]'}`}>{feedback.text}</p>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -57,6 +57,7 @@ test.each([
|
||||
const page = await WorkspaceItemPage(props)
|
||||
expect(page.type).toBe(PerformanceSalaryDashboard)
|
||||
expect(page.props.view).toBe('details')
|
||||
expect(page.props.role).toBe('ai-planning')
|
||||
expect(generateMetadata(props).title).toBe('绩效薪资 | 组织管理 | 品牌中心部门看板')
|
||||
})
|
||||
|
||||
@ -77,6 +78,40 @@ test('后台配置链接同样经过薪资权限门禁', async () => {
|
||||
await expect(WorkspaceItemPage({ ...props, searchParams: { view: 'configuration' } })).rejects.toThrow('redirect:/workspaces/dashboard/core-metrics')
|
||||
})
|
||||
|
||||
test.each(['ai-planning', 'photography', 'spatial-visual', 'management'])('岗位直达链接仍拦截旧超管会话:%s', async role => {
|
||||
getSession.mockResolvedValue({ user: { id: 'ordinary', isSuperAdmin: true, canAccessBrandCenter: true } })
|
||||
findUser.mockResolvedValue({ id: 'ordinary', isSuperAdmin: false, isActive: true, status: 'active', archivedAt: null })
|
||||
await expect(WorkspaceItemPage({ ...props, searchParams: { role } })).rejects.toThrow('redirect:/workspaces/dashboard/core-metrics')
|
||||
})
|
||||
|
||||
test.each([
|
||||
['ai-planning', 'ai-planning'],
|
||||
['photography', 'photography'],
|
||||
['spatial-visual', 'spatial-visual'],
|
||||
['management', 'management'],
|
||||
['unknown', 'ai-planning'],
|
||||
[['management', 'photography'], 'ai-planning'],
|
||||
])('授权访问解析岗位参数:%j', async (role, expectedRole) => {
|
||||
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: { role } })
|
||||
expect(page.props.role).toBe(expectedRole)
|
||||
})
|
||||
|
||||
test('岗位参数不覆盖后台配置视图', async () => {
|
||||
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: 'configuration', role: 'management' } })
|
||||
expect(page.props.view).toBe('configuration')
|
||||
})
|
||||
|
||||
test.each(['2027-01', '2026-09'])('已授权岗位直达链接解析薪资月份:%s', async month => {
|
||||
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: { role: 'management', month } })
|
||||
expect(page.props.month).toBe(month)
|
||||
})
|
||||
|
||||
test('其他组织管理板块不受薪资专属权限限制', async () => {
|
||||
await WorkspaceItemPage({ params: { section: 'organization', item: 'team-functions' } })
|
||||
expect(getSession).not.toHaveBeenCalled()
|
||||
|
||||
@ -2,6 +2,16 @@
|
||||
|
||||
本次仅完成长期基础档案;不计算月度薪资、提成或实际发薪。入口:`/workspaces/organization/performance-review?view=configuration`。
|
||||
|
||||
## 岗位薪资明细框架
|
||||
|
||||
“薪资明细”下固定展开 AI全案策划岗、摄影中心岗、空间视觉岗、管理岗,分别使用 `role=ai-planning`、`role=photography`、`role=spatial-visual`、`role=management`。缺少、无效或重复岗位参数默认首岗;`view=configuration` 优先显示后台配置。桌面二级栏纵向展开,手机两列排列,后台配置独立一行。
|
||||
|
||||
四岗按确认的源表结构展示只读模板,分别为 25、16、21、23 列与五行空白内容。AI 去掉保底提成、百分比、实际保底;空间视觉去掉百分比、实际绩效;管理岗将考核和薪资合为一个人员行,去掉保护提成,绩效得分和绩效系数分别保留。模板权重文字沿用原表,空间视觉分区 5% 与单项 6% 仅展示,不代表已确认计算规则。
|
||||
|
||||
月份使用 `month=YYYY-MM`,缺少、无效或重复参数回退上海时区当前月。选择月份后点击查询,岗位与配置导航保留月份,跨年比较列自动更新;浏览器刷新和前进后退按 URL 恢复。数据来源、可人工修改字段和计算规则待后续配置,不读取基础档案填充模板,不新增业务接口、数据库或人员岗位绑定。
|
||||
|
||||
“导出四岗模板”从同一模板配置生成 `绩效薪资模板_YYYY-MM.xlsx`,包含四个工作表,保持分区、字段顺序、月份、五行空白、冻结表头和首列。只有模板标题和表头文字,不含人员、实际薪资、公式、外链或隐藏页。沿用薪资查看权限;导出动态加载 ExcelJS,使用浏览器标准下载,不依赖宿主可能未提供的文件系统保存窗口,取消浏览器保存不改变月份,生成失败可重试。
|
||||
|
||||
## 数据与权限
|
||||
|
||||
- 七个快照字段:姓名、花名、部门、品牌、基本工资、职级工资、绩效工资。花名册只供选择在职人员和关联稳定 ID,不回写 HR,也不随 HR 更新覆盖配置。
|
||||
|
||||
61
lib/__tests__/performance-salary-export.test.ts
Normal file
61
lib/__tests__/performance-salary-export.test.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import ExcelJS from 'exceljs'
|
||||
import JSZip from 'jszip'
|
||||
import { buildSalaryTemplateWorkbook, salaryExportFileName, saveSalaryTemplateWorkbook } from '@/lib/performance-salary-export'
|
||||
|
||||
test('导出后重新读取:四岗模板字段、空行、冻结及月份均正确且无隐私数据或公式', async () => {
|
||||
const workbook = await buildSalaryTemplateWorkbook('2027-01')
|
||||
const buffer = await workbook.xlsx.writeBuffer()
|
||||
const reloaded = new ExcelJS.Workbook()
|
||||
await reloaded.xlsx.load(buffer)
|
||||
expect(reloaded.worksheets.map(sheet => sheet.name)).toEqual(['AI全案策划岗', '摄影中心岗', '空间视觉岗', '管理岗'])
|
||||
const expected = [
|
||||
{ columns: 25, headerRow: 3, lastHeader: '备注', firstMerge: 'A2:G2' },
|
||||
{ columns: 16, headerRow: 2, lastHeader: '备注', firstMerge: 'A1:P1' },
|
||||
{ columns: 21, headerRow: 3, lastHeader: '备注', firstMerge: 'A2:F2' },
|
||||
{ columns: 23, headerRow: 3, lastHeader: '2026年12月薪资', firstMerge: 'A2:C2' },
|
||||
]
|
||||
reloaded.worksheets.forEach((sheet, index) => {
|
||||
const target = expected[index]
|
||||
expect(sheet.state).toBe('visible')
|
||||
expect(sheet.columnCount).toBe(target.columns)
|
||||
expect(sheet.rowCount).toBe(target.headerRow + 5)
|
||||
expect(sheet.getCell(1, 1).value).toBe(`2027-01 ${sheet.name}薪资明细`)
|
||||
expect(sheet.getCell(target.headerRow, target.columns).value).toBe(target.lastHeader)
|
||||
expect(sheet.model.merges).toContain(target.firstMerge)
|
||||
expect(sheet.views[0]).toEqual(expect.objectContaining({ state: 'frozen', xSplit: 1, ySplit: target.headerRow }))
|
||||
for (let row = target.headerRow + 1; row <= sheet.rowCount; row += 1) {
|
||||
for (let col = 1; col <= target.columns; col += 1) expect(sheet.getCell(row, col).value).toBeNull()
|
||||
}
|
||||
})
|
||||
expect(reloaded.worksheets[1].getCell('N2').value).toBe('2026年11月合计薪资')
|
||||
const zip = await JSZip.loadAsync(buffer)
|
||||
expect(Object.keys(zip.files).some(path => /externalLinks|hidden/i.test(path))).toBe(false)
|
||||
for (const path of Object.keys(zip.files).filter(path => /^xl\/worksheets\/sheet\d+\.xml$/.test(path))) {
|
||||
const xml = await zip.file(path)!.async('string')
|
||||
expect(xml).not.toMatch(/<f[\s>]/)
|
||||
}
|
||||
})
|
||||
|
||||
test('校验导出月份与文件名', async () => {
|
||||
expect(salaryExportFileName('2026-09')).toBe('绩效薪资模板_2026-09.xlsx')
|
||||
await expect(buildSalaryTemplateWorkbook('../../secret')).rejects.toThrow('有效月份')
|
||||
})
|
||||
|
||||
test('标准下载文件并回收对象URL', async () => {
|
||||
const create = jest.fn(() => 'blob:salary-template')
|
||||
const revoke = jest.fn()
|
||||
Object.defineProperty(URL, 'createObjectURL', { configurable: true, value: create })
|
||||
Object.defineProperty(URL, 'revokeObjectURL', { configurable: true, value: revoke })
|
||||
const click = jest.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(function(this: HTMLAnchorElement) {
|
||||
expect(this.download).toBe('绩效薪资模板_2026-09.xlsx')
|
||||
})
|
||||
const timer = jest.spyOn(window, 'setTimeout')
|
||||
await saveSalaryTemplateWorkbook('2026-09')
|
||||
expect(create).toHaveBeenCalledWith(expect.any(Blob))
|
||||
expect(click).toHaveBeenCalledTimes(1)
|
||||
const cleanup = timer.mock.calls.find(call => call[1] === 1000)?.[0] as (() => void)
|
||||
cleanup()
|
||||
expect(revoke).toHaveBeenCalledWith('blob:salary-template')
|
||||
click.mockRestore()
|
||||
timer.mockRestore()
|
||||
})
|
||||
51
lib/__tests__/performance-salary-templates.test.ts
Normal file
51
lib/__tests__/performance-salary-templates.test.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import { currentSalaryMonth, getSalaryTemplate, resolveSalaryMonth, salaryDetailsHref, salaryMonthLabel } from '@/lib/performance-salary-templates'
|
||||
|
||||
describe('薪资模板月份与字段', () => {
|
||||
test('上海时区跨月及非法查询参数', () => {
|
||||
const now = new Date('2026-12-31T16:00:00Z')
|
||||
expect(currentSalaryMonth(now)).toBe('2027-01')
|
||||
for (const value of [undefined, '', '2026-13', '2026-1', '0000-01', ['2026-09'], '2026-09<script>']) {
|
||||
expect(resolveSalaryMonth(value, now)).toBe('2027-01')
|
||||
}
|
||||
expect(resolveSalaryMonth('2026-09', now)).toBe('2026-09')
|
||||
expect(salaryMonthLabel('2027-01', -1)).toBe('2026年12月')
|
||||
expect(salaryMonthLabel('2027-01', -2)).toBe('2026年11月')
|
||||
expect(salaryDetailsHref('management', '2027-01')).toBe('/workspaces/organization/performance-review?role=management&month=2027-01')
|
||||
})
|
||||
|
||||
test('AI按原表保留25列,并删除三项保底字段', () => {
|
||||
const template = getSalaryTemplate('ai-planning', '2026-09')
|
||||
expect(template.columns.map(column => column.label)).toEqual([
|
||||
'姓名', '花名', '部门', '品牌', '基本工资', '职级工资', '绩效工资', '2026年9月积分',
|
||||
'品牌调性评审案例评分', '品牌调性评审绩效占比100%', '跨部门协同评分', '跨部门协同绩效占比0%',
|
||||
'创意成果市场验证评分', '创意成果市场验证绩效占比10%', '项目按时交付率', '项目按时交付率绩效占比90%',
|
||||
'知识分享/月度复盘分享', '知识分享/月度复盘分享0%', '工作配合度评分', '工作配合度绩效占比100%',
|
||||
'绩效得分', '2026年9月合计总薪资', '2026年8月合计总薪资', '基础薪资差值', '备注',
|
||||
])
|
||||
})
|
||||
|
||||
test('摄影保留16列,薪资比较月份跨年', () => {
|
||||
const template = getSalaryTemplate('photography', '2027-01')
|
||||
expect(template.columns).toHaveLength(16)
|
||||
expect(template.grouped).toBe(false)
|
||||
expect(template.columns.slice(11, 14).map(column => column.label)).toEqual(['2027年1月合计薪资', '2026年12月合计薪资', '2026年11月合计薪资'])
|
||||
})
|
||||
|
||||
test('空间视觉21列,保留原表不同的分区与单项权重,不建立公式', () => {
|
||||
const template = getSalaryTemplate('spatial-visual', '2026-10')
|
||||
expect(template.columns).toHaveLength(21)
|
||||
expect(template.columns.map(column => column.label)).not.toEqual(expect.arrayContaining(['百分比', '实际绩效']))
|
||||
expect(template.groups.find(group => group.key === 'cooperation')?.label).toBe('配合度 · 维度权重5%')
|
||||
expect(template.columns.map(column => column.label)).toContain('工作配合度绩效占比6%')
|
||||
})
|
||||
|
||||
test('管理岗合并为23列,身份唯一,保留得分与系数', () => {
|
||||
const template = getSalaryTemplate('management', '2027-01')
|
||||
const labels = template.columns.map(column => column.label)
|
||||
expect(labels).toHaveLength(23)
|
||||
expect(labels.filter(label => ['姓名', '花名', '部门'].includes(label))).toEqual(['姓名', '花名', '部门'])
|
||||
expect(labels).not.toContain('保护提成')
|
||||
expect(labels).toEqual(expect.arrayContaining(['2027年1月绩效得分', '绩效系数', '2027年1月新薪资', '2026年12月薪资']))
|
||||
expect(new Set(template.columns.map(column => column.key)).size).toBe(23)
|
||||
})
|
||||
})
|
||||
83
lib/performance-salary-export.ts
Normal file
83
lib/performance-salary-export.ts
Normal file
@ -0,0 +1,83 @@
|
||||
import type ExcelJS from 'exceljs'
|
||||
import { SALARY_ROLES } from './performance-salary-roles'
|
||||
import { getSalaryTemplate, isSalaryMonth, SALARY_TEMPLATE_BLANK_ROWS } from './performance-salary-templates'
|
||||
|
||||
const XLSX_MIME = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
|
||||
export function salaryExportFileName(month: string) {
|
||||
if (!isSalaryMonth(month)) throw new Error('请选择有效月份后重试。')
|
||||
return `绩效薪资模板_${month}.xlsx`
|
||||
}
|
||||
|
||||
export async function buildSalaryTemplateWorkbook(month: string) {
|
||||
salaryExportFileName(month)
|
||||
const { default: Excel } = await import('exceljs')
|
||||
const workbook = new Excel.Workbook()
|
||||
workbook.creator = '品牌中心'
|
||||
const border: Partial<ExcelJS.Borders> = {
|
||||
top: { style: 'thin', color: { argb: 'FFE2E8F0' } }, bottom: { style: 'thin', color: { argb: 'FFE2E8F0' } },
|
||||
left: { style: 'thin', color: { argb: 'FFE2E8F0' } }, right: { style: 'thin', color: { argb: 'FFE2E8F0' } },
|
||||
}
|
||||
for (const role of SALARY_ROLES) {
|
||||
const template = getSalaryTemplate(role.key, month)
|
||||
const sheet = workbook.addWorksheet(role.title)
|
||||
const size = template.columns.length
|
||||
const headerRow = template.grouped ? 3 : 2
|
||||
sheet.mergeCells(1, 1, 1, size)
|
||||
const title = sheet.getCell(1, 1)
|
||||
title.value = `${month} ${role.title}薪资明细`
|
||||
title.font = { name: '微软雅黑', size: 14, bold: true, color: { argb: 'FF101828' } }
|
||||
title.alignment = { vertical: 'middle', horizontal: 'left' }
|
||||
sheet.getRow(1).height = 34
|
||||
if (template.grouped) {
|
||||
let start = 1
|
||||
for (const group of template.groups) {
|
||||
const end = start + group.columns.length - 1
|
||||
if (end > start) sheet.mergeCells(2, start, 2, end)
|
||||
sheet.getCell(2, start).value = group.label
|
||||
start = end + 1
|
||||
}
|
||||
sheet.getRow(2).height = 28
|
||||
}
|
||||
template.columns.forEach((column, index) => {
|
||||
sheet.getColumn(index + 1).width = Math.round(column.width / 7)
|
||||
sheet.getCell(headerRow, index + 1).value = column.label
|
||||
})
|
||||
sheet.getRow(headerRow).height = 64
|
||||
for (let row = 2; row <= headerRow + SALARY_TEMPLATE_BLANK_ROWS; row += 1) {
|
||||
if (row > headerRow) sheet.getRow(row).height = 30
|
||||
for (let col = 1; col <= size; col += 1) {
|
||||
const cell = sheet.getCell(row, col)
|
||||
cell.border = border
|
||||
cell.alignment = { vertical: 'middle', horizontal: 'center', wrapText: true }
|
||||
cell.font = { name: '微软雅黑', size: 11, color: { argb: 'FF344054' }, bold: row <= headerRow }
|
||||
if (row <= headerRow) cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: row < headerRow ? 'FFE6EDF5' : 'FFF8FAFC' } }
|
||||
else {
|
||||
const kind = template.columns[col - 1].kind
|
||||
cell.numFmt = kind === 'money' ? '#,##0.00' : kind === 'percent' ? '0.00%' : kind === 'number' ? '0.##' : '@'
|
||||
}
|
||||
}
|
||||
}
|
||||
sheet.views = [{ state: 'frozen', xSplit: 1, ySplit: headerRow, topLeftCell: `B${headerRow + 1}` }]
|
||||
sheet.pageSetup = { orientation: 'landscape', printTitlesRow: `1:${headerRow}` }
|
||||
sheet.pageSetup.printArea = `A1:${sheet.getColumn(size).letter}${headerRow + SALARY_TEMPLATE_BLANK_ROWS}`
|
||||
}
|
||||
return workbook
|
||||
}
|
||||
|
||||
export async function saveSalaryTemplateWorkbook(month: string) {
|
||||
const workbook = await buildSalaryTemplateWorkbook(month)
|
||||
const buffer = await workbook.xlsx.writeBuffer()
|
||||
const blob = new Blob([buffer], { type: XLSX_MIME })
|
||||
if (typeof URL.createObjectURL !== 'function') throw new Error('当前浏览器无法下载文件,请更换浏览器后重试。')
|
||||
const url = URL.createObjectURL(blob)
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = url
|
||||
anchor.download = salaryExportFileName(month)
|
||||
anchor.style.display = 'none'
|
||||
document.body.appendChild(anchor)
|
||||
try { anchor.click() } finally {
|
||||
anchor.remove()
|
||||
window.setTimeout(() => URL.revokeObjectURL(url), 1000)
|
||||
}
|
||||
}
|
||||
12
lib/performance-salary-roles.ts
Normal file
12
lib/performance-salary-roles.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export const SALARY_ROLES = [
|
||||
{ key: 'ai-planning', title: 'AI全案策划岗' },
|
||||
{ key: 'photography', title: '摄影中心岗' },
|
||||
{ key: 'spatial-visual', title: '空间视觉岗' },
|
||||
{ key: 'management', title: '管理岗' },
|
||||
] as const
|
||||
|
||||
export type SalaryRole = typeof SALARY_ROLES[number]['key']
|
||||
|
||||
export function resolveSalaryRole(value: unknown): SalaryRole {
|
||||
return SALARY_ROLES.find((role) => role.key === value)?.key ?? SALARY_ROLES[0].key
|
||||
}
|
||||
124
lib/performance-salary-templates.ts
Normal file
124
lib/performance-salary-templates.ts
Normal file
@ -0,0 +1,124 @@
|
||||
import { SALARY_ROLES, type SalaryRole } from './performance-salary-roles'
|
||||
|
||||
export const SALARY_TEMPLATE_BLANK_ROWS = 5
|
||||
export const SALARY_PATH = '/workspaces/organization/performance-review'
|
||||
|
||||
export type SalaryTemplateColumn = {
|
||||
key: string
|
||||
label: string
|
||||
kind: 'text' | 'money' | 'number' | 'percent'
|
||||
width: number
|
||||
}
|
||||
export type SalaryTemplateGroup = { key: string; label: string; columns: SalaryTemplateColumn[] }
|
||||
export type SalaryTemplate = {
|
||||
role: SalaryRole
|
||||
title: string
|
||||
month: string
|
||||
grouped: boolean
|
||||
groups: SalaryTemplateGroup[]
|
||||
columns: SalaryTemplateColumn[]
|
||||
}
|
||||
|
||||
export function currentSalaryMonth(now = new Date()): string {
|
||||
const parts = new Intl.DateTimeFormat('en-US', {
|
||||
timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit',
|
||||
}).formatToParts(now)
|
||||
return `${parts.find(part => part.type === 'year')!.value}-${parts.find(part => part.type === 'month')!.value}`
|
||||
}
|
||||
|
||||
export function isSalaryMonth(value: unknown): value is string {
|
||||
return typeof value === 'string' && /^(?!0000)\d{4}-(0[1-9]|1[0-2])$/.test(value)
|
||||
}
|
||||
|
||||
export function resolveSalaryMonth(value: unknown, now = new Date()): string {
|
||||
return isSalaryMonth(value) ? value : currentSalaryMonth(now)
|
||||
}
|
||||
|
||||
export function salaryMonthLabel(month: string, offset = 0): string {
|
||||
const [year, number] = month.split('-').map(Number)
|
||||
const index = year * 12 + number - 1 + offset
|
||||
return `${Math.floor(index / 12)}年${((index % 12) + 12) % 12 + 1}月`
|
||||
}
|
||||
|
||||
export function salaryDetailsHref(role: SalaryRole, month: string): string {
|
||||
return `${SALARY_PATH}?${new URLSearchParams({ role, month })}`
|
||||
}
|
||||
|
||||
const column = (key: string, label: string, kind: SalaryTemplateColumn['kind'] = 'text', width = 144): SalaryTemplateColumn => ({ key, label, kind, width })
|
||||
const group = (key: string, label: string, columns: SalaryTemplateColumn[]): SalaryTemplateGroup => ({ key, label, columns })
|
||||
const identity = (brand = false) => [
|
||||
column('name', '姓名', 'text', 104), column('nickname', '花名', 'text', 104),
|
||||
column('department', '部门', 'text', 160), ...(brand ? [column('brand', '品牌', 'text', 136)] : []),
|
||||
]
|
||||
const baseWages = () => [column('baseSalary', '基本工资', 'money'), column('gradeSalary', '职级工资', 'money'), column('performanceSalary', '绩效工资', 'money')]
|
||||
const review = (key: string, label: string, weight: string, scoreLabel = `${label}评分`) => [
|
||||
column(`${key}Score`, scoreLabel, 'number', 176),
|
||||
column(`${key}Weighted`, `${label}绩效占比${weight}`, 'percent', 192),
|
||||
]
|
||||
const aiSharing = () => [column('sharingScore', '知识分享/月度复盘分享', 'number', 184), column('sharingWeighted', '知识分享/月度复盘分享0%', 'percent', 192)]
|
||||
|
||||
export function getSalaryTemplate(role: SalaryRole, month: string): SalaryTemplate {
|
||||
const current = salaryMonthLabel(month)
|
||||
const previous = salaryMonthLabel(month, -1)
|
||||
const beforePrevious = salaryMonthLabel(month, -2)
|
||||
const salarySummary = () => group('salary', '薪资', [
|
||||
column('currentTotal', `${current}合计总薪资`, 'money', 184),
|
||||
column('previousTotal', `${previous}合计总薪资`, 'money', 184),
|
||||
column('salaryDifference', '基础薪资差值', 'money', 160),
|
||||
])
|
||||
const settlement = () => group('settlement', '绩效结算', [column('performanceScore', '绩效得分', 'number')])
|
||||
const remarks = () => group('remarks', '备注', [column('remarks', '备注', 'text', 224)])
|
||||
const templates: Record<SalaryRole, SalaryTemplateGroup[]> = {
|
||||
'ai-planning': [
|
||||
group('identity', '基础信息', [...identity(true), ...baseWages()]),
|
||||
group('points', '积分', [column('points', `${current}积分`, 'number', 160)]),
|
||||
group('qualitative', '定性 · 维度权重25%', [
|
||||
...review('brandReview', '品牌调性评审', '100%', '品牌调性评审案例评分'), ...review('collaboration', '跨部门协同', '0%'),
|
||||
]),
|
||||
group('quantitative', '定量 · 维度权重70%', [
|
||||
...review('marketValidation', '创意成果市场验证', '10%'),
|
||||
column('onTimeRate', '项目按时交付率', 'percent', 160), column('onTimeWeighted', '项目按时交付率绩效占比90%', 'percent', 192), ...aiSharing(),
|
||||
]),
|
||||
group('cooperation', '配合度 · 维度权重5%', review('cooperation', '工作配合度', '100%')),
|
||||
settlement(), salarySummary(), remarks(),
|
||||
],
|
||||
photography: [group('photography', '', [
|
||||
column('nickname', '花名', 'text', 104), column('level', 'P级', 'text', 104), column('position', '岗位', 'text', 160), column('department', '部门', 'text', 160),
|
||||
column('baseSalaryBasis', '基础薪资基数', 'money', 160), column('baseSalary', '基础薪资', 'money'),
|
||||
column('performanceSalaryBasis', '绩效薪资基数', 'money', 160), column('performanceCoefficient', '绩效系数', 'number'),
|
||||
column('performanceSalary', '绩效薪资', 'money'), column('bonus', '奖金工资', 'money'), column('fixedPay', '固定薪酬', 'number'),
|
||||
column('currentTotal', `${current}合计薪资`, 'money', 184), column('previousTotal', `${previous}合计薪资`, 'money', 184),
|
||||
column('beforePreviousTotal', `${beforePrevious}合计薪资`, 'money', 184), column('monthOverMonth', '环比', 'percent'), column('remarks', '备注', 'text', 224),
|
||||
])],
|
||||
'spatial-visual': [
|
||||
group('identity', '基础信息', [...identity(), ...baseWages()]),
|
||||
group('qualitative', '定性 · 维度权重20%', [
|
||||
...review('aiTools', '协助搭建部门AI辅助工具', '16%'), ...review('collaboration', '跨部门协同', '4%'),
|
||||
]),
|
||||
group('quantitative', '定量', [
|
||||
column('onTimeRate', '项目按时交付率', 'percent', 160), column('onTimeWeighted', '项目按时交付率绩效占比90%', 'percent', 192), ...aiSharing(),
|
||||
]),
|
||||
group('cooperation', '配合度 · 维度权重5%', review('cooperation', '工作配合度', '6%')),
|
||||
settlement(), salarySummary(), remarks(),
|
||||
],
|
||||
management: [
|
||||
group('identity', '人员信息', identity()),
|
||||
group('qualitative', '定性 · 维度权重70%', [
|
||||
...review('visualTone', '视觉调性', '80%'), ...review('collaboration', '跨部门协同', '20%'),
|
||||
]),
|
||||
group('quantitative', '定量 · 维度权重20%', [
|
||||
...review('marketValidation', '创意成果市场验证', '40%'), ...review('onTime', '项目按时交付率', '40%'),
|
||||
...review('sharing', '知识分享/项目复盘', '20%', '知识分享/项目复盘分享评分'),
|
||||
]),
|
||||
group('satisfaction', '满意度 · 维度权重10%', review('cooperation', '工作配合度', '100%')),
|
||||
group('settlement', '绩效得分', [column('performanceScore', `${current}绩效得分`, 'number', 184)]),
|
||||
group('salary', '薪资', [
|
||||
column('salaryBasis', '基础薪资', 'money'), column('baseSalary', '基本工资', 'money'), column('gradeSalary', '职级工资', 'money'),
|
||||
column('performanceSalary', '绩效薪资', 'money'), column('performanceCoefficient', '绩效系数', 'number'),
|
||||
column('currentTotal', `${current}新薪资`, 'money', 184), column('previousTotal', `${previous}薪资`, 'money', 184),
|
||||
]),
|
||||
],
|
||||
}
|
||||
const groups = templates[role]
|
||||
return { role, title: SALARY_ROLES.find(item => item.key === role)!.title, month, grouped: role !== 'photography', groups, columns: groups.flatMap(item => item.columns) }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user