<!--
  @description: 代理机构-投标-标书投递-查看标书投递详情
  @Modifier: haoFx
  @routerPath: /bidding/projectDrive/tenderBid/tenderDeliveryDetail
  @date: 2020/2/12-17:04
-->
<template>
  <div class="main">
    <section>
      <dl class="projectInfoDetail">
        <dt>
          <p class="projectInfoDetail_icon">
            <i class="iconfont icon-biaoduanbaoxinxi" />
          </p>
          投标人信息
        </dt>
        <dd>
          <table class="tableData">
            <tr>
              <td>投标人名称</td>
              <td>{{ supplierInfo.supplierName }}</td>
              <td>联系人名称</td>
              <td>{{ supplierInfo.linker }}</td>
            </tr>
            <tr>
              <td>联系电话</td>
              <td>{{ supplierInfo.linkerTel }}</td>
              <td>联系人邮箱</td>
              <td>{{ supplierInfo.linkerEmail }}</td>
            </tr>
          </table>
        </dd>
      </dl>
    </section>
    <section>
      <dl class="projectInfoDetail">
        <dt>
          <p class="projectInfoDetail_icon">
            <i class="iconfont icon-biaoduanbaoxinxi" />
          </p>
          查看投标信息
        </dt>
        <dd>
          <el-table
            ref="smallTable"
            :data="bidFileList"
          >
            <el-table-column
              align="center"
              label="投标文件"
            >
              <template slot-scope="scope">
                <download-tenderBid-file :data="scope.row.fileData" />
              </template>
            </el-table-column>
            <el-table-column
              header-align="center"
              label="文件类型"
              align="center"
            >
              <template slot-scope="scope">
                <span
                  v-for="(groupItem,index) in bidSubmitTypeList"
                  v-if="scope.row.bidType===groupItem.typecode"
                  :key="index"
                >{{ groupItem.typename }}</span>
              </template>
            </el-table-column>
            <el-table-column
              header-align="center"
              label="上传时间"
              prop="bidTime"
              align="center"
            />
            <el-table-column
              :label="dict.djrq "
              header-align="center"
              prop="bidTime"
              align="center"
            />
          </el-table>
        </dd>
      </dl>
    </section>
    <section>
      <dl class="projectInfoDetail">
        <dt>
          <p class="projectInfoDetail_icon">
            <i class="iconfont icon-biaoduanbaoxinxi" />
          </p>
          查看回执文件
        </dt>
        <dd>
          <el-table
            ref="smallTable"
            :data="receiptFileList"
          >
            <el-table-column
              label="投标回执文件"
              align="center"
            >
              <template slot-scope="scope">
                <downloadFile :data="scope.row.fileData" />
              </template>
            </el-table-column>
            <el-table-column
              header-align="center"
              prop="bidType"
              label="文件类型"
              align="center"
            >
              <template slot-scope="scope">
                <span
                  v-for="(groupItem,index) in bidSubmitTypeList"
                  v-if="scope.row.bidType===groupItem.typecode"
                  :key="index"
                >{{ groupItem.typename }}</span>
              </template>
            </el-table-column>
            <el-table-column
              header-align="center"
              prop="receiptType"
              label="回执文件类型"
              align="center"
            >
              <template slot-scope="scope">
                <span
                  v-for="(groupItem,index) in receiptTypeList"
                  v-if="scope.row.receiptType===groupItem.typecode"
                  :key="index"
                >{{ groupItem.typename }}</span>
              </template>
            </el-table-column>
            <el-table-column
              header-align="center"
              label="回执时间"
              prop="createTime"
              align="center"
            />
          </el-table>
        </dd>
      </dl>
    </section>
    <!--返回-->
    <div class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button @click="back">
            返 回
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* api*/
import { tenderBidFileInfo } from '@api/bidding/bid'
import { tenderBidGroupMixin } from './../mixins/tenderBidGroupMixin'// 投标-字典信息
import { tenderBidMixin } from './../mixins/tenderBidMixin'// 投标-公共参数
/* 组件*/
import downloadFile from '@comp/common/updownload/downloadFile' // 获取附件信息 下载组件
import downloadTenderBidFile from './downloadTenderBidFile'
/* 组件*/
import tabs from '@comp/common/tabs'
export default {
  name: 'TenderDeliveryDetail',
  components: {
    tabs,
    downloadFile, // 文件下载
    'download-tenderBid-file': downloadTenderBidFile
  },
  mixins: [tenderBidGroupMixin, tenderBidMixin],
  data() {
    return {
      stageType: this.$store.getters.tenderBase.stageType, // 00资格预审,01 资格后审
      groupId: this.$store.getters.groupId, // 包Id 项目Id 阶段id
      supplierInfo: {}, // 投标人信息
      tableData: [], // 获取投标供应商投标文件详情
      // 投标文件列表
      bidFileList: [
        /*     {
          bidId: '', // 投标id
          bidStatus: '', // 投递状态 00申请投标 01确认投标 02撤标
          bidTime: '', // 投递时间
          bidType: '' // 投标类型
        }*/
      ],
      // 回执文件列表
      receiptFileList: [
        /*      {
          bidType: '', // 投标类型
          createTime: '', // 创建时间
          receiptId: '', // 回执id
          receiptType: '' // 回执类型 00投标回执 01撤标回执
        }*/
      ],
      // 递交日期-字典标题
      dict: {
        djrq: '' // 递交日期
      }
    }
  },
  mounted() {
    this.supplierInfo = JSON.parse(sessionStorage.getItem('supplierInfo'))

    this.getTenderBidFileInfo() //  获取投标供应商投标文件详情

    this.initDict() // 初始化字段标题
  },
  methods: {
    // 递交日期-初始化字段标题
    initDict() {
      if (this.stageType === '00') { // 资格预审
        // 字典标题
        this.dict = {
          djrq: '资格预审申请文件成功递交日期'
        }
      } else if (this.stageType === '01') { // 资格后审
        // 字典标题
        this.dict = {
          djrq: '递交日期'
        }
      }
    },
    //  获取投标供应商投标文件详情
    getTenderBidFileInfo() {
      const params = {
        stageId: this.groupId.stageId,
        tenderId: this.groupId.tenderId,
        supplierId: this.$route.query.supplierId
      }
      tenderBidFileInfo(params).then(res => {
        this.tableData = res.data
        // 投标解密文件
        this.bidFileList = res.data.bidFileList
        this.handleBidFileList(this.bidFileList)
        // 查询回执文件
        this.receiptFileList = res.data.receiptFileList
        this.handleReceiptFileList()
      }).catch(() => {
      })
    },
    // 投标文件
    handleBidFileList() {
      // 投标文件
      this.bidFileList.map(item => {
        // 递交时间/上传时间
        item.bidTime = this.$Moment(item.bidTime).format(this.momentSaveFormat)
        /* 投标文件*/
        item.fileData = {
          fileType: item.fileType, // 投标解密文件
          bizId: item.bidId// 投标Id
        }
      })
    },
    // 回执文件
    handleReceiptFileList() {
      // 回执文件
      this.receiptFileList.map(item => {
        // 回执时间
        item.createTime = this.$Moment(item.createTime).format(this.momentSaveFormat)
        // 投标回执文件/撤销回执文件
        if (item.receiptType === '00') { // 投标回执文件
          item.fileData = {
            ...this.reFileData
          }
        } else if (item.receiptType === '01') { // 撤销回执文件
          item.fileData = {
            ...this.receiptFileData
          }
        }
        item.fileData.bizId = item.receiptId// 业务主键Id
      })
    },
    // 返回
    back() {
      this.$router.push({
        path: '/bidding/projectDrive/tenderBid/tenderDeliveryList',
        query: {
          ...this.$route.query
        }
      })
    }
  }
}
</script>

<style scoped lang="less">
</style>
