<template>
<div class="app-container calendar-list-container">
  <!-- 筛选条件 -->
  <div class="filter-container">
      <el-input @keyup.enter.native="handleSearch" style="width: 200px;" class="filter-item" clearable placeholder="用户昵称" v-model="params.search_like_nickname"></el-input>
    <el-input @keyup.enter.native="handleSearch" style="width: 138px;" class="filter-item" clearable placeholder="用户手机号" v-model="params.search_like_mobile"></el-input>
      <el-input @keyup.enter.native="handleSearch" style="width: 200px;" class="filter-item" clearable placeholder="场馆名称" v-model="params.name"></el-input>

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

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

      <!-- 用户ID -->
      <el-table-column align="center" label="用户昵称">
        <template scope="scope">
          <span>{{scope.row.nickname}}</span>
        </template>
      </el-table-column>

      <!-- 用户手机 -->
      <el-table-column align="center" label="用户手机号">
        <template scope="scope">
          <span>{{scope.row.mobile}}</span>
        </template>
      </el-table-column>

      <!-- 会员卡类型 -->
      <el-table-column align="center" label="会员卡类型">
        <template scope="scope">
          <span>{{scope.row.cardType}}</span>
        </template>
      </el-table-column>

      <!-- 场馆类型 -->
      <el-table-column align="center" label="场馆类型">
        <template scope="scope">
          <span v-if="scope.row.venueType === 1">篮球馆</span>
          <span v-if="scope.row.venueType === 2">健身馆</span>
        </template>
      </el-table-column>

      <!-- 场馆ID -->
      <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.createdTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
        </template>
      </el-table-column>
  </Pagination>
</div>
</template>

<script>
import { remove, updateStatus } from '@/api//gift/member/card'
import waves from '@/directive/waves.js'// 水波纹指令
import Pagination from '@/components/Pagination'
import Status from '@/components/Status'
import statusOptions from '@/utils/constants.js'

export default {
  name: 'giftMemberCard_list',
  components: { Pagination, Status },
  directives: {
    waves
  },
  data() {
    return {
      params: {
        search_like_mobile: undefined,
        name: '',
        search_like_nickname: undefined
      },
      options: {
        status: statusOptions
      }
    }
  },
  created() {
  },
  methods: {
    /**
     * 搜索送会员卡记录
     */
    handleSearch() {
      this.$refs.pagination.handleCurrentChange(1)
      // this.$refs.pagination.pageRequest()
    },

    /**
     * 编辑送会员卡记录
     */
    handleEdit(id) {
      this.$router.push({ path: '/gift/member/card/edit', query: { id: id }})
    },

    /**
     * 创建送会员卡记录
     */
    handleCreate() {
      this.$router.push({ path: '/gift/member/card/edit' })
    },

    /**
     * 更新送会员卡记录状态
     */
    handleUpdateStatus(row, status) {
      updateStatus(row.id, status).then(response => {
        this.handleSearch()
      })
    },

    /**
     * 删除送会员卡记录
     */
    handleDelete(row) {
      this.$confirm('确认删除该送会员卡记录？').then(_ => {
        remove(row.id).then(response => {
          this.$refs.pagination.removeItem(row)
        })
      }).catch(_ => {})
    }
  }
}
</script>

