<!--
  @description:开标前数据查看
  @Modifier: yangzy
  @routerPath: /bidding/bidingBeforeOpeningMonitor-detail
  @date: 2021/2/1 14:08
-->
<template>
  <div>
    <section class="title p0-16 clearfix">
      <template>
        <div class="title-back pointer" @click="back">
          <i class="iconfont icon-fanhui mr10" />开标前数据查看
        </div>
      </template>
    </section>
    <section class="p0-16">
      <div class="mb10">
        <el-button type="primary" @click="downloadNum">
          下载家数
        </el-button>
        <el-button type="primary" @click="payNum">
          缴费家次
        </el-button>
        <el-button type="primary" @click="bidNum">
          投标情况
        </el-button>
        <el-button type="primary" @click="queryNewTime">
          最新供应商投标时间
        </el-button>
      </div>
      <el-table
        ref="smallTable"
        :data="tableData"
      >
        <el-table-column
          prop="queryName"
          header-align="center"
          label="查询名称"
          min-width="140"
        />
        <el-table-column
          header-align="center"
          prop="queryResult"
          label="查询结果"
          min-width="230"
        />
        <el-table-column
          label="查询时间"
          prop="queryTime"
          align="center"
          min-width="140"
        />
      </el-table>
    </section>
  </div>
</template>
<script>
/* 接口*/
import { getStageIdsByTenderId } from '@/api/bidding/bidOpening' // 根据项目相关数据查询关联的stageIds
import { getOpenBidTenderProjectData } from '@/api/bidding/bidOpening' // 获取开标前数据监控数据

export default {
  name: 'BeforeOpeningMonitorDetail',
  data() {
    return {
      stageIdList: [], // 阶段id集合
      tableData: [{
        queryName: '下载家数',
        queryResult: '',
        queryTime: ''
      },
      {
        queryName: '缴费家次',
        queryResult: '',
        queryTime: ''
      },
      {
        queryName: '投标情况',
        queryResult: '',
        queryTime: ''
      },
      {
        queryName: '最新供应商投标时间',
        queryResult: '',
        queryTime: ''
      }]
    }
  },
  created() {
    // 查询阶段id
    this.initStageIds()
  },
  methods: {
    // 获取stageId集合
    initStageIds() {
      const data = {
        tenderId: this.$route.params.tenderId, // 项目id
        openBidStartTime: this.$route.params.openBidStartTime, // 开标时间/技术标开标时间
        economicOpenBidStartTime: this.$route.params.economicOpenBidStartTime // 经济标开标时间
      }
      getStageIdsByTenderId(data).then(response => {
        this.stageIdList = response.data
      })
    },
    // 下载家数
    downloadNum() {
      const data = {
        type: '01', // 类型 00:缴费家数 01:下载家数 02:投标信息 03:最新投标时间
        stageIds: this.stageIdList // 阶段集合
      }
      getOpenBidTenderProjectData(data).then(response => {
        this.tableData[0].queryResult = response.data.bidderNum
        this.tableData[0].queryTime = response.data.queryTime
      })
    },
    // 缴费家次
    payNum() {
      const data = {
        type: '00', // 类型 00:缴费家数 01:下载家数 02:投标信息 03:最新投标时间
        stageIds: this.stageIdList // 阶段集合
      }
      getOpenBidTenderProjectData(data).then(response => {
        this.tableData[1].queryResult = response.data.bidderNum
        this.tableData[1].queryTime = response.data.queryTime
      })
    },
    // 投标情况
    bidNum() {
      const data = {
        type: '02', // 类型 00:缴费家数 01:下载家数 02:投标信息 03:最新投标时间
        stageIds: this.stageIdList // 阶段集合
      }
      getOpenBidTenderProjectData(data).then(response => {
        this.tableData[2].queryResult = response.data.bidderNum + '， ' + response.data.fileSize
        this.tableData[2].queryTime = response.data.queryTime
      })
    },
    // 最新投标时间
    queryNewTime() {
      const data = {
        type: '03', // 类型 00:缴费家数 01:下载家数 02:投标信息 03:最新投标时间
        stageIds: this.stageIdList // 阶段集合
      }
      getOpenBidTenderProjectData(data).then(response => {
        this.tableData[3].queryResult = response.data.bidTime
        this.tableData[3].queryTime = response.data.queryTime
      })
    },
    // 返回
    back() {
      this.$router.push({
        path: 'bidingOpeningMonitor-list'
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
