import { throttle } from '@ibizstudio/runtime';
import { PickupView3Base } from '../../../view/pickupview3-base';
import { AppLayoutService } from '../../../app-service';
export class AppPickupView3Base extends PickupView3Base {
    /**
     * 渲染选择视图按钮
     *
     * @memberof PickupViewBase
     */
    renderPickButton() {
        var _a, _b, _c, _d;
        if (this.isShowButton) {
            return (<card dis-hover={true} bordered={false} class='footer'>
          <row style={{ textAlign: 'right' }}>
            <i-button type='primary' disabled={this.viewSelections.length > 0 ? false : true} on-click={(...params) => throttle(this.onClickOk, params, this)}>
              {(_b = (_a = this.containerModel) === null || _a === void 0 ? void 0 : _a.view_okbtn) === null || _b === void 0 ? void 0 : _b.text}
            </i-button>
            &nbsp;&nbsp;
            <i-button on-click={(...params) => throttle(this.onClickCancel, params, this)}>{(_d = (_c = this.containerModel) === null || _c === void 0 ? void 0 : _c.view_cancelbtn) === null || _d === void 0 ? void 0 : _d.text}</i-button>
          </row>
        </card>);
        }
    }
    renderPickupViewPanel(panel) {
        let { targetCtrlParam, targetCtrlEvent, targetCtrlName } = this.computeTargetCtrlData(panel);
        return this.$createElement(targetCtrlName, { props: targetCtrlParam, ref: panel.name, on: targetCtrlEvent });
    }
    renderPickupViewPanelTab(panel, tabName) {
        var _a;
        const name = panel.name || panel.codeName;
        return (<tab-pane lazy={true} name={name} tab={tabName} label={this.$tl((_a = panel.getCapPSLanguageRes()) === null || _a === void 0 ? void 0 : _a.lanResTag, panel.caption)}>
        {this.renderPickupViewPanel(panel)}
      </tab-pane>);
    }
    renderMainContent() {
        const tabName = `${this.appDeCodeName}_${this.viewInstance.viewType}_${this.viewInstance.name}`;
        return (<div class='pickupview3-tabs-container' slot='default'>
        <tabs value={this.activedPickupViewPanel} class='pickupview3-tabs' name={tabName} on-on-click={($event) => throttle(this.tabPanelClick, [$event], this)}>
          {this.pickupViewPanelModels.map((panel) => {
                return this.renderPickupViewPanelTab(panel, tabName);
            })}
        </tabs>
      </div>);
    }
    /**
     * 数据视图渲染
     *
     * @memberof AppPickupViewBase
     */
    render(h) {
        if (!this.viewIsLoaded) {
            return null;
        }
        const targetViewLayoutComponent = AppLayoutService.getLayoutComponent(`${this.viewInstance.viewType}-${this.viewInstance.viewStyle}`);
        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.renderMainContent(), this.renderPickButton(), this.renderBottomMessage()]);
    }
}
