提交 175fab60 编写于 作者: Mosher's avatar Mosher

update:更新

上级 9cf7c3fd
......@@ -5,6 +5,14 @@
*/
export interface IAppCounterService {
/**
* 计数器唯一标识
*
* @type {string}
* @memberof IAppCounterService
*/
id: string;
/**
* 计数器数据
*
......
import { MainControl, TabExpPanelControlState, TabExpPanelControlProps } from '@core';
import { MainControl, TabExpPanelControlState, TabExpPanelControlProps, IParam } from '@core';
import { IAppCounterService } from '@core/interface';
/**
* @description 分页导航部件
......@@ -32,6 +33,49 @@ export class TabExpPanelControl extends MainControl {
this.state.activePanel = this.props.defaultActivePanel;
}
/**
* 使用计数器模块
*
* @return {*}
* @memberof TabExpPanelControl
*/
public useCounterService() {
const { appCounterRefs, context, viewParams } = this.state;
const { counterService } = toRefs(this.state);
if (appCounterRefs && appCounterRefs.length) {
counterService.value = [];
appCounterRefs.forEach((counterRef: IParam) => {
const _counterService = App.getCounterService(counterRef, context, viewParams);
_counterService.execute().then(() => {
counterService.value.push(_counterService);
});
});
}
onUnmounted(() => {
if (counterService && counterService.value && counterService.value.length) {
counterService.value.forEach((service: IAppCounterService) => {
service.destory();
});
}
});
// 获取计数器数据
const getCounterData = (counterId: string, viewPanelCounterName?: string, ): number => {
if (viewPanelCounterName) {
const viewPanelCounter = this.state[viewPanelCounterName];
if (!viewPanelCounter) {
return 0;
}
const service: IAppCounterService = counterService.value.find((_service: IAppCounterService) => _service.id === viewPanelCounter.id);
if (service && service.data && service.data[viewPanelCounter.counterId]) {
return service.data[counterId];
}
}
return 0;
}
return getCounterData;
}
/**
* @description 安装部件所有功能模块的方法
* @param {TabExpPanelControlProps} props
......
......@@ -34,11 +34,10 @@ export class AppCounterService implements IAppCounterService {
/**
* @description 计数器唯一标识
* @private
* @type {string}
* @memberof AppCounterService
*/
private counterId: string = '';
public id: string = '';
/**
* @description 计数器实体标识
......@@ -84,7 +83,7 @@ export class AppCounterService implements IAppCounterService {
this.delayTime = counterRef.timer;
this.getAction = counterRef.getAction;
this.deCodeName = counterRef.deCodeName;
this.counterId = counterRef.id;
this.id = counterRef.id;
}
/**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册