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

调整计数器对象加载数据逻辑

上级 687ce1b6
......@@ -10,14 +10,6 @@ TARGET=PSAPPCOUNTER
*/
export default class ${srfclassname('${item.getCodeName()}')}CounterServiceBase extends CounterService {
/**
* 当前计数器数据对象
*
* @param {*} [opts={}]
* @memberof ${srfclassname('${item.getCodeName()}')}CounterServiceBase
*/
public counterData:any ={};
/**
* Creates an instance of ${srfclassname('${item.getCodeName()}')}CounterServiceBase.
*
......@@ -27,8 +19,8 @@ export default class ${srfclassname('${item.getCodeName()}')}CounterServiceBase
constructor(opts: any = {}) {
super(opts);
this.initCounterData();
setInterval(() => {
this.fetchCounterData();
this.timer = setInterval(() => {
this.fetchCounterData(this.context,this.viewparams);
}, <#if item.getTimer()??>${item.getTimer()?c}<#else>6000</#if>);
}
......@@ -39,7 +31,7 @@ export default class ${srfclassname('${item.getCodeName()}')}CounterServiceBase
* @memberof ${srfclassname('${item.getCodeName()}')}CounterServiceBase
*/
public initCounterData(){
this.fetchCounterData();
this.fetchCounterData(this.context,this.viewparams);
}
/**
......@@ -48,19 +40,14 @@ export default class ${srfclassname('${item.getCodeName()}')}CounterServiceBase
* @param {*} [opts={}]
* @memberof ${srfclassname('${item.getCodeName()}')}CounterServiceBase
*/
public async fetchCounterData(){
this.counterData = {
item1:parseInt((Math.random()*10)+''),
item2:parseInt((Math.random()*100)+''),
item3:parseInt((Math.random()*100)+''),
item4:parseInt((Math.random()*100)+''),
item5:parseInt((Math.random()*100)+''),
item6:parseInt((Math.random()*100)+''),
item7:parseInt((Math.random()*100)+''),
item8:parseInt((Math.random()*100)+''),
item9:parseInt((Math.random()*100)+''),
item10:parseInt((Math.random()*100)+'')
public async fetchCounterData(context:any,data:any){
<#if item.getPSAppDataEntity?? && item.getPSAppDataEntity()?? && item.getGetPSAppDEAction?? && item.getGetPSAppDEAction()??>
let _appEntityService:any = await this.appEntityService.getService('${item.getPSAppDataEntity().getCodeName()?lower_case}');
if (_appEntityService['${item.getGetPSAppDEAction().getCodeName()}'] && _appEntityService['${item.getGetPSAppDEAction().getCodeName()}'] instanceof Function) {
let result = _appEntityService['${item.getGetPSAppDEAction().getCodeName()}'](context,data, false);
this.counterData = result.data;
}
</#if>
}
/**
......@@ -69,8 +56,9 @@ export default class ${srfclassname('${item.getCodeName()}')}CounterServiceBase
* @memberof ${srfclassname('${item.getCodeName()}')}CounterServiceBase
*/
public async refreshData(){
const res = await this.fetchCounterData();
return res;
if (this['fetchCounterData'] && this['fetchCounterData'] instanceof Function) {
await this.fetchCounterData(this.context,this.viewparams);
}
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册