
<template>
  <div class="app-content layoutEmbedded" style="height: 76vh;overflow: auto;">
    <a-spin :spinning="loading" style="width: 100%;height: 100%;">
      <!-- 申报项目详情 -->
      <!-- <a-button type="primary" @click="onExport">导出</a-button> -->
      <project-info v-model="projectInfo" v-if="projType" />
      <project-info-Key v-model="projectInfo" v-else />
    </a-spin>
  </div>
</template>
<script>
const projectKPI = { 
  reportYear: "",
  projName: "",
  appUnitName: "",
  projAttribute: "",
  projDeadline: "",
  totalBudget: 0.00,
  applyFunds: 0.00,
  selfFunds: 0.00,
  yearTotal: 0.00,
  yearApply: 0.00,
  yearSelf: 0.00,
  totalRowSpan: 0, //总合并行数
  outTarget: 0, //一级指标(产出指标)
  benefitTarget: 0, //一级指标(效益指标)
  satisfactionDegree: 0, //一级指标(满意度指标)
  quantityTarget: 0, //二级指标(数量指标)
  qualityTarget: 0, //二级指标(质量指标)
  validityTarget: 0, //二级指标(时效指标)
  costTarget: 0, //二级指标(成本指标)
  economicTarget: 0, //二级指标(经济效益指标)
  socialTarget: 0, //二级指标(社会效益指标)
  ecologicalTarget: 0, //二级指标(生态效益指标)
  sustainableTarget: 0, //二级指标(可持续影响指标)
  serviceTarget: 0, //二级指标(服务对象满意度指标)
  threeLevel: [],
};

import { budgetList } from '@/views/report/project/config'
import { getType } from '@/views/utils/auth'
import projectInfo from '@/views/report/project/components/projectInfo'
import projectInfoKey from "@/views/report/project/components/keyProject/projectInfo"
export default {
  name: "projectView",
  components: {
    projectInfo, projectInfoKey
  },
  data () {
    return {
      projectInfo: {
        id: null,
        organizationCode: null,
        address: null,
        registeredAddress: null,
        postCode: null,
        legalPerson: null,
        workforce: null,
        specializedPersonnel: null,
        researchPersonnel: null,
        depositBank: null,
        bankAccount: null,
        depositBankAddress: null,
        interbankNumber: null,
        researchTotal: null,
        isResearchActive: null,
        researchCount: null,
        researchPersonCount: null,
        projName: null,
        leadUnit: null,
        recommendUnit: null,
        startDate: null,
        endDate: null,
        technologyInnovationBase: null,
        knowledgeId: null,
        totalFunding: null,
        govFunding: null,
        linkName: null,
        linkMobile: null,
        linkEmail: null,
        projAbstract: null,
        projKeywords: null,
        researchContent: null,
        memResume: null,
        researchProgress: null,
        researchContent: null,
        technologyTarget: null,
        economyTarget: null,
        achievementTarget: null,
        otherTarget: null,
        projectKPI: projectKPI,
        cooperativeUnits: [],
        members: [],
        budget: [],
        equipments: [],
        projectSubList: [],
        managementRuleList: [],
        fileList: [],
        projType: getType()
      },
      loading: false,
      projType: getType() == "1"
    };
  },
  props: {
    value: {
      type: String,
      default: () => {
        return null
      }
    }
  },
  created () {
    this.getProjectInfoById()
  },
  methods: {
    getProjectInfoById () {
      if (this.value != null) {
        this.loading = true
        this.$api.project.getProjectInfoById({ id: this.value }).then(({ data = {} }) => {
          if (data) {
            this.projectInfo = data
            this.loading = false
          } else
            this.$emit('close', 'error')
        }).catch(() => { this.$emit('close', 'error') })
      }
    },
    onExport () {
      this.$api.project.export({ id: this.value }).then((res) => {
        let blob = new Blob([res], {
          type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8",
        });
        const fileName = this.projectInfo.projName + '.doc';
        let downloadElement = document.createElement('a')
        let href = window.URL.createObjectURL(blob); //创建下载的链接
        downloadElement.href = href;
        downloadElement.download = fileName; //下载后文件名
        document.body.appendChild(downloadElement);
        downloadElement.click(); //点击下载
        document.body.removeChild(downloadElement); //下载完成移除元素
        window.URL.revokeObjectURL(href); //释放blob
      })
    }
  },
}
</script>


