
<!--
  @description: 采购人-成交结果公告查看详情
  @author: wxy/gmy
  @routerPath:/procurement/procurementDrive/procurementPublicty
  @date: 2020-9-10 9:37:58
-->
<template>
  <div>
    <div>
      <!-- 成交结果公示详情查看 html -->
      <pdf v-if="isPdf" :pdf-url="pdfUrl" />
      <div v-else class="html" v-html="htmlContent" />
      <!--   下载报价单/关闭 -- 按钮 -->
      <div class="but_footer">
        <div class="but_footer-h">
          <div class="but_footer-but">
            <gx-button :code="'001_008_002'" @click="closeClick">
              关闭
            </gx-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* api接口*/
import { getTemplateById } from '@/api/procurement/procurementResult' // 预览发送结果通知书接口
import { getFileDetail } from '@/api/common/uploadCenter' // 文件下载方法
import { readImageRoot } from '@api/common/uploadCenter' // 图片查看路径
/* 组件*/
import pdf from '@comp/common/pdf/pdf'
export default {
  name: 'ProcurementProjectAdd',
  components: {
    pdf
  },
  data() {
    return {
      htmlContent: '',
      pdfUrl: '',
      isPdf: true,
      readImageUrl: readImageRoot
    }
  },
  watch: {
  },
  created() {
    const id = this.$route.query.id // 获取公告id
    this.getTemplateByIdInfo(id) // 查看成交结果公示详情
  },
  methods: {
    // 关闭
    closeClick() {
      this.$router.push({ path: '/procurement/procurementDrive/procurementPublicty' })
    },
    // 获取成交通知书信息
    getTemplateByIdInfo(id) {
      const params = {
        bizId: id,
        fileType: 'prot_procurement_result_bulletin_pdf'
      }
      getFileDetail(params).then((response) => {
        this.isPdf = response.data.length > 0
        const url = this.readImageUrl + response.data[0].path
        // 加密处理
        this.pdfUrl = encodeURIComponent(url)
      })
      getTemplateById(id).then(res => {
        this.htmlContent = res.data
      })
    }
  }
}
</script>

<style lang="less" scoped>
.html{
.liststyle{
  h2{
    line-height: 100px !important;
  }
}
}

</style>
