<!--
  @description: 查看证书弹框
  @Modifier: qk
  @routerPath:supplierDeclaration/supplier/enterpriseQualification
  @date: 2020-2-20 14:35
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="data.dialog"
    :close-on-click-modal="false"
    title="查看证书"
    width="700px"
    custom-class="el-dialog__body-p0"
    top="calc((100vh - 336px) / 2)"
  >
    <div class="main" style="margin-bottom:10px">
      <table class="tableData">
        <tr>
          <td>证书名称</td>
          <td>{{ formDataDialog.certificateName }}</td>
        </tr>
        <tr>
          <td>证书等级</td>
          <td>{{ formDataDialog.awardLevel }}</td>
        </tr>
        <tr>
          <td>证书编号</td>
          <td>{{ formDataDialog.certificateNo }}</td>
        </tr>
        <tr>
          <td>发证单位</td>
          <td>{{ formDataDialog.issuingUnit }}</td>
        </tr>
        <tr>
          <td>发证时间</td>
          <td>{{ formDataDialog.issuingTime }}</td>
        </tr>
        <tr>
          <td>有效期至</td>
          <td>{{ formDataDialog.validityEndTime }}</td>
        </tr>
        <tr>
          <td>证书扫描件</td>
          <td><downloadFile v-if="certificateScanData.bizId" :data="certificateScanData" /></td>
        </tr>
      </table>
    </div>
  </el-dialog>
</template>

<script>
/* 接口*/
import { queryCertificateInfo } from '@/api/supplier/supplierCertificate'
/* 混合开发*/
import { declareHegSupperMixins } from '@/views/supplier/editorDeclaration/mixins/declareHegSupperMixins'// 供应商-公用方法参数
/* 组件*/
import downloadFile from '@comp/common/updownload/downloadFile'
import { mapGetters } from 'vuex'
export default {
  name: 'EnterpriseQualificationDialog',
  components: {
    downloadFile
  },
  mixins: [declareHegSupperMixins],
  props: {
    // 弹框展示状态
    data: {
      type: Object,
      default: function() {
        return {
          dialog: false, // 展示状态
          id: '', // 编辑时才会有证书id
          oldId: '' // 修改时用的Id
        }
      }
    }
  },
  data() {
    return {
      formDataDialog: {}
    }
  },
  computed: {
    ...mapGetters(['language'])
  },
  created() {
    this.seeData()
  },
  methods: {
    // 查询证书
    seeData() {
      const data = {
        id: this.data.id,
        oldId: this.data.oldId
      }
      queryCertificateInfo(data).then(res => {
        this.formDataDialog = res.data
        if (this.formDataDialog.longTerm === '01') { // 判断是否为长期
          this.formDataDialog.validityEndTime = '长期'
        } else {
          if (this.formDataDialog.validityEndTime) this.formDataDialog.validityEndTime = this.$Moment(this.formDataDialog.validityEndTime).format(this.momentDate)// 有效期至
        }
        if (this.formDataDialog.issuingTime) this.formDataDialog.issuingTime = this.$Moment(this.formDataDialog.issuingTime).format(this.momentDate)// 发证时间
        this.certificateScanData.bizId = this.formDataDialog.id// 证书扫描附件
      })
    }
  }
}
</script>

<style scoped lang="less">
</style>
