counter-service-base.ts 2.1 KB
Newer Older
KK's avatar
KK committed
1 2
import { Store } from 'vuex';
import {EntityService} from '@/ibiz-core';
neko's avatar
neko committed
3 4 5 6
/**
 * 计数器服务基类
 *
 * @export
7
 * @class CounterService
neko's avatar
neko committed
8
 */
KK's avatar
KK committed
9
export  class CounterService {
neko's avatar
neko committed
10

KK's avatar
KK committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    /**
     * Vue 状态管理器
     *
     * @private
     * @type {(any | null)}
     * @memberof CounterService
     */
    private $store: Store<any> | null = null;
    
    /**
     * 当前计数器数据
     * 
     * @protected
     * @type {*}
     * @memberof  CounterService
     */
    protected counterData:any ={};

    /**
     * 应用实体数据服务
     *
     * @protected
     * @type {EntityService}
     * @memberof CounterService
     */    
    protected appEntityService:EntityService = new EntityService();

    /**
     * 当前计数器导航上下文
     * 
     * @protected
     * @type {*}
     * @memberof  CounterService
     */
    protected context:any ={};

    /**
     * 当前计数器导航参数
     * 
     * @protected
     * @type {*}
     * @memberof  CounterService
     */
    protected viewparams:any ={};

    /**
     * 当前计数器定时器对象
     * 
     * @protected
     * @type {*}
     * @memberof  CounterService
     */
    protected timer:any;

neko's avatar
neko committed
65
    /**
66 67 68 69
     * Creates an instance of CounterService.
     * 
     * @param {*} [opts={}]
     * @memberof CounterService
neko's avatar
neko committed
70
     */
71
    constructor(opts: any = {}) {
KK's avatar
KK committed
72 73 74 75
        this.$store = opts.$store;
        this.context = opts.context?opts.context:{};
        this.viewparams = opts.viewparams?opts.viewparams:{};
    }
neko's avatar
neko committed
76

KK's avatar
KK committed
77 78 79 80 81 82 83 84
    /**
     * 获取状态管理器
     *
     * @returns {(any | null)}
     * @memberof CounterService
     */
    public getStore(): Store<any> | null {
        return this.$store;
neko's avatar
neko committed
85 86 87
    }

    /**
88
     * 获取计数器服务
neko's avatar
neko committed
89 90
     *
     * @protected
91
     * @param {string} name 实体名称
neko's avatar
neko committed
92
     * @returns {Promise<any>}
93
     * @memberof CounterService
neko's avatar
neko committed
94
     */
95
    public getService(name: string): Promise<any> {
tony001's avatar
tony001 committed
96
        return window.counterServiceConstructor.getService(name);
neko's avatar
neko committed
97 98
    }

KK's avatar
KK committed
99 100 101 102 103 104 105 106
    /**
     * 销毁计数器
     *
     * @memberof ActionCounterCounterServiceBase
     */
    public destroyCounter(){
        if(this.timer) clearInterval(this.timer);
    }
107
   
neko's avatar
neko committed
108
}