<!--
  @description: 开标大厅等待开标-开标倒计时界面-点击项目或者标段数 弹框-未开启标段列表-tab1（开标时间未到）
  @Modifier: haoFx
  @routerPath:
  @date: 2020/3/18-17:48
-->
<template>
  <div>
    <el-scrollbar class="scrollbar scrollbar-list">
      <el-table
        ref="multipleTable"
        :data="notOpenPack"
        :row-key="getRowKeys"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          :selectable="isDisabled"
          disabled="true"
          :reserve-selection="true"
          align="center"
          type="selection"
          width="55"
        />
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="项目名称"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="tenderNo"
          label="项目编号"
          width="160"
        />
        <el-table-column
          header-align="center"
          label="标段名称"
          prop="packName"
          align="left"
          min-width="200"
        />
        <el-table-column
          label="标段编号"
          prop="packNo"
          align="center"
          min-width="180"
        />
        <el-table-column
          label="有效投标家次"
          prop="validBidderNumber"
          align="center"
          min-width="110"
        >
          <template slot-scope="scope">
            <span :class="scope.row.isSelect ==='02'?'fontColor':''">{{ scope.row.validBidderNumber }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-scrollbar>
    <p class="p16-0 bidOpening_hint">
      已选中
      <span class="blue">{{ selectNotOpenPackSum }}</span>
      个标段包
      <!--客户端解密 && 经济标显示-->
      <template v-if="todayOpeningInfo.bidDocumentDecryptionMethod==='00' && todayOpeningInfo.openStageType==='02'">
        ，还有
        <span class="red">{{ manualSelectionSum }}</span>
        个标段包商务技术未解密（如需选择请手动选择！）
      </template>
    </p>
  </div>
</template>

<script>
/* 接口*/
import { listStartOpeningTenderPackagePages } from '@api/bidding/bidOpening'
/* 混合开发方法-参数字段*/
import { bidOpeningMixin } from '../mixins/bidOpeningMixin'
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  name: 'NotOpenList',
  components: {
    pagination
  },
  mixins: [bidOpeningMixin],
  props: {
    // 开标解密状态 00:未开启 01:已开启
    activeName: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      selectNotOpenPackSum: 0, // 满足开标条件的标包数
      manualSelectionSum: 0, // 可手动选择标包数
      allOptional: '', // 可手动选择标包信息
      notOpenPack: [] // 未开启标段列表
    }
  },
  watch: {
    activeName(val) {
      if (val === '00') {
        this.loadData()
      }
    }
  },
  methods: {
    // 获取row的key值
    getRowKeys(row) {
      return row.stageId
    },
    // 获取未开启标段列表
    loadData() {
      const params = {
        ...this.openTypeStageIds,
        isStartOpeningDecryptStatus: this.activeName,
        pageNo: 1,
        pageSize: 1000
      }
      listStartOpeningTenderPackagePages(params).then(response => {
        this.notOpenPack = response.data.records
        // isSelect 是否选中 00 未选中(项目经理可勾选) 01选中 02禁止选中(项目经理不可勾选)
        // 设置table默认选中
        this.notOpenPack.forEach((item, index) => {
          if (item.isSelect === '01') {
            // 等表格数据加载完成后
            this.$nextTick(() => {
              this.$refs.multipleTable.toggleRowSelection(this.notOpenPack[index], true)
            })
          }
        })
        // 处理项目经理可勾选列表 openStageType 02价格开标阶段(两步经济) isSelect00 项目经理可勾选
        this.allOptional = this.notOpenPack.filter(item => item.isSelect === '00')
        this.manualSelectionSum = this.allOptional.length
      }).catch(() => {

      })
    },
    // 复选框部分禁用
    isDisabled(row) {
      // isSelect 是否选中 00 未选中(项目经理可勾选) 01选中 02禁止选中(项目经理不可勾选)
      return row.isSelect === '00' || row.isSelect === '01'
    },
    // 选中标包
    handleSelectionChange(val) {
      // 已选中的满足条件的标段个数
      this.selectNotOpenPackSum = val.length
      this.$emit('notOpenData', val)
    }
  }
}
</script>

<style scoped lang="less">
  @import "../index";
 .scrollbar-list {
    height: 500px;
    overflow-x: hidden !important;
  }
  .bidOpening_hint{
    text-align: right;
  }
</style>
