<!--
  @description: 开标大厅-开标中-批量唱标标段列表弹框（-在宫格图点击批量唱标）
  @Modifier: zhuyc
  @routerPath:
  @date: 2020/8/18-17:16
-->
<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    custom-class="el-dialog__body-p8 el-dialog_table"
    :title="`批量${bidAnnouncementText}`"
    top="6vh"
    width="70%"
  >
    <el-scrollbar class="pack_wrap_scrollbar scrollbar">
      <el-table
        :data="batchSingingPack"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          :selectable="isDisabled"
          disabled="true"
          align="center"
          type="selection"
          width="55"
        />
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          header-align="center"
          label="标段名称"
          prop="packName"
          align="left"
          min-width="180"
        />
        <el-table-column
          label="标段编号"
          prop="packNo"
          align="center"
          min-width="160"
        />
        <el-table-column
          label="有效投标家次"
          prop="validBidderNumber"
          align="center"
          min-width="110"
        />
        <el-table-column
          label="解密成功家次"
          prop="decryptionNumber"
          align="center"
          min-width="110"
        />
        <el-table-column
          header-align="center"
          prop="openingStatus"
          label="开标状态"
          min-width="75"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.openingStatus ==='00'">未开标</span>
            <span v-if="scope.row.openingStatus ==='01'">已{{ bidAnnouncementText }}</span>
            <span v-if="scope.row.openingStatus ==='02'">开标中</span>
          </template>
        </el-table-column>
      </el-table>
    </el-scrollbar>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="confirmSingingResult">确 认</el-button>
      <el-button @click="dialogVisible = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
/* 接口*/
import { getOpeningTenderPackageInfoListByStageIdList,
  uploadBatchSingingResult } from '@api/bidding/bidOpening'
/* 混合开发方法-参数字段*/
import { bidOpeningMixin } from '../mixins/bidOpeningMixin'

export default {
  name: 'BatchSingingPackList',
  mixins: [bidOpeningMixin],
  props: {
    // 是否到开标时间
    msTimeShow: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      dialogVisible: false,
      batchSingingPack: [], // 唱标标段列表
      selectBatchSingingPack: [], // 已选唱标标段列表
      stageIds: '' // 已选标段列表stageId集合
    }
  },
  methods: {
    // 开标大厅-开标倒计时界面-调用此方法打开弹框-查看开启未开启列表
    open() {
      this.dialogVisible = true
      getOpeningTenderPackageInfoListByStageIdList(this.openTypeStageIds).then(response => {
        this.batchSingingPack = response.data
      }).catch(() => {

      })
    },
    // 选中标包
    handleSelectionChange(val) {
      this.selectBatchSingingPack = val
    },
    // 确认唱标
    confirmSingingResult() {
      if (this.selectBatchSingingPack.length > 0) {
        this.dialogVisible = false
        const stageIds = []
        this.selectBatchSingingPack.map((item) => {
          stageIds.push(item.stageId)
        })
        this.stageIds = stageIds.join(',')

        this.$confirm(`确认${this.bidAnnouncementText}吗，确认${this.bidAnnouncementText}后将结束解密?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          confirmButtonClass: 'confirmBtn',
          cancelButtonClass: 'cancelBtn',
          type: 'warning'
        }).then(() => {
          const data = {
            openStageType: this.openTypeStageIds.openStageType,
            stageIds: this.stageIds
          }
          uploadBatchSingingResult(data).then(res => {
            this.$message({
              type: 'success',
              message: res.header.msg
            })
          }).catch(() => {
          })
        }).catch(() => {

        })
      } else {
        // 未选中标段
        this.$message({
          type: 'warning',
          message: '请选择标段（包）'
        })
      }
    },
    // 复选框部分禁用
    isDisabled(row) {
      // openingStatus ==='02' 开标中可以勾选 未开标已唱标禁用不可选
      return row.openingStatus === '02'
    }
  }
}
</script>

<style scoped lang="less">
  @import "../index";
</style>
