<!--
@description: 采购人-报价大厅-生成报价单组件
@Modifier: gmy
@routerPath:/procurement/procurementDrive/procurementOfferBillPdf
@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" :file-list="fileList" :data="procurementOfferFileData" />
          <el-button style="margin-left: 10px" @click="closeClick">
            关闭
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* 公共方法*/
import { getFileDetail } from '@/api/common/uploadCenter' // 文件下载方法
import { readImageRoot } from '@api/common/uploadCenter' // 图片查看路径
import { procurementOfferGroupMixin } from '../mixins/procurementOffGroupMixin'
/* 公共组件*/
import downloadFile from '@comp/common/updownload/downloadFile'// 文件回显组件
/* 组件*/
import pdf from '@comp/common/pdf/pdf'
export default {
  name: 'OfferQuotationPdfDetailVue',
  components: {
    pdf,
    downloadFile
  },
  mixins: [procurementOfferGroupMixin],
  props: {
    publictyId: {
      type: String,
      default: () => {}
    }
  },
  data() {
    return {
      // 获取公告内容pdf
      pdfUrl: '',
      readImageUrl: readImageRoot,
      fileList: []
    }
  },
  created() {
    // 获取报价单文件id
    const offerId = this.$route.query.offerId
    if (offerId) {
      this.procurementOfferFileData.bizId = offerId
      // 调用生成报价单接口
      this.getBulletinContentPdf(this.procurementOfferFileData)
    }
  },
  methods: {
    // 关闭
    closeClick() {
      // 返回前一个路由
      this.$router.push({ path: '/procurement/procurementDrive/offerPurchase', query: {
        ...this.$route.query
      }})
    },
    // 封装获取成交公示pdf文件路径方法
    getBulletinContentPdf(data) {
      getFileDetail(data).then(response => {
        // 拼接pdf的url路径
        const url = this.readImageUrl + response.data[0].path
        this.fileList = response.data
        // 加密处理
        this.pdfUrl = encodeURIComponent(url)
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped>

</style>
