| | |
| | | * 判断手机号码是否正确 |
| | | */ |
| | | export function isvalidatemobile(phone) { |
| | | let list = []; |
| | | let result = true; |
| | | const list = []; |
| | | let result = true; // true=不通过(保持你的语义) |
| | | let msg = ''; |
| | | var isPhone = /^0\d{2,3}-?\d{7,8}$/; |
| | | //增加134 减少|1349[0-9]{7},增加181,增加145,增加17[678] |
| | | if (!validatenull(phone)) { |
| | | if (phone.length === 11) { |
| | | if (isPhone.test(phone)) { |
| | | msg = '手机号码格式不正确'; |
| | | } else { |
| | | result = false; |
| | | } |
| | | } else { |
| | | msg = '手机号码长度不为11位'; |
| | | } |
| | | } else { |
| | | msg = '手机号码不能为空'; |
| | | |
| | | const raw = String(phone ?? '').trim(); |
| | | if (!raw) { |
| | | return [true, '手机号不能为空']; |
| | | } |
| | | |
| | | // 1) 归一化:去空格/括号/短横线 |
| | | // 2) 去掉 +86/86 前缀 |
| | | const value = raw |
| | | .replace(/[\s()()-]+/g, '') |
| | | .replace(/^(?:\+?86)/, ''); |
| | | |
| | | // 只允许纯数字11位手机号 |
| | | const mobile = /^1[3-9]\d{9}$/; |
| | | |
| | | if (mobile.test(value)) { |
| | | result = false; // 通过 |
| | | } else { |
| | | msg = '手机号格式不正确'; |
| | | } |
| | | |
| | | list.push(result); |
| | | list.push(msg); |
| | | return list; |
| | |
| | | import { ElMessage } from 'element-plus' |
| | | import { fwDeviceDetailApi, fwDeviceSubmitApi } from '@/views/aICrudTemplate/aICrudTemplateApi' |
| | | import { getUserListApi } from '@/api/system/user' |
| | | import { fieldRules } from '@ztzf/utils' |
| | | import { contactPhoneRules, fieldRules } from '@ztzf/utils' |
| | | |
| | | const initForm = () => ({ |
| | | belongDept: '', // 所属部门 |
| | |
| | | deviceAtt: fieldRules(true), |
| | | deviceModel: fieldRules(true, 50), |
| | | belongDept: fieldRules(true), |
| | | contactPhone: fieldRules(true, 50), |
| | | contactPhone: contactPhoneRules(true, 50), |
| | | charger: fieldRules(true), |
| | | } |
| | | |
| | |
| | | import { computed, nextTick, ref, watch } from 'vue' |
| | | import { ElMessage } from 'element-plus' |
| | | import { fwPoliceStationDetailApi, fwPoliceStationSubmitApi } from './precinctInfoApi' |
| | | import { fieldRules } from '@ztzf/utils' |
| | | import { contactPhoneRules, fieldRules } from '@ztzf/utils' |
| | | import CommonCesiumMap from '@/components/map-container/common-cesium-map.vue' |
| | | import * as Cesium from 'cesium' |
| | | import axios from 'axios' |
| | |
| | | address: fieldRules(true, 50), |
| | | stationName: fieldRules(true, 50), |
| | | contactPerson: fieldRules(true, 50), |
| | | contactPhone: fieldRules(true, 50), |
| | | contactPhone: contactPhoneRules(true, 50), |
| | | longitude: fieldRules(true), |
| | | } |
| | | |
| | |
| | | import { ElMessage } from 'element-plus' |
| | | import { getUserListApi } from '@/api/system/user' |
| | | import { getLazyTree } from '@/api/base/region' |
| | | import { fieldRules } from '@ztzf/utils' |
| | | import { contactPhoneRules, fieldRules } from '@ztzf/utils' |
| | | import { fwDeviceTrackSubmitApi } from '@/views/basicManage/deviceStock/fwDeviceTrackApi' |
| | | import { saveOperationLog } from '@ztzf/apis' |
| | | import { useRoute } from 'vue-router' |
| | |
| | | |
| | | const rules = { |
| | | charger: fieldRules(true), // 负责人 |
| | | contactPhone: fieldRules(true, 50), // 联系电话 |
| | | contactPhone: contactPhoneRules(true, 50), // 联系电话 |
| | | outTarget: fieldRules(true, 50), |
| | | outTime: fieldRules(true), |
| | | purpose: fieldRules(true, 50), // 用途 |
| | |
| | | import { ElMessage } from 'element-plus' |
| | | import { fwDeviceDetailApi, fwDeviceSubmitApi } from '@/views/basicManage/deviceStock/fwDevice' |
| | | import { getUserListApi } from '@/api/system/user' |
| | | import { fieldRules, getDictLabel } from '@ztzf/utils' |
| | | import { contactPhoneRules, fieldRules, getDictLabel } from '@ztzf/utils' |
| | | import { fwDeviceTrackPageApi } from '@/views/basicManage/deviceStock/fwDeviceTrackApi' |
| | | import { saveOperationLog } from '@ztzf/apis' |
| | | import { useRoute } from 'vue-router' |
| | |
| | | source: fieldRules(true, 50), |
| | | purpose: fieldRules(true, 50), |
| | | belongDept: fieldRules(true), |
| | | contactPhone: fieldRules(true, 50), |
| | | contactPhone: contactPhoneRules(true, 50), |
| | | charger: fieldRules(true), |
| | | } |
| | | |
| | |
| | | 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(','); |