fix(ShareholdersTable): 修复股东表格文本溢出和排序提示问题

- 股东类型/股份性质列:移除固定宽度,添加 whiteSpace: nowrap 防止换行
- 股东名称列:限制宽度 200px,超长文本显示省略号
- 表格启用水平滚动:scroll={{ x: 'max-content' }}
- 排序提示改为中文:showSorterTooltip={{ title: '点击切换排序' }}
- 移除取消排序选项:sortDirections: ['descend', 'ascend']
- 添加 antd 中文语言包:locale={zhCN}
- Mock 数据添加长文本测试用例

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-26 14:21:55 +08:00
parent fa54fa5521
commit 998fbd8e29
2 changed files with 18 additions and 13 deletions

View File

@@ -4,6 +4,7 @@
import React, { useMemo, memo } from "react";
import { Box, HStack, Heading, Badge, Icon, useBreakpointValue } from "@chakra-ui/react";
import { Table, Tag, Tooltip, ConfigProvider } from "antd";
import zhCN from "antd/locale/zh_CN";
import type { ColumnsType } from "antd/es/table";
import { Users, LineChart } from "lucide-react";
import type { Shareholder } from "../../types";
@@ -133,10 +134,13 @@ const ShareholdersTable: React.FC<ShareholdersTableProps> = ({
title: "股东名称",
dataIndex: "shareholder_name",
key: "name",
ellipsis: true,
width: 200,
ellipsis: {
showTitle: false,
},
render: (name: string) => (
<Tooltip title={name}>
<span style={{ fontWeight: 500, color: "#F4D03F" }}>{name}</span>
<Tooltip title={name} placement="topLeft">
<span style={{ fontWeight: 500, color: "#F4D03F", display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth: 180 }}>{name}</span>
</Tooltip>
),
},
@@ -144,10 +148,9 @@ const ShareholdersTable: React.FC<ShareholdersTableProps> = ({
title: "股东类型",
dataIndex: "shareholder_type",
key: "type",
width: 90,
responsive: ["md"],
render: (shareholderType: string) => (
<Tag color={getShareholderTypeColor(shareholderType)}>{shareholderType || "-"}</Tag>
<Tag color={getShareholderTypeColor(shareholderType)} style={{ whiteSpace: 'nowrap' }}>{shareholderType || "-"}</Tag>
),
},
{
@@ -158,6 +161,7 @@ const ShareholdersTable: React.FC<ShareholdersTableProps> = ({
align: "right",
responsive: ["md"],
sorter: (a: Shareholder, b: Shareholder) => (a.holding_shares || 0) - (b.holding_shares || 0),
sortDirections: ["descend", "ascend"],
render: (shares: number) => (
<span style={{ color: "#F4D03F" }}>{formatShares(shares)}</span>
),
@@ -173,6 +177,7 @@ const ShareholdersTable: React.FC<ShareholdersTableProps> = ({
const bVal = (b[config.ratioField] as number) || 0;
return aVal - bVal;
},
sortDirections: ["descend", "ascend"],
defaultSortOrder: "descend",
render: (ratio: number) => (
<span style={{ color: type === "circulation" ? "#805AD5" : "#3182CE", fontWeight: "bold" }}>
@@ -188,10 +193,9 @@ const ShareholdersTable: React.FC<ShareholdersTableProps> = ({
title: "股份性质",
dataIndex: "share_nature",
key: "nature",
width: 80,
responsive: ["lg"],
render: (nature: string) => (
<Tag color="default">{nature || "流通股"}</Tag>
<Tag color="default" style={{ whiteSpace: 'nowrap' }}>{nature || "流通股"}</Tag>
),
});
}
@@ -211,14 +215,15 @@ const ShareholdersTable: React.FC<ShareholdersTableProps> = ({
<Heading size="sm" color={THEME.gold}>{config.title}</Heading>
{reportDate && <Badge colorScheme="yellow" variant="subtle">{formatDate(reportDate)}</Badge>}
</HStack>
<ConfigProvider theme={TABLE_THEME}>
<ConfigProvider theme={TABLE_THEME} locale={zhCN}>
<Table
columns={columns}
dataSource={shareholders.slice(0, 10)}
rowKey={(record: Shareholder) => `${record.shareholder_name}-${record.shareholder_rank ?? ''}-${record.end_date ?? ''}`}
pagination={false}
size={isMobile ? "small" : "middle"}
scroll={{ x: isMobile ? 400 : undefined }}
scroll={{ x: 'max-content' }}
showSorterTooltip={{ title: '点击切换排序' }}
/>
</ConfigProvider>
</Box>