<!--
  @description: 供应商-采购结果查看
  @author: gmy
  @routerPath:/procurement/procurementDriveSupplier/procurementSupplierResult
  @date: 2020-7-3 13:04:58
-->
<template>
  <div style="padding: 76px">
    <div v-html="htmlContent" />
    <div class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <!-- 导出 -->
          <el-button type="primary" @click="adviceDerive">
            导出
          </el-button>
        </div>
      </div>
    </div>
    <!-- <downloadFile :data="bidAccessory" /> -->
  </div>
</template>

<script>
/* api接口*/
import { queryNoticeOrSupplier, getNoticePdfAttachment } from '@/api/procurement/procurementResult'
import { downLoadFile } from '@/api/common/uploadCenter' // 前端文件下载接口
/*  公共方法 */
import { download } from '@/assets/js/utils'
export default {
  name: 'ProcurementResultPdfDetailVue',
  inject: ['getTenderBase'],
  data() {
    return {
      htmlContent: '', // html文件
      queryNoticeData: {
        packId: '' // 项目标段id
      },
      tenderBase: this.getTenderBase()
    }
  },
  created() {
    if (this.tenderBase.packId) {
      this.queryNoticeData.packId = this.tenderBase.packId
      this.getPdfData(this.queryNoticeData) // 调用获取数据方法
    }
  },
  methods: {
    // 导出
    adviceDerive() {
      // 调用导出采购结果附件接口
      this.getNoticePdfAttachmentData()
    },
    /*
    获取中选通知书附件信息请求
    入参：packId项目标段id supplierId
    */
    getNoticePdfAttachmentData() {
      const data = {
        packId: this.tenderBase.packId,
        supplierId: this.$store.getters.info.currentDepart.id
      }
      getNoticePdfAttachment(data).then(response => {
        const fileData = {
          fileId: response.data.fileId,
          fileType: response.data.fileType
        }
        this.setDownLoadFile(fileData)
      })
    },
    // 文件下载请求
    setDownLoadFile(data) {
      downLoadFile(data).then(res => {
        download(res, '【' + this.tenderBase.tenderName + '】成交通知书文件.pdf')
      })
    },
    // 封装获取项目采购结果html
    getPdfData(packId) {
      queryNoticeOrSupplier(packId).then(res => {
        this.htmlContent = res.data
      }).catch(() => {})
    }

  }
}
</script>

<style lang="less" scoped>

</style>
