<script setup lang="ts">
import { Subject } from 'rxjs';
import { GridExpView, IActionParam, IParam, IContext } from '@core';
import { viewState } from './{{spinalCase page.codeName}}-state';
{{#page.ctrls}}
{{#eq controlType "GRIDEXPBAR"}}
import { {{codeName}}GridExpBar } from '@widgets/{{spinalCase psAppDataEntity.codeName}}/{{spinalCase codeName}}-grid-exp-bar';
{{/eq}}
{{/page.ctrls}}
interface Props {
  context?: IContext;
  viewParams?: IParam;
  openType?: "ROUTE" | "MODAL" | "EMBED";
  viewSubject?: Subject<IActionParam>;
}

const props = withDefaults(defineProps<Props>(), {
  openType:'ROUTE',
  viewSubject: () => new Subject<IActionParam>()
})

interface ViewEmit {
  (name: "viewEvent", value: IActionParam): void;
}

const emit = defineEmits<ViewEmit>();
//  安装功能模块
const gridExpView = new GridExpView(viewState(), props, emit).moduleInstall()
const { state, onCtrlEvent, onToolbarEvent } = gridExpView;
</script>

<template>
    <AppGridExpViewLayout :class="['app-grid-exp-view', state.viewSysCss]">
      <template v-slot:caption>
        <AppIconText class="app-view__caption" size="large" :text="state.viewCaption" />
      </template>
      {{#page.ctrls}}
      {{#eq controlType "TOOLBAR"}}
      <template v-slot:toolbar>
        <AppToolbar
          mode="button"
          name="{{lowerCase codeName}}"
          :actionModel="state.toolbar"
          @onToolbarEvent="onToolbarEvent"/>
      </template>
      {{/eq}}
      {{#eq controlType "GRIDEXPBAR"}}
      <{{codeName}}GridExpBar
        name="{{name}}"
        :context="state.context"
        :showBusyIndicator="true"
        :viewParams="state.viewParams"
        :viewSubject="state.viewSubject"
        :parent="gridExpView"
        @ctrlEvent="onCtrlEvent"
      ></{{codeName}}GridExpBar>
      {{/eq}}
      {{/page.ctrls}}
    </AppGridExpViewLayout>
</template>