Browse Source

添加校验规则

liusungtsun 1 year ago
parent
commit
c3e49182f3

+ 2 - 0
src/views/APICONFIG/index.vue

@@ -455,12 +455,14 @@ export default {
         ],
         apiCode: [
           { required: true, message: "接口编号不能为空", trigger: "blur" },
+               { pattern: /^[1-9a-zA-Z]{1,}$/, message: '接口编号只能输入数字和字母', trigger: 'blur' }
         ],
         apiName: [
           { required: true, message: "接口名称不能为空", trigger: "blur" },
         ],
         apiUrl: [
           { required: true, message: "接口url不能为空", trigger: "blur" },
+          {pattern: /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$/, message: '请输入正确的url链接', trigger: 'blur' }
         ],
         request: [
           { required: true, message: "请求参数示例不能为空", trigger: "blur" },

+ 0 - 1
src/views/CONTACTUS/index.vue

@@ -172,7 +172,6 @@ export default {
     validateMobile(rule, value, callback) {
       let reg1 = /^1[3|4|5|7|8][0-9]\d{8}$/;//11位手机号
       let reg2 = /^(\d{3,4}-)?\d{6,8}$/;//座机和传真格式是一样的:区号-号码
-      console.log(!reg1.test(value) , !reg2.test(value));
       if(!value && value!=='0'){
         callback()
       }else{

+ 0 - 1
src/views/ONLINE/index.vue

@@ -152,7 +152,6 @@ export default {
     validateMobile(rule, value, callback) {
       let reg1 = /^1[3|4|5|7|8][0-9]\d{8}$/;//11位手机号
       let reg2 = /^(\d{3,4}-)?\d{6,8}$/;//座机和传真格式是一样的:区号-号码
-      console.log(!reg1.test(value) , !reg2.test(value));
       if(!value && value!=='0'){
         callback()
       }else{

+ 10 - 5
src/views/norm/dataSubmission.vue

@@ -195,15 +195,20 @@ export default {
         fvalue: [{ required: true, message: '指标参数不能为空', trigger: 'blur' }],
         fname: [{ required: true, message: '报送参数名称不能为空', trigger: 'blur' }],
         funit: [{ required: true, message: '计量单位不能为空', trigger: 'blur' }],
-        normRatio: [{ required: true, message: '分类占比不能为空', trigger: 'blur' }],
-        fnumber: [{ required: true, message: '权数不能为空', trigger: 'blur' }],
+        normRatio: [{ required: true, message: '分类占比不能为空', trigger: 'blur' },
+               { pattern: /^[1-9]{1,}$/, message: '分类占比只能输入整数数字', trigger: 'blur' }],
+        fnumber: [{ required: true, message: '权数不能为空', trigger: 'blur' },
+               { pattern: /^[1-9]{1,}$/, message: '权数只能输入整数数字', trigger: 'blur' }],
         status: [{ required: true, message: '是否启用(1=启用,0不启用)不能为空', trigger: 'blur' }],
         startTime: [{ required: true, message: '启用时间不能为空', trigger: 'blur' }],
         stopTime: [{ required: true, message: '停用时间不能为空', trigger: 'blur' }],
         remark: [{ required: true, message: '备注不能为空', trigger: 'blur' }],
-        collValue: [{ required: true, message: '采集参考值不能为空', trigger: 'blur' }],
-        meritsValue: [{ required: true, message: '绩效参考值不能为空', trigger: 'blur' }],
-        dfRetio: [{ required: true, message: '上下公差占比不能为空', trigger: 'blur' }],
+        collValue: [{ required: true, message: '采集参考值不能为空', trigger: 'blur' },
+               { pattern: /^[1-9]{1,}$/, message: '采集参考值只能输入整数数字', trigger: 'blur' }],
+        meritsValue: [{ required: true, message: '绩效参考值不能为空', trigger: 'blur' },
+               { pattern: /^[1-9]{1,}$/, message: '绩效参考值只能输入整数数字', trigger: 'blur' }],
+        dfRetio: [{ required: true, message: '上下公差占比不能为空', trigger: 'blur' },
+               { pattern: /^[1-9]{1,}$/, message: '上下公差占比只能输入整数数字', trigger: 'blur' }],
         type: [{ required: true, message: '明细类型(1=绩效,2=采集)不能为空', trigger: 'change' }]
       },
       unitSel: null

+ 11 - 7
src/views/norm/index.vue

@@ -53,19 +53,19 @@
     <!-- 添加或修改指标分类对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" :close-on-click-modal="false"  append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label-width="100px" label="指标分类编号">
+        <el-form-item label-width="120px" prop="code" label="指标分类编号">
           <el-input v-model="form.code"></el-input>
         </el-form-item>
-        <el-form-item label-width="100px" label="指标排序">
+        <el-form-item label-width="120px" prop="sort" label="指标排序">
           <el-input v-model="form.sort"></el-input>
         </el-form-item>
-        <el-form-item label-width="100px" label="指标分类名称">
+        <el-form-item label-width="120px" prop="name" label="指标分类名称">
           <el-input v-model="form.name"></el-input>
         </el-form-item>
-        <el-form-item label-width="100px" label="备注">
+        <el-form-item label-width="120px" prop="remark" label="备注">
           <el-input type="textarea" v-model="form.remark" rows="5"></el-input>
         </el-form-item>
-        <el-form-item label-width="100px" prop="status" label="状态">
+        <el-form-item label-width="120px" prop="status" label="状态">
           <el-radio-group v-model="form.status">
             <el-radio label="1">启用</el-radio>
             <el-radio label="0">不启用</el-radio>
@@ -145,11 +145,15 @@ export default {
       // 表单校验
       rules: {
         id: [{ required: true, message: 'id不能为空', trigger: 'blur' }],
-        sort: [{ required: true, message: '排序为数值', trigger: 'blur' }],
+        sort: [{ required: true, message: '排序为数值', trigger: 'blur' },
+               { pattern: /^[1-9]{1,}$/, message: '排序只能输入数字', trigger: 'blur' }
+              ],
         delFlag: [{ required: true, message: '删除标识不能为空', trigger: 'blur' }],
         deptId: [{ required: true, message: '部门id不能为空', trigger: 'blur' }],
         name: [{ required: true, message: '指标分类名称不能为空', trigger: 'blur' }],
-        code: [{ required: true, message: '指标分类编号不能为空', trigger: 'blur' }],
+        code: [{ required: true, message: '指标分类编号不能为空', trigger: 'blur' },
+               { pattern: /^[1-9a-zA-Z]{1,}$/, message: '指标分类编号只能输入数字和字母', trigger: 'blur' }
+              ],
         status: [
           {
             required: true,