| | |
| | | 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) { |
| | |
| | | elink.click() |
| | | document.body.removeChild(elink) |
| | | } |
| | | |
| | | export function geomAnalysis(str) { |
| | | if (!str) return [] |
| | | return str |
| | | .replace('POLYGON((', '') |
| | | .replace('))', '') |
| | | .split(',') |
| | | .map(pair => { |
| | | const [longitude, latitude] = pair.trim().split(' ').map(Number) |
| | | return { longitude, latitude } |
| | | }) |
| | | } |