<template>
<div class="app-container calendar-list-container">
  <!-- 筛选条件 -->
  <div class="filter-container">
    <el-input @keyup.enter.native="handleSearch" style="width: 120px;" clearable class="filter-item" placeholder="姓名" v-model="params.search_like_name"></el-input>
    <el-input @keyup.enter.native="handleSearch" style="width: 200px;" clearable class="filter-item" placeholder="银行卡号" v-model="params.search_like_bankNo"></el-input>
    <el-select v-model="params.search_eq_status" style="width: 120px" class="filter-item" clearable placeholder="状态">
      <el-option v-for="item in options.statu"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
    </el-select>

    <el-button class="filter-item" type="primary" v-waves icon="search" @click="handleSearch">搜索</el-button>
  </div>

  <!-- 列表数据 -->
  <Pagination uri="/member/withdraw/applys" :request-params="params" ref="pagination">

      <!-- 姓名 -->
      <el-table-column align="center" label="姓名">
        <template scope="scope">
          <span>{{scope.row.name}}</span>
        </template>
      </el-table-column>

      <!-- 开户行 -->
      <el-table-column align="center" label="开户行">
        <template scope="scope">
          <span>{{scope.row.bankName}}</span>
        </template>
      </el-table-column>

      <!-- 银行卡号 -->
      <el-table-column align="center" label="银行卡号">
        <template scope="scope">
          <span>{{scope.row.bankNo}}</span>
        </template>
      </el-table-column>

      <!-- 状态 -->
      <el-table-column align="center" label="状态">
        <template scope="scope">
          <WithdrawStatus :status="scope.row.status"></WithdrawStatus>
        </template>
      </el-table-column>

      <!-- 提现金额 -->
      <el-table-column align="center" label="提现金额">
        <template scope="scope">
          <span>{{scope.row.money}}</span>
        </template>
      </el-table-column>

      <!-- 创建时间 -->
      <el-table-column align="center" label="审核时间">
        <template scope="scope">
          <span v-if="scope.row.status != 0">{{scope.row.modifiedTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
        </template>
      </el-table-column>
      
      <!-- 创建时间 -->
      <el-table-column align="center" label="申请时间">
        <template scope="scope">
          <span>{{scope.row.createdTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
        </template>
      </el-table-column>

    <el-table-column label="操作" align="center" width="150">
      <template scope="scope">
        <el-button v-if="scope.row.status === 0" size="small" type="text" @click="handleUpdateStatus(scope.row, -1, scope.row.memberId)">拒绝</el-button>
        <el-button v-if="scope.row.status === 0" size="small" type="text" @click="handleUpdateStatus(scope.row, 1, scope.row.memberId)">同意</el-button>
      </template>
    </el-table-column>
  </Pagination>
</div>
</template>

<script>
import { remove, updateStatus } from '@/api//member/withdraw/apply'
import waves from '@/directive/waves.js'// 水波纹指令
import Pagination from '@/components/Pagination'
import WithdrawStatus from '@/components/WithdrawStatus'

export default {
  name: 'memberWithdrawApply_list',
  components: { Pagination, WithdrawStatus },
  directives: {
    waves
  },
  data() {
    return {
      form: {
        id: undefined,
        type: '',
        money: '',
        memberId: '',
        payType: 2,
        platformId: 1
      },
      options: {
        statu: [
          {
            value: -1,
            label: '已拒绝'
          },
          {
            value: 0,
            label: '审核中'
          },
          {
            value: 1,
            label: '已提现'
          }
        ]
      },
      onSubmit: '',
      params: {
        search_like_name: undefined,
        search_like_bankNo: undefined,
        search_eq_status: undefined
      },
      rules: { }
    }
  },
  created() {
  },
  methods: {
    /**
     * 搜索用户提现申请
     */
    handleSearch() {
      // this.$refs.pagination.pageRequest()
      this.$refs.pagination.handleCurrentChange(1)
    },

    /**
     * 编辑用户提现申请
     */
    handleEdit(id) {
      this.$router.push({ path: '/member/withdraw/apply/edit', query: { id: id }})
    },

    /**
     * 创建用户提现申请
     */
    handleCreate() {
      this.$router.push({ path: '/member/withdraw/apply/edit' })
    },

    /**
     * 更新用户状态
     */
    handleUpdateStatus(row, status, memberId) {
      updateStatus(row.id, status, memberId).then(response => {
        this.handleSearch()
      })
    },

    /**
     * 删除用户提现申请
     */
    handleDelete(row) {
      this.$confirm('确认删除该用户提现申请？').then(_ => {
        remove(row.id).then(response => {
          this.$refs.pagination.removeItem(row)
        })
      }).catch(_ => {})
    }
  }
}
</script>

