<template>
  <div class="subPage">
    <div class="system-table-search">
      <div class="flex-h">
        <div class="flex-item flex-h"></div>
        <ul>
          <li>
            <el-input
              placeholder="请输入用户手机号"
              v-model="fromPhone"
            >
            </el-input>
          </li>
          <li>
            <el-input
              placeholder="请输入被分享用户手机号"
              v-model="toPhone"
            >
            </el-input>
          </li>
        </ul>
        <el-button
          size="mini"
          type="primary" @click="search">搜索</el-button>
          <!-- <el-button
          size="mini"
          type="danger" @click="excel">导出Excel</el-button> -->
      </div>
      <div class="moreFilter"></div>
    </div>
    <div class="system-table-box">
      <el-table
        :data="currentList"
        stripe
        style="width: 100%">
        <el-table-column
          prop="FromCustomerWxname"
          label="用户昵称">
        </el-table-column>
        <el-table-column
          prop="FromCustomerName"
          label="用户姓名">
        </el-table-column>
        <el-table-column
          prop="FromCustomerTel"
          label="用户手机号">
        </el-table-column>
        <el-table-column
          prop="ToCustomerWxname"
          label="被分享用户昵称">
        </el-table-column>
        <el-table-column
          prop="ToCustomerName"
          label="被分享用户姓名">
        </el-table-column>
        <el-table-column
          prop="ToCustomerTel"
          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>
    </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,
      toPhone: '',
      fromPhone: '',
      postData: { // 表格搜索条件
        page: 1, // 当前页码
        pagesize: 10, // 请求数据量
      },
      currentList: []
    }
  },
  mounted () {
    this.$nextTick(function () {
      this.getList()
    })
  },
  computed: {
    ...mapLuckState({
      list: x => x.luckDrawShareList
    }),
  },
  methods: {
    ...mapLuckActions(['getLuckDrawShareList']),
    search () { // 搜索
      this.postData.page = 1
      this.currentList = []
      this.getList()
    },
    getList () { // 获取列表
      this.getLuckDrawShareList({ ...this.postData, toPhone: this.toPhone, fromPhone: this.fromPhone }).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>
