<!--
  @description:竞价大厅外部页
  @Modifier:hdk
  @routerPath2:/procurement/procurementDrive/biddingLobbyExternalState 竞价大厅外部页
  @date:2020/9/25-13:23
-->
<template>
  <div class="procurementBiddingExternal" style="margin-top:0px">
    <div v-loading="loading" class="row-bg">
      <!-- 竞价外部未开始、进行中 -->
      <procurementBiddingExternalIsStart v-if="biddingStatus === '00'" :project-rules-data="formData" :bidding-status="biddingStatus" />
      <!-- 竞价结束竞价详情-采购 -->
      <procurementBiddingExternalEnd v-if="biddingStatus === '01' && hallType === '00'" />
      <!-- 竞价结束竞价详情-供应商 -->
      <procurementBiddingExternalSupplierEnd v-if="biddingStatus === '01' && hallType === '01'" />
      <!--  进入竞价大厅按钮-->
      <gx-button class="enterOffer el-button--primary el-button--small" @click="enterBiddingHall()">
        进入竞价大厅
      </gx-button>
    </div>
    <!-- 采购大厅 -->
    <procurementBiddingInTheOpenAgentAdd
      v-if="intoHallType === '00'"
      :project-rules-data="formData"
      :bidding-status="biddingStatus"
      :hall-type="hallType"
      @closeHall="closeHall"
    />
    <!-- 供应商大厅 -->
    <procurementBiddingInTheOpenSupplierAdd
      v-if="intoHallType === '01'"
      :project-rules-data="formData"
      :bidding-status="biddingStatus"
      :hall-type="hallType"
      @closeHall="closeHall"
    />
  </div>
</template>

<script>
/* 引入公共方法*/
import { commonMxin } from '@/mixins/commonMxin'
// import { procurementBiddingGroupMixin } from '../mixins/procurementBiddingGrounpMixins'
import { procurementBiddingMixins } from '../mixins/procurementBiddingMixins'
// import { createURL } from '@/assets/js/utils/index'
/* 组件*/
import procurementBiddingExternalIsStart from './procurementBiddingExternalIsStart.vue' // 竞价大厅外部是否开始
import procurementBiddingExternalEnd from './procurementBiddingExternalEnd.vue' // 供应商-竞价大厅外部结束
import procurementBiddingExternalSupplierEnd from './procurementBiddingExternalSupplierEnd.vue' // 采购人-竞价大厅外部结束
import procurementBiddingInTheOpenAgentAdd from '../procurementBiddingInTheOpen/procurementBiddingInTheOpenAgent-add.vue' // 采购人-竞价大厅已开启
import procurementBiddingInTheOpenSupplierAdd from '../procurementBiddingInTheOpen/procurementBiddingInTheOpenSupplier-add.vue' // 供应商-竞价大厅已开启
export default {
  name: 'ProcurementBiddingExternal',
  components: {
    procurementBiddingExternalIsStart, // 竞价大厅外部是否开始
    procurementBiddingExternalEnd, // 采购人-竞价大厅外部结束
    procurementBiddingExternalSupplierEnd, // 供应商-竞价大厅外部结束
    procurementBiddingInTheOpenAgentAdd, // 采购人-竞价大厅已开启
    procurementBiddingInTheOpenSupplierAdd // 供应商-竞价大厅已开启
  },
  mixins: [commonMxin, procurementBiddingMixins], // , procurementBiddingGroupMixin
  inject: ['getTenderBase'],
  props: {
    // 竞价规则
    projectRulesData: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      loading: true,
      // 当前时间
      nowTime: '',
      // 竞价状态 00竞价未开始 01竞价开始 02竞价结束
      // NEW 00竞价未开始 竞价开始 01竞价结束
      biddingStatus: '00',
      // 定时器
      interval: null,
      // 大厅类型 00采购 01供应商
      hallType: '',
      // 进入大厅类型 00采购 01供应商
      intoHallType: '',
      // 获取项目信息
      tenderBase: this.getTenderBase()
    }
  },
  watch: {
  },
  created() {
    // 页面初始化
    this.pageInit()
    if (this.$route.path.split('/').indexOf('procurementDrive') !== -1) { // 采购
      this.hallType = '00'
    } else if (this.$route.path.split('/').indexOf('procurementDriveSupplier') !== -1) { // 供应商
      this.hallType = '01'
    }
  },
  beforeDestroy() {
    clearInterval(this.interval)
  },
  methods: {
    // 页面初始化
    pageInit() {
      // 获取竞价规则
      this.getOfferRulesData(this.tenderBase.packId)
      this.getStatus()
      // 轮询
      this.interval = setInterval(() => {
        this.getOfferRulesData(this.tenderBase.packId)
        // 进入页面的状态
        this.getStatus()
      }, 1000)
    },
    getStatus() {
      // 竞价结束
      if (this.formData.status === '01') {
        this.biddingStatus = '01'
        this.loading = false
        clearInterval(this.interval)
      // 竞价开始
      } else if (this.formData.status === '00') {
        this.biddingStatus = '00'
        this.loading = false
      }
    },
    // 进入竞价大厅
    enterBiddingHall() {
      if (this.$route.path.split('/').indexOf('procurementDrive') !== -1) {
        // 采购
        this.intoHallType = '00'
      } else if (this.$route.path.split('/').indexOf('procurementDriveSupplier') !== -1) {
        // 供应商
        this.intoHallType = '01'
      }
    },
    closeHall() {
      this.intoHallType = ''
    }
  }
}
</script>

<style lang="less" scoped>
  .procurementBiddingExternal{
    .row-bg {
      width: 100%;
      height: calc(100vh - 96px - 42px);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background: url("~@assets/img/procurement/procurementEvaluation/offerLobbyBg.png") no-repeat;
      background-size: cover;
      -webkit-background-size: cover;
      -o-background-size: cover;
      background-position: center 0;
      position: relative;
      .enterOffer{
        width:168px;
        height: 36px;
        text-align: center;
        margin-top: 80px;
      }
    }
  }
</style>
