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

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

上级 90ad9521
......@@ -8,6 +8,7 @@
<#assign import_block>
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import schema from 'async-validator';
</#assign>
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
......@@ -371,7 +372,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 +383,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 +396,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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册