Преглед изворни кода

修改正则表达式,以及系统bug

GeekFish пре 4 година
родитељ
комит
f5d5764e36

+ 28 - 0
src/api/CONST.js

@@ -248,3 +248,31 @@ export const nation = [
     "name": "基诺族"
   }
 ]
+
+//公用正则
+export const globalReg = {
+  // 最多两位小数 大于0
+  regNumberToFixed2: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/,
+  // 整数 - 包括0
+  regNumberIncludeZero: /^(0)|([1-9][0-9]*)$/,
+  // 整数 - 非0
+  regNumber: /^([1-9][0-9]*)$/,
+  // 手机号
+  regPhone: /^1[\d]{10}$/,
+  // 座机
+  regTel: /^0\d{2,3}-\d{7,8}$/,
+  // 手机号 && 座机
+  regTelPhone: /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/,
+  // 身份证
+  regIdCard: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
+  // 验证中文 2到6位
+  regChinese: /^[\u4e00-\u9fa5]{2,6}$/,
+  // 银行卡 15或19位
+  regBankCard: /^([1-9]{1})(\d{14}|\d{18})$/,
+  // 字母
+  regLetter: /^[a-zA-Z]$/,
+  // 邮箱
+  regEmail: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
+  // 增值税率
+  regVat: /^(([1-9][0-9]{0,2})|(([0]\.\d{1,2}|[1-9][0-9]{0,2}\.\d{1,2})))$/
+}

+ 10 - 3
src/views/belongToSubject/org/modal/addMobiel.vue

@@ -11,7 +11,7 @@
             </el-form-item>
             <el-row :gutter="20">
               <el-col :span="12">
-                <el-form-item label="联系电话">
+                <el-form-item label="联系电话" prop="phone">
                   <el-input type="text" v-model="form.phone" :disabled="limit.isRead"></el-input>
                 </el-form-item>
               </el-col>
@@ -158,7 +158,7 @@
 
 <script>
 import { getToken } from '@/utils/auth';
-import { peopleType, nation, sexList } from '@/api/CONST.js';
+import { peopleType, nation, sexList , globalReg } from '@/api/CONST.js';
 import { listArea, listPeople, saverCollectiveFarmer, updateCollectiveFarmer } from '@/api/belongToSubject/org';
 export default {
   name: 'addMobiel',
@@ -220,7 +220,14 @@ export default {
       //验证
       rules: {
         collectiveName: [{ required: true, message: '姓名不能为空!', trigger: 'blur' }],
-        fkPovertyAreaName: [{ required: true, message: '帮扶区域不能为空!', trigger: 'blur' }]
+        fkPovertyAreaName: [{ required: true, message: '帮扶区域不能为空!', trigger: 'blur' }],
+        phone:[
+          {
+            pattern:globalReg.regTelPhone,
+            message: "请输入正确号码/座机号请以区号-格式",
+            trigger: "blur"
+          }
+        ]
       },
       //图片列表
       fileList: [],

+ 22 - 6
src/views/belongToSubject/people/modal/addMobiel.vue

@@ -35,7 +35,7 @@
             <el-row :gutter="20">
               <el-col :span="8">
                 <el-form-item label="人均年收入">
-                    <el-input type="text" v-model="form.incomeVal" :disabled="limit.isRead"></el-input>
+                    <el-input type="number" v-model="form.incomeVal" :disabled="limit.isRead"></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="8">
@@ -44,7 +44,7 @@
                 </el-form-item>
               </el-col>
               <el-col :span="8">
-                <el-form-item label="联系电话">
+                <el-form-item label="联系电话" prop="phone">
                     <el-input type="text" v-model="form.phone" :disabled="limit.isRead"></el-input>
                 </el-form-item>
               </el-col>
@@ -52,11 +52,11 @@
             <el-row :gutter="20">
               <el-col :span="8">
                 <el-form-item label="家庭人数">
-                    <el-input type="text" v-model="form.familyNum" :disabled="limit.isRead"></el-input>
+                    <el-input type="number" v-model="form.familyNum" :disabled="limit.isRead"></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="8">
-                <el-form-item label="身份证号">
+                <el-form-item label="身份证号" prop="pid">
                     <el-input type="text" v-model="form.pid" :disabled="limit.isRead"></el-input>
                 </el-form-item>
               </el-col>
@@ -183,7 +183,7 @@
 
 <script>
 import { getToken } from "@/utils/auth";
-import {peopleType , nation , sexList} from "@/api/CONST.js"
+import {peopleType , nation , sexList , globalReg} from "@/api/CONST.js"
 import { listArea ,saverAreaPeople , updateAreaPeople} from "@/api/belongToSubject/people";
 export default {
   name: 'addMobiel',
@@ -245,7 +245,23 @@ export default {
       //验证
       rules: {
         farmerName: [{ required: true, message: '姓名不能为空!', trigger: 'blur' }],
-        methodology: [{ required: true, message: '帮扶区域不能为空!', trigger: 'blur' }]
+        methodology: [{ required: true, message: '帮扶区域不能为空!', trigger: 'blur' }],
+        phone:[
+          { required: false, message: "手机号码不能为空", trigger: "blur" },
+          {
+            pattern:globalReg.regTelPhone,
+            message: "请输入正确号码/座机号请以区号-格式",
+            trigger: "blur"
+          },
+        ],
+        pid:[
+          {
+            pattern:globalReg.regIdCard,
+            message: "身份证号格式错误,请检查!",
+            trigger: "blur"
+          }
+        ]
+        // idcard
       },
       //图片列表
       fileList:[],