feat(customers): 区分注名称与经营名称,商户编号改为选填
新增必填商户经营名称,原商户名称改为注名称;列表/导出/导入与生日提醒同步展示。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,7 +16,8 @@ datasource db {
|
|||||||
/// 客户(系统核心,~1.4 万行)
|
/// 客户(系统核心,~1.4 万行)
|
||||||
model Customer {
|
model Customer {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
customerName String? @default("") @map("customer_name")
|
customerName String? @default("") @map("customer_name") // 商户注名称
|
||||||
|
businessName String? @map("business_name") // 商户经营名称
|
||||||
customerNo String? @map("customer_no") @db.Text // 商户编号,数字与字母,区分大小写,不限位数
|
customerNo String? @map("customer_no") @db.Text // 商户编号,数字与字母,区分大小写,不限位数
|
||||||
contacts String? // 联系人
|
contacts String? // 联系人
|
||||||
contactsPhone String? @default("") @map("contacts_phone") // 联系人手机号
|
contactsPhone String? @default("") @map("contacts_phone") // 联系人手机号
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- 商户表增加商户经营名称
|
||||||
|
-- 执行:本地与生产库均需执行;执行后运行 npm run prisma:generate
|
||||||
|
-- 历史行保持 NULL,新录入/导入必填
|
||||||
|
|
||||||
|
ALTER TABLE customers
|
||||||
|
ADD COLUMN business_name VARCHAR(500) NULL COMMENT '商户经营名称' AFTER customer_name;
|
||||||
@@ -11,14 +11,16 @@ import { isSuperAdmin } from "@/lib/acl";
|
|||||||
import { fmtDate, parseDate } from "@/lib/utils";
|
import { fmtDate, parseDate } from "@/lib/utils";
|
||||||
|
|
||||||
// 校验规则对齐老系统必填项(customer_name/contacts/balance_user/detail/salesman/report_date)
|
// 校验规则对齐老系统必填项(customer_name/contacts/balance_user/detail/salesman/report_date)
|
||||||
|
// 商户编号非必填;有值时仅允许数字和字母
|
||||||
const customerNoSchema = z
|
const customerNoSchema = z
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1, "商户编号必填")
|
.default("")
|
||||||
.regex(/^[A-Za-z0-9]+$/, "商户编号只能包含数字和字母,区分大小写");
|
.refine((s) => s === "" || /^[A-Za-z0-9]+$/.test(s), "商户编号只能包含数字和字母,区分大小写");
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
customerName: z.string().trim().min(1, "商户名称必填").max(500),
|
customerName: z.string().trim().min(1, "商户注名称必填").max(500),
|
||||||
|
businessName: z.string().trim().min(1, "商户经营名称必填").max(500),
|
||||||
customerNo: customerNoSchema,
|
customerNo: customerNoSchema,
|
||||||
contacts: z.string().trim().min(1, "联系人必填").max(500),
|
contacts: z.string().trim().min(1, "联系人必填").max(500),
|
||||||
balanceUser: z.string().trim().min(1, "结算人必填").max(500),
|
balanceUser: z.string().trim().min(1, "结算人必填").max(500),
|
||||||
@@ -39,14 +41,14 @@ const schema = z.object({
|
|||||||
remark: z.string().trim().optional().default(""),
|
remark: z.string().trim().optional().default(""),
|
||||||
});
|
});
|
||||||
|
|
||||||
// 新增商户更严格:名称无空格、联系人/结算人手机号必填 11 位、押金/买断/生日必填(仅用于创建,编辑仍用 schema)
|
// 新增商户更严格:注名称无空格、联系人/结算人手机号必填 11 位、押金/买断/生日必填(仅用于 create,编辑仍用 schema)
|
||||||
const createSchema = schema.extend({
|
const createSchema = schema.extend({
|
||||||
customerName: z
|
customerName: z
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1, "商户名称必填")
|
.min(1, "商户注名称必填")
|
||||||
.max(500)
|
.max(500)
|
||||||
.refine((s) => !/\s/.test(s), "商户名称不能包含空格"),
|
.refine((s) => !/\s/.test(s), "商户注名称不能包含空格"),
|
||||||
contactsPhone: z.string().trim().regex(/^1\d{10}$/, "联系人手机号必须为 11 位数字"),
|
contactsPhone: z.string().trim().regex(/^1\d{10}$/, "联系人手机号必须为 11 位数字"),
|
||||||
balanceUserPhone: z.string().trim().regex(/^1\d{10}$/, "结算人手机号必须为 11 位数字"),
|
balanceUserPhone: z.string().trim().regex(/^1\d{10}$/, "结算人手机号必须为 11 位数字"),
|
||||||
deposit: z.string().trim().min(1, "押金必填"),
|
deposit: z.string().trim().min(1, "押金必填"),
|
||||||
@@ -64,7 +66,8 @@ export type ActionState = { error?: string };
|
|||||||
function pickForm(formData: FormData) {
|
function pickForm(formData: FormData) {
|
||||||
return {
|
return {
|
||||||
customerName: formData.get("customerName"),
|
customerName: formData.get("customerName"),
|
||||||
customerNo: formData.get("customerNo"),
|
businessName: formData.get("businessName"),
|
||||||
|
customerNo: formData.get("customerNo") ?? "",
|
||||||
contacts: formData.get("contacts"),
|
contacts: formData.get("contacts"),
|
||||||
balanceUser: formData.get("balanceUser"),
|
balanceUser: formData.get("balanceUser"),
|
||||||
detail: formData.get("detail"),
|
detail: formData.get("detail"),
|
||||||
@@ -83,9 +86,10 @@ function pickForm(formData: FormData) {
|
|||||||
|
|
||||||
/** 把校验后的表单值转成 Prisma 写入数据(日期字段转 Date) */
|
/** 把校验后的表单值转成 Prisma 写入数据(日期字段转 Date) */
|
||||||
function toData(v: z.infer<typeof schema>) {
|
function toData(v: z.infer<typeof schema>) {
|
||||||
const { reportDate, birthday, ...rest } = v;
|
const { reportDate, birthday, customerNo, ...rest } = v;
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
|
customerNo: customerNo || null,
|
||||||
reportDate: parseDate(reportDate),
|
reportDate: parseDate(reportDate),
|
||||||
birthday: parseDate(birthday),
|
birthday: parseDate(birthday),
|
||||||
};
|
};
|
||||||
@@ -143,7 +147,10 @@ export async function deleteCustomer(id: number): Promise<void> {
|
|||||||
// ============ Excel 导入 ============
|
// ============ Excel 导入 ============
|
||||||
|
|
||||||
const HEADER_MAP: Record<string, string> = {
|
const HEADER_MAP: Record<string, string> = {
|
||||||
|
商户注名称: "customerName",
|
||||||
|
// 兼容旧版导入模板表头
|
||||||
商户名称: "customerName",
|
商户名称: "customerName",
|
||||||
|
商户经营名称: "businessName",
|
||||||
商户编号: "customerNo",
|
商户编号: "customerNo",
|
||||||
联系人: "contacts",
|
联系人: "contacts",
|
||||||
联系人电话: "contactsPhone",
|
联系人电话: "contactsPhone",
|
||||||
@@ -187,9 +194,11 @@ export async function importCustomers(formData: FormData): Promise<ImportResult>
|
|||||||
}
|
}
|
||||||
|
|
||||||
const errors: string[] = [];
|
const errors: string[] = [];
|
||||||
if (!rec.customerName) errors.push("商户名称必填");
|
if (!rec.customerName) errors.push("商户注名称必填");
|
||||||
if (!rec.customerNo) errors.push("商户编号必填");
|
if (!rec.businessName) errors.push("商户经营名称必填");
|
||||||
else if (!/^[A-Za-z0-9]+$/.test(rec.customerNo)) errors.push("商户编号只能包含数字和字母");
|
if (rec.customerNo && !/^[A-Za-z0-9]+$/.test(rec.customerNo)) {
|
||||||
|
errors.push("商户编号只能包含数字和字母");
|
||||||
|
}
|
||||||
const reportDate = parseDate(rec.reportDate);
|
const reportDate = parseDate(rec.reportDate);
|
||||||
if (!rec.reportDate || !reportDate) errors.push("报单日期必填且格式为 YYYY-MM-DD");
|
if (!rec.reportDate || !reportDate) errors.push("报单日期必填且格式为 YYYY-MM-DD");
|
||||||
if (rec.birthday && !parseDate(rec.birthday)) errors.push("生日格式应为 YYYY-MM-DD");
|
if (rec.birthday && !parseDate(rec.birthday)) errors.push("生日格式应为 YYYY-MM-DD");
|
||||||
@@ -199,7 +208,8 @@ export async function importCustomers(formData: FormData): Promise<ImportResult>
|
|||||||
} else {
|
} else {
|
||||||
validData.push({
|
validData.push({
|
||||||
customerName: rec.customerName,
|
customerName: rec.customerName,
|
||||||
customerNo: rec.customerNo,
|
businessName: rec.businessName,
|
||||||
|
customerNo: rec.customerNo || null,
|
||||||
contacts: rec.contacts || null,
|
contacts: rec.contacts || null,
|
||||||
contactsPhone: rec.contactsPhone || null,
|
contactsPhone: rec.contactsPhone || null,
|
||||||
balanceUser: rec.balanceUser || null,
|
balanceUser: rec.balanceUser || null,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
export const BIRTHDAY_COLUMN_STORAGE_KEY = "crm-birthday-columns-v1";
|
export const BIRTHDAY_COLUMN_STORAGE_KEY = "crm-birthday-columns-v2";
|
||||||
|
|
||||||
export type BirthdayColumnKey =
|
export type BirthdayColumnKey =
|
||||||
| "customerName"
|
| "customerName"
|
||||||
|
| "businessName"
|
||||||
| "customerNo"
|
| "customerNo"
|
||||||
| "contacts"
|
| "contacts"
|
||||||
| "balanceUser"
|
| "balanceUser"
|
||||||
@@ -23,13 +24,14 @@ export type BirthdayColumnDef = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const BIRTHDAY_COLUMNS: BirthdayColumnDef[] = [
|
export const BIRTHDAY_COLUMNS: BirthdayColumnDef[] = [
|
||||||
{ key: "customerName", label: "商户名称", defaultVisible: true, className: "w-[12%]" },
|
{ key: "customerName", label: "商户注名称", defaultVisible: true, className: "w-[11%]" },
|
||||||
{ key: "customerNo", label: "商户编号", defaultVisible: true, className: "w-[10%]" },
|
{ key: "businessName", label: "商户经营名称", defaultVisible: true, className: "w-[11%]" },
|
||||||
{ key: "balanceUser", label: "结算人", defaultVisible: true, className: "w-[12%]" },
|
{ key: "customerNo", label: "商户编号", defaultVisible: true, className: "w-[9%]" },
|
||||||
{ key: "contacts", label: "联系人", defaultVisible: true, className: "w-[12%]" },
|
{ key: "balanceUser", label: "结算人", defaultVisible: true, className: "w-[11%]" },
|
||||||
{ key: "birthday", label: "生日", defaultVisible: true, className: "w-[14%]" },
|
{ key: "contacts", label: "联系人", defaultVisible: true, className: "w-[11%]" },
|
||||||
{ key: "salesman", label: "业务员", defaultVisible: true, className: "w-[8%]" },
|
{ key: "birthday", label: "生日", defaultVisible: true, className: "w-[13%]" },
|
||||||
{ key: "remark", label: "备注", defaultVisible: true, className: "w-[20%]" },
|
{ key: "salesman", label: "业务员", defaultVisible: true, className: "w-[7%]" },
|
||||||
|
{ key: "remark", label: "备注", defaultVisible: true, className: "w-[16%]" },
|
||||||
{ key: "reportDate", label: "报单日期", defaultVisible: false, className: "w-[10%]" },
|
{ key: "reportDate", label: "报单日期", defaultVisible: false, className: "w-[10%]" },
|
||||||
{ key: "deposit", label: "押金", defaultVisible: false, className: "w-[8%]" },
|
{ key: "deposit", label: "押金", defaultVisible: false, className: "w-[8%]" },
|
||||||
{ key: "buy", label: "买断", defaultVisible: false, className: "w-[8%]" },
|
{ key: "buy", label: "买断", defaultVisible: false, className: "w-[8%]" },
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
export type BirthdayRow = {
|
export type BirthdayRow = {
|
||||||
id: number;
|
id: number;
|
||||||
customerName: string | null;
|
customerName: string | null;
|
||||||
|
businessName: string | null;
|
||||||
customerNo: string | null;
|
customerNo: string | null;
|
||||||
contacts: string | null;
|
contacts: string | null;
|
||||||
contactsPhone: string | null;
|
contactsPhone: string | null;
|
||||||
@@ -96,6 +97,8 @@ function renderCell(key: BirthdayColumnKey, row: BirthdayRow): ReactNode {
|
|||||||
switch (key) {
|
switch (key) {
|
||||||
case "customerName":
|
case "customerName":
|
||||||
return <span className="block break-words font-medium whitespace-normal">{text(row.customerName)}</span>;
|
return <span className="block break-words font-medium whitespace-normal">{text(row.customerName)}</span>;
|
||||||
|
case "businessName":
|
||||||
|
return <span className="block break-words font-medium whitespace-normal">{text(row.businessName)}</span>;
|
||||||
case "customerNo":
|
case "customerNo":
|
||||||
return <span className="block break-all whitespace-normal">{text(row.customerNo)}</span>;
|
return <span className="block break-all whitespace-normal">{text(row.customerNo)}</span>;
|
||||||
case "contacts":
|
case "contacts":
|
||||||
@@ -286,6 +289,11 @@ export function BirthdayList({ rows }: { rows: BirthdayRow[] }) {
|
|||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className="break-words font-medium whitespace-normal">{text(row.customerName)}</div>
|
<div className="break-words font-medium whitespace-normal">{text(row.customerName)}</div>
|
||||||
|
{visible.includes("businessName") && row.businessName ? (
|
||||||
|
<div className="mt-0.5 break-words text-xs text-[var(--color-muted-foreground)]">
|
||||||
|
经营名称 {text(row.businessName)}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
{visible.includes("customerNo") && (
|
{visible.includes("customerNo") && (
|
||||||
<div className="mt-0.5 break-all text-xs text-[var(--color-muted-foreground)]">
|
<div className="mt-0.5 break-all text-xs text-[var(--color-muted-foreground)]">
|
||||||
编号 {text(row.customerNo)}
|
编号 {text(row.customerNo)}
|
||||||
@@ -298,7 +306,13 @@ export function BirthdayList({ rows }: { rows: BirthdayRow[] }) {
|
|||||||
</div>
|
</div>
|
||||||
<dl className="mt-3 grid grid-cols-2 gap-x-3 gap-y-2 text-sm">
|
<dl className="mt-3 grid grid-cols-2 gap-x-3 gap-y-2 text-sm">
|
||||||
{ordered
|
{ordered
|
||||||
.filter((c) => c.key !== "customerName" && c.key !== "customerNo" && c.key !== "birthday")
|
.filter(
|
||||||
|
(c) =>
|
||||||
|
c.key !== "customerName" &&
|
||||||
|
c.key !== "businessName" &&
|
||||||
|
c.key !== "customerNo" &&
|
||||||
|
c.key !== "birthday"
|
||||||
|
)
|
||||||
.map((col) => (
|
.map((col) => (
|
||||||
<div key={col.key} className={col.key === "detail" || col.key === "remark" ? "col-span-2" : undefined}>
|
<div key={col.key} className={col.key === "detail" || col.key === "remark" ? "col-span-2" : undefined}>
|
||||||
<dt className="text-xs text-[var(--color-muted-foreground)]">{col.label}</dt>
|
<dt className="text-xs text-[var(--color-muted-foreground)]">{col.label}</dt>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export default async function BirthdayPage({
|
|||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
customer_name AS customerName,
|
customer_name AS customerName,
|
||||||
|
business_name AS businessName,
|
||||||
customer_no AS customerNo,
|
customer_no AS customerNo,
|
||||||
contacts,
|
contacts,
|
||||||
contacts_phone AS contactsPhone,
|
contacts_phone AS contactsPhone,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type { ActionState } from "./actions";
|
|||||||
|
|
||||||
type CustomerValues = {
|
type CustomerValues = {
|
||||||
customerName?: string | null;
|
customerName?: string | null;
|
||||||
|
businessName?: string | null;
|
||||||
customerNo?: string | null;
|
customerNo?: string | null;
|
||||||
contacts?: string | null;
|
contacts?: string | null;
|
||||||
contactsPhone?: string | null;
|
contactsPhone?: string | null;
|
||||||
@@ -101,20 +102,25 @@ export function CustomerForm({
|
|||||||
<FormSection title="基本">
|
<FormSection title="基本">
|
||||||
<div className="grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2 lg:grid-cols-3">
|
<div className="grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||||
<Field
|
<Field
|
||||||
label="商户名称"
|
label="商户注名称"
|
||||||
name="customerName"
|
name="customerName"
|
||||||
defaultValue={v.customerName}
|
defaultValue={v.customerName}
|
||||||
required
|
required
|
||||||
pattern={requireAll ? "\\S+" : undefined}
|
pattern={requireAll ? "\\S+" : undefined}
|
||||||
title={requireAll ? "商户名称不能包含空格" : undefined}
|
title={requireAll ? "商户注名称不能包含空格" : undefined}
|
||||||
|
/>
|
||||||
|
<Field
|
||||||
|
label="商户经营名称"
|
||||||
|
name="businessName"
|
||||||
|
defaultValue={v.businessName}
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
label="商户编号"
|
label="商户编号"
|
||||||
name="customerNo"
|
name="customerNo"
|
||||||
defaultValue={v.customerNo}
|
defaultValue={v.customerNo}
|
||||||
required
|
|
||||||
pattern="[A-Za-z0-9]+"
|
pattern="[A-Za-z0-9]+"
|
||||||
title="只能填写数字和字母,区分大小写,位数不限"
|
title="只能填写数字和字母,区分大小写,位数不限;可不填"
|
||||||
/>
|
/>
|
||||||
<Field label="业务员" name="salesman" defaultValue={v.salesman} required />
|
<Field label="业务员" name="salesman" defaultValue={v.salesman} required />
|
||||||
<Field
|
<Field
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { fmtDate, cn } from "@/lib/utils";
|
|||||||
type CustomerViewProps = {
|
type CustomerViewProps = {
|
||||||
customer: {
|
customer: {
|
||||||
customerName?: string | null;
|
customerName?: string | null;
|
||||||
|
businessName?: string | null;
|
||||||
customerNo?: string | null;
|
customerNo?: string | null;
|
||||||
contacts?: string | null;
|
contacts?: string | null;
|
||||||
contactsPhone?: string | null;
|
contactsPhone?: string | null;
|
||||||
@@ -43,7 +44,7 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
|||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
// 各分区是否至少有一个字段,用于隐藏整块为空的小标题
|
// 各分区是否至少有一个字段,用于隐藏整块为空的小标题
|
||||||
const hasBasic = !!(customer.customerName || customer.customerNo || customer.detail);
|
const hasBasic = !!(customer.customerName || customer.businessName || customer.customerNo || customer.detail);
|
||||||
const hasContacts = !!(customer.contacts || customer.contactsPhone);
|
const hasContacts = !!(customer.contacts || customer.contactsPhone);
|
||||||
const hasBalanceUser = !!(customer.balanceUser || customer.balanceUserPhone);
|
const hasBalanceUser = !!(customer.balanceUser || customer.balanceUserPhone);
|
||||||
const hasBusiness = !!(customer.deposit || customer.buy || customer.salesman || customer.reportDate);
|
const hasBusiness = !!(customer.deposit || customer.buy || customer.salesman || customer.reportDate);
|
||||||
@@ -80,7 +81,8 @@ export function CustomerView({ customer }: CustomerViewProps) {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
{hasBasic && (
|
{hasBasic && (
|
||||||
<Section title="基本">
|
<Section title="基本">
|
||||||
<InfoRow label="商户名称" value={customer.customerName} />
|
<InfoRow label="商户注名称" value={customer.customerName} />
|
||||||
|
<InfoRow label="商户经营名称" value={customer.businessName} />
|
||||||
<InfoRow label="商户编号" value={customer.customerNo} />
|
<InfoRow label="商户编号" value={customer.customerNo} />
|
||||||
<InfoRow label="产品明细" value={customer.detail} className="whitespace-pre-wrap" />
|
<InfoRow label="产品明细" value={customer.detail} className="whitespace-pre-wrap" />
|
||||||
</Section>
|
</Section>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export async function GET(req: NextRequest) {
|
|||||||
for (const c of rows) {
|
for (const c of rows) {
|
||||||
aoa.push([
|
aoa.push([
|
||||||
c.customerName ?? "",
|
c.customerName ?? "",
|
||||||
|
c.businessName ?? "",
|
||||||
c.customerNo ?? "",
|
c.customerNo ?? "",
|
||||||
c.contacts ?? "",
|
c.contacts ?? "",
|
||||||
c.contactsPhone ?? "",
|
c.contactsPhone ?? "",
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ export default async function CustomersPage({
|
|||||||
<Table striped bordered>
|
<Table striped bordered>
|
||||||
<THead>
|
<THead>
|
||||||
<tr>
|
<tr>
|
||||||
<TH>商户名称</TH>
|
<TH>商户注名称</TH>
|
||||||
|
<TH>商户经营名称</TH>
|
||||||
<TH>商户编号</TH>
|
<TH>商户编号</TH>
|
||||||
<TH>联系人</TH>
|
<TH>联系人</TH>
|
||||||
<TH>结算人</TH>
|
<TH>结算人</TH>
|
||||||
@@ -81,7 +82,7 @@ export default async function CustomersPage({
|
|||||||
<tbody>
|
<tbody>
|
||||||
{rows.length === 0 && (
|
{rows.length === 0 && (
|
||||||
<tr>
|
<tr>
|
||||||
<TD colSpan={12} className="py-14 text-center text-[var(--color-muted-foreground)]">
|
<TD colSpan={13} className="py-14 text-center text-[var(--color-muted-foreground)]">
|
||||||
暂无数据
|
暂无数据
|
||||||
</TD>
|
</TD>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -92,6 +93,7 @@ export default async function CustomersPage({
|
|||||||
return (
|
return (
|
||||||
<TR key={c.id}>
|
<TR key={c.id}>
|
||||||
<TD className="font-medium">{c.customerName}</TD>
|
<TD className="font-medium">{c.customerName}</TD>
|
||||||
|
<TD className="font-medium">{c.businessName || "—"}</TD>
|
||||||
<TD className="font-medium break-all">{c.customerNo || "—"}</TD>
|
<TD className="font-medium break-all">{c.customerNo || "—"}</TD>
|
||||||
<TD>
|
<TD>
|
||||||
<div>{c.contacts}</div>
|
<div>{c.contacts}</div>
|
||||||
@@ -148,6 +150,11 @@ export default async function CustomersPage({
|
|||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className="truncate font-medium">{c.customerName}</div>
|
<div className="truncate font-medium">{c.customerName}</div>
|
||||||
|
{c.businessName ? (
|
||||||
|
<div className="mt-0.5 truncate text-xs text-[var(--color-muted-foreground)]">
|
||||||
|
经营名称 {c.businessName}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
<div className="mt-0.5 break-all text-xs text-[var(--color-muted-foreground)]">
|
<div className="mt-0.5 break-all text-xs text-[var(--color-muted-foreground)]">
|
||||||
编号 {c.customerNo || "—"}
|
编号 {c.customerNo || "—"}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export function buildCustomerWhere(sp: CustomerSearch): Prisma.CustomerWhereInpu
|
|||||||
if (keyword) {
|
if (keyword) {
|
||||||
where.OR = [
|
where.OR = [
|
||||||
{ customerName: { contains: keyword } },
|
{ customerName: { contains: keyword } },
|
||||||
|
{ businessName: { contains: keyword } },
|
||||||
{ customerNo: { contains: keyword } },
|
{ customerNo: { contains: keyword } },
|
||||||
{ contacts: { contains: keyword } },
|
{ contacts: { contains: keyword } },
|
||||||
{ contactsPhone: { contains: keyword } },
|
{ contactsPhone: { contains: keyword } },
|
||||||
@@ -32,7 +33,8 @@ export function buildCustomerWhere(sp: CustomerSearch): Prisma.CustomerWhereInpu
|
|||||||
|
|
||||||
/** 导出/导入的列定义(表头 ↔ 字段) */
|
/** 导出/导入的列定义(表头 ↔ 字段) */
|
||||||
export const EXCEL_COLUMNS: { header: string; key: string }[] = [
|
export const EXCEL_COLUMNS: { header: string; key: string }[] = [
|
||||||
{ header: "商户名称", key: "customerName" },
|
{ header: "商户注名称", key: "customerName" },
|
||||||
|
{ header: "商户经营名称", key: "businessName" },
|
||||||
{ header: "商户编号", key: "customerNo" },
|
{ header: "商户编号", key: "customerNo" },
|
||||||
{ header: "联系人", key: "contacts" },
|
{ header: "联系人", key: "contacts" },
|
||||||
{ header: "联系人电话", key: "contactsPhone" },
|
{ header: "联系人电话", key: "contactsPhone" },
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ export async function GET() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const headers = [
|
const headers = [
|
||||||
"商户名称",
|
"商户注名称",
|
||||||
|
"商户经营名称",
|
||||||
"商户编号",
|
"商户编号",
|
||||||
"联系人",
|
"联系人",
|
||||||
"联系人电话",
|
"联系人电话",
|
||||||
@@ -26,7 +27,8 @@ export async function GET() {
|
|||||||
|
|
||||||
// 示例行(用户导入前需删除此行)
|
// 示例行(用户导入前需删除此行)
|
||||||
const example = [
|
const example = [
|
||||||
"模板名称_此行删除",
|
"模板注名称_此行删除",
|
||||||
|
"模板经营名称",
|
||||||
"Ab12Cd",
|
"Ab12Cd",
|
||||||
"侯磊",
|
"侯磊",
|
||||||
"13813855555",
|
"13813855555",
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ export default async function DashboardPage() {
|
|||||||
<Table>
|
<Table>
|
||||||
<THead>
|
<THead>
|
||||||
<tr>
|
<tr>
|
||||||
<TH>商户名称</TH>
|
<TH>商户注名称</TH>
|
||||||
|
<TH>商户经营名称</TH>
|
||||||
<TH>商户编号</TH>
|
<TH>商户编号</TH>
|
||||||
<TH>联系人</TH>
|
<TH>联系人</TH>
|
||||||
<TH>业务员</TH>
|
<TH>业务员</TH>
|
||||||
@@ -141,6 +142,7 @@ export default async function DashboardPage() {
|
|||||||
{recent.map((c) => (
|
{recent.map((c) => (
|
||||||
<TR key={c.id}>
|
<TR key={c.id}>
|
||||||
<TD className="font-medium">{c.customerName}</TD>
|
<TD className="font-medium">{c.customerName}</TD>
|
||||||
|
<TD className="font-medium">{c.businessName || "—"}</TD>
|
||||||
<TD className="break-all">{c.customerNo || "—"}</TD>
|
<TD className="break-all">{c.customerNo || "—"}</TD>
|
||||||
<TD>{c.contacts}</TD>
|
<TD>{c.contacts}</TD>
|
||||||
<TD>{c.salesman}</TD>
|
<TD>{c.salesman}</TD>
|
||||||
@@ -161,6 +163,11 @@ export default async function DashboardPage() {
|
|||||||
<div key={c.id} className="flex items-start justify-between gap-3 px-4 py-3">
|
<div key={c.id} className="flex items-start justify-between gap-3 px-4 py-3">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className="truncate font-medium">{c.customerName}</div>
|
<div className="truncate font-medium">{c.customerName}</div>
|
||||||
|
{c.businessName ? (
|
||||||
|
<div className="mt-0.5 truncate text-xs text-[var(--color-muted-foreground)]">
|
||||||
|
经营名称 {c.businessName}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
{c.customerNo ? (
|
{c.customerNo ? (
|
||||||
<div className="mt-0.5 break-all text-xs text-[var(--color-muted-foreground)]">
|
<div className="mt-0.5 break-all text-xs text-[var(--color-muted-foreground)]">
|
||||||
编号 {c.customerNo}
|
编号 {c.customerNo}
|
||||||
|
|||||||
Reference in New Issue
Block a user