ctrl-loading-service.ts 1.2 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
import { LoadingServiceBase } from './loading-service-base';

/**
 * 部件加载服务类
 *
 * @export
 * @class CtrlLoadingService
 * @extends {LoadingServiceBase}
 */
export class CtrlLoadingService extends LoadingServiceBase {

    /**
     * 计算部件元素Id
     *
     * @private
     * @memberof CtrlLoadingService
     */
    private calcCtrlId(model: any) {
        return '#' + (model?.appDataEntity?.codeName || '') + `${+ model?.codeName}control`;
    }

    /**
     * 部件加载
     *
     * @public
     * @memberof CtrlLoadingService
     */
    public beginLoading(controlInstance: any) {
        if (controlInstance) {
            return
        }
        const selection = document.querySelector(this.calcCtrlId(controlInstance));
        if (!selection || this.isLoading) {
            return
        }
        super.beginLoading(selection);
    }

    /**
     * 部件加载结束
     *
     * @public
     * @memberof CtrlLoadingService
     */
    public endLoading(controlInstance: any) {
        if (controlInstance) {
            return
        }
        const selection = document.querySelector(this.calcCtrlId(controlInstance));
        if (!selection) {
            return
        }
        super.endLoading(selection);
    }
}