From 72ba4e4e721cb12dda4ee3b34cb4ad5c96a157b0 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 09 Feb 2026 10:22:06 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
packages/utils/common/index.js | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/packages/utils/common/index.js b/packages/utils/common/index.js
index 9d00919..c213e19 100644
--- a/packages/utils/common/index.js
+++ b/packages/utils/common/index.js
@@ -12,9 +12,30 @@
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 function getDictLabel(value, dictList) {
- return dictList.find(item => item.dictKey === value)?.dictValue || 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(',');
+ return dictList
+ .filter(item => values.includes(String(item.dictKey)))
+ .map(item => item.dictValue)
+ .join(',');
}
export function blobDownload(res) {
--
Gitblit v1.9.3