fix(customers): 注册名称与结算人手机选填,调整生日提醒默认列
新增页放宽两项必填;生日提醒默认展示注册/经营名称、编号、联系人、明细、生日与报单日期。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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().max(500).optional().default(""),
|
||||
businessName: z.string().trim().min(1, "商户经营名称必填").max(500),
|
||||
customerNo: customerNoSchema,
|
||||
contacts: z.string().trim().min(1, "联系人必填").max(500),
|
||||
@@ -41,16 +41,20 @@ const schema = z.object({
|
||||
remark: z.string().trim().optional().default(""),
|
||||
});
|
||||
|
||||
// 新增商户更严格:注册名称无空格、联系人/结算人手机号必填 11 位、押金/买断/生日必填(仅用于 create,编辑仍用 schema)
|
||||
// 新增商户更严格:注册名称有值时禁止空格;联系人手机号必填;结算人手机号选填(有值须 11 位);押金/买断/生日必填
|
||||
const createSchema = schema.extend({
|
||||
customerName: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, "商户注册名称必填")
|
||||
.max(500)
|
||||
.refine((s) => !/\s/.test(s), "商户注册名称不能包含空格"),
|
||||
.default("")
|
||||
.refine((s) => s === "" || !/\s/.test(s), "商户注册名称不能包含空格"),
|
||||
contactsPhone: z.string().trim().regex(/^1\d{10}$/, "联系人手机号必须为 11 位数字"),
|
||||
balanceUserPhone: z.string().trim().regex(/^1\d{10}$/, "结算人手机号必须为 11 位数字"),
|
||||
balanceUserPhone: z
|
||||
.string()
|
||||
.trim()
|
||||
.default("")
|
||||
.refine((s) => s === "" || /^1\d{10}$/.test(s), "结算人手机号必须为 11 位数字"),
|
||||
deposit: z.string().trim().min(1, "押金必填"),
|
||||
buy: z.string().trim().min(1, "买断必填"),
|
||||
birthday: z
|
||||
@@ -195,7 +199,6 @@ export async function importCustomers(formData: FormData): Promise<ImportResult>
|
||||
}
|
||||
|
||||
const errors: string[] = [];
|
||||
if (!rec.customerName) errors.push("商户注册名称必填");
|
||||
if (!rec.businessName) errors.push("商户经营名称必填");
|
||||
if (rec.customerNo && !/^[A-Za-z0-9]+$/.test(rec.customerNo)) {
|
||||
errors.push("商户编号只能包含数字和字母");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const BIRTHDAY_COLUMN_STORAGE_KEY = "crm-birthday-columns-v2";
|
||||
export const BIRTHDAY_COLUMN_STORAGE_KEY = "crm-birthday-columns-v3";
|
||||
|
||||
export type BirthdayColumnKey =
|
||||
| "customerName"
|
||||
@@ -17,25 +17,25 @@ export type BirthdayColumnKey =
|
||||
export type BirthdayColumnDef = {
|
||||
key: BirthdayColumnKey;
|
||||
label: string;
|
||||
/** 默认展示:打电话常用信息 */
|
||||
/** 默认展示:生日提醒常用信息 */
|
||||
defaultVisible: boolean;
|
||||
/** 表头/单元格宽度,避免名称列被表格拉得很宽 */
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export const BIRTHDAY_COLUMNS: BirthdayColumnDef[] = [
|
||||
{ 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%]" },
|
||||
{ key: "contacts", label: "联系人", defaultVisible: true, className: "w-[11%]" },
|
||||
{ key: "birthday", label: "生日", defaultVisible: true, className: "w-[13%]" },
|
||||
{ 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: "customerName", label: "商户注册名称", defaultVisible: true, className: "w-[12%]" },
|
||||
{ key: "businessName", label: "商户经营名称", defaultVisible: true, className: "w-[12%]" },
|
||||
{ key: "customerNo", label: "商户编号", defaultVisible: true, className: "w-[10%]" },
|
||||
{ key: "contacts", label: "联系人", defaultVisible: true, className: "w-[12%]" },
|
||||
{ key: "detail", label: "产品明细", defaultVisible: true, className: "w-[18%]" },
|
||||
{ key: "birthday", label: "生日", defaultVisible: true, className: "w-[14%]" },
|
||||
{ key: "reportDate", label: "报单日期", defaultVisible: true, className: "w-[10%]" },
|
||||
{ key: "balanceUser", label: "结算人", defaultVisible: false, className: "w-[11%]" },
|
||||
{ key: "salesman", label: "业务员", defaultVisible: false, className: "w-[8%]" },
|
||||
{ key: "remark", label: "备注", defaultVisible: false, className: "w-[16%]" },
|
||||
{ key: "deposit", label: "押金", defaultVisible: false, className: "w-[8%]" },
|
||||
{ key: "buy", label: "买断", defaultVisible: false, className: "w-[8%]" },
|
||||
{ key: "detail", label: "产品明细", defaultVisible: false, className: "w-[18%]" },
|
||||
];
|
||||
|
||||
export function defaultBirthdayColumns(): BirthdayColumnKey[] {
|
||||
|
||||
@@ -105,9 +105,8 @@ export function CustomerForm({
|
||||
label="商户注册名称"
|
||||
name="customerName"
|
||||
defaultValue={v.customerName}
|
||||
required
|
||||
pattern={requireAll ? "\\S+" : undefined}
|
||||
title={requireAll ? "商户注册名称不能包含空格" : undefined}
|
||||
title={requireAll ? "有值时不能包含空格" : undefined}
|
||||
/>
|
||||
<Field
|
||||
label="商户经营名称"
|
||||
@@ -155,10 +154,9 @@ export function CustomerForm({
|
||||
label="手机号"
|
||||
name="balanceUserPhone"
|
||||
defaultValue={v.balanceUserPhone}
|
||||
required={requireAll}
|
||||
pattern={requireAll ? "1\\d{10}" : undefined}
|
||||
inputMode={requireAll ? "numeric" : undefined}
|
||||
title={requireAll ? "请输入 11 位手机号" : undefined}
|
||||
pattern="1\\d{10}"
|
||||
inputMode="numeric"
|
||||
title="有值时须为 11 位手机号;可不填"
|
||||
/>
|
||||
</div>
|
||||
</FormSection>
|
||||
|
||||
Reference in New Issue
Block a user