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

校验逻辑调整

上级 8ed78386
...@@ -444,12 +444,13 @@ import { Util } from '@/ibiz-core/utils'; ...@@ -444,12 +444,13 @@ import { Util } from '@/ibiz-core/utils';
</#if> </#if>
} }
/** /**
* 表单项检查逻辑 * 表单项校验逻辑
* *
* @public * @public
* @param name 属性名 * @param name 属性名
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof Main2Base
*/ */
public validItem(property:string, data:any):Promise<any>{ public validItem(property:string, data:any):Promise<any>{
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -463,6 +464,19 @@ import { Util } from '@/ibiz-core/utils'; ...@@ -463,6 +464,19 @@ import { Util } from '@/ibiz-core/utils';
}); });
} }
/**
* 校验全部
*/
public async validAll() {
let validateState = true;
for (let item of Object.keys(this.rules)) {
if(!await this.validItem(item,this.data[item])){
validateState = false;
}
}
return validateState
}
/** /**
* 表单值变化 * 表单值变化
...@@ -998,7 +1012,7 @@ import { Util } from '@/ibiz-core/utils'; ...@@ -998,7 +1012,7 @@ import { Util } from '@/ibiz-core/utils';
* @memberof ${srfclassname('${ctrl.codeName}')} * @memberof ${srfclassname('${ctrl.codeName}')}
*/ */
protected async autoSave(opt: any = {}): Promise<any> { protected async autoSave(opt: any = {}): Promise<any> {
if (await !this.formValidateStatus()) { if (await !this.validAll()) {
return Promise.reject(); return Promise.reject();
} }
const arg: any = { ...opt }; const arg: any = { ...opt };
...@@ -1046,7 +1060,7 @@ import { Util } from '@/ibiz-core/utils'; ...@@ -1046,7 +1060,7 @@ import { Util } from '@/ibiz-core/utils';
protected async save(opt: any = {}, showResultInfo?: boolean, isStateNext: boolean = true): Promise<any> { protected async save(opt: any = {}, showResultInfo?: boolean, isStateNext: boolean = true): Promise<any> {
showResultInfo = showResultInfo === undefined ? true : false; showResultInfo = showResultInfo === undefined ? true : false;
opt.saveEmit = opt.saveEmit === undefined ? true : false; opt.saveEmit = opt.saveEmit === undefined ? true : false;
if (await !this.formValidateStatus()) { if (await !this.validAll()) {
this.$notice.error('值规则校验异常'); this.$notice.error('值规则校验异常');
return Promise.reject(); return Promise.reject();
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册