<script setup lang="ts">
import { Subject } from 'rxjs';
import { ListExpView, IActionParam, IParam, IContext } from '@core';
import { viewState } from './{{spinalCase page.codeName}}-state';
{{#page.ctrls}}
{{#eq controlType "LISTEXPBAR"}}
import { {{codeName}}ListExpBar } from '@widgets/{{spinalCase psAppDataEntity.codeName}}/{{spinalCase codeName}}-list-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 listExpView = new ListExpView(viewState(), props, emit).moduleInstall()
const { state, onCtrlEvent, onToolbarEvent } = listExpView;
</script>

<template>
    <AppListExpViewLayout :class="['app-list-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 "LISTEXPBAR"}}
      <{{codeName}}ListExpBar
        name="{{name}}"
        :context="state.context"
        :showBusyIndicator="true"
        :viewParams="state.viewParams"
        :viewSubject="state.viewSubject"
        :parent="listExpView"
        @ctrlEvent="onCtrlEvent"
      ></{{codeName}}ListExpBar>
      {{/eq}}
      {{/page.ctrls}}
    </AppListExpViewLayout>
</template>