<template>
  <div class="payreturnPage">
    <!-- 搜索 -->
    <div class="formSearch">
      <!-- 搜索条件 -->
      <el-form :inline="true" :model="query" class="demo-form-inline">
        <el-form-item label="活动名称">
          <el-input v-model="query.search" maxlength="20" placeholder="请输入活动名称" />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" plain @click="search">查询</el-button>
          <el-button plain @click="clear">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格 -->
    <div class="tableBox">
      <el-table ref="multipleTable" :data="tableData" border :header-cell-style="{ background: '#EEF3FF', color: '#333333' }" tooltip-effect="dark" style="width: 100%">
        <el-table-column align="center" type="index" label="#" width="55"></el-table-column>
        <el-table-column prop="amount" label="免单池金额" align="center">
          <template slot-scope="scope">
            <span style="color: #f40">￥{{ scope.row.amount || '--' }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="platformParticipationFreeActivities.activitiesName" label="对应活动名称" align="center"></el-table-column>

        <el-table-column width="280" label="操作" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="btnList">
              <el-button type="text" @click="$refs.detailModalRef && $refs.detailModalRef.show(scope.row.id)">详情</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="fenye">
        <el-pagination
          :current-page="query.page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </div>

    <!-- 详情 -->
    <DetailModal ref="detailModalRef"></DetailModal>
  </div>
</template>

<script>
import { getFreeQueuingPoolListApi } from '@/api/freeQueuing'
import DetailModal from './components/DetailModal.vue'

export default {
  components: {DetailModal},
  data() {
    return {
      query: { page: 1, pageSize: 10, search: undefined },
      total: 1,
      tableData: []
    }
  },
  created() {
    this.getAll()
  },
  methods: {
    async getAll() {
      const res = await getFreeQueuingPoolListApi(this.query)
      this.tableData = res.data.list
      this.total = res.data.total
    },
    handleSizeChange(val) {
      this.query.pageSize = val
      this.getAll()
    },
    handleCurrentChange(val) {
      this.query.page = val
      this.getAll()
    },
    search() {
      this.total = 1
      this.query.page = 1
      this.getAll()
    },
    clear() {
      this.query = {
        page: 1,
        pageSize: 10,
        search: ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.payreturnPage {
  padding: 30px;

  .tableBox {
    .fenye {
      margin: 20px;
    }
  }
}
</style>
