feat(ui): 适配手机端布局与触控交互
窄屏改用抽屉导航和卡片列表,加大触控区域并处理安全区,避免表格横向溢出。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -22,17 +22,19 @@ export function BirthdayControl({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<div className="flex w-full flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center">
|
||||
<div className="flex overflow-hidden rounded-md border">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => go({ mode: "today" })}
|
||||
className={`px-3 py-1.5 text-sm ${mode === "today" ? "bg-[var(--color-primary)] text-white" : "bg-white hover:bg-[var(--color-accent)]"}`}
|
||||
className={`min-h-11 flex-1 touch-manipulation px-3 py-1.5 text-sm sm:min-h-0 sm:flex-none ${mode === "today" ? "bg-[var(--color-primary)] text-white" : "bg-white hover:bg-[var(--color-muted)]"}`}
|
||||
>
|
||||
当天
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => go({ mode: "week" })}
|
||||
className={`border-l px-3 py-1.5 text-sm ${mode === "week" ? "bg-[var(--color-primary)] text-white" : "bg-white hover:bg-[var(--color-accent)]"}`}
|
||||
className={`min-h-11 flex-1 touch-manipulation border-l px-3 py-1.5 text-sm sm:min-h-0 sm:flex-none ${mode === "week" ? "bg-[var(--color-primary)] text-white" : "bg-white hover:bg-[var(--color-muted)]"}`}
|
||||
>
|
||||
未来 7 天
|
||||
</button>
|
||||
@@ -41,7 +43,7 @@ export function BirthdayControl({
|
||||
type="date"
|
||||
defaultValue={date}
|
||||
onChange={(e) => go({ date: e.target.value })}
|
||||
className="w-40"
|
||||
className="w-full sm:w-40"
|
||||
/>
|
||||
<span className="text-sm text-[var(--color-muted-foreground)]">
|
||||
(不填默认今天)
|
||||
|
||||
@@ -76,14 +76,14 @@ export default async function BirthdayPage({
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Card className="flex flex-wrap items-center justify-between gap-3 p-3">
|
||||
<Card className="flex flex-col gap-3 p-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between">
|
||||
<BirthdayControl mode={mode} date={dateStr} />
|
||||
<div className="pr-1 text-sm text-[var(--color-muted-foreground)]">
|
||||
<div className="text-sm text-[var(--color-muted-foreground)] sm:pr-1">
|
||||
命中 <span className="font-semibold text-[var(--color-foreground)]">{rows.length}</span> 位商户
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card className="overflow-hidden">
|
||||
<Card className="hidden overflow-hidden md:block">
|
||||
<Table>
|
||||
<THead>
|
||||
<tr>
|
||||
@@ -131,6 +131,50 @@ export default async function BirthdayPage({
|
||||
</tbody>
|
||||
</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 ownerName = c.birthdayOwner === 1 ? c.balanceUser : c.contacts;
|
||||
const ownerPhone =
|
||||
(c.birthdayOwner === 1 ? c.balanceUserPhone : c.contactsPhone) || c.phone;
|
||||
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 || "—"}
|
||||
</div>
|
||||
</div>
|
||||
<Badge tone={c.birthdayType === 2 ? "warning" : "info"} className="shrink-0">
|
||||
{c.birthdayType === 2 ? "农历" : "阳历"}
|
||||
</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>{ownerName || "—"}</dd>
|
||||
<dd className="text-xs tabular-nums text-[var(--color-muted-foreground)]">
|
||||
{superAdmin ? ownerPhone : maskPhone(ownerPhone)}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-xs text-[var(--color-muted-foreground)]">生日</dt>
|
||||
<dd className="tabular-nums">{fmtDate(c.birthday)}</dd>
|
||||
<dd className="text-xs text-[var(--color-muted-foreground)]">
|
||||
{c.birthdayOwner === 1 ? "结算人" : "联系人"}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ export function CustomerForm({
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="flex gap-2 border-t pt-4">
|
||||
<div className="sticky bottom-0 z-10 -mx-4 flex gap-2 border-t bg-[var(--color-surface)] px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:static md:mx-0 md:px-0 md:pb-0 md:pt-4">
|
||||
<Button type="submit" disabled={pending}>
|
||||
{pending ? "保存中…" : submitLabel}
|
||||
</Button>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useRef, useState, useTransition } from "react";
|
||||
import { useRef, useTransition } from "react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Plus, Upload, Download, Search, RotateCcw } from "lucide-react";
|
||||
@@ -78,50 +78,54 @@ export function CustomerToolbar({
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="flex flex-wrap items-center justify-between gap-3 p-3">
|
||||
<form onSubmit={onSearch} className="flex flex-wrap items-center gap-2">
|
||||
<div className="relative">
|
||||
<Card className="flex flex-col gap-3 p-3 md:flex-row md:flex-wrap md:items-center md:justify-between">
|
||||
<form onSubmit={onSearch} className="flex w-full min-w-0 flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center md:w-auto">
|
||||
<div className="relative min-w-0 flex-1 sm:flex-none">
|
||||
<Search className="pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--color-muted-foreground)]" />
|
||||
<Input
|
||||
name="keyword"
|
||||
placeholder="商户 / 联系人 / 联系电话 / 业务员"
|
||||
defaultValue={defaultKeyword}
|
||||
className="w-64 pl-8"
|
||||
className="w-full pl-8 sm:w-64"
|
||||
/>
|
||||
</div>
|
||||
<Input name="start" type="date" defaultValue={defaultStart} className="w-[150px]" />
|
||||
<span className="text-[var(--color-muted-foreground)]">~</span>
|
||||
<Input name="end" type="date" defaultValue={defaultEnd} className="w-[150px]" />
|
||||
<Button type="submit" variant="soft" disabled={pending}>
|
||||
查询
|
||||
</Button>
|
||||
<Button type="button" variant="ghost" size="icon" title="重置" onClick={() => router.push("/customers")}>
|
||||
<RotateCcw className="h-4 w-4" />
|
||||
</Button>
|
||||
<div className="flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center">
|
||||
<Input name="start" type="date" defaultValue={defaultStart} className="w-full sm:w-[150px]" />
|
||||
<span className="hidden shrink-0 text-[var(--color-muted-foreground)] sm:inline">~</span>
|
||||
<Input name="end" type="date" defaultValue={defaultEnd} className="w-full sm:w-[150px]" />
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button type="submit" variant="soft" disabled={pending} className="flex-1 sm:flex-none">
|
||||
查询
|
||||
</Button>
|
||||
<Button type="button" variant="ghost" size="icon" title="重置" onClick={() => router.push("/customers")}>
|
||||
<RotateCcw className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="grid grid-cols-2 gap-2 sm:flex sm:flex-wrap sm:items-center">
|
||||
<input ref={fileRef} type="file" accept=".xlsx,.xls" hidden onChange={onFile} />
|
||||
<Button variant="outline" disabled={importing} onClick={() => fileRef.current?.click()}>
|
||||
<Upload className="h-4 w-4" />
|
||||
{importing ? "导入中…" : "导入"}
|
||||
</Button>
|
||||
<a href="/customers/template">
|
||||
<Button variant="outline">
|
||||
<a href="/customers/template" className="contents sm:block">
|
||||
<Button variant="outline" className="w-full">
|
||||
<Download className="h-4 w-4" />
|
||||
下载模板
|
||||
</Button>
|
||||
</a>
|
||||
{canExport && (
|
||||
<a href={exportHref}>
|
||||
<Button variant="outline">
|
||||
<a href={exportHref} className="contents sm:block">
|
||||
<Button variant="outline" className="w-full">
|
||||
<Download className="h-4 w-4" />
|
||||
导出
|
||||
</Button>
|
||||
</a>
|
||||
)}
|
||||
<Link href="/customers/new">
|
||||
<Button>
|
||||
<Link href="/customers/new" className="col-span-2 sm:col-span-1">
|
||||
<Button className="w-full">
|
||||
<Plus className="h-4 w-4" />
|
||||
新增商户
|
||||
</Button>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useEffect, useState, type ReactNode } from "react";
|
||||
import { Eye, X } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { fmtDate } from "@/lib/utils";
|
||||
import { fmtDate, cn } from "@/lib/utils";
|
||||
|
||||
type CustomerViewProps = {
|
||||
customer: {
|
||||
@@ -35,7 +35,12 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
||||
if (e.key === "Escape") setOpen(false);
|
||||
};
|
||||
window.addEventListener("keydown", handleEsc);
|
||||
return () => window.removeEventListener("keydown", handleEsc);
|
||||
const prev = document.body.style.overflow;
|
||||
document.body.style.overflow = "hidden";
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleEsc);
|
||||
document.body.style.overflow = prev;
|
||||
};
|
||||
}, [open]);
|
||||
|
||||
const birthdayLabel = customer.birthdayType === 2 ? "阴历" : "阳历";
|
||||
@@ -56,11 +61,11 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
||||
|
||||
{open && (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4"
|
||||
className="fixed inset-0 z-50 flex items-end justify-center bg-black/40 p-0 overscroll-contain sm:items-center sm:p-4"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<Card
|
||||
className="w-full max-w-lg max-h-[85vh] overflow-y-auto"
|
||||
className="max-h-[min(92dvh,100%)] w-full max-w-lg overflow-y-auto rounded-b-none rounded-t-2xl pb-[env(safe-area-inset-bottom)] sm:rounded-[var(--radius)] sm:pb-0"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<CardHeader>
|
||||
@@ -69,7 +74,7 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen(false)}
|
||||
className="text-[var(--color-muted-foreground)] hover:text-[var(--color-foreground)] transition-colors"
|
||||
className="-mr-2 flex h-11 w-11 items-center justify-center text-[var(--color-muted-foreground)] hover:text-[var(--color-foreground)] transition-colors"
|
||||
aria-label="关闭"
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
@@ -147,8 +152,8 @@ function InfoRow({
|
||||
if (!value) return null;
|
||||
return (
|
||||
<div className="flex gap-3 text-sm">
|
||||
<span className="w-24 text-[var(--color-muted-foreground)] flex-shrink-0">{label}</span>
|
||||
<span className={className}>{value}</span>
|
||||
<span className="w-20 shrink-0 text-[var(--color-muted-foreground)] sm:w-24">{label}</span>
|
||||
<span className={cn("min-w-0 break-words", className)}>{value}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -18,7 +18,7 @@ export default async function DashboardLayout({
|
||||
|
||||
return (
|
||||
<SidebarProvider>
|
||||
<div className="flex h-screen overflow-hidden">
|
||||
<div className="flex h-dvh overflow-hidden overscroll-none">
|
||||
<Sidebar isSuperAdmin={superAdmin} />
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<Topbar
|
||||
@@ -29,9 +29,9 @@ export default async function DashboardLayout({
|
||||
image: null, // 旧 face 为老站点相对路径,统一用文字头像
|
||||
}}
|
||||
/>
|
||||
<main className="flex-1 overflow-y-auto">
|
||||
<div className="p-6">{children}</div>
|
||||
<footer className="flex items-center justify-between border-t px-6 py-4 text-xs text-[var(--color-muted-foreground)]">
|
||||
<main className="flex-1 overflow-y-auto overflow-x-hidden overscroll-y-contain">
|
||||
<div className="p-4 md:p-6">{children}</div>
|
||||
<footer className="flex flex-col gap-1 border-t px-4 py-4 text-xs text-[var(--color-muted-foreground)] pb-[max(1rem,env(safe-area-inset-bottom))] md:flex-row md:items-center md:justify-between md:px-6">
|
||||
<span>{copyright()}</span>
|
||||
<span>{brand.name} · {brand.tagline}</span>
|
||||
</footer>
|
||||
|
||||
@@ -27,7 +27,7 @@ export function ProfileForm({ nickname, username }: { nickname: string; username
|
||||
<Label htmlFor="nickname">昵称</Label>
|
||||
<Input id="nickname" name="nickname" defaultValue={nickname} />
|
||||
</div>
|
||||
<Button type="submit" disabled={pending}>{pending ? "保存中…" : "保存资料"}</Button>
|
||||
<Button type="submit" disabled={pending} className="w-full sm:w-auto">{pending ? "保存中…" : "保存资料"}</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export function PasswordForm() {
|
||||
<Label htmlFor="confirmPassword">确认新密码</Label>
|
||||
<Input id="confirmPassword" name="confirmPassword" type="password" autoComplete="new-password" />
|
||||
</div>
|
||||
<Button type="submit" disabled={pending}>{pending ? "提交中…" : "修改密码"}</Button>
|
||||
<Button type="submit" disabled={pending} className="w-full sm:w-auto">{pending ? "提交中…" : "修改密码"}</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ export default async function MePage() {
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-4">
|
||||
<Avatar name={admin.nickname} size={56} />
|
||||
<div>
|
||||
<div className="text-lg font-semibold">{admin.nickname}</div>
|
||||
<div className="mt-1 flex items-center gap-2 text-sm text-[var(--color-muted-foreground)]">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-lg font-semibold">{admin.nickname}</div>
|
||||
<div className="mt-1 flex flex-wrap items-center gap-2 text-sm text-[var(--color-muted-foreground)]">
|
||||
<span className="tabular-nums">{admin.username}</span>
|
||||
<Badge tone="primary">{roleLabel}</Badge>
|
||||
</div>
|
||||
|
||||
@@ -80,21 +80,21 @@ export default async function DashboardPage() {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* 统计卡片 */}
|
||||
<div className="grid grid-cols-2 gap-4 lg:grid-cols-4">
|
||||
<div className="grid grid-cols-2 gap-3 lg:grid-cols-4">
|
||||
{stats.map((s) => {
|
||||
const Icon = s.icon;
|
||||
return (
|
||||
<Card key={s.label}>
|
||||
<CardContent className="flex items-center gap-4">
|
||||
<CardContent className="flex items-center gap-2.5 md:gap-4">
|
||||
<span
|
||||
className="flex h-12 w-12 items-center justify-center rounded-xl"
|
||||
className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl md:h-12 md:w-12"
|
||||
style={{ background: toneBg[s.tone], color: toneFg[s.tone] }}
|
||||
>
|
||||
<Icon className="h-6 w-6" />
|
||||
<Icon className="h-5 w-5 md:h-6 md:w-6" />
|
||||
</span>
|
||||
<div>
|
||||
<div className="text-sm text-[var(--color-muted-foreground)]">{s.label}</div>
|
||||
<div className="mt-0.5 text-2xl font-semibold tabular-nums">{s.value}</div>
|
||||
<div className="min-w-0">
|
||||
<div className="text-xs text-[var(--color-muted-foreground)] md:text-sm">{s.label}</div>
|
||||
<div className="mt-0.5 text-xl font-semibold tabular-nums md:text-2xl">{s.value}</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -121,40 +121,70 @@ export default async function DashboardPage() {
|
||||
<CardTitle>最近报单商户</CardTitle>
|
||||
<Link
|
||||
href="/customers"
|
||||
className="flex items-center gap-1 text-[13px] font-medium text-[var(--color-primary)] hover:underline"
|
||||
className="flex min-h-11 items-center gap-1 text-[13px] font-medium text-[var(--color-primary)] hover:underline md:min-h-0"
|
||||
>
|
||||
查看全部 <ArrowUpRight className="h-3.5 w-3.5" />
|
||||
</Link>
|
||||
</CardHeader>
|
||||
<Table>
|
||||
<THead>
|
||||
<tr>
|
||||
<TH>商户名称</TH>
|
||||
<TH>联系人</TH>
|
||||
<TH>业务员</TH>
|
||||
<TH>报单时间</TH>
|
||||
<TH>生日</TH>
|
||||
</tr>
|
||||
</THead>
|
||||
<tbody>
|
||||
{recent.map((c) => (
|
||||
<TR key={c.id}>
|
||||
<TD className="font-medium">{c.customerName}</TD>
|
||||
<TD>{c.contacts}</TD>
|
||||
<TD>{c.salesman}</TD>
|
||||
<TD className="tabular-nums">{fmtDate(c.reportDate)}</TD>
|
||||
<TD>
|
||||
<span className="tabular-nums">{fmtDate(c.birthday)}</span>
|
||||
{c.birthday && (
|
||||
<Badge tone={c.birthdayType === 2 ? "warning" : "info"} className="ml-2">
|
||||
{c.birthdayType === 2 ? "农历" : "阳历"}
|
||||
</Badge>
|
||||
)}
|
||||
</TD>
|
||||
</TR>
|
||||
))}
|
||||
</tbody>
|
||||
</Table>
|
||||
<div className="hidden md:block">
|
||||
<Table>
|
||||
<THead>
|
||||
<tr>
|
||||
<TH>商户名称</TH>
|
||||
<TH>联系人</TH>
|
||||
<TH>业务员</TH>
|
||||
<TH>报单时间</TH>
|
||||
<TH>生日</TH>
|
||||
</tr>
|
||||
</THead>
|
||||
<tbody>
|
||||
{recent.map((c) => (
|
||||
<TR key={c.id}>
|
||||
<TD className="font-medium">{c.customerName}</TD>
|
||||
<TD>{c.contacts}</TD>
|
||||
<TD>{c.salesman}</TD>
|
||||
<TD className="tabular-nums">{fmtDate(c.reportDate)}</TD>
|
||||
<TD>
|
||||
<span className="tabular-nums">{fmtDate(c.birthday)}</span>
|
||||
{c.birthday && (
|
||||
<Badge tone={c.birthdayType === 2 ? "warning" : "info"} className="ml-2">
|
||||
{c.birthdayType === 2 ? "农历" : "阳历"}
|
||||
</Badge>
|
||||
)}
|
||||
</TD>
|
||||
</TR>
|
||||
))}
|
||||
</tbody>
|
||||
</Table>
|
||||
</div>
|
||||
<div className="divide-y md:hidden">
|
||||
{recent.length === 0 && (
|
||||
<div className="px-4 py-10 text-center text-sm text-[var(--color-muted-foreground)]">
|
||||
暂无报单
|
||||
</div>
|
||||
)}
|
||||
{recent.map((c) => (
|
||||
<div key={c.id} className="flex items-start justify-between gap-3 px-4 py-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.contacts || "—"}
|
||||
{c.salesman ? ` · ${c.salesman}` : ""}
|
||||
</div>
|
||||
</div>
|
||||
<div className="shrink-0 text-right">
|
||||
<div className="text-xs tabular-nums text-[var(--color-muted-foreground)]">
|
||||
{fmtDate(c.reportDate)}
|
||||
</div>
|
||||
{c.birthday && (
|
||||
<Badge tone={c.birthdayType === 2 ? "warning" : "info"} className="mt-1">
|
||||
{c.birthdayType === 2 ? "农历" : "阳历"} {fmtDate(c.birthday)}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -61,7 +61,7 @@ export function AdminForm({
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="flex gap-2 border-t pt-4">
|
||||
<div className="sticky bottom-0 z-10 -mx-4 flex gap-2 border-t bg-[var(--color-surface)] px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:static md:mx-0 md:px-0 md:pb-0 md:pt-4">
|
||||
<Button type="submit" disabled={pending}>
|
||||
{pending ? "保存中…" : "保存"}
|
||||
</Button>
|
||||
|
||||
@@ -26,12 +26,12 @@ export default async function AdminsPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex justify-end">
|
||||
<Link href="/rbac/admins/new">
|
||||
<Button><Plus className="h-4 w-4" />新增管理员</Button>
|
||||
<div className="flex">
|
||||
<Link href="/rbac/admins/new" className="w-full sm:ml-auto sm:w-auto">
|
||||
<Button className="w-full"><Plus className="h-4 w-4" />新增管理员</Button>
|
||||
</Link>
|
||||
</div>
|
||||
<Card className="overflow-hidden">
|
||||
<Card className="hidden overflow-hidden md:block">
|
||||
<Table>
|
||||
<THead>
|
||||
<tr>
|
||||
@@ -75,6 +75,39 @@ export default async function AdminsPage() {
|
||||
</tbody>
|
||||
</Table>
|
||||
</Card>
|
||||
|
||||
<div className="space-y-3 md:hidden">
|
||||
{admins.map((a) => (
|
||||
<Card key={a.id} className="p-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<Avatar name={a.nickname} size={36} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="truncate font-medium">{a.nickname}</span>
|
||||
{adminRole.get(a.id) ? (
|
||||
<Badge tone="primary" className="shrink-0">{adminRole.get(a.id)}</Badge>
|
||||
) : (
|
||||
<span className="shrink-0 text-xs text-[var(--color-muted-foreground)]">未分配</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-0.5 text-xs tabular-nums text-[var(--color-muted-foreground)]">
|
||||
{a.username}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 flex flex-wrap gap-1.5 border-t pt-3">
|
||||
<Link href={`/rbac/admins/${a.id}/edit`}>
|
||||
<Button variant="outline" size="sm">编辑</Button>
|
||||
</Link>
|
||||
<ConfirmDelete
|
||||
action={deleteAdmin.bind(null, a.id)}
|
||||
name={a.nickname}
|
||||
disabled={a.id === 1}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ export default async function PermissionsPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex justify-end">
|
||||
<Link href="/rbac/permissions/new">
|
||||
<Button><Plus className="h-4 w-4" />新增权限</Button>
|
||||
<div className="flex">
|
||||
<Link href="/rbac/permissions/new" className="w-full sm:ml-auto sm:w-auto">
|
||||
<Button className="w-full"><Plus className="h-4 w-4" />新增权限</Button>
|
||||
</Link>
|
||||
</div>
|
||||
<Card className="overflow-hidden">
|
||||
<Card className="hidden overflow-hidden md:block">
|
||||
<Table>
|
||||
<THead>
|
||||
<tr>
|
||||
@@ -85,6 +85,26 @@ export default async function PermissionsPage() {
|
||||
</tbody>
|
||||
</Table>
|
||||
</Card>
|
||||
|
||||
<div className="space-y-3 md:hidden">
|
||||
{rows.map(({ p, depth }) => (
|
||||
<Card key={p.id} className="p-4" style={{ marginLeft: depth * 12 }}>
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="font-medium">{p.title || p.name}</div>
|
||||
<div className="mt-1 truncate text-xs text-[var(--color-muted-foreground)]">{p.name}</div>
|
||||
</div>
|
||||
{p.isMenu ? <Badge tone="primary" className="shrink-0">菜单</Badge> : <Badge className="shrink-0">操作</Badge>}
|
||||
</div>
|
||||
<div className="mt-3 flex flex-wrap gap-1.5 border-t pt-3">
|
||||
<Link href={`/rbac/permissions/${p.id}/edit`}>
|
||||
<Button variant="outline" size="sm">编辑</Button>
|
||||
</Link>
|
||||
<ConfirmDelete action={deletePermission.bind(null, p.id)} name={p.title || p.name} />
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export function PermissionForm({
|
||||
const v = defaultValues ?? {};
|
||||
return (
|
||||
<form action={formAction} className="max-w-lg space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="title">权限名称<span className="ml-0.5 text-[var(--color-danger)]">*</span></Label>
|
||||
<Input id="title" name="title" defaultValue={v.title} placeholder="如:商户列表" />
|
||||
@@ -53,12 +53,12 @@ export function PermissionForm({
|
||||
<Label htmlFor="sort">排序</Label>
|
||||
<Input id="sort" name="sort" type="number" defaultValue={String(v.sort ?? 0)} />
|
||||
</div>
|
||||
<label className="flex items-center gap-2 self-end pb-2">
|
||||
<label className="flex min-h-11 items-center gap-2 sm:self-end sm:pb-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="isMenu"
|
||||
defaultChecked={v.isMenu}
|
||||
className="h-4 w-4 accent-[var(--color-primary)]"
|
||||
className="h-5 w-5 accent-[var(--color-primary)]"
|
||||
/>
|
||||
<span className="text-sm">显示为菜单</span>
|
||||
</label>
|
||||
@@ -68,7 +68,7 @@ export function PermissionForm({
|
||||
{state.error}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex gap-2 border-t pt-4">
|
||||
<div className="sticky bottom-0 z-10 -mx-4 flex gap-2 border-t bg-[var(--color-surface)] px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:static md:mx-0 md:px-0 md:pb-0 md:pt-4">
|
||||
<Button type="submit" disabled={pending}>{pending ? "保存中…" : "保存"}</Button>
|
||||
<Link href="/rbac/permissions"><Button type="button" variant="outline">取消</Button></Link>
|
||||
</div>
|
||||
|
||||
@@ -52,17 +52,21 @@ export function AssignPermissions({
|
||||
const renderNode = (node: PermNode, depth: number) => (
|
||||
<div key={node.id}>
|
||||
<label
|
||||
className="flex items-center gap-2.5 rounded-md px-2 py-1.5 hover:bg-[var(--color-muted)]"
|
||||
style={{ paddingLeft: depth * 20 + 8 }}
|
||||
className="flex min-h-11 items-center gap-2.5 rounded-md py-2 pr-2 hover:bg-[var(--color-muted)]"
|
||||
style={{ paddingLeft: 8 + depth * 14 }}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
className="h-4 w-4 accent-[var(--color-primary)]"
|
||||
className="h-5 w-5 shrink-0 accent-[var(--color-primary)]"
|
||||
checked={checked.has(node.id)}
|
||||
onChange={(e) => toggle(node, e.target.checked)}
|
||||
/>
|
||||
<span className="text-sm">{node.title}</span>
|
||||
<span className="text-xs text-[var(--color-muted-foreground)]">{node.name}</span>
|
||||
<span className="min-w-0">
|
||||
<span className="text-sm">{node.title}</span>
|
||||
<span className="mt-0.5 block truncate text-xs text-[var(--color-muted-foreground)] sm:ml-1.5 sm:mt-0 sm:inline">
|
||||
{node.name}
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
{node.children.map((c) => renderNode(c, depth + 1))}
|
||||
</div>
|
||||
@@ -73,8 +77,8 @@ export function AssignPermissions({
|
||||
<div className="rounded-[var(--radius)] border p-2">
|
||||
{tree.map((n) => renderNode(n, 0))}
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button onClick={save} disabled={pending}>
|
||||
<div className="sticky bottom-0 z-10 -mx-4 flex gap-2 border-t bg-[var(--color-surface)] px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:static md:mx-0 md:px-0 md:pb-0 md:pt-4">
|
||||
<Button onClick={save} disabled={pending} className="flex-1 sm:flex-none">
|
||||
{pending ? "保存中…" : `保存(已选 ${checked.size} 项)`}
|
||||
</Button>
|
||||
<Link href="/rbac/roles"><Button variant="outline">取消</Button></Link>
|
||||
|
||||
@@ -18,12 +18,12 @@ export default async function RolesPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex justify-end">
|
||||
<Link href="/rbac/roles/new">
|
||||
<Button><Plus className="h-4 w-4" />新增角色</Button>
|
||||
<div className="flex">
|
||||
<Link href="/rbac/roles/new" className="w-full sm:ml-auto sm:w-auto">
|
||||
<Button className="w-full"><Plus className="h-4 w-4" />新增角色</Button>
|
||||
</Link>
|
||||
</div>
|
||||
<Card className="overflow-hidden">
|
||||
<Card className="hidden overflow-hidden md:block">
|
||||
<Table>
|
||||
<THead>
|
||||
<tr>
|
||||
@@ -62,6 +62,35 @@ export default async function RolesPage() {
|
||||
</tbody>
|
||||
</Table>
|
||||
</Card>
|
||||
|
||||
<div className="space-y-3 md:hidden">
|
||||
{roles.map((r) => (
|
||||
<Card key={r.id} className="p-4">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2 font-medium">
|
||||
<ShieldCheck className="h-4 w-4 shrink-0 text-[var(--color-primary)]" />
|
||||
<span className="truncate">{r.title || r.name}</span>
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-[var(--color-muted-foreground)]">{r.name}</div>
|
||||
</div>
|
||||
<Badge tone="info" className="shrink-0">{countMap.get(r.id) ?? 0} 项权限</Badge>
|
||||
</div>
|
||||
{r.remark && (
|
||||
<p className="mt-2 text-sm text-[var(--color-muted-foreground)]">{r.remark}</p>
|
||||
)}
|
||||
<div className="mt-3 flex flex-wrap gap-1.5 border-t pt-3">
|
||||
<Link href={`/rbac/roles/${r.id}/permissions`}>
|
||||
<Button variant="soft" size="sm">分配权限</Button>
|
||||
</Link>
|
||||
<Link href={`/rbac/roles/${r.id}/edit`}>
|
||||
<Button variant="outline" size="sm">编辑</Button>
|
||||
</Link>
|
||||
<ConfirmDelete action={deleteRole.bind(null, r.id)} name={r.title || r.name} disabled={r.id === 1} />
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export function RoleForm({
|
||||
{state.error}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex gap-2 border-t pt-4">
|
||||
<div className="sticky bottom-0 z-10 -mx-4 flex gap-2 border-t bg-[var(--color-surface)] px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:static md:mx-0 md:px-0 md:pb-0 md:pt-4">
|
||||
<Button type="submit" disabled={pending}>{pending ? "保存中…" : "保存"}</Button>
|
||||
<Link href="/rbac/roles"><Button type="button" variant="outline">取消</Button></Link>
|
||||
</div>
|
||||
|
||||
@@ -17,20 +17,21 @@ export function MonthlyReportChart({ data }: { data: MonthPoint[] }) {
|
||||
const max = Math.max(1, ...data.map((d) => d.count));
|
||||
|
||||
return (
|
||||
<div className="h-72 w-full">
|
||||
<div className="h-52 w-full md:h-72">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={data} margin={{ top: 8, right: 8, left: -12, bottom: 0 }}>
|
||||
<BarChart data={data} margin={{ top: 8, right: 4, left: -18, bottom: 0 }}>
|
||||
<CartesianGrid strokeDasharray="3 3" stroke="#eef0f3" vertical={false} />
|
||||
<XAxis
|
||||
dataKey="label"
|
||||
tick={{ fontSize: 12, fill: "#64748b" }}
|
||||
tick={{ fontSize: 10, fill: "#64748b" }}
|
||||
tickLine={false}
|
||||
axisLine={{ stroke: "#e8eaed" }}
|
||||
interval="preserveStartEnd"
|
||||
/>
|
||||
<YAxis
|
||||
allowDecimals={false}
|
||||
width={40}
|
||||
tick={{ fontSize: 12, fill: "#64748b" }}
|
||||
width={32}
|
||||
tick={{ fontSize: 11, fill: "#64748b" }}
|
||||
tickLine={false}
|
||||
axisLine={false}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user