feat(customer-view): 查看弹窗分区美化(基本/生日/业务/备注)
- 把平铺的 InfoRow 切成 基本/生日/业务/备注 四块,每块带灰色小标题 + 浅灰分隔线 - 生日类型/生日归属/生日 聚到「生日」块 - 新增 Section helper(复用 --color-border / --color-muted-foreground,不新增组件文件) - 空分区整体隐藏;首块无顶部分隔线(first: 变体动态生效) - CardTitle「商户信息」、Esc/遮罩/✕ 关闭、InfoRow、长文本换行 均保留 校验:tsc --noEmit 通过;next build 全路由编译通过。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
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";
|
||||
@@ -40,6 +40,10 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
||||
const birthdayLabel = customer.birthdayType === 2 ? "阴历" : "阳历";
|
||||
const birthdayOwnerLabel = customer.birthdayOwner === 1 ? "结算人" : "联系人";
|
||||
|
||||
// 各分区是否至少有一个字段,用于隐藏整块为空的小标题
|
||||
const hasBasic = !!(customer.customerName || customer.contacts || customer.balanceUser || customer.phone || customer.detail);
|
||||
const hasBusiness = !!(customer.deposit || customer.buy || customer.salesman || customer.reportDate);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button variant="outline" size="sm" onClick={() => setOpen(true)}>
|
||||
@@ -69,20 +73,36 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
||||
</button>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<InfoRow label="商户名称" value={customer.customerName} />
|
||||
<InfoRow label="联系人" value={customer.contacts} />
|
||||
<InfoRow label="结算人" value={customer.balanceUser} />
|
||||
<InfoRow label="联系电话" value={customer.phone} />
|
||||
<InfoRow label="产品明细" value={customer.detail} className="whitespace-pre-wrap" />
|
||||
<InfoRow label="押金" value={customer.deposit} />
|
||||
<InfoRow label="买断" value={customer.buy} />
|
||||
<InfoRow label="生日类型" value={customer.birthday ? birthdayLabel : undefined} />
|
||||
<InfoRow label="生日归属" value={customer.birthday ? birthdayOwnerLabel : undefined} />
|
||||
<InfoRow label="生日" value={fmtDate(customer.birthday)} />
|
||||
<InfoRow label="业务员" value={customer.salesman} />
|
||||
<InfoRow label="报单日期" value={fmtDate(customer.reportDate)} />
|
||||
<InfoRow label="备注" value={customer.remark} className="whitespace-pre-wrap" />
|
||||
<CardContent>
|
||||
{hasBasic && (
|
||||
<Section title="基本">
|
||||
<InfoRow label="商户名称" value={customer.customerName} />
|
||||
<InfoRow label="联系人" value={customer.contacts} />
|
||||
<InfoRow label="结算人" value={customer.balanceUser} />
|
||||
<InfoRow label="联系电话" value={customer.phone} />
|
||||
<InfoRow label="产品明细" value={customer.detail} className="whitespace-pre-wrap" />
|
||||
</Section>
|
||||
)}
|
||||
{customer.birthday && (
|
||||
<Section title="生日">
|
||||
<InfoRow label="生日类型" value={birthdayLabel} />
|
||||
<InfoRow label="生日归属" value={birthdayOwnerLabel} />
|
||||
<InfoRow label="生日" value={fmtDate(customer.birthday)} />
|
||||
</Section>
|
||||
)}
|
||||
{hasBusiness && (
|
||||
<Section title="业务">
|
||||
<InfoRow label="押金" value={customer.deposit} />
|
||||
<InfoRow label="买断" value={customer.buy} />
|
||||
<InfoRow label="业务员" value={customer.salesman} />
|
||||
<InfoRow label="报单日期" value={fmtDate(customer.reportDate)} />
|
||||
</Section>
|
||||
)}
|
||||
{customer.remark && (
|
||||
<Section title="备注">
|
||||
<p className="whitespace-pre-wrap text-sm">{customer.remark}</p>
|
||||
</Section>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
@@ -91,6 +111,18 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
||||
);
|
||||
}
|
||||
|
||||
// 分区容器:小标题 + 内容;块间用浅灰分隔线隔开,首块无顶部分隔线
|
||||
function Section({ title, children }: { title: string; children: ReactNode }) {
|
||||
return (
|
||||
<section className="space-y-2.5 border-t border-[var(--color-border)] pt-5 mt-5 first:border-0 first:pt-0 first:mt-0">
|
||||
<h4 className="text-xs font-semibold tracking-wide text-[var(--color-muted-foreground)]">
|
||||
{title}
|
||||
</h4>
|
||||
{children}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function InfoRow({
|
||||
label,
|
||||
value,
|
||||
|
||||
Reference in New Issue
Block a user