<template>
  <div class="safety-platform-container">
    <header class="safety-platform-container__header">
      <BreadcrumbBack />
      <span class="breadcrumb-title">{{ headerTitle }}</span>
    </header>
    <component :is="dynamicComponent" :id="id" />
  </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 id = computed(() => Number(route.query.id));

  const headerTitle = computed(() => {
    switch (operate.value) {
      case 'evaluationSystem-create':
        return '新增安全考核';
      case 'evaluationSystem-edit':
        return '编辑安全考核';
      case 'evaluationSystem-view':
        return '查看安全考核';
      case 'evaluationSystem-target':
        return '考核对象';
      case 'evaluationSystem-advanced-group':
        return '部门考核';
      case 'evaluationSystem-advanced-person':
        return '先进个人';
      case 'evaluationSystem-feedback':
        return '复核';
      case 'evaluationSystem-feedback-view':
        return '部门考核详情';
      case 'evaluationSystem-audit':
        return '审核';
      default:
        return '未知操作';
    }
  });

  const dynamicComponent = computed(() => {
    switch (operate.value) {
      case 'evaluationSystem-create':
      case 'evaluationSystem-edit':
      case 'evaluationSystem-view':
        return defineAsyncComponent(() => import('./components/EvaluationSystemDetail.vue'));
      case 'evaluationSystem-target':
      case 'evaluationSystem-advanced-group':
        return defineAsyncComponent(() => import('./components/EvaluationTarget.vue'));
      case 'evaluationSystem-advanced-person':
        return defineAsyncComponent(() => import('./components/EvaluationSystemAdvancedPerson.vue'));
      case 'evaluationSystem-feedback':
      case 'evaluationSystem-feedback-view':
      case 'evaluationSystem-audit':
        return defineAsyncComponent(() => import('./components/EvaluationSystemFeedback.vue'));
      default:
        return '';
    }
  });
</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>
