<template>
  <view class="setup-wrapper">
    <CommonSection title="立项概览" isFirst>
      <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?.planStartDate) + ' ~ ' + formatDate(projectData?.planEndDate)" />
      <CommonInfoRow label="研究类型" :value="getDictLabel('sci_pjt_type', projectData?.studyType)" />
      <CommonInfoRow label="统计年度" :value="formatDate(projectData?.statisticalYear, 'YYYY')" />
      <CommonInfoRow label="项目负责人/合作完成人" :value="projectData?.projectLeaderName" />
      <CommonInfoRow label="所属科室" :value="projectData?.deptName" />
      <CommonInfoRow label="负责人电话" :value="projectData?.projectLeaderPhone" />
      <CommonInfoRow label="负责人邮箱" :value="projectData?.projectLeaderMail" />
      <CommonInfoRow label="是否中医药"
        :value="projectData?.isMedicine == '10' ? '是' : (projectData?.isMedicine == '20' ? '否' : '--')" />
      <CommonInfoRow label="包干制项目"
        :value="projectData?.isLumpSum == '10' ? '是' : (projectData?.isLumpSum == '20' ? '否' : '--')" />
      <CommonInfoRow label="获批时间" :value="projectData?.approvalDate ? formatDate(projectData.approvalDate) : '--'" />
      <CommonInfoRow label="获批编号" :value="projectData?.projectNo" />
      <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(projectData?.totalAmount)" isAmount />
      <CommonInfoRow label="单位排名"
        :value="projectData?.unitRank == '10' ? '第一单位' : (projectData?.unitRank == '20' ? '非第一单位' : '--')" noBorder />
    </CommonSection>
  </view>
</template>

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

const props = defineProps<{
  projectData: any;
}>();

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

const amountUnitFormatter = (num: any) => {
  return formatWithComma(num);
};
</script>

<style lang="scss" scoped>
.setup-wrapper {
  width: 100%;
  padding-bottom: 20px;
}
</style>
