<template>
  <div class="subPage">
    <div class="system-table-search">
      <div class="flex-h">
        <div class="flex-item"></div>
        <ul>
          <li>
            <el-select v-model="CaseId" placeholder="请选择">
              <el-option
                v-for="item in cases"
                :key="item.CaseId"
                :label="item.CaseName"
                :value="item.CaseId">
              </el-option>
            </el-select>
          </li>
          <li>
            <!-- <span>VIP卡号：</span> -->
            <el-input
              placeholder="请输入VIP卡号"
              v-model="postData.cardNo"
              clearable>
            </el-input>
          </li>
          <li>
            <!-- <span>销售：</span> -->
            <el-input
              placeholder="请输入销售姓名"
              v-model="postData.sellerName"
              clearable>
            </el-input>
          </li>
          <li>
            <!-- <span>用户：</span> -->
            <el-input
              placeholder="请输入用户姓名"
              v-model="postData.userName"
              clearable>
            </el-input>
          </li>
        </ul>
        <el-button
          size="mini"
          type="primary" @click="search">搜索</el-button>
      </div>
      <div class="moreFilter"></div>
      <div class="flex-h">
        <div class="flex-item flex-h" style="margin-top: 20px;">
          <el-button size="mini" type="success" @click='addVIP'>新增VIP</el-button>
          <el-button size="mini" type="success" @click='activateVip'>激活VIP</el-button>
        </div>
      </div>
    </div>
    <div class="system-table-box">
      <el-table
        :data="currentList"
        stripe
        style="width: 100%">
        <el-table-column
          prop="CardNo"
          label="卡号">
        </el-table-column>
        <el-table-column
          prop="Price"
          label="价格">
        </el-table-column>
        <el-table-column
          prop="Status"
          label="状态">
        </el-table-column>
        <el-table-column
          prop="SellerName"
          label="销售">
        </el-table-column>
        <el-table-column
          prop="CaseName"
          label="案场">
        </el-table-column>
        <el-table-column
          prop="UserName"
          label="用户">
        </el-table-column>
        <el-table-column
          prop="ActivationTime"
          label="激活时间">
        </el-table-column>
        <el-table-column
          prop="CreatTime"
          label="创建时间">
        </el-table-column>
      </el-table>
    </div>
    <el-pagination
      @current-change="handleCurrentChange"
      :current-page.sync="postData.page"
      :page-size="postData.pagesize"
      layout="prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  name: '',
  data () {
    return {
      total: 0,
      postData: { // 表格搜索条件
        caseid: '', // 案场id
        page: 1, // 当前页码
        pagesize: 10, // 请求数据量
        cardNo: '', // vip卡号
        sellerName: '', // 销售姓名
        userName: '', // 用户名
      },
      currentList: [{
        CardNo: 'xxx',
        Price: 'xxx',
        Status: 'xxx',
        SellerName: 'xxx',
        CaseName: 'xxx',
        UserName: 'xxx',
        ActivationTime: 'xxx',
        CreatTime: 'xxx',
      }]
    }
  },
  mounted () {
    this.$nextTick(function () {
      this.getList()
    })
  },
  computed: {
    ...mapState({
      cases: x => x.app.cases.list,
      defaultCaseId: x => x.app.cases.default
    }),
    CaseId: {
      get () {
        return this.postData.caseid || this.defaultCaseId
      },
      set (val) {
        this.postData.caseid = val
      }
    }
  },
  methods: {
    search () { // 搜索
      this.postData.page = 1
      this.currentList = []
      this.getList()
    },
    getList () { // 获取列表
    },
    handleCurrentChange (val) { // 跳转到分页
      this.getList()
    },
    addVIP () {
      this.$router.push({ name: 'editVip' })
    },
    activateVip () {
      this.$router.push({ name: 'activateVip' })
    },
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
@import "page.scss";
</style>
