From b43f375c866dba4d4e920efdce4333485221abc5 Mon Sep 17 00:00:00 2001 From: luishou Date: Sun, 12 Jul 2026 16:58:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=9F=E6=97=A5=E5=BD=92=E5=B1=9E?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E8=B4=AF=E9=80=9A=E5=85=A8=E9=83=A8=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=EF=BC=88=E6=9F=A5=E7=9C=8B/=E5=88=97=E8=A1=A8/?= =?UTF-8?q?=E6=8F=90=E9=86=92/=E5=AF=BC=E5=85=A5/=E5=AF=BC=E5=87=BA/?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补全 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 --- prisma/schema.prisma | 1 + src/app/(dashboard)/customers/actions.ts | 4 ++++ .../(dashboard)/customers/birthday/page.tsx | 6 ++++- .../(dashboard)/customers/customer-form.tsx | 23 ++++++++++++++----- .../(dashboard)/customers/customer-view.tsx | 3 +++ src/app/(dashboard)/customers/export/route.ts | 1 + src/app/(dashboard)/customers/page.tsx | 5 ++++ src/app/(dashboard)/customers/query.ts | 1 + .../(dashboard)/customers/template/route.ts | 2 ++ 9 files changed, 39 insertions(+), 7 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ea2d62b..55ce49b 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -24,6 +24,7 @@ model Customer { deposit String? // 押金 buy String? // 买断 birthdayType Int? @default(1) @map("birthday_type") // 1阳历 2阴历 + birthdayOwner Int? @default(2) @map("birthday_owner") // 1结算人 2联系人 birthday DateTime? @db.Date // 已清洗为 date(阴历行月日为农历,年份占位) birthdayRaw String? @map("birthday_raw") // 清洗前原始脏值备份 salesman String? // 业务员 diff --git a/src/app/(dashboard)/customers/actions.ts b/src/app/(dashboard)/customers/actions.ts index d94bf3f..ea43603 100644 --- a/src/app/(dashboard)/customers/actions.ts +++ b/src/app/(dashboard)/customers/actions.ts @@ -26,6 +26,7 @@ const schema = z.object({ deposit: z.string().trim().optional().default(""), buy: z.string().trim().optional().default(""), 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(""), remark: z.string().trim().optional().default(""), }); @@ -63,6 +64,7 @@ function pickForm(formData: FormData) { deposit: formData.get("deposit") ?? "", buy: formData.get("buy") ?? "", birthdayType: formData.get("birthdayType") ?? 1, + birthdayOwner: formData.get("birthdayOwner") ?? 2, birthday: formData.get("birthday") ?? "", remark: formData.get("remark") ?? "", }; @@ -127,6 +129,7 @@ const HEADER_MAP: Record = { 押金: "deposit", 买断: "buy", 生日类型: "birthdayType", + 生日归属: "birthdayOwner", 生日: "birthday", 业务员: "salesman", 报单日期: "reportDate", @@ -179,6 +182,7 @@ export async function importCustomers(formData: FormData): Promise salesman: rec.salesman || null, remark: rec.remark || null, birthdayType: rec.birthdayType === "阴历" || rec.birthdayType === "2" ? 2 : 1, + birthdayOwner: rec.birthdayOwner === "结算人" || rec.birthdayOwner === "1" ? 1 : 2, birthday: parseDate(rec.birthday), reportDate, }); diff --git a/src/app/(dashboard)/customers/birthday/page.tsx b/src/app/(dashboard)/customers/birthday/page.tsx index 4c7c748..702cef8 100644 --- a/src/app/(dashboard)/customers/birthday/page.tsx +++ b/src/app/(dashboard)/customers/birthday/page.tsx @@ -16,6 +16,7 @@ type Row = { reportDate: Date | null; birthday: Date | null; birthdayType: number | null; + birthdayOwner: number | null; remark: string | null; }; @@ -52,6 +53,7 @@ export default async function BirthdayPage({ report_date AS reportDate, birthday, birthday_type AS birthdayType, + birthday_owner AS birthdayOwner, remark FROM customers WHERE deleted_at IS NULL AND ( @@ -81,12 +83,13 @@ export default async function BirthdayPage({ 业务员 生日 历法 + 归属 {rows.length === 0 && ( - + 该时段暂无生日商户 @@ -103,6 +106,7 @@ export default async function BirthdayPage({ {c.birthdayType === 2 ? "农历" : "阳历"} + {c.birthdayOwner === 1 ? "结算人" : "联系人"} ))} diff --git a/src/app/(dashboard)/customers/customer-form.tsx b/src/app/(dashboard)/customers/customer-form.tsx index c465f9f..dc1659a 100644 --- a/src/app/(dashboard)/customers/customer-form.tsx +++ b/src/app/(dashboard)/customers/customer-form.tsx @@ -17,6 +17,7 @@ type CustomerValues = { deposit?: string | null; buy?: string | null; birthdayType?: number | null; + birthdayOwner?: number | null; birthday?: Date | null; salesman?: string | null; reportDate?: Date | null; @@ -108,12 +109,22 @@ export function CustomerForm({ /> -
- - + {/* 生日类型 + 生日归属,同行两个下拉框 */} +
+
+ + +
+
+ + +
@@ -76,6 +78,7 @@ export function CustomerView({ customer }: CustomerViewProps) { + diff --git a/src/app/(dashboard)/customers/export/route.ts b/src/app/(dashboard)/customers/export/route.ts index 69976a1..975ff77 100644 --- a/src/app/(dashboard)/customers/export/route.ts +++ b/src/app/(dashboard)/customers/export/route.ts @@ -33,6 +33,7 @@ export async function GET(req: NextRequest) { c.deposit ?? "", c.buy ?? "", c.birthdayType === 2 ? "阴历" : "阳历", + c.birthdayOwner === 1 ? "结算人" : "联系人", fmtDate(c.birthday), c.salesman ?? "", fmtDate(c.reportDate), diff --git a/src/app/(dashboard)/customers/page.tsx b/src/app/(dashboard)/customers/page.tsx index d58ee76..7cd2fa5 100644 --- a/src/app/(dashboard)/customers/page.tsx +++ b/src/app/(dashboard)/customers/page.tsx @@ -100,6 +100,11 @@ export default async function CustomersPage({ {c.birthdayType === 2 ? "农历" : "阳历"} )} + {c.birthday && ( + + {c.birthdayOwner === 1 ? "结算人" : "联系人"} + + )} {c.salesman} {fmtDate(c.reportDate)} diff --git a/src/app/(dashboard)/customers/query.ts b/src/app/(dashboard)/customers/query.ts index cde29dc..76c7fa2 100644 --- a/src/app/(dashboard)/customers/query.ts +++ b/src/app/(dashboard)/customers/query.ts @@ -37,6 +37,7 @@ export const EXCEL_COLUMNS: { header: string; key: string }[] = [ { header: "押金", key: "deposit" }, { header: "买断", key: "buy" }, { header: "生日类型", key: "birthdayType" }, + { header: "生日归属", key: "birthdayOwner" }, { header: "生日", key: "birthday" }, { header: "业务员", key: "salesman" }, { header: "报单日期", key: "reportDate" }, diff --git a/src/app/(dashboard)/customers/template/route.ts b/src/app/(dashboard)/customers/template/route.ts index 370b14a..e31e2f1 100644 --- a/src/app/(dashboard)/customers/template/route.ts +++ b/src/app/(dashboard)/customers/template/route.ts @@ -17,6 +17,7 @@ export async function GET() { "押金", "买断", "生日类型", + "生日归属", "生日", "业务员", "报单日期", @@ -33,6 +34,7 @@ export async function GET() { "100", "100", "阴历", + "联系人", "生日格式要求:2022-06-21", "A", "报单日期格式要求:2022-06-21",