import { __decorate } from "tslib";
import { Component } from 'vue-property-decorator';
import { AppLayoutService } from '../../../app-service';
import { AppPickupGridViewBase } from '../../../components';
import { VueLifeCycleProcessing } from '../../../decorators';
import './design-style-preview.less';
/**
 * 应用选择表格视图
 *
 * @export
 * @class DesignStylePreview
 * @extends {AppTreeExpViewBase}
 */
let DesignStylePreview = class DesignStylePreview extends AppPickupGridViewBase {
    constructor() {
        super(...arguments);
        this.selection = null;
    }
    onCtrlEvent(controlname, action, data) {
        if (Object.is(controlname, 'grid') && Object.is(action, 'selectionchange') && data.length > 0) {
            this.selection = data[0];
        }
        super.onCtrlEvent(controlname, action, data);
    }
    renderDefaultView(h) {
        var _a, _b, _c;
        const targetViewLayoutComponent = AppLayoutService.getLayoutComponent(`${(_a = this.viewInstance) === null || _a === void 0 ? void 0 : _a.viewType}-DEFAULT`);
        return h(targetViewLayoutComponent, {
            props: { viewInstance: this.viewInstance, model: this.model, modelService: this.modelService, viewparams: this.viewparams, context: this.context }
        }, [
            this.renderTopMessage(),
            this.renderBodyMessage(),
            this.renderToolBar(),
            this.renderQuickGroup(),
            this.renderQuickSearch(),
            !(((_b = this.viewInstance) === null || _b === void 0 ? void 0 : _b.viewStyle) == 'DEFAULT' && ((_c = this.viewInstance) === null || _c === void 0 ? void 0 : _c.enableQuickSearch)) ? this.renderSearchForm() : null,
            this.renderMainContent(),
            this.renderBottomMessage(),
        ]);
    }
    /**
     * 表格选择视图渲染
     *
     * @memberof AppPickupGridViewBase
     */
    render(h) {
        if (!this.viewIsLoaded) {
            return null;
        }
        return <div class='design-style-preview'>
      {this.renderDefaultView(h)}
      <style-preview-content data={this.selection} context={this.context} class="preview-wrapper"/>
    </div>;
    }
};
DesignStylePreview = __decorate([
    Component({}),
    VueLifeCycleProcessing()
], DesignStylePreview);
export { DesignStylePreview };
