提交 39c07c4f 编写于 作者: Mosher's avatar Mosher

update:更新

上级 26263836
......@@ -689,22 +689,30 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* @param {*} [opt={}]
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public loadDraft(opt: any = {},mode?:string): void {
public async loadDraft(opt: any = {},mode?:string): Promise<any> {
if(!this.loaddraftAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}' + (this.$t('app.searchForm.notConfig.loaddraftAction') as string) });
return;
}
const arg: any = { ...opt } ;
Object.assign(arg,{viewparams:this.viewparams});
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
Object.assign(arg, { viewparams:this.viewparams });
if (!(await this.handleCtrlEvents('onbeforeloaddraft', { data: arg }))) {
return;
}
try {
const response = await this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
if (!response.status || response.status !== 200) {
if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response && response.data ? response.data : arg }))) {
return;
}
if (response.data && response.data.message) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return response;
}
if (!(await this.handleCtrlEvents('onloaddraftsuccess', { data: response.data }))) {
return;
}
const data = response.data;
this.resetDraftFormStates();
this.onFormLoad(data,'loadDraft');
......@@ -727,7 +735,11 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
}).catch((response: any) => {
return response;
} catch(response: any) {
if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response && response.data ? response.data : arg }))) {
return;
}
if (response && response.status === 401) {
return;
}
......@@ -738,7 +750,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
const { data: _data } = response;
this.$Notice.error({ title: _data.title, desc: _data.message });
});
}
}
/**
......@@ -782,7 +794,11 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
if (!this.formValidateStatus()) {
return;
}
this.$emit('search', this.data);
this.handleCtrlEvents('onsearch', { }).then((result: boolean) => {
if (result) {
this.$emit('search', this.data);
}
})
}
/**
......@@ -791,7 +807,11 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public onReset() {
this.loadDraft({},'RESET');
this.handleCtrlEvents('onreset', { }).then((result: boolean) => {
if (result) {
this.loadDraft({},'RESET');
}
})
}
</#if>
<#if ctrl.getSearchButtonStyle() == 'SEARCHONLY'>
......@@ -805,7 +825,11 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
if (!this.formValidateStatus()) {
return;
}
this.$emit('search', this.data);
this.handleCtrlEvents('onsearch', { }).then((result: boolean) => {
if (result) {
this.$emit('search', this.data);
}
})
}
</#if>
</#if>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册