diff --git a/client/src/pages/admin/Users.tsx b/client/src/pages/admin/Users.tsx index d0b9d3d..025e2d9 100644 --- a/client/src/pages/admin/Users.tsx +++ b/client/src/pages/admin/Users.tsx @@ -747,23 +747,50 @@ export default function Users() {

- 参与的活动({detail.activities.length} 次) + 参与的活动({detail.activities.length} 次)按登记时间倒序,最新补录/登记在最上方

{r.title} }, - { key: 'time', title: '时间', render: (r: any) => formatDateRange(r.start_time, r.end_time) }, + { + key: 'title', + title: '活动名称', + width: '30%', + render: (r: any) => ( +
{r.title}
+ ), + }, + { + key: 'time', + title: '活动时间', + width: '240px', + render: (r: any) => ( +
+ {formatDateRange(r.start_time, r.end_time)} +
+ ), + }, { key: 'hours', title: '时长', + width: '100px', render: (r: any) => ( - {Number(r.hours || 0).toFixed(1)}h + + {Number(r.hours || 0).toFixed(1)}h + + ), + }, + { + key: 'remark', + title: '备注', + render: (r: any) => ( +
+ {r.remark || —} +
), }, - { key: 'remark', title: '备注', render: (r: any) => r.remark || '—' }, ]} data={detail.activities} - rowKey={(r: any) => r.id} + rowKey={(r: any) => `${r.id}-${r.reg_at || r.hours}-${r.remark || ''}`} />
diff --git a/client/src/utils/export.ts b/client/src/utils/export.ts index 72db3cb..b7e6dc9 100644 --- a/client/src/utils/export.ts +++ b/client/src/utils/export.ts @@ -271,9 +271,12 @@ export async function exportTableToImage(el: HTMLElement, filename: string) { } export function formatDateRange(s: string, e: string) { - const a = s?.replace('T', ' ')?.slice(0, 16); - const b = e?.replace('T', ' ')?.slice(0, 16); - return `${a || ''} ~ ${b || ''}`; + const a = s?.replace('T', ' ')?.slice(0, 16) || ''; + const b = e?.replace('T', ' ')?.slice(0, 16) || ''; + if (a && b && a.slice(0, 10) === b.slice(0, 10)) { + return `${a} ~ ${b.slice(11)}`; + } + return `${a} ~ ${b}`; } export function formatCnDateTime(s?: string | null, withSeconds = false): string { diff --git a/server/src/routes/users.ts b/server/src/routes/users.ts index 14aa43b..551fc1b 100644 --- a/server/src/routes/users.ts +++ b/server/src/routes/users.ts @@ -76,11 +76,11 @@ router.get('/:id', (req: Request, res: Response) => { if (!raw) return res.status(404).json({ error: '部员不存在' }); const user = enrichUser(raw); const activities = db.prepareCompat(` - SELECT a.id, a.title, a.start_time, a.end_time, h.hours, h.remark + SELECT a.id, a.title, a.start_time, a.end_time, h.hours, h.remark, h.created_at AS reg_at FROM hours h JOIN activities a ON h.activity_id = a.id WHERE h.user_id = ? - ORDER BY a.start_time DESC + ORDER BY h.created_at DESC, a.start_time DESC `).all(id); res.json({ ...user, activities }); });