Procházet zdrojové kódy

身份证号、手机号正则表达式修改

duy před 2 roky
rodič
revize
b0c444c924

+ 5 - 2
src/util/validate.js

@@ -133,7 +133,8 @@ export function cardid(code) {
     };
     if (!validatenull(code)) {
         if (code.length == 18) {
-            if (!code || !/(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(code)) {
+            // if (!code || !/(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(code)) {
+                if (!code || !/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(code)) {
                 msg = "证件号码格式错误";
             } else if (!city[code.substr(0, 2)]) {
                 msg = "地址编码错误";
@@ -178,10 +179,12 @@ export function isvalidatemobile(phone) {
     let list = [];
     let result = true;
     let msg = '';
-    var isPhone = /^0\d{2,3}-?\d{7,8}$/;
+    // var isPhone = /^0\d{2,3}-?\d{7,8}$/;
+    var isPhone = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/
     //增加134 减少|1349[0-9]{7},增加181,增加145,增加17[678]  
     if (!validatenull(phone)) {
         if (phone.length == 11) {
+            console.log(isPhone.test(phone),'isPhone.test(phone)');
             if (isPhone.test(phone)) {
                 msg = '手机号码格式不正确';
             } else {

+ 5 - 3
src/views/certificate/list.vue

@@ -181,15 +181,17 @@ export default {
       console.log(res);
       if (res.code == 200) {
         this.options = res.data
+        this.value=this.options[0].id
+        this.listpage()
       }
     },
     async listpage () {//分页获取证书列表数据
       const { data: res } = await listpage({
         current: this.pageindex,
         size: this.pagesize,
-        projectId: this.value,
+        projectId: this.value||"",
       })
-      console.log(res);
+     
       if (res.code == 200) {
         this.tableData = res.data.records
         this.total = res.data.total
@@ -210,7 +212,7 @@ export default {
   },
   created () {
     this.queryProjectList()
-    this.listpage()
+    // this.listpage()
   },
 }
 </script>

+ 5 - 2
src/views/system/user.vue

@@ -431,7 +431,8 @@ export default {
       }
     };
     const phoneRules = (rule, value, callback) => {
-      if (!/^1[345789]\d{9}$/.test(value)) {
+      // if (!/^1[345789]\d{9}$/.test(value)) {
+         if (!/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(value)) {
         callback(new Error('请输入正确的手机号'));
       } else {
         callback();
@@ -441,7 +442,9 @@ export default {
       if (!value) {
         callback();
       } else {
-        if (!/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(value)) {
+        // if (!/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(value)) {
+          //  /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)
+          if (! /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
           callback(new Error('请输入正确的身份证号'));
         } else {
           callback();