<template>
  <div class="safety-platform-container">
    <header class="safety-platform-container__header">
      <BreadcrumbBack />
      <span class="breadcrumb-title">{{ headerTitle }}</span>
    </header>
    <component :is="dynamicComponent" />
  </div>
</template>

<script setup lang="ts">
  import { computed, defineAsyncComponent } from 'vue';
  import { useRoute } from 'vue-router';
  import BreadcrumbBack from '@/components/BreadcrumbBack.vue';

  const route = useRoute();
  const operate = computed(() => route.query.operate as string);

  const headerTitle = computed(() => {
    switch (operate.value) {
      case 'one-by-one-create':
        return '新增举一反三';
      case 'one-by-one-edit':
        return '编辑举一反三';
      case 'one-by-one-view':
        return '查看举一反三';
      case 'one-by-one-notify-target':
        return '通知对象';
      case 'one-by-one-audit-detail':
        return '审核';
      default:
        return '未知操作';
    }
  });

  const dynamicComponent = computed(() => {
    switch (operate.value) {
      case 'one-by-one-notify-target':
        return defineAsyncComponent(() => import('./components/OneByOneNotifyTarget.vue'));
      case 'one-by-one-audit-detail':
        return defineAsyncComponent(() => import('./components/OneByOneAuditDetail.vue'));
      default:
        return defineAsyncComponent(() => import('./components/oneByOneManagementDetail.vue'));
    }
  });
</script>

<style scoped lang="scss">
  @use '@/styles/page-details-layout.scss' as *;
  @use '@/styles/page-main-layout.scss' as *;

  .safety-platform-container__header {
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 8px !important;
  }
</style>

