DashboardViewBase.tsx 1.9 KB
Newer Older
1
import { ViewBase } from './ViewBase';
2
import { events } from '../global';
3 4 5 6 7 8 9 10 11 12

/**
 * 看板视图基类
 *
 * @export
 * @class DashboardViewBase
 * @extends {ViewBase}
 */
export class DashboardViewBase extends ViewBase {

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
    /**
     * 应用实体服务
     *
     * @protected
     * @type {*}
     * @memberof DashboardViewBase
     */
    protected appEntityService: any;

    /**
     * 视图挂载完毕
     *
     * @protected
     * @memberof DashboardViewBase
     */
    protected viewMounted(): void {
        super.viewMounted();
        this.accLocalTags.push(this.$acc.commandLocal(() => {
            this.loadModel();
        }, 'update', this.appDeName.toUpperCase()));
    }

    /**
     * 加载模型
     *
     * @protected
     * @memberof DashboardViewBase
     */
    protected async loadModel(): Promise<any> {
        if (this.appEntityService && this.context[this.appDeName]) {
            this.appEntityService.getDataInfo(this.context, {}, false).then((response: any) => {
                if (!response || response.status !== 200) {
                    return;
                }
                const { data } = response;
                if (data && data[this.appDeMajor]) {
                    data[this.appDeName] = data[this.appDeKey];
                    this.$appService.contextStore.setContextData(this.context, this.appDeName, { data });
                    Object.assign(this.model, { dataInfo: data[this.appDeMajor] });
                    if (this.$route) {
                        this.$route.meta.info = this.model.dataInfo;
                    }
                    Object.assign(this.model, { srfTitle: `${this.$t(this.model.srfCaption)} - ${this.model.dataInfo}` });
                    this.$appService.navHistory.setCaption({ tag: this.viewtag, info: this.model.dataInfo });
                    this.$emit(events.view.MODEL_LOADED, data);
                }
            })
        }
    }
62
}