<!--
  @description: 中标人退款管理
  @Modifier: haofengxian
  @routerPath: /fee/bidWinnerRefund
  @date: 2020-10-9-14:59
-->
<template>
  <div>
    <table-crud
      ref="tableCrud"
      :search-form="searchForm"
      search-label-width="110px"
      @on-load="getSupplierOfDepositRefund"
    >
      <template v-slot:header>
        保证金退款记录
      </template>
      <template v-slot:search="search" :page-flag="false">
        <el-form-item ref="packNo" label="标段（包）编号" prop="packNo">
          <el-input
            v-model.trim="searchForm.packNo"
            placeholder="标段（包）编号"
            style="width:220px"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <el-form-item ref="packName" label="标段（包）名称" prop="packName">
          <el-input
            v-model.trim="searchForm.packName"
            placeholder="标段（包）名称"
            style="width:220px"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <el-form-item ref="tenderNo" label="招标项目编号" prop="tenderNo">
          <el-input
            v-model.trim="searchForm.tenderNo"
            placeholder="招标项目编号"
            style="width:220px"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <el-form-item ref="tenderName" label="招标项目名称" prop="tenderName">
          <el-input
            v-model.trim="searchForm.tenderName"
            style="width:220px"
            placeholder="招标项目名称"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
      </template>
      <template v-slot:GXTable>
        <el-table
          ref="cashDepositRefundTable"
          :data="tableData"
        >
          <el-table-column
            type="index"
            label="序号"
            fixed
            width="60px"
            align="center"
          />
          <!-- 标段（包）编号 -->
          <el-table-column
            header-align="center"
            prop="packNo"
            label="标段（包）编号"
          />
          <!-- 标段名称 -->
          <el-table-column
            style="width:220px"

            header-align="center"
            prop="packName"
            label="标段（包）名称"
          />
          <!-- 退款金额 -->
          <el-table-column
            header-align="center"
            prop="tenderNo"
            label="招标项目编号"
          />
          <!-- 退款金额 -->
          <el-table-column
            style="width:220px"

            header-align="center"
            prop="tenderName"
            label="招标项目名称"
          />
          <!-- 退款金额 -->
          <el-table-column
            header-align="center"
            prop="refundAmount"
            label="退款金额"
            align="right"
          />
          <!-- 退款时间 -->
          <el-table-column
            label="退款时间"
            prop="refundTime"
            align="center"
          >
            <template slot-scope="scope">
              {{ scope.row.refundTime && $Moment(scope.row.refundTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <!-- 退款状态 -->
          <el-table-column
            label="退款状态"
            align="center"
          >
            <template slot-scope="scope">
              <span
                v-for="(item,index) in detailRefundStatuList"
                v-if="scope.row.refundStatus === item.typecode"
                :key="index"
              >{{ item.typename }}</span>
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            label="操作"
            width="100"
          >
            <template slot-scope="scope">
              <el-link
                v-if="scope.row.refundStatus==='01'"
                type="primary"
                @click.stop="Refund(scope.row)"
              >
                [申请退款]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </table-crud>
    <!-- 申请退款弹框-->
    <depositRefundDialog ref="depositRefund" />
  </div>
</template>

<script>
/* 接口*/
import { querySupplierOfDepositRefundList } from '@api/fee/bailfee'
/* 混入公共方法*/
import { cashDepositGroupMixin } from '../mixins/cashDepositGroupMixin'
/* 组件*/
import depositRefundDialog from './depositRefund-dialog'

export default {
  name: 'BidWinnerRefundManage',
  components: {
    depositRefundDialog // 申请退款弹框
  },
  mixins: [cashDepositGroupMixin],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        packName: '', // 标段包名称
        packNo: '', // 标段包编号
        tenderName: '', // 项目名称
        tenderNo: '' // 项目编号
      },
      tableData: []
    }
  },
  methods: {
    // 保证金退款申请列表-投标人退款
    getSupplierOfDepositRefund(params, callback) {
      // params.supplierId = this.$store.getters.info.id
      querySupplierOfDepositRefundList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 申请退款
    Refund(row) {
      this.$refs.depositRefund.openDialogDepositRefund(row)
    }
  }
}
</script>

<style scoped>

</style>
