<template>
  <div class="app-container">
    <div class="filter-container">
      <el-button
        class="filter-item"
        style="margin-left: 10px;"
        type="primary"
        icon="el-icon-edit"
        @click="handleCreate">创建
      </el-button>
    </div>
    <el-table
      v-loading="listLoading"
      ref="multipleTable"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%"
      @selection-change="handleSelectionChange">
      <el-table-column align="center" label="文案ID ">
        <template slot-scope="scope">
          <router-link :to="'/advertise/edit/'+scope.row.id" class="link-type">
            <span>{{ scope.row.id }}</span>
          </router-link>
        </template>
      </el-table-column>
      <el-table-column align="center" label="文案内容">
        <template slot-scope="scope">
          <span>{{ scope.row.content }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="邀请人数要求">
        <template slot-scope="scope">
          <span>{{ scope.row.invitees_num }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="每次解锁数">
        <template slot-scope="scope">
          <span>{{ scope.row.unlocks_num }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="创建时间">
        <template slot-scope="scope">
          <span>{{ scope.row.create_time }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="更新时间">
        <template slot-scope="scope">
          <span>{{ scope.row.update_time }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { fetchList } from '@/api/advertise'
import waves from '@/directive/waves'

export default {
  name: 'AdvertiseList',
  components: { },
  directives: { waves },
  data() {
    return {
      list: null,
      total: 0,
      listLoading: true,
      multipleSelection: [],
      del_list: [],
      listQuery: {
        page: 0,
        limit: 10
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        console.log(response.data.data)
        this.list = response.data.data.data
        this.total = response.data.data.total
        this.listLoading = false
      })
    },
    handleCreate() {
      this.$router.push('/advertise/create')
    }
  }
}
</script>

<style scoped>
  .edit-input {
    padding-right: 100px;
  }

  .cancel-btn {
    position: absolute;
    right: 15px;
    top: 10px;
  }
</style>