<!--
  @description: 证书详情
  @Modifier: ht
  @date: 2020-7-17-10:57
-->
<template>
    <div>
        <div class="title p0-16 clearfix">
            <div class="title-back pointer" @click="back">
                <i class="iconfont icon-fanhui mr10" />证书详情
            </div>
        </div>
        <div :class="invitationDetailType = 'view'">
            <!--项目信息-->
            <dl class="projectInfoDetail">
                <dt>
                    <p class="projectInfoDetail_icon">
                        <i class="iconfont icon-xiangmujibenxinxi" />
                    </p>
                    证书详情
                </dt>
                <dd>
                    <table class="tableData" v-if="formData.articleType ==='EQ_Qualification_ZLTX' || formData.articleType ==='EQ_Qualification_HBTX' || formData.articleType ==='EQ_Qualification_ZYJK' || formData.articleType ==='EQ_Qualification_ZXDJ' || formData.articleType ==='EQ_Qualification_SCXK'|| formData.articleType ==='EQ_Qualification'">
                        <tr>
                            <td>证书名称</td>
                            <td>{{ formData.certificateName }}</td>
                            <td>证书编号</td>
                            <td>{{ formData.certificateNumber }}</td>
                        </tr>
                        <tr>
                            <td>企业名称</td>
                            <td>{{ formData.companyName }}</td>
                            <td>发证单位</td>
                            <td>{{ formData.issueAuthority }}</td>
                        </tr>
                        <tr>
                            <td>发证日期</td>
                            <td>{{ formData.issueDate }}</td>
                            <td v-if="formData.articleType !='EQ_Qualification'">有效期</td>
                            <td v-if="formData.articleType !='EQ_Qualification'">{{ formData.periodValidity }}</td>
                            <td v-if="formData.articleType ==='EQ_Qualification'">证书等级</td>
                            <td v-if="formData.articleType ==='EQ_Qualification'">{{ formData.awardLevel }}</td>
                        </tr>
                        <tr v-if="formData.articleType ==='EQ_Qualification_ZXDJ'">
                            <td>证书等级</td>
                            <td>{{ formData.awardLevel }}</td>
                            <td v-if="formData.articleType !='EQ_Qualification_ZXDJ'">获奖工程名称</td>
                            <td v-if="formData.articleType !='EQ_Qualification_ZXDJ'">{{ formData.projectName }}</td>
                        </tr>
<!--                        <tr>-->
<!--                            <td>是否是长期有效的</td>-->
<!--                            <td>{{ formData.isPerpetual }}</td>-->
<!--                        </tr>-->
                    </table>
                    <table class="tableData" v-if="formData.articleType ==='EQ_Qualification_SJ_GCJX'||formData.articleType ==='EQ_Qualification_GJ_GCJX'||formData.articleType ==='EQ_Qualification_GJ_JX'||formData.articleType ==='EQ_Qualification_SJ_JX'">
                        <tr>
                            <td>企业名称</td>
                            <td>{{ formData.companyName }}</td>
                            <td>获奖名称</td>
                            <td>{{ formData.certificateName }}</td>
                        </tr>
                        <tr>
                            <td>发奖单位</td>
                            <td>{{ formData.issueAuthority }}</td>
                            <td>获奖年份</td>
                            <td>{{ formData.issueDate }}</td>
                        </tr>
                        <tr v-if="formData.articleType !='EQ_Qualification_GJ_JX' && formData.articleType !='EQ_Qualification_SJ_JX'">
                            <td>获奖工程名称</td>
                            <td>{{ formData.projectName }}</td>
                        </tr>
                    </table>
                </dd>
            </dl>
            <!--附件信息-->
            <dl class="projectInfoDetail">
                <dt>
                    <p class="projectInfoDetail_icon">
                        <i class="iconfont icon-xiangmujibenxinxi" />
                    </p>
                    附件信息
                </dt>
                <dd>
                    <table class="tableData">
                    <tr class="singleRow">
                        <td>附件下载</td>
                        <td colspan="3">
                            <div v-for="(item,index) in scanCertificate" :key="index" class="file">
                                <a ref="downLoads" class="inline-file">
                                      <span @click="downLoadClick(item)">
                                        <i class="iconfont icon-icon_file" />
                                        {{ item.fileName }}
                                      </span>
                                </a>
                            </div>
                        </td>
                    </tr>
                </table>
                </dd>
            </dl>
        </div>
        <!--当前页面从哪进来的  01 驱动内列表页 并且不是工作流-->
        <div class="but_footer">
            <div class="but_footer-h" />
            <div class="but_footer-but">
                <el-button @click="back()">
                    返 回
                </el-button>
            </div>
        </div>
    </div>
</template>
<script>
/* 接口*/
import { findCertificateInfo, downAttachmentLoadFile } from '@api/bidding/bidderRepresentative'
import { download } from '@/assets/js/utils/index'
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法

export default {
  name: 'CertificateInfo',
  data() {
    return {
      loading: true,
      searchForm: {
        id: this.$route.query.id
      },
      formData: {
        relChapterType: '', // 章节类型
        certificateName: '', // 证书名称
        awardProjectName: '', // 获奖项目
        companyName: '', // 企业名称
        awardLevel: '', // 获奖等级
        certificateNumber: '', // 证书编号
        issueAuthority: '', // 发证单位
        issueDate: '', // 发证日期
        periodValidity: '', // 有效期
        isPerpetual: '', // 是否是长期有效的
        projectName: '' // 获奖工程名称
      },
      scanCertificate: []
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    loadData() {
      const params = this.getQueryParams() // 查询条件
      findCertificateInfo(params).then(response => {
        this.loading = false
        this.formData = response.data
        this.scanCertificate = response.data.scanCertificate
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      return filterObj(param)
    },
    // 返回
    back() {
      this.$router.push('/bidderRepresentative/certificateList')
    },
    downLoadClick(item) {
      const params = {
        fileName: item.fileName,
        fileId: item.fileId
      }
      downAttachmentLoadFile(params).then(res => {
        download(res, item.fileName)
      }).catch(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>
