<!--
@description: 部门经理-中选审核-行项目查看报价单
@Modifier: gmy
@routerPath:/procurement/procurementDrive/offerResultQuotation
@date: 2020-5-28 8:45:15
-->
<template>
  <div>
    <pdf :pdf-url="pdfUrl" />
    <!--   下载报价单/关闭 -- 按钮 -->
    <div class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <downloadFile
            v-if="procurementOfferFileData.bizId"
            :one-download="true"
            :data="procurementOfferFileData"
          />
          <el-button style="margin-left: 10px" @click="closeClick">
            关闭
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* 公共方法*/
import { readImageRoot } from '@api/common/uploadCenter' // 图片查看路径
import { getFileDetail } from '@/api/common/uploadCenter' // 文件下载方法
import { orderManagementMixins } from '../mixins/orderManagementMixins'
/* 公共组件*/
import downloadFile from '@comp/common/updownload/downloadFile' // 文件回显组件
/* 组件*/
import pdf from '@comp/common/pdf/pdf'
export default {
  name: 'OfferQuotationPdfDetailVue',
  components: {
    pdf, // pdf组件
    downloadFile // 文件回显组件
  },
  mixins: [orderManagementMixins],
  data() {
    return {
      readImageUrl: readImageRoot, // 预览图片
      pdfUrl: ''
    }
  },
  created() {
    // 获取报价单文件id
    const offerId = this.$route.params.offerId
    if (offerId) {
      this.procurementOfferFileData.bizId = offerId
      // 调用生成报价单接口
      this.getBulletinContentPdf(this.procurementOfferFileData)
    }
  },

  methods: {
    // 关闭
    closeClick() {
      // 返回前一个路由
      this.$router.push({
        name: 'winningLowestAuditAdd',
        params: {
          ...this.$route.params
        }
      })
    },
    // 封装获取成交公示pdf文件路径方法
    getBulletinContentPdf(data) {
      getFileDetail(data)
        .then(response => {
          // 拼接pdf的url路径
          const url = this.readImageUrl + response.data[0].path
          // 加密处理
          this.pdfUrl = encodeURIComponent(url)
        })
        .catch(() => {})
    }
  }
}
</script>

<style scoped>
</style>
