'use client' import { useEffect, useRef } from 'react' import { createPortal } from 'react-dom' export function PerformanceSurveyExportDialog({ open, positionName, monthLabel, employeeSummary, assessmentCount, busy, error, onClose, onExport, }: { open: boolean positionName: string monthLabel: string employeeSummary: string assessmentCount: number busy: boolean error: string | null onClose: () => void onExport: () => void }) { const exportButtonRef = useRef(null) useEffect(() => { if (!open) return const previousActiveElement = document.activeElement as HTMLElement | null window.requestAnimationFrame(() => exportButtonRef.current?.focus()) const onKeyDown = (event: KeyboardEvent) => { if (event.key === 'Escape' && !busy) onClose() } document.addEventListener('keydown', onKeyDown) return () => { document.removeEventListener('keydown', onKeyDown) previousActiveElement?.focus() } }, [busy, onClose, open]) if (!open || typeof document === 'undefined') return null return createPortal(
{ if (event.target === event.currentTarget && !busy) onClose() }} >

导出公共看板

生成 WPS/Excel 可直接打开的 .xlsx 表格。

{[ ['岗位', positionName], ['月份', monthLabel], ['人员范围', employeeSummary], ['考核项', `${assessmentCount} 项`], ].map(([label, value]) => (
{label}
{value}
))}

表格包含岗位、考核月份、姓名、工号、组织、职级及全部考核项得分。支持保存位置选择的浏览器会先打开本地路径窗口;其他浏览器将保存到默认下载目录。

{error && (
{error}
)}
, document.body, ) }