<!--
  @description: 开标大厅等待开标-倒计时结束界面-点击项目或者标段数 弹框-未开启标段列表_tab父页面
  @Modifier: haoFx
  @routerPath:
  @date: 2020/3/18-17:16
-->
<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    custom-class="el-dialog__body-minHeight"
    title="开启标段"
    top="6vh"
    width="70%"
  >
    <div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="未开启" name="00">
          <notOpenList
            ref="notOpen"
            :active-name="activeName"
            @notOpenData="notOpenData"
          />
        </el-tab-pane>
        <el-tab-pane label="已开启" name="01">
          <hasBeenOpenList
            :active-name="activeName"
          />
        </el-tab-pane>
        <el-tab-pane label="有效投标人不足三家" name="02">
          <validBidderList
            ref="validBidder"
            :active-name="activeName"
          />
        </el-tab-pane>
      </el-tabs>
    </div>
    <span v-if="activeName==='00' && !msTimeShow" slot="footer" class="dialog-footer">
      <el-button type="primary" @click="confirmOpen">开 标</el-button>
      <el-button @click="dialogVisible = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
/* 组件*/
import notOpenList from './notOpen-list'
import hasBeenOpenList from './hasBeenOpen-list'
import validBidderList from './validBidder-list'
export default {
  name: 'SelectOpenPackDialog',
  components: {
    notOpenList, // 未开启列表
    hasBeenOpenList, // 已开启列表
    validBidderList // 不足三家标段列表
  },
  props: {
    // 是否到开标时间
    msTimeShow: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      dialogVisible: false,
      activeName: '00', // 开标解密状态 00:未开启 01:已开启
      selectNotOpenPackList: [], // 已选标段列表
      stageIds: '' // 已选标段列表stageId集合
    }
  },
  methods: {
    // 已选未开启得标段
    notOpenData(val) {
      const stageIds = []
      this.selectNotOpenPackList = val // 已选标段列表
      this.selectNotOpenPackList.map((item) => {
        stageIds.push(item.stageId)
      })
      this.stageIds = stageIds.join(',')
    },
    // 确认开启
    confirmOpen() {
      if (this.selectNotOpenPackList.length > 0) {
        this.dialogVisible = false
        // 调用父组件开标方法
        this.$emit('makeSureOpen', this.stageIds, true)
      } else {
        // 未选中标段
        this.$message({
          type: 'warning',
          message: '请选择标段（包）'
        })
      }
    },
    // 开标大厅-开标倒计时界面-调用此方法打开弹框-查看开启未开启列表
    open(type) {
      this.dialogVisible = true
      this.activeName = type // 根据参数默认选中选项卡
      if (type === '00') {
        this.$nextTick(function() {
          // 点击标包 获取数据
          this.$refs.notOpen.loadData()
        })
      } else if (type === '02') {
        this.$nextTick(function() {
          // 点击有效投标人不足三家 获取数据
          this.$refs.validBidder.loadData()
        })
      }
    },
    // 切换tab
    handleClick(tab) {
      this.activeName = tab.name
    }
  }
}
</script>

<style scoped lang="less">
  @import "../index";
  /deep/.el-dialog__body-minHeight{
    .el-dialog__body {
      min-height: 600px;
    }
  }
</style>
