
<!--
  @description: 评标大厅-评审报表
  @Modifier：wxy/yf
  @routerPath: /procurement/evaluationLobbyDrive/reportReview
  @date： 2020-08-05 21:28:26
-->
<template>
  <div class="clearfix file_list_opt">
    <div class="fl leftList p0-16 list_report">
      <ul>
        <li v-for="(item,index) in reportList" :key="index" class="report" @click="switchFiles(item)">
          <span class="iconfont icon-pingshenbaobiao icon" />
          <p style="word-break: break-all;margin-top: -8px">
            {{ item.pdfName }}
          </p>
          <!-- <p v-if="item.isFinishSignature === '00'&&item.exchangeStatus!=='00'" :class="item.isFinishSignature=== '00'?'redItem':''">
            未查看
          </p>
          <p v-if="item.isFinishSignature === '00'&&item.exchangeStatus==='00'" :class="item.isFinishSignature=== '00'?'redItems':''">
            {{ item.exchangeTip }}
          </p>
          <p v-if="item.isFinishSignature === '01'" :class="item.isFinishSignature=== '01'?'blueItem':''">
            已查看
          </p> -->
        </li>
      </ul>
    </div>
    <div class="fr rightContent">
      <!--未签章-->
      <el-link v-if="!isShowPdf&&!isPdfSignature" :underline="false" type="primary" class="tip">
        请在左侧选择可以预览的文件
      </el-link>
      <pdf v-if="isShowPdf&&!isPdfSignature" :pdf-url="pdfUrl" />
      <pdfSignature v-if="isPdfSignature" :pdf-url="pdfUrl" :report-detail-id="reportDetailId" :get-tender-base="getTenderBase" @reloadDriver="reloadDriver" />
    </div>
    <!-- 电子签章-暂时隐藏 -->
    <!-- <div class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button :disabled="(pdfUrl!==''&&!isAlreadySigned)?false:true" :loading="loading" type="primary" size="medium" @click="electronicSignature">
            电子签章
          </el-button>
        </div>
      </div>
    </div> -->
  </div>
</template>

<script>
/*   api接口 */
import {
  qryExchangeEvalReportSignatureListInfo // 获取签章文件数据
} from '@/api/procurement/procurementEvaluation' // qryEvalExpertSignatureReportStatus // 判断签章状态
import { readImageRoot } from '@api/common/uploadCenter' // 图片查看路径
/* 公共组件 */
import pdf from '@comp/common/pdf/pdf' // pdf查看
import pdfSignature from '@comp/procurement/pdf/pdf' // pdf签章
export default {
  components: {
    pdf,
    pdfSignature
  },
  inject: ['getTenderBase', 'driveReload', 'getDriveTask'],
  data() {
    return {
      loading: false,
      // 上传评审报告
      reviewReportFilsData: {
        bizId: '', // 业务主键Id
        fileType: 'reviewReports'// 文件类型
      },
      reportList: [], // 报表数据
      pdfUrl: '', // pdf地址
      readImageUrl: readImageRoot, // 公共下载地址
      isShowPdf: false, // 是否展示pdf
      isAlreadySigned: false, // 是否已完成签章
      isPdfSignature: false, // 是否显示pdf签章
      currentReport: {}, // 当前选中报表
      getTenderBase: this.getTenderBase(),
      reportDetailId: '', // 报表详情表主键ID
      timer: null // 定时查询报表定时器
    }
  },
  beforeDestroy() {
    clearInterval(this.timer)
  },
  created() {
    this.initData()
    setTimeout(() => {
      this.timedQueryList()
    })
  },
  methods: {
    // 查询报表列表
    initData() {
      const data = {
        evalExpertId: this.getTenderBase.evalExpertId,
        driverId: this.getTenderBase.driverId,
        packId: this.getTenderBase.packId,
        evalRule: this.getTenderBase.evalRule
      }
      qryExchangeEvalReportSignatureListInfo(data).then(res => {
        this.reportList = res.data
      })
    },
    // 切换报表文件
    switchFiles(data) {
      // 拼接pdf的url路径
      const url = this.readImageUrl + data.pdfUrl
      // 加密处理
      this.pdfUrl = encodeURIComponent(url)
      // 报表详情表主键ID
      this.reportDetailId = data.reportDetailId
      this.isShowPdf = true
      // const params = {
      //   reportDetailId: data.reportDetailId
      // }
      // qryEvalExpertSignatureReportStatus(params).then(res => { // 供应商点击签章提示信息
      //   if (res.data.status !== 'false') {
      //     // 保存当前选中的报表信息
      //     this.currentReport = data
      //     // 判断当前文件是否签章
      //     if (data.isFinishSignature === '01') {
      //       this.isAlreadySigned = true
      //     } else {
      //       this.isAlreadySigned = false
      //     }
      //     // 拼接pdf的url路径
      //     const url = this.readImageUrl + data.pdfUrl
      //     // 加密处理
      //     this.pdfUrl = encodeURIComponent(url)
      //     // 报表详情表主键ID
      //     this.reportDetailId = data.reportDetailId
      //     this.isShowPdf = true
      //   } else {
      //     this.$message.warning(res.data.msg)
      //   }
      // })
    },
    // 签章按钮是否禁用
    signature() {
      // 判断是否有pdf路径和是否已完成签章
      if (!this.pdfUrl || !this.isAlreadySigned) {
        return true
      }
    },
    // 电子签章
    electronicSignature() {
      // 显示pdf签章
      this.isPdfSignature = true
    },
    // 刷新驱动
    reloadDriver() {
      this.driveReload()
      this.getDriveTask()
    },
    // 定时查询列表
    timedQueryList() {
      this.timer = setInterval(() => {
        this.initData()
      }, 10000)
    }
  }
}
</script>

<style lang="less" scoped>
    @import '~@assets/style/common/public.less';
    .icon{
        font-size: 25px;
    }
    /deep/.report{
      margin-bottom: 12px;
      cursor: pointer;
    }
    /deep/ul li {
        text-align: center;
        margin-bottom: 5px;
        a {
          word-break: normal;
        }
    }
    .rightContent {
        width: 88%;
        height: calc(100vh - 150px);
        background-color: @french-grey;
        text-align: center;
    }
    .leftList {
      max-width: 12%;
      max-height: 100%;
      overflow: auto;
    }
    /deep/.tip {
      margin-top: 150px;
      span{
        font-size: 19px;
        font-weight: bold;
      }
    }
    .blueItem{
      color: @hyacinthine;
    }
    .redItem{
      color: @green;
    }
    .redItems{
      color: @orange;
      font-size: 12px;
    }
    .file_list_opt{
      overflow: hidden;
    }
    .list_report{
      overflow-y: auto;
    height: calc(100vh - 56px - 140px);
    }
    .list_report li{
      margin-left: 16px;
    }
</style>
