diff --git a/app/performance-survey/[[...path]]/page.tsx b/app/performance-survey/[[...path]]/page.tsx index 2684c7dd..b599a6cb 100644 --- a/app/performance-survey/[[...path]]/page.tsx +++ b/app/performance-survey/[[...path]]/page.tsx @@ -289,50 +289,89 @@ function Dashboard() { const surveys = useApi('/surveys', []) const me = useApi('/me', []) const canManage = Boolean(me.data?.permissions?.isDepartmentAdmin) + const pendingItems = surveys.data?.pending || [] + const createdItems = surveys.data?.created || [] + const resultItems = surveys.data?.results || [] + const openTotal = createdItems.filter((item: any) => item.status === 'open').length + const responseTotal = createdItems.reduce((sum: number, item: any) => sum + Number(item.counts?.responses || 0), 0) + const displayName = me.data?.employee?.displayName || me.data?.employee?.flowerName || me.data?.user?.name || '当前用户' + const avatarUrl = me.data?.user?.avatar || '' + const avatarInitial = String(displayName || '用').trim().charAt(0).toUpperCase() || '用' + const departmentLabel = me.data?.employee?.departmentName || me.data?.user?.department || '未同步部门' + const positionLabel = [me.data?.employee?.positionTitle, me.data?.employee?.positionLevel].filter(Boolean).join(' · ') const tabs = [ - { id: 'pending', label: '待我评价' }, - { id: 'created', label: '我发起的' }, - { id: 'results', label: '我的结果' }, - ...(canManage ? [{ id: 'manage', label: '管理' }] : []), + { id: 'pending', label: '待我评价', count: pendingItems.length }, + { id: 'created', label: '我发起的', count: createdItems.length }, + { id: 'results', label: '我的结果', count: resultItems.length }, + ...(canManage ? [{ id: 'manage', label: '管理', count: undefined }] : []), ] return ( -
-
-
-

考核调研

-
- {me.data?.user?.name || '当前用户'} - {me.data?.employee?.departmentName && {me.data.employee.departmentName}} - {me.data?.employee?.positionLevel && {me.data.employee.positionLevel}} +
+
+
+
+
+
考核调研
+

我的调研工作台

+
+ {displayName} + + {departmentLabel} + {positionLabel && ( + <> + + {positionLabel} + + )} +
+
+
+ {avatarUrl ? ( + // eslint-disable-next-line @next/next/no-img-element + {displayName} + ) : ( + avatarInitial + )} +
+
+
+ + +
-
+
{tabs.map((item) => ( ))}
-
+
{surveys.loading && 加载中...} {surveys.error && } - {surveys.data && } - {surveys.data && tab === 'pending' && } + {surveys.data && } + {surveys.data && tab === 'pending' && } {surveys.data && tab === 'created' && ( - + )} - {surveys.data && tab === 'results' && } + {surveys.data && tab === 'results' && } {canManage && tab === 'manage' && ( { @@ -345,7 +384,16 @@ function Dashboard() { ) } -function DashboardStats({ data }: { data: any }) { +function DashboardMetric({ label, value, emphasis }: { label: string; value: number; emphasis?: boolean }) { + return ( +
+
{label}
+
{value}
+
+ ) +} + +function DashboardStats({ data, activeTab }: { data: any; activeTab: string }) { const created = data.created || [] const templateStats = data.templateStats || [] const responseTotal = created.reduce((sum: number, item: any) => sum + Number(item.counts?.responses || 0), 0) @@ -358,7 +406,7 @@ function DashboardStats({ data }: { data: any }) { ] return ( -
+
{items.map((item) => (
{item.label}
@@ -371,27 +419,34 @@ function DashboardStats({ data }: { data: any }) { function PendingList({ items }: { items: any[] }) { if (items.length === 0) { - return + return ( +
+
0
+

暂无待评价

+

新的考核调研会出现在这里。

+
+ ) } return (
{items.map((item) => ( -
+
-
-

{item.title}

-

{item.targetName}

+
+
待填写
+

{item.title}

+

评价对象:{item.targetName}

-
+
{item.dueAt ? `截止 ${formatDate(item.dueAt)}` : '无截止时间'} - 填写 + 去评价