import SysOperator from '@/codelist/sys-operator';   
import { Store } from 'vuex';

/**
 * 动态代码表服务类
 *
 * @export
 * @class CodeListService
 */
export default class CodeListService {

    /**
     * Vue 状态管理器
     *
     * @private
     * @type {(any | null)}
     * @memberof CodeListService
     */
    private $store: Store<any> | null = null;

    constructor(opts: any = {}) {
        this.$store = opts.$store;
    }

    /**
     * 获取状态管理器
     *
     * @returns {(any | null)}
     * @memberof CodeListService
     */
    public getStore(): Store<any> | null {
        return this.$store;
    }


    /**
     * 代码表--云系统操作者
     *
     * @type {SysOperator}
     * @memberof CodeListService
     */
    public SysOperator: SysOperator = new SysOperator();

    /**
     * 获取动态代码表
     *
     * @param {string} tag 代码表标识
     * @returns {Promise<any[]>}
     * @memberof CodeListService
     */
    public getItems(tag: string,data?: any, isloading?: boolean,): Promise<any[]> {
        let _this: any = this;
        if (_this[tag]) {
            return _this[tag].getItems(data,isloading);
        }
        return Promise.reject([]);
    }
}