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

属性值规则

上级 e902c399
......@@ -273,6 +273,12 @@ import schema from 'async-validator';
</#if>
</#if>
</#if>
<#-- 属性值规则 -->
<#if fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??>
<#assign deRule = fideValueRule.getPSDEFValueRule()/>
{validator:(rule:any, value:any)=>{return this.verifyDeRules("${fideValueRule.getPSDEFormItemName()}")},message: '<#if deRule.getRuleInfo?? && deRule.getRuleInfo()??>${deRule.getRuleInfo()}</#if>', trigger: 'change' },
{validator:(rule:any, value:any)=>{return this.verifyDeRules("${fideValueRule.getPSDEFormItemName()}")},message: '<#if deRule.getRuleInfo?? && deRule.getRuleInfo()??>${deRule.getRuleInfo()}</#if>', trigger: 'blur' },
</#if>
</#if>
</#list>
</#if>
......@@ -281,6 +287,68 @@ import schema from 'async-validator';
</#list>
}
/**
* 属性值规则
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public deRules:any = {
<#if ctrl.getPSDEFormItemVRs?? && ctrl.getPSDEFormItemVRs()??>
<#list ctrl.getPSDEFormItemVRs() as fideValueRule>
<#if 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>
{
type:"<#if condItem.getCondType?? && condItem.getCondType()??>${condItem.getCondType()}</#if>",
<#if condItem.getParamValue?? && condItem.getParamValue()??>paramValue:"${condItem.getParamValue()}",</#if>
<#if condItem.getParamType?? && condItem.getParamType()??>paramType:"${condItem.getParamType()}",</#if>
<#if condItem.isNotMode?? && condItem.isNotMode()??>isNotMode:${condItem.isNotMode()?c},</#if>
<#if condItem.getRegExCode?? && condItem.getRegExCode()??>RegExCode:/${condItem.getRegExCode()}/,</#if>
<#if condItem.getMaxValue?? && condItem.getMaxValue()??>maxValue:${condItem.getMaxValue()?c},</#if>
<#if condItem.getMinValue?? && condItem.getMinValue()??>minValue:${condItem.getMinValue()?c},</#if>
condOP:"<#if condItem.getCondOP?? && condItem.getCondOP()??>${condItem.getCondOP()}</#if>",
},
</#list>
</#if>],
</#if>
</#if>
</#list>
</#if>
};
/**
* 校验属性值规则
*
* @public
* @param {{ name: string }} { name }
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public verifyDeRules(name:string) :boolean{
let falg :boolean= true;
if(!this.deRules[name]){
return falg;
}
this.deRules[name].forEach((item:any) => {
if(item.type == 'SIMPLE' && this.data[name] != item.paramValue){
falg = false;
}
if(item.type == 'REGEX' && (item.isNotMode? item.RegExCode.test(this.data[name]) : !item.RegExCode.test(this.data[name]))){
falg = false;
}
if(item.type == 'STRINGLENGTH' ){
let valueLength :number = this.data[name]?this.data[name].length:0;
if(item.isNotMode? valueLength > item.minValue && valueLength < item.maxValue : !(valueLength > item.minValue && valueLength < item.maxValue)){
falg = false;
}
}
});
return falg;
}
/**
* 详情模型集合
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册