Explorar o código

字段映射【】中不能添加特殊字符

zhangxc %!s(int64=5) %!d(string=hai) anos
pai
achega
d988755557
Modificáronse 1 ficheiros con 25 adicións e 0 borrados
  1. 25 0
      src/components/qualityControl/FieldMatch.vue

+ 25 - 0
src/components/qualityControl/FieldMatch.vue

@@ -38,6 +38,7 @@
                 </el-form-item>
                 <el-form-item label="取值字段:" prop="value">
                     <el-input type="text" placeholder="请输入取值字段" v-model="form.val"></el-input>
+                    
                 </el-form-item>
                 <el-form-item label="关联缺陷条目:" prop="casesEntryIds">
                     <el-select filterable
@@ -53,6 +54,7 @@
                                 :value="String(item.id)">
                         </el-option>
                     </el-select>
+                    
                 </el-form-item>
                 <el-form-item>
                     <el-checkbox v-model="form.addLine" :true-label="Number(1)" :false-label="Number(0)">换行</el-checkbox>
@@ -167,6 +169,21 @@
         }*/
         this.$refs[form].validate((valid) => {
           if (valid) {
+            const { val } = this.form
+            let regex = /(?<=【)(.+?)(?=】)/g;
+             let regex2 = /[^\u4e00-\u9fa5|a-zA-Z0-9]+/
+            const matchVal = val.match(regex) ||[]
+            let illegalCode = false
+            for(let i = 0; i < matchVal.length; i++){
+              if(regex2.test(matchVal[i])){
+                illegalCode = true
+              }
+            }
+            if(illegalCode){
+              this.warning("取值字段【】含有非法字符")
+              return;
+            }
+          
             if(this.id){//修改
               const param = Object.assign({},this.form,{id:this.id});
               this.saveDisable = true;  //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
@@ -213,6 +230,14 @@
           }
         });
       },
+      warning(msg, type,time) {
+          this.$message({
+              showClose: true,
+              message: msg,
+              type: type || 'warning',
+              duration:time || '3000'
+          })
+      },
     }
   }
 </script>