吉安感知网项目-前端
罗广辉
2026-03-04 b5bbbd19cf0b3c2b7674e5ecb6c1847f0ec734e4
packages/utils/common/index.js
@@ -1,13 +1,3 @@
/*
 * @Author       : yuan
 * @Date         : 2026-01-20 17:01:20
 * @LastEditors  : yuan
 * @LastEditTime : 2026-01-20 17:20:21
 * @FilePath     : \packages\utils\common\index.js
 * @Description  :
 * Copyright 2026 OBKoro1, All Rights Reserved.
 * 2026-01-20 17:01:20
 */
export function fieldRules(required,max) {
// export function fieldRules({ required = true, isSelect = false, max = 50,type = 'string' }) {
   const trigger = ['blur', 'change']
@@ -22,6 +12,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(',');