Explorar o código

feat:线下销售订单-手机号格式限制

Moss hai 1 ano
pai
achega
952ed2cebb
Modificáronse 1 ficheiros con 18 adicións e 1 borrados
  1. 18 1
      src/views/mallManagement/order/offline_order_list/index.vue

+ 18 - 1
src/views/mallManagement/order/offline_order_list/index.vue

@@ -429,6 +429,22 @@ export default {
     }
   },
   data() {
+    const validatePhone2 = (rule, value, callback) => {
+      if(value && !(/^1[3456789]\d{9}$/.test(value))) {
+        callback('请输入正确的手机号')
+      } else {
+        callback()
+      }
+    }
+    const validatePhone = (rule, value, callback) => {
+      if(!value) {
+        callback('请输入手机号')
+      } else if(!(/^1[3456789]\d{9}$/.test(value))) {
+        callback('请输入正确的手机号')
+      } else {
+        callback()
+      }
+    }
     return {
       baseURL: process.env.VUE_APP_BASE_API,
       myHeaders: { 'x-token': getToken() },
@@ -472,7 +488,8 @@ export default {
       formRules: {
         orderSmallType: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
         receUserName: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
-        recePhone: [{ required: true, message: '请输入客户电话', trigger: 'blur' }],
+        recePhone: [{ required: true, validator: validatePhone, trigger: 'blur' }],
+        saleMobile: [{ validator: validatePhone2, trigger: 'blur' }],
         payType: [{ required: true, message: '请选择支付方式', trigger: 'change' }],
       },
       formType: 'add',