<!--
  @description: 代理机构-项目管理-定标-中标公示-查看中标公示
  @author: 肖文龙
  @Modifier: hfx联调 2020/2/20-09:54
  @routerPath:/bidding/projectDrive/calibration/successfulPublicity-detail
  @date: 2019-11-16 15:49:35
  flowStatus: true 从工作流进入
-->
<template>
  <div>
    <!--查看pdf来源 00为菜单下进入  01为驱动-->
    <div v-if="resultBulletinDetailType==='00'" class="title p0-16 clearfix">
      <!-- 返回 -->
      <div class="title-back pointer" @click="back">
        <i class="iconfont icon-fanhui mr10" />
        中标结果公示
      </div>
    </div>
    <pdf :pdf-url="pdfUrl" />
    <div v-show="isShow" class="view mb16">
      <div class="page-title">
        中标结果公示附件
      </div>
      <downloadFile :data="upLoadData" @file="fileList" />
    </div>
    <!--01驱动下进入 并且不是工作流进入 显示返回按钮-->
    <div v-if="resultBulletinDetailType==='01' && !flowStatus " class="but_footer">
      <div class="but_footer-h" />
      <div class="but_footer-but">
        <el-button @click="back()">
          返 回
        </el-button>
      </div>
    </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'
/* 混入公共方法*/
import { bidResultBulletinCommon } from '../mixins/bidResultBulletinCommon'

export default {
  name: 'SuccessfulPublicityDetail',
  components: {
    pdf,
    downloadFile
  },
  mixins: [bidResultBulletinCommon],
  data() {
    return {
      resultBulletinDetailType: this.$route.meta.resultBulletinDetailType, // 查看pdf来源 00 为菜单下进入  01为驱动
      readImageUrl: readImageRoot, // 预览图片
      pdfUrl: '',
      isShow: true // 是否展示附件
    }
  },
  created() {
    // 获取结果公示内容pdf
    this.getResultBulletinContentPdf()
  },
  methods: {
    // 获取结果公示内容
    getResultBulletinContentPdf() {
      getFileDetail(this.bulletinContentData).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
      }
    },
    // 返回
    back() {
      // 返回菜单
      if (this.resultBulletinDetailType === '00') {
        this.$router.push({
          path: '/bidding/resultBulletin'
        })
      }
      // 返回驱动
      if (this.resultBulletinDetailType === '01') {
        this.$router.push({
          path: '/bidding/projectDrive/calibration/successfulPublicity-add',
          query: {
            ...this.$route.query
          }
        })
      }
    }
  }
}
</script>

<style lang="less" scoped>

</style>
