<!--
  @description: 服务费开票申请-选择中标人弹框
  @Modifier: sunxinman/haofengxian
  @routerPath:
  @date: 2020/04/07-10:33
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="bidderVisible"
    :close-on-click-modal="false"
    :title="'选择'+paymentPartyLabel"
    width="840px"
    custom-class="el-dialog__body-p8 el-dialog_table"
  >
    <!--查询列表-->
    <section>
      <el-table
        ref="singleTable"
        v-loading="loading"
        :data="list"
        class="pointer"
        size="mini"
        highlight-current-row
        @current-change="currentChange"
      >
        <el-table-column
          type="index"
          label="序号"
          align="center"
          width="80"
        />
        <el-table-column
          header-align="center"
          :label="paymentPartyLabel"
          prop="supplierName"
          min-width="260"
        />
        <el-table-column
          header-align="center"
          label="联系电话"
          prop="supplierTel"
        />
        <el-table-column
          header-align="center"
          label="招标代理服务费（元）"
          prop="invoiceAmount"
          align="right"
        />
      </el-table>
    </section>
    <!--底部操作按钮-->
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="ensure">确 定</el-button>
      <el-button @click="bidderVisible = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
/* 接口*/
import { queryPackWinnerList } from '@api/fee/servicefee'
import { ServiceGroupMixin } from '../../mixins/serviceFeeGroupMixin'

export default {
  name: 'ChooseBidWinnerDialog',
  mixins: [ServiceGroupMixin],
  data() {
    return {
      loading: true,
      bidderVisible: false, // 是否打开弹框
      list: [], // 列表数据
      currentData: {}// 当前选择的信息
    }
  },
  methods: {
    // 父组件触发--打开弹框选择中标人
    openDialogSelectBidWinner(paymentPart) {
      this.bidderVisible = true // 打开弹框
      if (paymentPart === '01') {
        this.paymentPartyLabel = '招标人'
      }
      this.loadData() // 获取数据
    },
    // 当前选择的信息
    currentChange(val) {
      this.currentData = val
    },
    // 加载数据
    loadData() {
      const params = {
        packId: this.$route.query.packId,
        tenderId: this.$route.query.tenderId
      }
      queryPackWinnerList(params).then(response => {
        this.list = response.data
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    },
    // 选择信息-确定
    ensure() {
      if (JSON.stringify(this.currentData) !== '{}') {
        this.$emit('bidWinnerInfo', this.currentData)
        this.bidderVisible = false
      } else {
        this.$message({
          message: '请选择中标人',
          type: 'warning'
        })
      }
    }
  }
}
</script>

<style scoped lang="less">

</style>
