From bbf6d58d453cda88220d8513e98df808a698c7c7 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Tue, 03 Feb 2026 11:38:32 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
packages/utils/common/index.js | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/packages/utils/common/index.js b/packages/utils/common/index.js
index 43fcec6..2fe1b9c 100644
--- a/packages/utils/common/index.js
+++ b/packages/utils/common/index.js
@@ -22,6 +22,23 @@
return rules
}
+const isContactPhone = value => {
+ const mobile = /^1[3-9]\d{9}$/
+ const landline = /^0\d{2,3}-?\d{7,8}$/
+ return mobile.test(value) || landline.test(value)
+}
+
+export const contactPhoneRules = (required = true, max = 50) => {
+ const validateContactPhone = (rule, value, callback) => {
+ const nextValue = String(value || '').trim()
+ if (!nextValue) return callback()
+ if (isContactPhone(nextValue)) return callback()
+ return callback(new Error('联系电话格式不正确'))
+ }
+
+ return [...fieldRules(required, max), { validator: validateContactPhone, trigger: ['blur', 'change'] }]
+}
+
export function getDictLabel(value, dictList = []) {
if (value === null || value === undefined || value === '') return '';
const values = String(value).split(',');
--
Gitblit v1.9.3