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

表单项更新需判断正则--fix

上级 90ad9521
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<#assign import_block> <#assign import_block>
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail'; import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import schema from 'async-validator';
</#assign> </#assign>
<#ibizinclude> <#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl ../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
...@@ -371,7 +372,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -371,7 +372,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal } * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void { public async formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }){
<#if P.getPartCode(item,'FORM_LOGIC').code?length gt 0> <#if P.getPartCode(item,'FORM_LOGIC').code?length gt 0>
${P.getPartCode(item,'FORM_LOGIC').code} ${P.getPartCode(item,'FORM_LOGIC').code}
</#if> </#if>
...@@ -382,7 +383,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -382,7 +383,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
if(Object.is(name, '${formitem.name}')){ if(Object.is(name, '${formitem.name}')){
const details: string[] = [<#list itemUpdate.getPSDEFIUpdateDetails() as detail><#if detail_index gt 0>, </#if>'${detail.getPSDEFormDetailName()?lower_case}'</#list>]; const details: string[] = [<#list itemUpdate.getPSDEFIUpdateDetails() as detail><#if detail_index gt 0>, </#if>'${detail.getPSDEFormDetailName()?lower_case}'</#list>];
if(this.checkItem('${formitem.name}')){ if(await this.checkItem('${formitem.name}')){
this.updateFormItems('${itemUpdate.getPSAppDEMethod().getCodeName()}', this.data, details, ${itemUpdate.isShowBusyIndicator()?c}); this.updateFormItems('${itemUpdate.getPSAppDEMethod().getCodeName()}', this.data, details, ${itemUpdate.isShowBusyIndicator()?c});
} }
} }
...@@ -395,23 +396,19 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -395,23 +396,19 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* 表单项检查逻辑 * 表单项检查逻辑
* *
* @public * @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal } * @param name 属性名
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public checkItem(name:string):boolean{ public checkItem(name:string):Promise<any> {
let regular :any = null; return new Promise((resolve, reject) => {
let isRight :boolean = false; var validator = new schema({[name]:this.rules[name]});
this.rules[name].forEach((item:any)=>{ validator.validate({[name]:this.data[name]}).then(()=>{
Object.keys(item).forEach((name:string)=>{ resolve(true);
if(name == 'pattern'){ })
regular = item[name]; .catch(() => {
} resolve(false);
}); });;
}); })
if(regular){
isRight = regular.test(this.data[name]);
}
return isRight;
} }
/** /**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册