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

表单部件——属性值规则

上级 c225f744
......@@ -251,6 +251,97 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
</#list>
}
/**
* 属性值规则
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public deRules:any = {
<#if ctrl.getPSDEFormItemVRs?? && ctrl.getPSDEFormItemVRs()??>
<#list ctrl.getPSDEFormItemVRs() as fideValueRule>
<#if fideValueRule.getCheckMode?? && fideValueRule.getCheckMode()?? && fideValueRule.getCheckMode() != 2 && fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??>
<#assign deRule = fideValueRule.getPSDEFValueRule()/>
<#if fideValueRule.getPSDEFormItemName?? && fideValueRule.getPSDEFormItemName()??>
${fideValueRule.getPSDEFormItemName()}:[
<#if deRule.getPSDEFVRGroupCondition?? && deRule.getPSDEFVRGroupCondition()?? && deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions?? && deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions()??>
<#list deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions() as condItem>
<@getDeRule condItem />
</#list>
</#if>],
</#if>
</#if>
</#list>
</#if>
};
/**
* 校验属性值规则
*
* @public
* @param {{ name: string }} { name }
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public verifyDeRules(name:string,rule:any = this.deRules,op:string = "AND") :{isPast:boolean,infoMessage:string}{
let falg:any = {infoMessage:""};
if(!rule[name]){
return falg;
}
let opValue = op == 'AND'? true :false;
let startOp = (val:boolean)=>{
if(falg.isPast){
if(opValue){
falg.isPast = falg && val;
}else{
falg.isPast = falg || val;
}
}else{
falg.isPast = val;
}
}
rule[name].forEach((item:any) => {
let dataValue = item.deName?this.data[this.service.getItemNameByDeName(item.deName)]:"";
// 常规规则
if(item.type == 'SIMPLE'){
startOp(!this.$verify.checkFieldSimpleRule(dataValue,item.condOP,item.paramValue,item.ruleInfo,item.paramType,{},item.isKeyCond));
falg.infoMessage = item.ruleInfo;
}
// 数值范围
if(item.type == 'VALUERANGE2'){
startOp( !this.$verify.checkFieldValueRangeRule(dataValue,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
}
// 正则式
if (item.type == "REGEX") {
startOp(!this.$verify.checkFieldRegExRule(dataValue,item.regExCode,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
}
// 长度
if (item.type == "STRINGLENGTH") {
startOp(!this.$verify.checkFieldStringLengthRule(dataValue,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
}
// 系统值规则
if(item.type == "SYSVALUERULE") {
startOp(!this.$verify.checkFieldSysValueRule(dataValue,item.sysRule.regExCode,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
}
// 分组
if(item.type == 'GROUP'){
falg = this.verifyDeRules('group',item)
if(item.isNotMode){
falg.isPast = !falg.isPast;
}
}
});
if(!falg.hasOwnProperty("isPast")){
falg.isPast = true;
}
return falg;
}
/**
* 详情模型集合
*
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册