ui-service.ts 2.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
import { Store } from 'vuex';
import AuthService from '@/authservice/auth-service';
import store from '@/store';

/**
 * 界面服务基类
 *
 * @export
 * @class UIService
 */
export default class UIService {

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

    /**
     * 所有关联视图
     * 
     * @memberof  IBIZSample0021UIServiceBase
     */
    protected allViewMap: Map<string, Object> = new Map();

    /**
     * 流程状态数组
     *
     * @protected
     * @type {Array<string>}
     * @memberof UIService
     */
    protected InWorkflowArray: Array<string> = ['todo', 'toread'];

    /**
     * 所依赖权限服务
     *
     * @memberof UIService
     */
    public authService: any;

    /**
     * Creates an instance of UIService.
     * 
     * @param {*} [opts={}]
     * @memberof UIService
     */
    constructor(opts: any = {}) {
        this.$store = store;
    }

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

    /**
     * 获取UI实体服务
     *
     * @protected
     * @param {string} name 实体名称
     * @returns {Promise<any>}
     * @memberof UIService
     */
    public getService(name: string): Promise<any> {
        return (window as any)['uiServiceRegister'].getService(name);
    }

    /**
    * 获取资源标识是否有权限(无数据目标)
    * 
    * @param tag 资源标识
    * @memberof  UIService
    */
    public getResourceOPPrivs(tag: any) {
        if (!this.authService) {
            this.authService = new AuthService(this.getStore());
        }
        return this.authService.getResourcePermission(this.authService.sysOPPrivsMap.get(tag)) ? 1 : 0;
    }

    /**
     * 获取工作流视图
     *
     * @memberof UIService
     */
    public getWFView() {
        let result = this.allViewMap.get("WFEDITVIEW:");
        if (!result) {
            const allViews:any = this.allViewMap.values();
            for (let value of allViews) {
                if(value.viewType === 'DEWFDYNAEDITVIEW'){
                    return value;
                }
            }
        }else{
            return result;
        }   
    }


}