<template>
  <view class="setup-wrapper">
    <CommonSection title="立项概览" :isFirst="true">
      <CommonInfoRow label="项目名称" :value="projectData?.projectName" />
      <CommonInfoRow label="项目编号" :value="projectData?.projectCode" />
      <CommonInfoRow label="项目分类" :value="projectData?.projectClazzName" />
      <CommonInfoRow label="项目来源" :value="projectData?.projectSource" />
      <CommonInfoRow label="项目日期"
        :value="formatDate(projectData?.startDate) + ' ~ ' + formatDate(projectData?.endDate)" />
      <CommonInfoRow label="所属科室" :value="projectData?.deptName" />
      <CommonInfoRow label="统计年度" :value="projectData?.statisticalYear" />
      <CommonInfoRow label="项目负责人" :value="projectData?.projectLeaderName" />
      <CommonInfoRow label="项目负责人类型" :value="getDictLabel('sci_leader_type', projectData?.projectLeaderType)" />
      <CommonInfoRow label="负责人电话" :value="projectData?.projectLeaderPhone" />
      <CommonInfoRow label="负责人邮箱" :value="projectData?.projectLeaderMail" />

      <CommonInfoRow label="合同经费(元)" :value="amountUnitFormatter(projectData?.contractFunds)" isAmount />
      <CommonInfoRow label="批准经费(元)" :value="amountUnitFormatter(projectData?.approvedFunds)" isAmount />
      <CommonInfoRow label="匹配经费(元)" :value="amountUnitFormatter(projectData?.supportFunds)" isAmount />
      <CommonInfoRow label="自筹经费(元)" :value="amountUnitFormatter(projectData?.selfFunds)" isAmount />
      <CommonInfoRow label="总金额(元)"
        :value="amountUnitFormatter((Number(projectData?.contractFunds || 0) + Number(projectData?.supportFunds || 0) + Number(projectData?.selfFunds || 0)))"
        isAmount />
      <CommonInfoRow label="承担单位排名"
        :value="projectData?.unitRank == '10' ? '第一单位' : (projectData?.unitRank == '20' ? '非第一单位' : '--')" />

      <CommonInfoRow label="研究类别" :value="projectData?.researchCategory" />
      <CommonInfoRow label="预期成果" :value="projectData?.expectedResults" />
      <CommonInfoRow label="备注" :value="projectData?.remark" :noBorder="true" />
    </CommonSection>
  </view>
</template>

<script setup lang="ts">
import { useDict } from '@/hooks/useDict';
import { formatWithComma } from '@/utils/format';
import { formatDate } from '@/utils/date';
import CommonSection from '@/components/ui/CommonSection.vue';
import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';

const { getDictLabel } = useDict('sci_leader_type');

/**
 * 自发类项目 立项信息展示组件
 */
const props = defineProps<{
  /** 项目主数据详情 */
  projectData: any;
}>();

/**
 * 金额格式化处理
 */
const amountUnitFormatter = (num: any) => {
  return formatWithComma(num);
};
</script>

<style lang="scss" scoped>
.setup-wrapper {
  /* 基础容器样式 */
  width: 100%;
  padding-bottom: 20px;
}
</style>
