feat: 生日归属字段贯通全部界面(查看/列表/提醒/导入/导出/模板)
补全 birthdayOwner(1=结算人 2=联系人)在 schema 写入链路之外的所有流转环节: - 查看弹窗 customer-view:新增"生日归属"行 - 商户列表 page:生日单元格追加归属 badge - 生日提醒页 birthday:新增"归属"列(Row 类型 / SQL / 表头 / colSpan 6→7 / 单元格) - 导入 actions.importCustomers:validData 写入 birthdayOwner(结算人或"1"→1,否则→2) - 导出 export/route + query.EXCEL_COLUMNS:新增"生日归属"列与对应行值 - 导入模板 template/route:表头与示例行同步插入"生日归属"/"联系人" - 表单 customer-form:CustomerValues 类型补 birthdayOwner(消除 v.birthdayOwner 的 TS 报错,编辑页正确回填) 前置条件:MySQL customers 表需新增 birthday_owner 列(见 PR 说明),否则写入与生日页 SQL 会报 Unknown column。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ model Customer {
|
|||||||
deposit String? // 押金
|
deposit String? // 押金
|
||||||
buy String? // 买断
|
buy String? // 买断
|
||||||
birthdayType Int? @default(1) @map("birthday_type") // 1阳历 2阴历
|
birthdayType Int? @default(1) @map("birthday_type") // 1阳历 2阴历
|
||||||
|
birthdayOwner Int? @default(2) @map("birthday_owner") // 1结算人 2联系人
|
||||||
birthday DateTime? @db.Date // 已清洗为 date(阴历行月日为农历,年份占位)
|
birthday DateTime? @db.Date // 已清洗为 date(阴历行月日为农历,年份占位)
|
||||||
birthdayRaw String? @map("birthday_raw") // 清洗前原始脏值备份
|
birthdayRaw String? @map("birthday_raw") // 清洗前原始脏值备份
|
||||||
salesman String? // 业务员
|
salesman String? // 业务员
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ const schema = z.object({
|
|||||||
deposit: z.string().trim().optional().default(""),
|
deposit: z.string().trim().optional().default(""),
|
||||||
buy: z.string().trim().optional().default(""),
|
buy: z.string().trim().optional().default(""),
|
||||||
birthdayType: z.coerce.number().int().min(1).max(2).default(1),
|
birthdayType: z.coerce.number().int().min(1).max(2).default(1),
|
||||||
|
birthdayOwner: z.coerce.number().int().min(1).max(2).default(2),
|
||||||
birthday: z.string().trim().optional().default(""),
|
birthday: z.string().trim().optional().default(""),
|
||||||
remark: z.string().trim().optional().default(""),
|
remark: z.string().trim().optional().default(""),
|
||||||
});
|
});
|
||||||
@@ -63,6 +64,7 @@ function pickForm(formData: FormData) {
|
|||||||
deposit: formData.get("deposit") ?? "",
|
deposit: formData.get("deposit") ?? "",
|
||||||
buy: formData.get("buy") ?? "",
|
buy: formData.get("buy") ?? "",
|
||||||
birthdayType: formData.get("birthdayType") ?? 1,
|
birthdayType: formData.get("birthdayType") ?? 1,
|
||||||
|
birthdayOwner: formData.get("birthdayOwner") ?? 2,
|
||||||
birthday: formData.get("birthday") ?? "",
|
birthday: formData.get("birthday") ?? "",
|
||||||
remark: formData.get("remark") ?? "",
|
remark: formData.get("remark") ?? "",
|
||||||
};
|
};
|
||||||
@@ -127,6 +129,7 @@ const HEADER_MAP: Record<string, string> = {
|
|||||||
押金: "deposit",
|
押金: "deposit",
|
||||||
买断: "buy",
|
买断: "buy",
|
||||||
生日类型: "birthdayType",
|
生日类型: "birthdayType",
|
||||||
|
生日归属: "birthdayOwner",
|
||||||
生日: "birthday",
|
生日: "birthday",
|
||||||
业务员: "salesman",
|
业务员: "salesman",
|
||||||
报单日期: "reportDate",
|
报单日期: "reportDate",
|
||||||
@@ -179,6 +182,7 @@ export async function importCustomers(formData: FormData): Promise<ImportResult>
|
|||||||
salesman: rec.salesman || null,
|
salesman: rec.salesman || null,
|
||||||
remark: rec.remark || null,
|
remark: rec.remark || null,
|
||||||
birthdayType: rec.birthdayType === "阴历" || rec.birthdayType === "2" ? 2 : 1,
|
birthdayType: rec.birthdayType === "阴历" || rec.birthdayType === "2" ? 2 : 1,
|
||||||
|
birthdayOwner: rec.birthdayOwner === "结算人" || rec.birthdayOwner === "1" ? 1 : 2,
|
||||||
birthday: parseDate(rec.birthday),
|
birthday: parseDate(rec.birthday),
|
||||||
reportDate,
|
reportDate,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type Row = {
|
|||||||
reportDate: Date | null;
|
reportDate: Date | null;
|
||||||
birthday: Date | null;
|
birthday: Date | null;
|
||||||
birthdayType: number | null;
|
birthdayType: number | null;
|
||||||
|
birthdayOwner: number | null;
|
||||||
remark: string | null;
|
remark: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ export default async function BirthdayPage({
|
|||||||
report_date AS reportDate,
|
report_date AS reportDate,
|
||||||
birthday,
|
birthday,
|
||||||
birthday_type AS birthdayType,
|
birthday_type AS birthdayType,
|
||||||
|
birthday_owner AS birthdayOwner,
|
||||||
remark
|
remark
|
||||||
FROM customers
|
FROM customers
|
||||||
WHERE deleted_at IS NULL AND (
|
WHERE deleted_at IS NULL AND (
|
||||||
@@ -81,12 +83,13 @@ export default async function BirthdayPage({
|
|||||||
<TH>业务员</TH>
|
<TH>业务员</TH>
|
||||||
<TH>生日</TH>
|
<TH>生日</TH>
|
||||||
<TH>历法</TH>
|
<TH>历法</TH>
|
||||||
|
<TH>归属</TH>
|
||||||
</tr>
|
</tr>
|
||||||
</THead>
|
</THead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{rows.length === 0 && (
|
{rows.length === 0 && (
|
||||||
<tr>
|
<tr>
|
||||||
<TD colSpan={6} className="py-14 text-center text-[var(--color-muted-foreground)]">
|
<TD colSpan={7} className="py-14 text-center text-[var(--color-muted-foreground)]">
|
||||||
该时段暂无生日商户
|
该时段暂无生日商户
|
||||||
</TD>
|
</TD>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -103,6 +106,7 @@ export default async function BirthdayPage({
|
|||||||
{c.birthdayType === 2 ? "农历" : "阳历"}
|
{c.birthdayType === 2 ? "农历" : "阳历"}
|
||||||
</Badge>
|
</Badge>
|
||||||
</TD>
|
</TD>
|
||||||
|
<TD>{c.birthdayOwner === 1 ? "结算人" : "联系人"}</TD>
|
||||||
</TR>
|
</TR>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ type CustomerValues = {
|
|||||||
deposit?: string | null;
|
deposit?: string | null;
|
||||||
buy?: string | null;
|
buy?: string | null;
|
||||||
birthdayType?: number | null;
|
birthdayType?: number | null;
|
||||||
|
birthdayOwner?: number | null;
|
||||||
birthday?: Date | null;
|
birthday?: Date | null;
|
||||||
salesman?: string | null;
|
salesman?: string | null;
|
||||||
reportDate?: Date | null;
|
reportDate?: Date | null;
|
||||||
@@ -108,12 +109,22 @@ export function CustomerForm({
|
|||||||
/>
|
/>
|
||||||
<Field label="押金" name="deposit" defaultValue={v.deposit} required={requireAll} />
|
<Field label="押金" name="deposit" defaultValue={v.deposit} required={requireAll} />
|
||||||
<Field label="买断" name="buy" defaultValue={v.buy} required={requireAll} />
|
<Field label="买断" name="buy" defaultValue={v.buy} required={requireAll} />
|
||||||
<div className="space-y-1.5">
|
{/* 生日类型 + 生日归属,同行两个下拉框 */}
|
||||||
<Label htmlFor="birthdayType">生日类型</Label>
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<Select id="birthdayType" name="birthdayType" defaultValue={String(v.birthdayType ?? 1)}>
|
<div className="space-y-1.5">
|
||||||
<option value="1">阳历</option>
|
<Label htmlFor="birthdayType">生日类型</Label>
|
||||||
<option value="2">阴历</option>
|
<Select id="birthdayType" name="birthdayType" defaultValue={String(v.birthdayType ?? 1)}>
|
||||||
</Select>
|
<option value="1">阳历</option>
|
||||||
|
<option value="2">阴历</option>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<Label htmlFor="birthdayOwner">生日归属</Label>
|
||||||
|
<Select id="birthdayOwner" name="birthdayOwner" defaultValue={String(v.birthdayOwner ?? 2)}>
|
||||||
|
<option value="1">结算人</option>
|
||||||
|
<option value="2">联系人</option>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Field
|
<Field
|
||||||
label="生日"
|
label="生日"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type CustomerViewProps = {
|
|||||||
deposit?: string | null;
|
deposit?: string | null;
|
||||||
buy?: string | null;
|
buy?: string | null;
|
||||||
birthdayType?: number | null;
|
birthdayType?: number | null;
|
||||||
|
birthdayOwner?: number | null;
|
||||||
birthday?: Date | null;
|
birthday?: Date | null;
|
||||||
salesman?: string | null;
|
salesman?: string | null;
|
||||||
reportDate?: Date | null;
|
reportDate?: Date | null;
|
||||||
@@ -37,6 +38,7 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
|||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
const birthdayLabel = customer.birthdayType === 2 ? "阴历" : "阳历";
|
const birthdayLabel = customer.birthdayType === 2 ? "阴历" : "阳历";
|
||||||
|
const birthdayOwnerLabel = customer.birthdayOwner === 1 ? "结算人" : "联系人";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -76,6 +78,7 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
|||||||
<InfoRow label="押金" value={customer.deposit} />
|
<InfoRow label="押金" value={customer.deposit} />
|
||||||
<InfoRow label="买断" value={customer.buy} />
|
<InfoRow label="买断" value={customer.buy} />
|
||||||
<InfoRow label="生日类型" value={customer.birthday ? birthdayLabel : undefined} />
|
<InfoRow label="生日类型" value={customer.birthday ? birthdayLabel : undefined} />
|
||||||
|
<InfoRow label="生日归属" value={customer.birthday ? birthdayOwnerLabel : undefined} />
|
||||||
<InfoRow label="生日" value={fmtDate(customer.birthday)} />
|
<InfoRow label="生日" value={fmtDate(customer.birthday)} />
|
||||||
<InfoRow label="业务员" value={customer.salesman} />
|
<InfoRow label="业务员" value={customer.salesman} />
|
||||||
<InfoRow label="报单日期" value={fmtDate(customer.reportDate)} />
|
<InfoRow label="报单日期" value={fmtDate(customer.reportDate)} />
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export async function GET(req: NextRequest) {
|
|||||||
c.deposit ?? "",
|
c.deposit ?? "",
|
||||||
c.buy ?? "",
|
c.buy ?? "",
|
||||||
c.birthdayType === 2 ? "阴历" : "阳历",
|
c.birthdayType === 2 ? "阴历" : "阳历",
|
||||||
|
c.birthdayOwner === 1 ? "结算人" : "联系人",
|
||||||
fmtDate(c.birthday),
|
fmtDate(c.birthday),
|
||||||
c.salesman ?? "",
|
c.salesman ?? "",
|
||||||
fmtDate(c.reportDate),
|
fmtDate(c.reportDate),
|
||||||
|
|||||||
@@ -100,6 +100,11 @@ export default async function CustomersPage({
|
|||||||
{c.birthdayType === 2 ? "农历" : "阳历"}
|
{c.birthdayType === 2 ? "农历" : "阳历"}
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
|
{c.birthday && (
|
||||||
|
<Badge tone="neutral" className="ml-2">
|
||||||
|
{c.birthdayOwner === 1 ? "结算人" : "联系人"}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
</TD>
|
</TD>
|
||||||
<TD>{c.salesman}</TD>
|
<TD>{c.salesman}</TD>
|
||||||
<TD className="tabular-nums">{fmtDate(c.reportDate)}</TD>
|
<TD className="tabular-nums">{fmtDate(c.reportDate)}</TD>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export const EXCEL_COLUMNS: { header: string; key: string }[] = [
|
|||||||
{ header: "押金", key: "deposit" },
|
{ header: "押金", key: "deposit" },
|
||||||
{ header: "买断", key: "buy" },
|
{ header: "买断", key: "buy" },
|
||||||
{ header: "生日类型", key: "birthdayType" },
|
{ header: "生日类型", key: "birthdayType" },
|
||||||
|
{ header: "生日归属", key: "birthdayOwner" },
|
||||||
{ header: "生日", key: "birthday" },
|
{ header: "生日", key: "birthday" },
|
||||||
{ header: "业务员", key: "salesman" },
|
{ header: "业务员", key: "salesman" },
|
||||||
{ header: "报单日期", key: "reportDate" },
|
{ header: "报单日期", key: "reportDate" },
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export async function GET() {
|
|||||||
"押金",
|
"押金",
|
||||||
"买断",
|
"买断",
|
||||||
"生日类型",
|
"生日类型",
|
||||||
|
"生日归属",
|
||||||
"生日",
|
"生日",
|
||||||
"业务员",
|
"业务员",
|
||||||
"报单日期",
|
"报单日期",
|
||||||
@@ -33,6 +34,7 @@ export async function GET() {
|
|||||||
"100",
|
"100",
|
||||||
"100",
|
"100",
|
||||||
"阴历",
|
"阴历",
|
||||||
|
"联系人",
|
||||||
"生日格式要求:2022-06-21",
|
"生日格式要求:2022-06-21",
|
||||||
"A",
|
"A",
|
||||||
"报单日期格式要求:2022-06-21",
|
"报单日期格式要求:2022-06-21",
|
||||||
|
|||||||
Reference in New Issue
Block a user