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:
@@ -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({
|
||||
action,
|
||||
defaultValues,
|
||||
@@ -79,6 +97,7 @@ export function CustomerForm({
|
||||
|
||||
return (
|
||||
<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">
|
||||
<Field
|
||||
label="商户名称"
|
||||
@@ -107,10 +126,11 @@ export function CustomerForm({
|
||||
defaultValue={fmtDate(v.reportDate)}
|
||||
required
|
||||
/>
|
||||
<Field label="押金" name="deposit" defaultValue={v.deposit} required={requireAll} />
|
||||
<Field label="买断" name="buy" defaultValue={v.buy} required={requireAll} />
|
||||
{/* 生日类型 + 生日归属,同行两个下拉框 */}
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
</div>
|
||||
</FormSection>
|
||||
|
||||
<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">
|
||||
<Label htmlFor="birthdayType">生日类型</Label>
|
||||
<Select id="birthdayType" name="birthdayType" defaultValue={String(v.birthdayType ?? 1)}>
|
||||
@@ -125,7 +145,6 @@ export function CustomerForm({
|
||||
<option value="2">联系人</option>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<Field
|
||||
label="生日"
|
||||
name="birthday"
|
||||
@@ -134,18 +153,24 @@ export function CustomerForm({
|
||||
required={requireAll}
|
||||
/>
|
||||
</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">
|
||||
<Label htmlFor="detail">
|
||||
产品明细<span className="ml-0.5 text-[var(--color-danger)]">*</span>
|
||||
</Label>
|
||||
<Textarea id="detail" name="detail" defaultValue={v.detail ?? ""} rows={3} />
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="remark">备注</Label>
|
||||
<Textarea id="remark" name="remark" defaultValue={v.remark ?? ""} rows={2} />
|
||||
</div>
|
||||
</FormSection>
|
||||
|
||||
{state.error && (
|
||||
<p className="rounded-md bg-[var(--color-danger-soft)] px-3 py-2 text-sm text-[var(--color-danger)]">
|
||||
|
||||
Reference in New Issue
Block a user