
<!--
  @description: 评标大厅-评审报表
  @Modifier：wxy/yf
  @routerPath:
  @date： 2020-08-05 21:28:26
-->
<template>
  <div style="margin-top: 16px">
    <table class="tableData">
      <tr class="singleRow">
        <td>评审报告</td>
        <td>
          <upload
            v-if="isEdit"
            ref="upload"
            :title="''"
            :on-change="principalFile"
            :data="procurementFile"
            :file-list="principalList"
            :auto-delete="true"
            :auto-upload="true"
            :success="successList"
            accept=".pdf"
            file-ref="fileRef"
            but-text="点击上传"
          />
          <downloadFile v-if="!isEdit" :data="procurementFile" />
          <pdfDetail v-if="isPreview" :pdf-url="pdfUrl" />
        </td>
      </tr>
    </table>
  </div>
</template>

<script>

// 组件
import upload from '@comp/common/updownload/upload' // 附件上传组件
import downloadFile from '@comp/common/updownload/downloadFile' // 文件回显组件
import pdfDetail from '@comp/common/pdf/pdf' // pdf查看
import { readImageRoot } from '@api/common/uploadCenter' // 图片查看路径
/* 弹框组件 */
// import reuploadReport from './procurementReuploadReport-dialog'
import {
  getEvalReportUUid,
  qryProcurementEvalReportUploadStatus
} from '@/api/procurement/procurementEvaluation'
export default {
  components: { downloadFile, pdfDetail, upload
  // reuploadReport
  },
  inject: ['getTenderBase'],
  data() {
    return {
      dialogData: {
        dialog: false // 弹框是否显示
      },
      getTenderBase: this.getTenderBase(), // 获取项目基本信息
      procurementFile: {
        bizId: '', // 业务主键Id
        fileType: 'reviewReports'// 文件类型
      }, // 附件信息
      pdfUrl: '',
      readImageUrl: readImageRoot, // 公共下载地址
      isPreview: false, // 是否为预览操作
      isEdit: true, // 编辑
      principalList: []
    }
  },
  created() {
  },
  methods: {
    // 获取附件bizid
    initData() {
      getEvalReportUUid(this.getTenderBase.packId).then(res => {
        this.procurementFile.bizId = res.data
      })
    },
    // 预览
    preview() {
      this.isPreview = true
      qryProcurementEvalReportUploadStatus(this.getTenderBase.packId).then(res => {
        // 拼接pdf的url路径
        const url = this.readImageUrl + res.data.pdfUrl
        // 加密处理
        this.pdfUrl = encodeURIComponent(url)
      })
    },
    // 附件上传
    principalFile(file, fileList) {
      this.principalList = fileList
    },
    // 附件上传成功的回调
    successList(file) {
      this.loading = false
    }
  }
}
</script>

<style lang="less" scoped>

</style>
