import { IPSDEReportPanel } from '@ibizstudio/runtime';
import { AppReportPanelService } from '../ctrl-service/app-reportpanel-service';
import { MDControlBase } from './md-control-base';

export class ReportPanelControlBase extends MDControlBase {
    
    /**
     * 报表面板实例
     * 
     * @type {IPSDEReportPanel}
     * @memberof ReportPanelControlBase
     */
    declare controlInstance: IPSDEReportPanel;
    
    /**
     * 初始化报表面板模型
     *
     * @type {*}
     * @memberof ReportPanelControlBase
     */
    async ctrlModelInit() {
        await super.ctrlModelInit();
        if (!(this.Environment && this.Environment.isPreviewMode)) {
            this.service = new AppReportPanelService(this.controlInstance, this.context);
        }
    }

    /**
     * 报表面板部件初始化
     *
     * @memberof ReportPanelControlBase
     */
    ctrlInit() {
        super.ctrlInit();
    }

    viewStateAction(tag: string, action: string, data: any) {
      if (!Object.is(tag, this.name)) {
        return;
      }
      super.viewStateAction(tag, action, data);
      if (action == 'load') {
        this.load(data);
      }
    }

    load(data?: any) {
        console.log("报表部件加载数据");
    }
}