Compare commits

..
3 Commits
Author SHA1 Message Date
luishouandCursor 7a7ed1a217 fix(customers): 移除编辑页农历生日提示文案
商户表单不再展示「这个生日是按农历记的。」提醒。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-14 17:49:48 +08:00
luishouandCursor b82e1f5330 fix(customers): 修正手机号 HTML pattern 误拦截合法号码
将 \d 改为 [0-9],避免结算人/联系人手机号前端格式校验误报。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 14:12:40 +08:00
luishouandCursor 1a1b61cfb8 fix(customers): 注册名称与结算人手机选填,调整生日提醒默认列
新增页放宽两项必填;生日提醒默认展示注册/经营名称、编号、联系人、明细、生日与报单日期。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-24 14:52:21 +08:00
3 changed files with 26 additions and 31 deletions
+9 -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().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[] {
@@ -20,7 +20,6 @@ type CustomerValues = {
deposit?: string | null;
buy?: string | null;
birthday?: Date | null;
birthdayType?: number | null;
salesman?: string | null;
reportDate?: Date | null;
remark?: string | null;
@@ -105,9 +104,8 @@ export function CustomerForm({
label="商户注册名称"
name="customerName"
defaultValue={v.customerName}
required
pattern={requireAll ? "\\S+" : undefined}
title={requireAll ? "商户注册名称不能包含空格" : undefined}
title={requireAll ? "有值时不能包含空格" : undefined}
/>
<Field
label="商户经营名称"
@@ -141,7 +139,7 @@ export function CustomerForm({
name="contactsPhone"
defaultValue={v.contactsPhone}
required={requireAll}
pattern={requireAll ? "1\\d{10}" : undefined}
pattern={requireAll ? "1[0-9]{10}" : undefined}
inputMode={requireAll ? "numeric" : undefined}
title={requireAll ? "请输入 11 位手机号" : undefined}
/>
@@ -155,10 +153,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[0-9]{10}"
inputMode="numeric"
title="有值时须为 11 位手机号;可不填"
/>
</div>
</FormSection>
@@ -173,11 +170,6 @@ export function CustomerForm({
required={requireAll}
/>
</div>
{v.birthdayType === 2 && (
<p className="text-sm text-[var(--color-warning)]">
这个生日是按农历记的。
</p>
)}
</FormSection>
<FormSection title="其它">