<template>
  <view class="document-info-display">
    <view class="content-body">
      <!-- 动态加载单据表单组件，所有子组件均通过 code 接收业务编码，并在内部自行请求 API 获取数据 -->
      <!-- 完全对齐PC端 edit.vue 的单据类型判断逻辑 -->
      
      <!-- 纵向项目申报流程 -->
      <PlanListForm v-if="defCode === 'pre_sci_project_vertical'" :code="taskCode" />
      
      <!-- 学术会议 待确认-->
      <ConferenceForm v-else-if="defCode === 'sci_academic_conferences'" :code="taskCode" />
      
      <!-- 学术讲座 -->
      <LectureForm v-else-if="defCode === 'sci_academic_lectures'" :code="taskCode" />
      
      <!-- 纵向项目 -->
      <VerticalForm v-else-if="defCode === 'sci_project_vertical'" :code="taskCode" />
      
      <!-- 学术委员会职务 -->
      <DutiesForm v-else-if="defCode === 'sci_academic_committee_positions'" :code="taskCode" />
      
      <!-- 科研人员派遣 -->
      <DispatchForm v-else-if="defCode === 'sci_scientific_researchers_dispatch'" :code="taskCode" />
      
      <!-- 自发项目 -->
      <SpontaneityForm v-else-if="defCode === 'sci_project_spontaneity'" :code="taskCode" />
      
      <!-- 横向项目 -->
      <HorizontalForm v-else-if="defCode === 'sci_project_horizontal'" :code="taskCode" />
      
      <!-- 学术成果（根据taskCode判断具体类型） -->
      <AchPaperForm v-else-if="defCode === 'sci_academic_achievement' && taskCode.includes('学术论文')" :code="taskCode" />
      <AchAwardsForm v-else-if="defCode === 'sci_academic_achievement' && taskCode.includes('奖项荣誉')" :code="taskCode" />
      <AchPatentForm v-else-if="defCode === 'sci_academic_achievement' && taskCode.includes('学术专利')" :code="taskCode" />
      <AchPatentForm v-else-if="defCode === 'sci_academic_achievement' && taskCode.includes('专利转化')" :code="taskCode" />
      <AchWorkForm v-else-if="defCode === 'sci_academic_achievement' && taskCode.includes('学术著作')" :code="taskCode" />
      
      <!-- 学术委员会 -->
      <AchCommitteeForm v-else-if="defCode === 'sci_academic_committee'" :code="taskCode" />
      
      <!-- 考核批次 -->
      <AssessmentBatchForm v-else-if="defCode === 'sci_assessment_batch'" :code="taskCode" />
      
      <!-- 学科项目 -->
      <DisciplineForm v-else-if="defCode === 'sci_project_discipline'" :code="taskCode" />
      
      <!-- 经费认领审批 -->
      <ClaimForm v-else-if="defCode === 'sci_fund_allot_apply'" :code="taskCode" />
      
      <!-- 经费支出 -->
      <ReimbursementForm v-else-if="defCode === 'sci_fund_expense'" :code="taskCode" />
      
      <!-- 经费奖励 -->
      <RewardForm v-else-if="defCode === 'sci_fund_reward'" :code="taskCode" />
      
      <!-- 经费结转 -->
      <CarryForwardForm v-else-if="defCode === 'sci_fund_carryover'" :code="taskCode" />
      
      <!-- 项目中检 -->
      <InspectionForm v-else-if="defCode === 'sci_project_inspection'" :code="taskCode" />
      
      <!-- 项目验收审批流 -->
      <ConclusionForm v-else-if="defCode === 'sci_project_conclusion'" :code="taskCode" />
      
      <!-- 论文投稿审批流 -->
      <AchPaperSubmission v-else-if="defCode === 'sci_paper_submission'" :code="taskCode" />
      
      <!-- 学科中期 -->
      <DisciplineMidterm v-else-if="defCode === 'sci_project_discipline_midterm'" :code="taskCode" />
      
      <!-- 学科结题 -->
      <DisciplineFinal v-else-if="defCode === 'sci_project_discipline_final'" :code="taskCode" />
      
      <!-- 项目变更 -->
      <ProjectChange v-else-if="defCode === 'sci_project_change'" :code="taskCode" />
      
      <!-- 集成电路 -->
      <CircuitForm v-else-if="defCode === 'sci_property_circuit'" :code="taskCode" />
      
      <!-- 著作权 -->
      <CopyrightForm v-else-if="defCode === 'sci_property_copyright'" :code="taskCode" />
      
      <!-- 医药凭证 -->
      <CredentialForm v-else-if="defCode === 'sci_property_medicine_credential'" :code="taskCode" />
      
      <!-- 新品种 -->
      <VarietyForm v-else-if="defCode === 'sci_property_new_variety'" :code="taskCode" />
      
      <!-- 标准 -->
      <StandardForm v-else-if="defCode === 'sci_property_standard'" :code="taskCode" />
      
      <!-- 伦理审查 -->
      <ReviewForm v-else-if="defCode === 'sci_ethical_review_form'" :code="taskCode" />
      
      <!-- 自发项目申报 -->
      <SpontaneityFormPlan v-else-if="defCode === 'sci_project_spontaneity_declaration_project'" :code="taskCode" />
      
      <!-- 经费冲正 -->
      <SciFundReverse v-else-if="defCode === 'sci_fund_reverse'" :code="taskCode" />
      
      <!-- 临时借款 -->
      <TemporaryFundForm v-else-if="defCode === 'sci_temporary_fund_borrowing'" :code="taskCode" />
      
      <!-- 成果标准 -->
      <SciAchievementStandard v-else-if="defCode === 'sci_achievement_standard'" :code="taskCode" />

      <!-- 论文认领 -->
      <SciAchievementPaperPushClaim v-else-if="defCode === 'sci_achievement_paper_push_claim'" :code="taskCode" />
      
      <!-- 其他成果 -->
      <SciAchievementOther v-else-if="defCode === 'sci_achievement_other'" :code="taskCode" />
      
      <!-- 预申报 -->
      <DeclarationListForm v-else-if="defCode === 'sci_project_declaration_list'" :code="taskCode" />
      
      <!-- 软件著作权 -->
      <SciAchievementSoftware v-else-if="defCode === 'sci_achievement_software'" :code="taskCode" />

      <!-- 保底展示 -->
      <view v-else class="section-card fallback-card">
        <view class="section-title">单据详情 ({{ defCode }})</view>
        <view class="info-row"><text class="label">业务编码</text><text class="value">{{ taskCode }}</text></view>
        <!-- <view class="tip-box">该单据类型暂未适配详细布局预览。</view> -->
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
// 导入所有业务组件（完全对齐PC端）
import VerticalForm from './document/VerticalForm.vue';
import HorizontalForm from './document/HorizontalForm.vue';
import PlanListForm from './document/PlanListForm.vue';
import ConferenceForm from './document/ConferenceForm.vue';
import LectureForm from './document/LectureForm.vue';
import SpontaneityForm from './document/SpontaneityForm.vue';
import AchPaperForm from './document/AchPaperForm.vue';
import AchAwardsForm from './document/AchAwardsForm.vue';
import AchPatentForm from './document/AchPatentForm.vue';
import AchWorkForm from './document/AchWorkForm.vue';
import AchCommitteeForm from './document/AchCommitteeForm.vue';
import DutiesForm from './document/DutiesForm.vue';
import DispatchForm from './document/DispatchForm.vue';
import ClaimForm from './document/ClaimForm.vue';
import ReimbursementForm from './document/ReimbursementForm.vue';
import RewardForm from './document/RewardForm.vue';
import CarryForwardForm from './document/CarryForwardForm.vue';
import AssessmentBatchForm from './document/AssessmentBatchForm.vue';
import DisciplineForm from './document/DisciplineForm.vue';
import InspectionForm from './document/InspectionForm.vue';
import ConclusionForm from './document/ConclusionForm.vue';
import AchPaperSubmission from './document/AchPaperSubmission.vue';
import DisciplineMidterm from './document/DisciplineMidterm.vue';
import DisciplineFinal from './document/DisciplineFinal.vue';
import ProjectChange from './document/ProjectChange.vue';
import CircuitForm from './document/CircuitForm.vue';
import CopyrightForm from './document/CopyrightForm.vue';
import CredentialForm from './document/CredentialForm.vue';
import VarietyForm from './document/VarietyForm.vue';
import StandardForm from './document/StandardForm.vue';
import ReviewForm from './document/ReviewForm.vue';
import SpontaneityFormPlan from './document/SpontaneityFormPlan.vue';
import SciFundReverse from './document/SciFundReverse.vue';
import TemporaryFundForm from './document/TemporaryFundForm.vue';
import SciAchievementStandard from './document/SciAchievementStandard.vue';
import SciAchievementPaperPushClaim from './document/SciAchievementPaperPushClaim.vue';
import SciAchievementOther from './document/SciAchievementOther.vue';
import SciAchievementSoftware from './document/SciAchievementSoftware.vue';
import DeclarationListForm from './document/DeclarationListForm.vue';

const props = defineProps<{
  defCode: string; // 对应 PC 端的 state.taskDetail.defCode
  taskCode: string; // 对应 PC 端的 taskCode (row.businessCode)
}>();

</script>

<style lang="scss" scoped>
.document-info-display {
  padding: 10rpx 0;
  .empty-tip { padding: 100rpx 0; }
  .fallback-card {
    background: #fff;
    margin: 20rpx;
    padding: 30rpx;
    border-radius: 16rpx;
    .section-title { font-size: 32rpx; font-weight: bold; margin-bottom: 20rpx; color: #333; }
    .info-row {
      display: flex; justify-content: space-between; padding: 16rpx 0;
      border-bottom: 1rpx solid #f5f5f5; font-size: 28rpx;
      .label { color: #888; width: 220rpx; }
      .value { color: #333; flex: 1; text-align: right; }
    }
    .tip-box {
      margin-top: 30rpx; padding: 20rpx; background: #fffbe6;
      border: 1rpx solid #ffe58f; color: #856404; font-size: 24rpx; border-radius: 8rpx;
    }
  }
}
</style>
