feat(customer-form): 新增/编辑表单分区(基本/生日/其它)

- 加 FormSection helper(灰色小标题,复用 --color-muted-foreground,不新增组件文件)
- 字段拆成 基本(商户名称/联系人/结算人/业务员/联系电话/报单日期) / 生日(类型/归属/生日) / 其它(押金/买断/产品明细/备注)
- 保留紧凑网格(sm:2/lg:3),生日三字段独立成块;录入密度不降
- 与查看弹窗分区心智一致;required/校验/提交行 不变

校验:tsc --noEmit 通过;next build 全路由编译通过。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-12 20:11:57 +08:00
co-authored by Claude
parent 027a0b55a4
commit 63901b6de1
@@ -63,6 +63,24 @@ function Field({
); );
} }
// 表单分区:小标题 + 内容;块间靠外层 space-y-6 分隔,不加灰线(录入场景保持紧凑)
function FormSection({
title,
children,
}: {
title: string;
children: React.ReactNode;
}) {
return (
<section className="space-y-3">
<h4 className="text-xs font-semibold tracking-wide text-[var(--color-muted-foreground)]">
{title}
</h4>
{children}
</section>
);
}
export function CustomerForm({ export function CustomerForm({
action, action,
defaultValues, defaultValues,
@@ -79,6 +97,7 @@ export function CustomerForm({
return ( return (
<form action={formAction} className="space-y-6"> <form action={formAction} className="space-y-6">
<FormSection title="基本">
<div className="grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2 lg:grid-cols-3"> <div className="grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2 lg:grid-cols-3">
<Field <Field
label="商户名称" label="商户名称"
@@ -107,10 +126,11 @@ export function CustomerForm({
defaultValue={fmtDate(v.reportDate)} defaultValue={fmtDate(v.reportDate)}
required required
/> />
<Field label="押金" name="deposit" defaultValue={v.deposit} required={requireAll} /> </div>
<Field label="买断" name="buy" defaultValue={v.buy} required={requireAll} /> </FormSection>
{/* 生日类型 + 生日归属,同行两个下拉框 */}
<div className="grid grid-cols-2 gap-3"> <FormSection title="生日">
<div className="grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2 lg:grid-cols-3">
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label htmlFor="birthdayType">生日类型</Label> <Label htmlFor="birthdayType">生日类型</Label>
<Select id="birthdayType" name="birthdayType" defaultValue={String(v.birthdayType ?? 1)}> <Select id="birthdayType" name="birthdayType" defaultValue={String(v.birthdayType ?? 1)}>
@@ -125,7 +145,6 @@ export function CustomerForm({
<option value="2">联系人</option> <option value="2">联系人</option>
</Select> </Select>
</div> </div>
</div>
<Field <Field
label="生日" label="生日"
name="birthday" name="birthday"
@@ -134,18 +153,24 @@ export function CustomerForm({
required={requireAll} required={requireAll}
/> />
</div> </div>
</FormSection>
<FormSection title="其它">
<div className="grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2">
<Field label="押金" name="deposit" defaultValue={v.deposit} required={requireAll} />
<Field label="买断" name="buy" defaultValue={v.buy} required={requireAll} />
</div>
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label htmlFor="detail"> <Label htmlFor="detail">
产品明细<span className="ml-0.5 text-[var(--color-danger)]">*</span> 产品明细<span className="ml-0.5 text-[var(--color-danger)]">*</span>
</Label> </Label>
<Textarea id="detail" name="detail" defaultValue={v.detail ?? ""} rows={3} /> <Textarea id="detail" name="detail" defaultValue={v.detail ?? ""} rows={3} />
</div> </div>
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label htmlFor="remark">备注</Label> <Label htmlFor="remark">备注</Label>
<Textarea id="remark" name="remark" defaultValue={v.remark ?? ""} rows={2} /> <Textarea id="remark" name="remark" defaultValue={v.remark ?? ""} rows={2} />
</div> </div>
</FormSection>
{state.error && ( {state.error && (
<p className="rounded-md bg-[var(--color-danger-soft)] px-3 py-2 text-sm text-[var(--color-danger)]"> <p className="rounded-md bg-[var(--color-danger-soft)] px-3 py-2 text-sm text-[var(--color-danger)]">