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

update:更新

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