fix(customers): 商户注名称文案统一为商户注册名称

界面、校验与导入导出表头同步更名,并保留旧表头兼容。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-23 10:48:57 +08:00
co-authored by Cursor
parent e8d4df463e
commit 7c7ede7d49
9 changed files with 17 additions and 16 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ datasource db {
/// 客户(系统核心,~1.4 万行)
model Customer {
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 // 商户编号,数字与字母,区分大小写,不限位数
contacts String? // 联系人
+7 -6
View File
@@ -19,7 +19,7 @@ const customerNoSchema = z
.refine((s) => s === "" || /^[A-Za-z0-9]+$/.test(s), "商户编号只能包含数字和字母,区分大小写");
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,
contacts: z.string().trim().min(1, "联系人必填").max(500),
@@ -41,14 +41,14 @@ const schema = z.object({
remark: z.string().trim().optional().default(""),
});
// 新增商户更严格:注名称无空格、联系人/结算人手机号必填 11 位、押金/买断/生日必填(仅用于 create,编辑仍用 schema)
// 新增商户更严格:注册名称无空格、联系人/结算人手机号必填 11 位、押金/买断/生日必填(仅用于 create,编辑仍用 schema)
const createSchema = schema.extend({
customerName: z
.string()
.trim()
.min(1, "商户注名称必填")
.min(1, "商户注册名称必填")
.max(500)
.refine((s) => !/\s/.test(s), "商户注名称不能包含空格"),
.refine((s) => !/\s/.test(s), "商户注册名称不能包含空格"),
contactsPhone: z.string().trim().regex(/^1\d{10}$/, "联系人手机号必须为 11 位数字"),
balanceUserPhone: z.string().trim().regex(/^1\d{10}$/, "结算人手机号必须为 11 位数字"),
deposit: z.string().trim().min(1, "押金必填"),
@@ -147,8 +147,9 @@ export async function deleteCustomer(id: number): Promise<void> {
// ============ Excel 导入 ============
const HEADER_MAP: Record<string, string> = {
商户注名称: "customerName",
商户注册名称: "customerName",
// 兼容旧版导入模板表头
商户注名称: "customerName",
商户名称: "customerName",
商户经营名称: "businessName",
商户编号: "customerNo",
@@ -194,7 +195,7 @@ export async function importCustomers(formData: FormData): Promise<ImportResult>
}
const errors: string[] = [];
if (!rec.customerName) errors.push("商户注名称必填");
if (!rec.customerName) errors.push("商户注册名称必填");
if (!rec.businessName) errors.push("商户经营名称必填");
if (rec.customerNo && !/^[A-Za-z0-9]+$/.test(rec.customerNo)) {
errors.push("商户编号只能包含数字和字母");
@@ -24,7 +24,7 @@ export type BirthdayColumnDef = {
};
export const BIRTHDAY_COLUMNS: BirthdayColumnDef[] = [
{ key: "customerName", label: "商户注名称", defaultVisible: true, className: "w-[11%]" },
{ key: "customerName", label: "商户注册名称", defaultVisible: true, className: "w-[11%]" },
{ key: "businessName", label: "商户经营名称", defaultVisible: true, className: "w-[11%]" },
{ key: "customerNo", label: "商户编号", defaultVisible: true, className: "w-[9%]" },
{ key: "balanceUser", label: "结算人", defaultVisible: true, className: "w-[11%]" },
@@ -102,12 +102,12 @@ export function CustomerForm({
<FormSection title="基本">
<div className="grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2 lg:grid-cols-3">
<Field
label="商户注名称"
label="商户注册名称"
name="customerName"
defaultValue={v.customerName}
required
pattern={requireAll ? "\\S+" : undefined}
title={requireAll ? "商户注名称不能包含空格" : undefined}
title={requireAll ? "商户注册名称不能包含空格" : undefined}
/>
<Field
label="商户经营名称"
@@ -81,7 +81,7 @@ export function CustomerView({ customer }: CustomerViewProps) {
<CardContent>
{hasBasic && (
<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.detail} className="whitespace-pre-wrap" />
+1 -1
View File
@@ -64,7 +64,7 @@ export default async function CustomersPage({
<Table striped bordered>
<THead>
<tr>
<TH>商户注名称</TH>
<TH>商户注册名称</TH>
<TH>商户经营名称</TH>
<TH>商户编号</TH>
<TH>联系人</TH>
+1 -1
View File
@@ -33,7 +33,7 @@ export function buildCustomerWhere(sp: CustomerSearch): Prisma.CustomerWhereInpu
/** 导出/导入的列定义(表头 ↔ 字段) */
export const EXCEL_COLUMNS: { header: string; key: string }[] = [
{ header: "商户注名称", key: "customerName" },
{ header: "商户注册名称", key: "customerName" },
{ header: "商户经营名称", key: "businessName" },
{ header: "商户编号", key: "customerNo" },
{ header: "联系人", key: "contacts" },
@@ -9,7 +9,7 @@ export async function GET() {
}
const headers = [
"商户注名称",
"商户注册名称",
"商户经营名称",
"商户编号",
"联系人",
@@ -27,7 +27,7 @@ export async function GET() {
// 示例行(用户导入前需删除此行)
const example = [
"模板注名称_此行删除",
"模板注册名称_此行删除",
"模板经营名称",
"Ab12Cd",
"侯磊",
+1 -1
View File
@@ -129,7 +129,7 @@ export default async function DashboardPage() {
<Table>
<THead>
<tr>
<TH>商户注名称</TH>
<TH>商户注册名称</TH>
<TH>商户经营名称</TH>
<TH>商户编号</TH>
<TH>联系人</TH>