<template>
  <div class="subPage">
    <div class="system-table-search">
      <div class="flex-h">
        <div class="flex-item flex-h"></div>
      </div>
      <div class="moreFilter"></div>
    </div>
    <div class="system-table-box">
      <el-table
        :data="currentList"
        stripe
        style="width: 100%">
        <el-table-column
          prop="CaseName"
          label="案场">
        </el-table-column>
        <el-table-column
          prop="ActivitName"
          label="活动名称">
        </el-table-column>
        <el-table-column
          prop="Name"
          label="姓名">
        </el-table-column>
        <el-table-column
          prop="CustomerName"
          label="微信昵称">
        </el-table-column>
        <el-table-column
          prop="Phone"
          label="手机号">
        </el-table-column>
        <el-table-column
          prop="PrizeName"
          label="获取奖品">
        </el-table-column>
        <el-table-column
          label="获取时间">
          <template slot-scope="scope">
            <label>{{scope.row.CreateDate === '0001-01-01T00:00:00Z' ? '-' : toolClass.dateFormat(scope.row.CreateDate)}}</label>
          </template>
        </el-table-column>
        <el-table-column
          label="核销时间">
          <template slot-scope="scope">
            <label>{{scope.row.WriteoffDate === '0001-01-01T00:00:00Z' ? '-' : toolClass.dateFormat(scope.row.WriteoffDate)}}</label>
          </template>
        </el-table-column>
        <el-table-column
          label="状态">
          <template slot-scope="scope">
            <label>{{scope.row.Status === 0 ? '未核销' : '已核销'}}</label>
          </template>
        </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 { createNamespacedHelpers } from 'vuex'
const { mapState: mapLuckState, mapActions: mapLuckActions } = createNamespacedHelpers('luckDraw')

export default {
  name: '',
  data () {
    return {
      total: 0,
      postData: { // 表格搜索条件
        page: 1, // 当前页码
        pagesize: 10, // 请求数据量
      },
      currentList: []
    }
  },
  mounted () {
    this.$nextTick(function () {
      this.getList()
    })
  },
  computed: {
    ...mapLuckState({
      list: x => x.luckDrawList
    }),
  },
  methods: {
    ...mapLuckActions(['getLuckDrawList']),
    search () { // 搜索
      this.postData.page = 1
      this.currentList = []
      this.getList()
    },
    getCaseName (caseid) {
      return (this.cases.filter(x => x.CaseId === caseid)[0] || {}).CaseName
    },
    getList () { // 获取列表
      this.getLuckDrawList({ ...this.postData }).then((res) => {
        this.currentList = this.list.list
        this.postData.page = this.list.page
        this.total = this.list.pagenum
      })
    },
    handleCurrentChange (val) { // 跳转到分页
      this.getList()
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
</style>
