list.vue 3.82 KB
Newer Older
Davve's avatar
Davve committed
1 2 3 4 5 6 7 8 9 10 11
<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input :placeholder="'搜素'" v-model="listQuery.filter.value" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"/>
      <el-select v-model="listQuery.filter.key" :placeholder="'搜索字段'" clearable class="filter-item" style="width: 110px">
        <el-option v-for="item in SearchTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
      </el-select>
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
      <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" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange">
Davve's avatar
Davve committed
12
      <el-table-column align="center" label="推送ID" >
Davve's avatar
Davve committed
13 14 15 16 17 18 19
        <template slot-scope="scope">
          <router-link :to="'/push/edit/'+scope.row.id" class="link-type">
          <span>{{ scope.row.id }}</span>
            </router-link>
        </template>
      </el-table-column>

Davve's avatar
Davve committed
20
      <el-table-column  align="center" label="推送标题">
Davve's avatar
Davve committed
21 22 23 24 25
        <template slot-scope="scope">
          <span>{{ scope.row.title }}</span>
        </template>
      </el-table-column>

Davve's avatar
Davve committed
26
      <el-table-column  align="center" label="推送内容">
Davve's avatar
Davve committed
27 28 29 30 31
        <template slot-scope="scope">
          <span>{{ scope.row.content }}</span>
        </template>
      </el-table-column>

Davve's avatar
Davve committed
32
      <el-table-column  align="center" label="推送时间">
Davve's avatar
Davve committed
33 34 35 36 37
        <template slot-scope="scope">
          <span>{{ scope.row.push_time }}</span>
        </template>
      </el-table-column>

Davve's avatar
Davve committed
38
      <el-table-column  align="center" label="创建时间">
Davve's avatar
Davve committed
39 40 41 42 43
        <template slot-scope="scope">
          <span>{{ scope.row.create_time }}</span>
        </template>
      </el-table-column>

Davve's avatar
Davve committed
44
      <el-table-column  align="center" label="创建用户">
Davve's avatar
Davve committed
45
        <template slot-scope="scope">
Davve's avatar
Davve committed
46
          <span>{{ scope.row.user.name }}</span>
Davve's avatar
Davve committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />

  </div>
</template>

<script>
import { fetchList } from '@/api/push'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import waves from '@/directive/waves'

export default {
  name: 'PushList',
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      list: null,
      total: 0,
      listLoading: true,
      multipleSelection: [],
      del_list: [],
      listQuery: {
Davve's avatar
Davve committed
73
        page: 0,
Davve's avatar
Davve committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
        limit: 10,
        filter: {
          value: '',
          key: '',
        },
      },
      SearchTypeOptions:[
        {'key': 'id', 'display_name': '推送ID'},
        {'key': 'content', 'display_name': '推送内容'},
      ]
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.data.data
        this.total = response.data.data.total
        this.listLoading = false
      })
    },
    handleSelectionChange(val) {
        this.multipleSelection = val;
    },
    handleSizeChange(val) {
      this.listQuery.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.page = val
      this.getList()
    },
    handleFilter() {
Davve's avatar
Davve committed
110
      this.listQuery.page = 1
Davve's avatar
Davve committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
      this.getList()
    },
    handleCreate() {
      this.$router.push('/push/create')
    }
  }
}
</script>

<style scoped>
.edit-input {
  padding-right: 100px;
}
.cancel-btn {
  position: absolute;
  right: 15px;
  top: 10px;
}
</style>