提交 0344d774 编写于 作者: KK's avatar KK

值规则 逻辑调整

上级 bb3a4c40
......@@ -323,43 +323,54 @@ import schema from 'async-validator';
* @param {{ name: string }} { name }
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public verifyDeRules(name:string,rule:any = this.deRules) :{isPast:boolean,infoMessage:string}{
public verifyDeRules(name:string,rule:any = this.deRules,op:string = "AND") :{isPast:boolean,infoMessage:string}{
let falg = {isPast:true,infoMessage:""};
if(!rule[name]){
return falg;
}
rule[name].forEach((item:any) => {
if(!falg.isPast){
return falg;
}
let opValue = op=='AND'?true:false;
// 常规规则
if(item.type == 'SIMPLE'){
falg.isPast = this.$verify.checkFieldSimpleRule(this.data[this.service.getItemNameByDeName(item.deName)],item.condOP,item.paramValue,item.ruleInfo,item.paramType,{},item.isKeyCond);
falg.infoMessage = item.ruleInfo;
if(opValue){
falg.isPast = falg.isPast && this.$verify.checkFieldSimpleRule(this.data[this.service.getItemNameByDeName(item.deName)],item.condOP,item.paramValue,item.ruleInfo,item.paramType,{},item.isKeyCond);
}else{
falg.isPast = falg.isPast || this.$verify.checkFieldSimpleRule(this.data[this.service.getItemNameByDeName(item.deName)],item.condOP,item.paramValue,item.ruleInfo,item.paramType,{},item.isKeyCond);
}
}
// 正则式
if(item.type == 'REGEX'){
if(opValue){
falg.isPast = falg.isPast && !this.$verify.checkFieldRegExRule(this.data[this.service.getItemNameByDeName(item.deName)],item.RegExCode,item.ruleInfo,item.isKeyCond);
}else{
falg.isPast = falg.isPast || !this.$verify.checkFieldRegExRule(this.data[this.service.getItemNameByDeName(item.deName)],item.RegExCode,item.ruleInfo,item.isKeyCond);
}
}
// 数值范围
if(item.type == 'VALUERANGE2'){
falg.isPast = !this.$verify.checkFieldValueRangeRule(this.data[this.service.getItemNameByDeName(item.deName)],item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond);
falg.infoMessage = item.ruleInfo;
}
// 正则式
if (item.type == "REGEX") {
falg.isPast = !this.$verify.checkFieldRegExRule(this.data[this.service.getItemNameByDeName(item.deName)],item.RegExCode,item.ruleInfo,item.isKeyCond);
falg.infoMessage = item.ruleInfo;
if(opValue){
falg.isPast = falg.isPast && !this.$verify.checkFieldValueRangeRule(this.data[this.service.getItemNameByDeName(item.deName)],item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond);
}else{
falg.isPast = falg.isPast || !this.$verify.checkFieldValueRangeRule(this.data[this.service.getItemNameByDeName(item.deName)],item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond);
}
}
// 长度
if (item.type == "STRINGLENGTH") {
falg.isPast = !this.$verify.checkFieldStringLengthRule(this.data[this.service.getItemNameByDeName(item.deName)],item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond);
falg.infoMessage = item.ruleInfo;
if(opValue){
falg.isPast = falg.isPast && !this.$verify.checkFieldStringLengthRule(this.data[this.service.getItemNameByDeName(item.deName)],item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeManValue,item.ruleInfo,item.isKeyCond);
}else{
falg.isPast = falg.isPast || !this.$verify.checkFieldStringLengthRule(this.data[this.service.getItemNameByDeName(item.deName)],item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeManValue,item.ruleInfo,item.isKeyCond);
}
}
// 系统值规则
if(item.type === "SYSVALUERULE" && (item.isNotMode ? item.sysRule.RegExCode.test(this.data[name]) : !item.sysRule.RegExCode.test(this.data[name]))) {
falg.isPast = false;
falg.infoMessage = item.sysRule.ruleInfo;
}
falg.infoMessage = item.ruleInfo;
// 分组
if(item.type == 'GROUP'){
falg = this.verifyDeRules('group',item)
falg = this.verifyDeRules('group',item,item.condOP)
}
});
return falg;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册