mob-calendar-view-engine.ts 2.3 KB
Newer Older
zcdtk's avatar
zcdtk committed
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
import ViewEngine from './view-engine';

/**
 * 实体移动端日历视图界面引擎
 *
 * @export
 * @class MobCalendarViewEngine
 * @extends {ViewEngine}
 */
export default class MobCalendarViewEngine extends ViewEngine {

    /**
     * 日历部件
     *
     * @protected
     * @type {*}
     * @memberof MobCalendarViewEngine
     */
    protected calendar: any;

    /**
     * 初始化日历视图引擎
     *
     * @param {*} [options={}]
     * @memberof MobCalendarViewEngine
     */
    public init(options: any = {}): void {
        this.calendar = options.calendar;
        super.init(options);
    }

    /**
     * 引擎加载
     *
     * @param {*} [opts={}]
     * @memberof MobCalendarViewEngine
     */
    public load(opts: any = {}): void {
        super.load(opts);
        if (this.getCalendar() ) {
            const tag = this.getCalendar().name;
            const data: any = {};
            let action: string = 'load';
            Object.assign(data, this.view.viewParam);
            this.setViewState2({ tag: tag, action: action, viewdata: data });
        }
    }

    /**
     * 部件事件机制
     *
     * @param {string} ctrlName
     * @param {string} eventName
     * @param {*} args
     * @memberof MobCalendarViewEngine
     */
    public onCtrlEvent(ctrlName: string, eventName: string, args: any): void {
        super.onCtrlEvent(ctrlName, eventName, args);
        if (Object.is(ctrlName, 'calendar')) {
            this.calendarEvent(eventName, args);
        }
    }

    /**
     * 日历事件
     *
     * @param {string} eventName
     * @param {*} args
     * @memberof MobCalendarViewEngine
     */
    public calendarEvent(eventName: string, args: any): void {
        if (Object.is(eventName, 'load')) {
            this.onCalendarLoad(args);
        }
    }

    /**
     * 日历数据加载完成
     *
     * @param {*} args
     * @memberof MobCalendarViewEngine
     */
    public onCalendarLoad(arg: any): void {
        this.view.$emit('load',arg);
        this.view.$emit('viewdataschange',JSON.stringify({action:'load',status:'success',data:arg}));
     }

    /**
     * 获取日历对象
     *
     * @returns {*}
     * @memberof MobCalendarViewEngine
     */
    public getCalendar(): any {
        return this.calendar;
    }

}