<template>
  <div class="safety-platform-container">
    <header class="safety-platform-container__header">
      <BreadcrumbBack />
      <span class="breadcrumb-title">{{ headerTitle }}</span>
    </header>
    <AreaCheckPlanManagementDeptDetail v-if="operateType === 'view'" />
    <AreaCheckPlanRecordDetailDept v-else />
  </div>
</template>

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

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

  const operateType = computed(() => {
    if (operate.value === 'area-check-plan-record-view') return 'record-view';
    if (operate.value === 'area-check-plan-record-add') return 'record-add';
    if (operate.value === 'area-check-plan-dept-view') return 'view';
    return 'view';
  });

  const headerTitle = computed(() => {
    switch (operateType.value) {
      case 'record-view':
        return '检查记录查看';
      case 'record-add':
        return '新增检查日志';
      case 'view':
        return '查看区域检查计划';
      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>

