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

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

上级 c8110430
......@@ -371,7 +371,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @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>
${P.getPartCode(item,'FORM_LOGIC').code}
</#if>
......@@ -382,7 +382,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
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>];
if(this.checkItem('${formitem.name}')){
if(await this.checkItem('${formitem.name}')){
this.updateFormItems('${itemUpdate.getPSAppDEMethod().getCodeName()}', this.data, details, ${itemUpdate.isShowBusyIndicator()?c});
}
}
......@@ -395,23 +395,19 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* 表单项检查逻辑
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @param name 属性名
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public checkItem(name:string):boolean{
let regular :any = null;
let isRight :boolean = false;
this.rules[name].forEach((item:any)=>{
Object.keys(item).forEach((name:string)=>{
if(name == 'pattern'){
regular = item[name];
}
});
});
if(regular){
isRight = regular.test(this.data[name]);
}
return isRight;
public checkItem(name:string):Promise<any> {
return new Promise((resolve, reject) => {
var validator = new schema({[name]:this.rules[name]});
validator.validate({[name]:this.data[name]}).then(()=>{
resolve(true);
})
.catch(() => {
resolve(false);
});;
})
}
/**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册