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

属性值规则 --fix

上级 dff0f526
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<#if item.render??> <#if item.render??>
${item.render.code} ${item.render.code}
<#else> <#else>
<app-form-item name='${item.name}' :itemRules="this.rules.${item.name}" class='<#if item.getPSSysCss?? && item.getPSSysCss()??>${item.getPSSysCss().getCssName()}</#if>'<#if item.getLabelPSSysCss?? && item.getLabelPSSysCss()??> labelStyle="${item.getLabelPSSysCss().getCssName()}"</#if> :caption="<#if langbase??>$t('${langbase}.details.${item.name}')<#else>'${item.getCaption()}'</#if>" uiStyle="${item.getDetailStyle()}" :labelWidth="${item.getLabelWidth()?c}" :isShowCaption="${item.isShowCaption()?c}" :error="detailsModel.${item.name}.error" :isEmptyCaption="${item.isEmptyCaption()?c}" labelPos="${item.getLabelPos()}"> <app-form-item name='${item.name}' :itemRules="this.rules().${item.name}" class='<#if item.getPSSysCss?? && item.getPSSysCss()??>${item.getPSSysCss().getCssName()}</#if>'<#if item.getLabelPSSysCss?? && item.getLabelPSSysCss()??> labelStyle="${item.getLabelPSSysCss().getCssName()}"</#if> :caption="<#if langbase??>$t('${langbase}.details.${item.name}')<#else>'${item.getCaption()}'</#if>" uiStyle="${item.getDetailStyle()}" :labelWidth="${item.getLabelWidth()?c}" :isShowCaption="${item.isShowCaption()?c}" :error="detailsModel.${item.name}.error" :isEmptyCaption="${item.isEmptyCaption()?c}" labelPos="${item.getLabelPos()}">
<#if item.isCompositeItem()> <#if item.isCompositeItem()>
<#assign formitems=item.getPSDEFormItems()> <#assign formitems=item.getPSDEFormItems()>
<app-range-editor v-model="data.${item.name}" :activeData="data" :disabled="detailsModel.${item.name}.disabled" name="${item.name}" editorType="${item.getEditorType()}" format="${item.getEditorParam("TIMEFMT","")}" :refFormItem="[<#list formitems as formitem><#if formitem_index gt 0>,</#if>'${formitem.name}'</#list>]" @formitemvaluechange="onFormItemValueChange" style="<#if item.getContentWidth()?? && item.getContentWidth() != 0>width:${item.getContentWidth()}px;</#if><#if item.getContentHeight()?? && item.getContentHeight() != 0>height:${item.getContentHeight()}px;</#if>"></app-range-editor> <app-range-editor v-model="data.${item.name}" :activeData="data" :disabled="detailsModel.${item.name}.disabled" name="${item.name}" editorType="${item.getEditorType()}" format="${item.getEditorParam("TIMEFMT","")}" :refFormItem="[<#list formitems as formitem><#if formitem_index gt 0>,</#if>'${formitem.name}'</#list>]" @formitemvaluechange="onFormItemValueChange" style="<#if item.getContentWidth()?? && item.getContentWidth() != 0>width:${item.getContentWidth()}px;</#if><#if item.getContentHeight()?? && item.getContentHeight() != 0>height:${item.getContentHeight()}px;</#if>"></app-range-editor>
......
...@@ -240,7 +240,8 @@ import schema from 'async-validator'; ...@@ -240,7 +240,8 @@ import schema from 'async-validator';
* @type {*} * @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public rules: any = { public rules() :any {
return {
<#list ctrl.getAllPSDEFormDetails() as formdetail> <#list ctrl.getAllPSDEFormDetails() as formdetail>
<#if formdetail.getDetailType?? && formdetail.getDetailType() == 'FORMITEM'> <#if formdetail.getDetailType?? && formdetail.getDetailType() == 'FORMITEM'>
${formdetail.getName()}: [ ${formdetail.getName()}: [
...@@ -276,8 +277,8 @@ import schema from 'async-validator'; ...@@ -276,8 +277,8 @@ import schema from 'async-validator';
<#-- 属性值规则 --> <#-- 属性值规则 -->
<#if fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??> <#if fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??>
<#assign deRule = 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()}").isPast},message: this.verifyDeRules("${fideValueRule.getPSDEFormItemName()}").infoMessage, trigger: 'change' },
{validator:(rule:any, value:any)=>{return this.verifyDeRules("${fideValueRule.getPSDEFormItemName()}")},message: '<#if deRule.getRuleInfo?? && deRule.getRuleInfo()??>${deRule.getRuleInfo()}</#if>', trigger: 'blur' }, {validator:(rule:any, value:any)=>{return this.verifyDeRules("${fideValueRule.getPSDEFormItemName()}").isPast},message: this.verifyDeRules("${fideValueRule.getPSDEFormItemName()}").infoMessage, trigger: 'blur' },
</#if> </#if>
</#if> </#if>
</#list> </#list>
...@@ -286,6 +287,7 @@ import schema from 'async-validator'; ...@@ -286,6 +287,7 @@ import schema from 'async-validator';
</#if> </#if>
</#list> </#list>
} }
}
/** /**
* 属性值规则 * 属性值规则
...@@ -304,13 +306,26 @@ import schema from 'async-validator'; ...@@ -304,13 +306,26 @@ import schema from 'async-validator';
<#list deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions() as condItem> <#list deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions() as condItem>
{ {
type:"<#if condItem.getCondType?? && condItem.getCondType()??>${condItem.getCondType()}</#if>", type:"<#if condItem.getCondType?? && condItem.getCondType()??>${condItem.getCondType()}</#if>",
<#if condItem.getParamValue?? && condItem.getParamValue()??>paramValue:"${condItem.getParamValue()}",</#if> <#if condItem.getParamValue?? && condItem.getParamValue()??>
<#if condItem.getParamType?? && condItem.getParamType()??>paramType:"${condItem.getParamType()}",</#if> paramValue:"${condItem.getParamValue()}",<#t>
<#if condItem.isNotMode?? && condItem.isNotMode()??>isNotMode:${condItem.isNotMode()?c},</#if> </#if>
<#if condItem.getRegExCode?? && condItem.getRegExCode()??>RegExCode:/${condItem.getRegExCode()}/,</#if> <#if condItem.getParamType?? && condItem.getParamType()??>
<#if condItem.getMaxValue?? && condItem.getMaxValue()??>maxValue:${condItem.getMaxValue()?c},</#if> paramType:"${condItem.getParamType()}",<#t>
<#if condItem.getMinValue?? && condItem.getMinValue()??>minValue:${condItem.getMinValue()?c},</#if> </#if>
<#if condItem.isNotMode?? && condItem.isNotMode()??>
isNotMode:${condItem.isNotMode()?c},<#t>
</#if>
<#if condItem.getRegExCode?? && condItem.getRegExCode()??>
RegExCode:/${condItem.getRegExCode()}/,<#t>
</#if>
<#if condItem.getMaxValue?? && condItem.getMaxValue()??>
maxValue:${condItem.getMaxValue()?c},<#t>
</#if>
<#if condItem.getMinValue?? && condItem.getMinValue()??>
minValue:${condItem.getMinValue()?c},<#t>
</#if>
condOP:"<#if condItem.getCondOP?? && condItem.getCondOP()??>${condItem.getCondOP()}</#if>", condOP:"<#if condItem.getCondOP?? && condItem.getCondOP()??>${condItem.getCondOP()}</#if>",
ruleInfo:"<#if condItem.getRuleInfo?? && condItem.getRuleInfo()??>${condItem.getRuleInfo()}</#if>",
}, },
</#list> </#list>
</#if>], </#if>],
...@@ -327,22 +342,25 @@ import schema from 'async-validator'; ...@@ -327,22 +342,25 @@ import schema from 'async-validator';
* @param {{ name: string }} { name } * @param {{ name: string }} { name }
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public verifyDeRules(name:string) :boolean{ public verifyDeRules(name:string) :{isPast:boolean,infoMessage:string}{
let falg :boolean= true; let falg = {isPast:true,infoMessage:""};
if(!this.deRules[name]){ if(!this.deRules[name]){
return falg; return falg;
} }
this.deRules[name].forEach((item:any) => { this.deRules[name].forEach((item:any) => {
if(item.type == 'SIMPLE' && this.data[name] != item.paramValue){ if(item.type == 'SIMPLE' && this.data[name] != item.paramValue){
falg = false; falg.isPast = false;
falg.infoMessage = item.ruleInfo;
} }
if(item.type == 'REGEX' && (item.isNotMode? item.RegExCode.test(this.data[name]) : !item.RegExCode.test(this.data[name]))){ if(item.type == 'REGEX' && (item.isNotMode? item.RegExCode.test(this.data[name]) : !item.RegExCode.test(this.data[name]))){
falg = false; falg.isPast = false;
falg.infoMessage = item.ruleInfo;
} }
if(item.type == 'STRINGLENGTH' ){ if(item.type == 'STRINGLENGTH' ){
let valueLength :number = this.data[name]?this.data[name].length:0; 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)){ if(item.isNotMode? valueLength > item.minValue && valueLength < item.maxValue : !(valueLength > item.minValue && valueLength < item.maxValue)){
falg = false; falg.isPast = false;
falg.infoMessage = item.ruleInfo;
} }
} }
...@@ -479,7 +497,7 @@ import schema from 'async-validator'; ...@@ -479,7 +497,7 @@ import schema from 'async-validator';
*/ */
public checkItem(name:string):Promise<any> { public checkItem(name:string):Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var validator = new schema({[name]:this.rules[name]}); var validator = new schema({[name]:this.rules()[name]});
validator.validate({[name]:this.data[name]}).then(()=>{ validator.validate({[name]:this.data[name]}).then(()=>{
resolve(true); resolve(true);
}) })
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册