feat(ui): 适配手机端布局与触控交互

窄屏改用抽屉导航和卡片列表,加大触控区域并处理安全区,避免表格横向溢出。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-29 21:55:10 +08:00
co-authored by Cursor
parent 3535f56702
commit d981e53330
29 changed files with 519 additions and 202 deletions
+69 -5
View File
@@ -61,7 +61,7 @@ export default async function CustomersPage({
canExport={superAdmin}
/>
<Card className="overflow-hidden">
<Card className="hidden overflow-hidden md:block">
<Table striped bordered>
<THead>
<tr>
@@ -124,7 +124,7 @@ export default async function CustomersPage({
<TD className="tabular-nums">{fmtDate(c.reportDate)}</TD>
<TD className="max-w-[280px] whitespace-normal break-words">{c.remark}</TD>
<TD>
<div className="flex justify-end gap-1.5">
<div className="flex flex-wrap justify-end gap-1.5">
{/* 弹窗展示用的手机号在服务端预处理:超管和业务员看明文,其余角色脱敏 */}
<CustomerView
customer={{
@@ -146,8 +146,72 @@ export default async function CustomersPage({
</Table>
</Card>
<div className="space-y-3 md:hidden">
{rows.length === 0 && (
<Card className="py-14 text-center text-sm text-[var(--color-muted-foreground)]">
暂无数据
</Card>
)}
{rows.map((c) => {
const { phone: _legacyPhone, ...rest } = c;
return (
<Card key={c.id} className="p-4">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0">
<div className="truncate font-medium">{c.customerName}</div>
<div className="mt-1 text-xs text-[var(--color-muted-foreground)]">
{c.salesman}
{c.reportDate ? ` · ${fmtDate(c.reportDate)}` : ""}
</div>
</div>
{c.birthday && (
<Badge tone={c.birthdayType === 2 ? "warning" : "info"} className="shrink-0">
{c.birthdayType === 2 ? "农历" : "阳历"} {fmtDate(c.birthday)}
</Badge>
)}
</div>
<dl className="mt-3 grid grid-cols-2 gap-x-3 gap-y-2 text-sm">
<div>
<dt className="text-xs text-[var(--color-muted-foreground)]">联系人</dt>
<dd>{c.contacts || "—"}</dd>
<dd className="text-xs tabular-nums text-[var(--color-muted-foreground)]">
{superAdmin ? c.contactsPhone : maskPhone(c.contactsPhone)}
</dd>
</div>
<div>
<dt className="text-xs text-[var(--color-muted-foreground)]">结算人</dt>
<dd>{c.balanceUser || "—"}</dd>
<dd className="text-xs tabular-nums text-[var(--color-muted-foreground)]">
{superAdmin ? c.balanceUserPhone : maskPhone(c.balanceUserPhone)}
</dd>
</div>
{c.detail && (
<div className="col-span-2">
<dt className="text-xs text-[var(--color-muted-foreground)]">产品明细</dt>
<dd className="break-words">{c.detail}</dd>
</div>
)}
</dl>
<div className="mt-3 flex flex-wrap gap-1.5 border-t pt-3">
<CustomerView
customer={{
...rest,
contactsPhone: viewFullPhone ? c.contactsPhone : maskPhone(c.contactsPhone),
balanceUserPhone: viewFullPhone ? c.balanceUserPhone : maskPhone(c.balanceUserPhone),
}}
/>
<Link href={`/customers/${c.id}/edit`}>
<Button variant="outline" size="sm">编辑</Button>
</Link>
{superAdmin && <DeleteButton id={c.id} name={c.customerName ?? ""} />}
</div>
</Card>
);
})}
</div>
{/* 分页 */}
<div className="flex items-center justify-between text-sm text-[var(--color-muted-foreground)]">
<div className="flex flex-wrap items-center justify-between gap-2 text-sm text-[var(--color-muted-foreground)]">
<span>共 <span className="font-medium text-[var(--color-foreground)]">{total.toLocaleString()}</span> 条</span>
<div className="flex items-center gap-2">
<PageLink page={page - 1} disabled={page <= 1} sp={sp} label="上一页" />
@@ -172,7 +236,7 @@ function PageLink({
}) {
if (disabled) {
return (
<span className="rounded-md border px-3 py-1.5 opacity-40">{label}</span>
<span className="inline-flex min-h-11 items-center rounded-md border px-3 opacity-40 md:min-h-0 md:py-1.5">{label}</span>
);
}
const params = new URLSearchParams();
@@ -183,7 +247,7 @@ function PageLink({
return (
<Link
href={`/customers?${params.toString()}`}
className="rounded-md border bg-[var(--color-surface)] px-3 py-1.5 hover:bg-[var(--color-muted)]"
className="inline-flex min-h-11 items-center rounded-md border bg-[var(--color-surface)] px-3 hover:bg-[var(--color-muted)] md:min-h-0 md:py-1.5"
>
{label}
</Link>