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",