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

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

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