提交 f316615a 编写于 作者: tony001's avatar tony001

应用级状态数据同步

上级 9d140ba5
......@@ -5,6 +5,7 @@ import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
<#if ctrl.getPSAppCounterRefs?? && ctrl.getPSAppCounterRefs()??>
<#list ctrl.getPSAppCounterRefs() as singleCounterRef>
<#if singleCounterRef.getPSAppCounter()??>
......
......@@ -895,6 +895,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
const data = response.data;
this.onFormLoad(data,'load');
this.$emit('load', data);
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
......@@ -942,6 +945,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.resetDraftFormStates();
this.onFormLoad(data,'loadDraft');
this.$emit('load', data);
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
......@@ -1000,7 +1006,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.onFormLoad(data,'autoSave');
this.$emit('save', data);
<#if ctrl.getControlType() == 'FORM'>
this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
......@@ -1072,7 +1078,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.onFormLoad(data,'save');
this.$emit('save', data);
<#if ctrl.getControlType() == 'FORM'>
this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
......@@ -1122,6 +1128,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.formState.next({ type: 'remove', data: data });
this.data.ismodify = false;
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + '&nbsp;删除成功!' });
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
resolve(response);
}
}).catch((error: any) => {
......@@ -1219,6 +1228,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
// 保存完成UI处理
this.onFormLoad(arg,'save');
this.$emit('save', arg);
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => {
this.formState.next({ type: 'save', data: arg });
});
......@@ -1306,6 +1318,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.fillForm(_data,'updateFormItem');
this.formLogic({ name: '', newVal: null, oldVal: null });
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.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data });
});
......
......@@ -116,6 +116,15 @@ import { FormItemModel } from '@/model/form-detail';
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 应用状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public appStateEvent: Subscription | undefined;
/**
* 获取多项数据
*
......@@ -1099,6 +1108,16 @@ import { FormItemModel } from '@/model/form-detail';
}
});
}
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]);
}
})
}
}
/**
......@@ -1119,6 +1138,9 @@ import { FormItemModel } from '@/model/form-detail';
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if(this.appStateEvent){
this.appStateEvent.unsubscribe();
}
<#if destroyed_block??>
${destroyed_block}
</#if>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册