<!--
  @description: 终止招标内容
  @Modifier: haoFx
  @routerPath:
  @date: 2020/1/7-16:18
-->
<template>
  <div>
    <pdf :pdf-url="pdfUrl" />
    <div v-show="isShow" class="view mb16">
      <div class="page-title">
        终止公告附件
      </div>
      <downloadFile ref="downloadFile" :data="upLoadData" @file="fileList" />
    </div>
  </div>
</template>

<script>
/* api*/
import { readImageRoot } from '@api/common/uploadCenter'
import { getFileDetail } from '@/api/common/uploadCenter'
/* 组件*/
import downloadFile from '@comp/common/updownload/downloadFile' // 获取附件信息 下载组件
import pdf from '@comp/common/pdf/pdf'
export default {
  name: 'MakeTenderingBulletinPdfDetail',
  components: {
    downloadFile, // 文件下载
    pdf
  },
  data() {
    return {
      readImageUrl: readImageRoot, // 预览图片
      pdfUrl: '', // pdf显示url
      isShow: true, // 是否展示附件
      upLoadData: {
        bizId: '',
        fileType: 'stopbidding_bulletin_file_base'// 终止招标附件类型
      },
      upLoadPdfData: {
        bizId: '',
        fileType: 'stopbidding_bulletin_template_pdf_base'// 终止招标pdf类型
      }
    }
  },
  created() {
    const stopbiddingBulletinId = sessionStorage.getItem('bizId')
    // 终止招标id
    this.upLoadData.bizId = stopbiddingBulletinId
    this.upLoadPdfData.bizId = stopbiddingBulletinId
  },
  mounted() {
    // 获取公告内容pdf
    this.getBulletinContentPdf()
  },
  methods: {
    // 获取公告内容
    getBulletinContentPdf() {
      getFileDetail(this.upLoadPdfData).then(response => {
        const url = this.readImageUrl + response.data[0].path
        this.pdfUrl = encodeURIComponent(url)
      }).catch(() => {
      })
    },
    fileList(file) {
      if (file && file.length <= 0) {
        this.isShow = false
      }
    }
  }
}
</script>

<style scoped lang="less">

</style>
