fix(distribution-admin): 优化商品与账号展示页面表格列宽、中文化及防换行体验

This commit is contained in:
yml2213
2026-09-09 19:40:31 +08:00
parent dd709fc12c
commit 4098f8f50f
+69 -36
View File
@@ -70,6 +70,17 @@ const TX_OPTIONS = [
{ label: '出租中 (租赁履约)', value: 'rented' }, { label: '出租中 (租赁履约)', value: 'rented' },
] ]
const MAIN_LISTING_STATUS_MAP: Record<string, { label: string; color: string }> = {
published: { label: '主站在售', color: 'green' },
rented: { label: '在租中', color: 'cyan' },
completed: { label: '已售出/结单', color: 'blue' },
offline: { label: '主站下架', color: 'default' },
closed: { label: '已关闭', color: 'error' },
abnormal: { label: '异常冻结', color: 'error' },
sealed: { label: '已封存', color: 'magenta' },
draft: { label: '草稿', color: 'warning' },
}
function formatGameName(name?: string) { function formatGameName(name?: string) {
if (!name) return '默认游戏' if (!name) return '默认游戏'
const lower = name.toLowerCase().trim() const lower = name.toLowerCase().trim()
@@ -431,7 +442,7 @@ export default function Accounts() {
const kw = keyword.trim().toLowerCase() const kw = keyword.trim().toLowerCase()
const matchTitle = item.title && item.title.toLowerCase().includes(kw) const matchTitle = item.title && item.title.toLowerCase().includes(kw)
const matchNo = item.listing_no && item.listing_no.toLowerCase().includes(kw) const matchNo = item.listing_no && item.listing_no.toLowerCase().includes(kw)
const matchGame = item.game_name && item.game_name.toLowerCase().includes(kw) const matchGame = (item.game_name && item.game_name.toLowerCase().includes(kw)) || formatGameName(item.game_name).includes(kw)
const matchRegion = item.server_region && item.server_region.toLowerCase().includes(kw) const matchRegion = item.server_region && item.server_region.toLowerCase().includes(kw)
const matchPlatform = item.login_platform && item.login_platform.toLowerCase().includes(kw) const matchPlatform = item.login_platform && item.login_platform.toLowerCase().includes(kw)
const matchId = String(item.account_id).includes(kw) || String(item.listing_id).includes(kw) const matchId = String(item.account_id).includes(kw) || String(item.listing_id).includes(kw)
@@ -675,6 +686,7 @@ export default function Accounts() {
rowKey="id" rowKey="id"
loading={loading} loading={loading}
dataSource={filteredItems} dataSource={filteredItems}
scroll={{ x: 1200 }}
locale={{ locale={{
emptyText: ( emptyText: (
<Empty <Empty
@@ -715,22 +727,37 @@ export default function Accounts() {
{ {
title: '商品编号', title: '商品编号',
dataIndex: 'listing_no', dataIndex: 'listing_no',
width: 140, width: 170,
render: (v: string | undefined, row: AccountDisplay) => ( render: (v: string | undefined, row: AccountDisplay) => (
<Space direction="vertical" size={2}> <div style={{ whiteSpace: 'nowrap' }}>
<Typography.Text copyable strong> <div style={{ display: 'inline-flex', alignItems: 'center', whiteSpace: 'nowrap', marginBottom: 4 }}>
{v || `#${row.listing_id}`} <Typography.Text
</Typography.Text> copyable={{ text: v || String(row.listing_id), tooltips: ['复制商品编号', '已复制'] }}
{row.in_transaction ? ( strong
<Tag color="warning" style={{ margin: 0 }}> style={{
出租中 fontSize: 13,
</Tag> color: '#1677ff',
) : ( fontFamily: 'monospace',
<Tag color="green" style={{ margin: 0 }}> whiteSpace: 'nowrap',
在售空闲 display: 'inline-flex',
</Tag> alignItems: 'center',
)} }}
</Space> >
{v || `#${row.listing_id}`}
</Typography.Text>
</div>
<div>
{row.in_transaction ? (
<Tag color="warning" style={{ margin: 0, fontSize: 11 }}>
出租中
</Tag>
) : (
<Tag color="green" style={{ margin: 0, fontSize: 11 }}>
在售空闲
</Tag>
)}
</div>
</div>
), ),
}, },
{ {
@@ -761,28 +788,32 @@ export default function Accounts() {
{ {
title: '账号信息', title: '账号信息',
dataIndex: 'title', dataIndex: 'title',
minWidth: 240, width: 260,
render: (_: unknown, row: AccountDisplay) => ( render: (_: unknown, row: AccountDisplay) => (
<div> <div>
<Typography.Text strong style={{ display: 'block', fontSize: 14 }}> <Typography.Text
strong
style={{ fontSize: 14, lineHeight: '20px', display: 'block' }}
ellipsis={{ tooltip: row.title }}
>
{row.title || `账号 #${row.account_id}`} {row.title || `账号 #${row.account_id}`}
</Typography.Text> </Typography.Text>
<Space size={4} style={{ marginTop: 4 }}> <Space size={4} style={{ marginTop: 4 }} wrap>
<Tag color="blue">{formatGameName(row.game_name)}</Tag> <Tag color="blue">{formatGameName(row.game_name)}</Tag>
{row.server_region && <Tag>{row.server_region}</Tag>} {row.server_region && <Tag>{row.server_region}</Tag>}
{row.login_platform && <Tag>{row.login_platform}</Tag>} {row.login_platform && <Tag color="cyan">{row.login_platform}</Tag>}
</Space> </Space>
</div> </div>
), ),
}, },
{ {
title: '段位 / 资产', title: '段位 / 资产',
width: 140, width: 130,
render: (_: unknown, row: AccountDisplay) => ( render: (_: unknown, row: AccountDisplay) => (
<div> <div>
<div>{row.rank_level ? <Tag color="purple">{row.rank_level}</Tag> : '-'}</div> <div>{row.rank_level ? <Tag color="purple">{row.rank_level}</Tag> : '-'}</div>
{row.haf_coin_amount !== undefined && row.haf_coin_amount > 0 && ( {row.haf_coin_amount !== undefined && row.haf_coin_amount > 0 && (
<Typography.Text type="secondary" style={{ fontSize: 12 }}> <Typography.Text type="secondary" style={{ fontSize: 12, whiteSpace: 'nowrap', display: 'block', marginTop: 2 }}>
哈夫币: {row.haf_coin_amount.toLocaleString()} 哈夫币: {row.haf_coin_amount.toLocaleString()}
</Typography.Text> </Typography.Text>
)} )}
@@ -791,21 +822,21 @@ export default function Accounts() {
}, },
{ {
title: '租金 / 押金', title: '租金 / 押金',
width: 170, width: 150,
render: (_: unknown, row: AccountDisplay) => { render: (_: unknown, row: AccountDisplay) => {
const finalPrice = row.site_price_cent || row.price_cent const finalPrice = row.site_price_cent || row.price_cent
const hasMarkup = row.shelf_ratio_delta && row.shelf_ratio_delta > 0 const hasMarkup = row.shelf_ratio_delta && row.shelf_ratio_delta > 0
return ( return (
<div> <div>
<Typography.Text strong style={{ color: '#cf1322', fontSize: 15 }}> <Typography.Text strong style={{ color: '#cf1322', fontSize: 15, whiteSpace: 'nowrap', display: 'block' }}>
{formatMoney(finalPrice)} {formatMoney(finalPrice)}
</Typography.Text> </Typography.Text>
<div style={{ fontSize: 12, color: '#666' }}> <div style={{ fontSize: 12, color: '#888', whiteSpace: 'nowrap', marginTop: 2 }}>
押金: {formatMoney(row.deposit_amount_cent)} 押金: {formatMoney(row.deposit_amount_cent)}
</div> </div>
{hasMarkup && ( {hasMarkup && (
<div style={{ fontSize: 11, color: '#389e0d', marginTop: 2 }}> <div style={{ fontSize: 11, color: '#389e0d', marginTop: 2, whiteSpace: 'nowrap' }}>
含提价溢价: +{formatMoney(row.markup_amount_cent)} 含加价: +{formatMoney(row.markup_amount_cent)}
</div> </div>
)} )}
</div> </div>
@@ -815,7 +846,7 @@ export default function Accounts() {
{ {
title: '加价比例', title: '加价比例',
dataIndex: 'shelf_ratio_delta', dataIndex: 'shelf_ratio_delta',
width: 120, width: 110,
render: (v: number | undefined) => { render: (v: number | undefined) => {
if (v && v > 0) { if (v && v > 0) {
return ( return (
@@ -830,12 +861,11 @@ export default function Accounts() {
{ {
title: '主站状态', title: '主站状态',
dataIndex: 'listing_status', dataIndex: 'listing_status',
width: 100, width: 110,
render: (v: string | undefined) => ( render: (v: string | undefined) => {
<Tag color={v === 'published' ? 'green' : 'default'}> const conf = MAIN_LISTING_STATUS_MAP[v || ''] || { label: v || '未知', color: 'default' }
{v === 'published' ? '主站在售' : v || '未知'} return <Tag color={conf.color}>{conf.label}</Tag>
</Tag> },
),
}, },
{ {
title: '分销展示', title: '分销展示',
@@ -849,13 +879,15 @@ export default function Accounts() {
}, },
{ {
title: '操作', title: '操作',
width: 140, width: 110,
fixed: 'right' as const,
render: (_: unknown, row: AccountDisplay) => ( render: (_: unknown, row: AccountDisplay) => (
<Space size={2}> <Space size={2}>
<Button <Button
type="link" type="link"
size="small" size="small"
icon={<EditOutlined />} icon={<EditOutlined />}
style={{ padding: 0 }}
onClick={() => handleOpenMarkup(row)} onClick={() => handleOpenMarkup(row)}
> >
加价 加价
@@ -864,6 +896,7 @@ export default function Accounts() {
type="link" type="link"
size="small" size="small"
danger={row.display_status === 'enabled'} danger={row.display_status === 'enabled'}
style={{ padding: 0 }}
onClick={() => toggle(row)} onClick={() => toggle(row)}
> >
{row.display_status === 'enabled' ? '下架' : '展示'} {row.display_status === 'enabled' ? '下架' : '展示'}
@@ -918,7 +951,7 @@ export default function Accounts() {
</Col> </Col>
<Col span={12}> <Col span={12}>
<Typography.Text type="secondary">游戏区服:</Typography.Text> <Typography.Text type="secondary">游戏区服:</Typography.Text>
<span>{targetAccount.game_name || '-'} / {targetAccount.server_region || '-'}</span> <span>{formatGameName(targetAccount.game_name) || '-'} / {targetAccount.server_region || '-'}</span>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Typography.Text type="secondary">哈夫币资产:</Typography.Text> <Typography.Text type="secondary">哈夫币资产:</Typography.Text>