优化(登录任务): 表头与内容居中,收紧列宽

- 表头、单元格统一居中
- 固定表格布局并设定横向总宽,长文本省略显示
- 标签列加宽,ID/执行人/状态列收紧
This commit is contained in:
yml
2026-11-25 15:38:58 +08:00
parent f25e7a35a8
commit c348d7fa2b
+36 -12
View File
@@ -595,24 +595,29 @@ export default function LoginTasksPage() {
}; };
const columns = [ const columns = [
{ title: 'ID', dataIndex: 'id', width: 60 }, { title: 'ID', dataIndex: 'id', width: 78 },
{ title: '登录账号', dataIndex: 'account_username' }, {
title: '登录账号',
dataIndex: 'account_username',
width: 170,
ellipsis: true,
},
{ {
title: '标签', title: '标签',
dataIndex: 'account_tag', dataIndex: 'account_tag',
width: 110, width: 150,
render: (tag: string) => tag ? <Tag color="blue">{tag}</Tag> : <Text type="secondary">-</Text>, render: (tag: string) => tag ? <Tag color="blue">{tag}</Tag> : <Text type="secondary">-</Text>,
}, },
{ {
title: '当前归属客服', title: '当前归属客服',
dataIndex: 'assigned_username', dataIndex: 'assigned_username',
width: 130, width: 120,
render: (name: string) => name || <Text type="secondary">未分配</Text>, render: (name: string) => name || <Text type="secondary">未分配</Text>,
}, },
{ {
title: '触发方式', title: '触发方式',
dataIndex: 'trigger_source', dataIndex: 'trigger_source',
width: 170, width: 168,
render: (_: string, record: LoginTaskItem) => ( render: (_: string, record: LoginTaskItem) => (
<Tag color={loginSourceColor(record)}>{loginSourceLabel(record)}</Tag> <Tag color={loginSourceColor(record)}>{loginSourceLabel(record)}</Tag>
), ),
@@ -620,14 +625,15 @@ export default function LoginTasksPage() {
{ {
title: '执行人', title: '执行人',
dataIndex: 'created_by_username', dataIndex: 'created_by_username',
width: 110, width: 128,
ellipsis: true,
render: (name: string, record: LoginTaskItem) => render: (name: string, record: LoginTaskItem) =>
name || `#${record.created_by}`, name || `#${record.created_by}`,
}, },
{ {
title: 'CK 状态', title: 'CK 状态',
dataIndex: 'ck_check_status', dataIndex: 'ck_check_status',
width: 100, width: 96,
render: (status: string) => ( render: (status: string) => (
<Tag color={CK_STATUS_COLORS[status] || 'default'}> <Tag color={CK_STATUS_COLORS[status] || 'default'}>
{CK_STATUS_LABELS[status] || status || '未确认'} {CK_STATUS_LABELS[status] || status || '未确认'}
@@ -637,7 +643,7 @@ export default function LoginTasksPage() {
{ {
title: '账号状态', title: '账号状态',
dataIndex: 'account_status', dataIndex: 'account_status',
width: 100, width: 96,
render: (status: string) => ACCOUNT_STATUS_LABELS[status] || status || '-', render: (status: string) => ACCOUNT_STATUS_LABELS[status] || status || '-',
}, },
{ {
@@ -646,11 +652,20 @@ export default function LoginTasksPage() {
width: 100, width: 100,
render: (status: string) => <Tag color={STATUS_COLORS[status]}>{STATUS_LABELS[status] || status}</Tag>, render: (status: string) => <Tag color={STATUS_COLORS[status]}>{STATUS_LABELS[status] || status}</Tag>,
}, },
{ title: '消息', dataIndex: 'message', ellipsis: true }, {
{ title: '时间', dataIndex: 'created_at', width: 180, render: (val: string) => formatTime(val) }, title: '消息',
dataIndex: 'message',
ellipsis: { showTitle: true },
},
{
title: '时间',
dataIndex: 'created_at',
width: 172,
render: (val: string) => formatTime(val),
},
{ {
title: '操作', title: '操作',
width: 190, width: 176,
render: (_: unknown, record: LoginTaskItem) => ( render: (_: unknown, record: LoginTaskItem) => (
<Space size={4}> <Space size={4}>
<Button <Button
@@ -679,6 +694,13 @@ export default function LoginTasksPage() {
}, },
]; ];
// 表头和内容统一居中,列宽固定后不再因长文本抖动。
const centeredColumns = columns.map((column) => ({
...column,
align: 'center' as const,
onHeaderCell: () => ({ style: { textAlign: 'center' as const } }),
}));
return ( return (
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}> <div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
{/* 标题 + 筛选栏 */} {/* 标题 + 筛选栏 */}
@@ -1008,11 +1030,13 @@ export default function LoginTasksPage() {
</div> </div>
)} )}
<Table <Table
columns={columns} columns={centeredColumns}
dataSource={tasks} dataSource={tasks}
rowKey="id" rowKey="id"
size="small" size="small"
sticky sticky
tableLayout="fixed"
scroll={{ x: 1750 }}
rowSelection={{ rowSelection={{
selectedRowKeys, selectedRowKeys,
// 跨页保留勾选:翻页时不清空,否则用户「选了 10 个翻页就没了」。 // 跨页保留勾选:翻页时不清空,否则用户「选了 10 个翻页就没了」。