wizard-view-engine.ts 2.0 KB
Newer Older
ibizdev's avatar
ibizdev 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
import ViewEngine from './view-engine';

/**
 * 视图引擎基础
 *
 * @export
 * @class GridViewEngine
 */
export default class WizardViewEngine extends ViewEngine {

    /**
     * 向导面板部件
     *
     * @protected
     * @type {*}
     * @memberof EditViewEngine
     */
    protected wizardpanel: any;

    /**
     * 初始化编辑视图引擎
     *
     * @param {*} [options={}]
     * @memberof EditViewEngine
     */
    public init(options: any = {}): void {
        this.wizardpanel = options.wizardpanel;
        super.init(options);
    }

    /**
     * 引擎加载
     *
     * @param {*} [opts={}]
     * @memberof EditViewEngine
     */
    public load(opts: any = {}): void {
        super.load(opts);
        if (this.getWizardPanel()) {
            const tag = this.getWizardPanel().name;
            this.setViewState2({ tag: tag, action: 'load', viewdata: this.view.context });
        }
    }

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

    /**
     * 事件处理
     *
     * @param {string} eventName
     * @param {any[]} args
     * @memberof MDViewEngine
     */
    public wizardPanelEvent(eventName: string, args: any): void {
        if (Object.is(eventName, 'finish')) {
            this.onfinish(args);
        }
    }

    /**
     * 完成
     *
     * @param {*} args
     * @memberof WizardViewEngine
     */
    public onfinish(args: any): void {
        this.view.$emit('viewdataschange', [args]);
        this.view.$emit('close', null);
    }

    /**
     * 获取向导面板
     *
     * @returns {*}
     * @memberof WizardViewEngine
     */
    public getWizardPanel(): any {
        return this.wizardpanel;
    }
}