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

全局服务中心事件

上级 f98fab57
...@@ -95,6 +95,15 @@ import moment from 'moment'; ...@@ -95,6 +95,15 @@ import moment from 'moment';
*/ */
public calendarItems: any = {}; public calendarItems: any = {};
/**
* 应用状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public appStateEvent: Subscription | undefined;
/** /**
* 日历数据项模型 * 日历数据项模型
* *
...@@ -195,7 +204,7 @@ import moment from 'moment'; ...@@ -195,7 +204,7 @@ import moment from 'moment';
protected afterCreated() { protected afterCreated() {
this.initcurrentTime(); this.initcurrentTime();
if (this.viewState) { if (this.viewState) {
this.viewState.subscribe(({ tag, action, data }) => { this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(this.name, tag)) { if (!Object.is(this.name, tag)) {
return; return;
} }
...@@ -204,6 +213,16 @@ import moment from 'moment'; ...@@ -204,6 +213,16 @@ import moment from 'moment';
} }
}); });
} }
if(AppCenterService && AppCenterService.getMessageCenter()){
this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{
if(!Object.is(name,"${ctrl.getPSAppDataEntity().getCodeName()}")){
return;
}
if(Object.is(action,'appRefresh')){
this.formatData(this.currentDate, data);
}
})
}
} }
/** /**
...@@ -670,6 +689,34 @@ import moment from 'moment'; ...@@ -670,6 +689,34 @@ import moment from 'moment';
this.selectedArray.splice(count,1); this.selectedArray.splice(count,1);
} }
} }
/**
* vue 生命周期
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
protected afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if(this.appStateEvent){
this.appStateEvent.unsubscribe();
}
window.removeEventListener('contextmenu',()=>{});
<#if destroyed_block??>
${destroyed_block}
</#if>
}
<#ibizinclude> <#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl ../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude> </#ibizinclude>
......
...@@ -354,6 +354,16 @@ import { Util } from '@ibiz-core/utils' ...@@ -354,6 +354,16 @@ import { Util } from '@ibiz-core/utils'
} }
}); });
} }
if(AppCenterService && AppCenterService.getMessageCenter()){
this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{
if(!Object.is(name,"${ctrl.getPSAppDataEntity().getCodeName()}")){
return;
}
if(Object.is(action,'appRefresh')){
this.refresh([data]);
}
})
}
} }
/** /**
......
...@@ -187,6 +187,15 @@ ...@@ -187,6 +187,15 @@
*/ */
public group_data?:any = []; public group_data?:any = [];
/**
* 应用状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public appStateEvent: Subscription | undefined;
/** /**
* 分组标识 * 分组标识
* *
...@@ -833,7 +842,7 @@ ...@@ -833,7 +842,7 @@
return; return;
} }
if(Object.is(action,'appRefresh')){ if(Object.is(action,'appRefresh')){
this.refresh([data]); this.refresh();
} }
}) })
} }
...@@ -871,6 +880,9 @@ ...@@ -871,6 +880,9 @@
if (this.viewStateEvent) { if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe(); this.viewStateEvent.unsubscribe();
} }
if(this.appStateEvent){
this.appStateEvent.unsubscribe();
}
window.removeEventListener('contextmenu',()=>{}); window.removeEventListener('contextmenu',()=>{});
<#if destroyed_block??> <#if destroyed_block??>
${destroyed_block} ${destroyed_block}
......
...@@ -1163,6 +1163,9 @@ import { Util } from '@/ibiz-core/utils'; ...@@ -1163,6 +1163,9 @@ import { Util } from '@/ibiz-core/utils';
this.$emit('remove', data); this.$emit('remove', data);
this.formState.next({ type: 'remove', data: data }); this.formState.next({ type: 'remove', data: data });
this.data.ismodify = false; this.data.ismodify = false;
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$notice.success((data.srfmajortext ? data.srfmajortext : '') + '&nbsp;'+ this.$t('app.message.deleteSccess')); this.$notice.success((data.srfmajortext ? data.srfmajortext : '') + '&nbsp;'+ this.$t('app.message.deleteSccess'));
} else if (response && response.status !== 401) { } else if (response && response.status !== 401) {
const { error: _data } = response; const { error: _data } = response;
...@@ -1187,6 +1190,9 @@ import { Util } from '@/ibiz-core/utils'; ...@@ -1187,6 +1190,9 @@ import { Util } from '@/ibiz-core/utils';
let response: any = await this.service.wfstart(_this.WFStartAction, { ...this.context }, arg, this.showBusyIndicator); let response: any = await this.service.wfstart(_this.WFStartAction, { ...this.context }, arg, this.showBusyIndicator);
if (response && response.status === 200) { if (response && response.status === 200) {
this.$notice.success('工作流启动成功'); this.$notice.success('工作流启动成功');
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
} else if (response && response.status !== 401) { } else if (response && response.status !== 401) {
this.$notice.error('工作流启动失败, ' + response.error.message); this.$notice.error('工作流启动失败, ' + response.error.message);
} }
...@@ -1213,6 +1219,9 @@ import { Util } from '@/ibiz-core/utils'; ...@@ -1213,6 +1219,9 @@ import { Util } from '@/ibiz-core/utils';
const response: any = await this.service.wfsubmit(this.currentAction, { ...this.context }, datas, this.showBusyIndicator, arg); const response: any = await this.service.wfsubmit(this.currentAction, { ...this.context }, datas, this.showBusyIndicator, arg);
if (response && response.status === 200) { if (response && response.status === 200) {
this.$notice.success('工作流提交成功'); this.$notice.success('工作流提交成功');
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
} else if (response && response.status !== 401) { } else if (response && response.status !== 401) {
this.$notice.error('工作流提交失败, ' + response.error.message); this.$notice.error('工作流提交失败, ' + response.error.message);
return response; return response;
...@@ -1251,6 +1260,9 @@ import { Util } from '@/ibiz-core/utils'; ...@@ -1251,6 +1260,9 @@ import { Util } from '@/ibiz-core/utils';
this.fillForm(_data, 'updateFormItem'); this.fillForm(_data, 'updateFormItem');
this.formLogic({ name: '', newVal: null, oldVal: null }); this.formLogic({ name: '', newVal: null, oldVal: null });
this.dataChang.next(JSON.stringify(this.data)); this.dataChang.next(JSON.stringify(this.data));
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => { this.$nextTick(() => {
this.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data }); this.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data });
}); });
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册