Blame view
src/views/prod/list.vue
3.41 KB
5cb375940
![]() |
1 2 |
<template> <div class="app-container"> |
5cb375940
![]() |
3 |
<el-table |
5cb375940
![]() |
4 5 |
v-loading="listLoading" :data="list" |
5cb375940
![]() |
6 7 8 9 10 11 12 |
border fit highlight-current-row style="width: 100%" > <el-table-column align="center" |
04e55fcfe
![]() |
13 14 |
label="ID" width="80" |
5cb375940
![]() |
15 |
> |
04e55fcfe
![]() |
16 17 |
<template slot-scope="scope"> <span>{{ scope.row.id }}</span> |
5cb375940
![]() |
18 19 20 21 22 23 |
</template> </el-table-column> <el-table-column width="180px" align="center" |
04e55fcfe
![]() |
24 |
label="Date" |
5cb375940
![]() |
25 |
> |
04e55fcfe
![]() |
26 27 |
<template slot-scope="scope"> <span>{{ scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> |
5cb375940
![]() |
28 29 30 31 |
</template> </el-table-column> <el-table-column |
04e55fcfe
![]() |
32 |
width="120px" |
5cb375940
![]() |
33 34 35 |
align="center" label="Author" > |
04e55fcfe
![]() |
36 37 |
<template slot-scope="scope"> <span>{{ scope.row.author }}</span> |
5cb375940
![]() |
38 39 40 41 42 43 44 |
</template> </el-table-column> <el-table-column width="100px" label="Importance" > |
04e55fcfe
![]() |
45 |
<template slot-scope="scope"> |
5cb375940
![]() |
46 |
<svg-icon |
04e55fcfe
![]() |
47 |
v-for="n in +scope.row.importance" |
5cb375940
![]() |
48 49 |
:key="n" icon-class="star" |
04e55fcfe
![]() |
50 |
class="meta-item__icon" |
5cb375940
![]() |
51 52 53 54 55 |
/> </template> </el-table-column> <el-table-column |
5cb375940
![]() |
56 57 58 59 60 61 62 63 64 65 66 67 |
class-name="status-col" label="Status" width="110" > <template slot-scope="{row}"> <el-tag :type="row.status | statusFilter"> {{ row.status }} </el-tag> </template> </el-table-column> <el-table-column |
04e55fcfe
![]() |
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
min-width="300px" label="Title" > <template slot-scope="{row}"> <router-link :to="'/example/edit/'+row.id" class="link-type" > <span>{{ row.title }}</span> </router-link> </template> </el-table-column> <el-table-column |
5cb375940
![]() |
82 |
align="center" |
04e55fcfe
![]() |
83 84 |
label="Actions" width="120" |
5cb375940
![]() |
85 |
> |
04e55fcfe
![]() |
86 87 88 89 90 91 92 93 94 95 |
<template slot-scope="scope"> <router-link :to="'/example/edit/'+scope.row.id"> <el-button type="primary" size="small" icon="el-icon-edit" > Edit </el-button> </router-link> |
5cb375940
![]() |
96 97 98 |
</template> </el-table-column> </el-table> |
04e55fcfe
![]() |
99 100 101 102 103 104 105 106 |
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" /> |
5cb375940
![]() |
107 108 109 110 |
</div> </template> <script> |
04e55fcfe
![]() |
111 112 |
import { fetchList } from '@/api/article' import Pagination from '@/components/Pagination' // Secondary package based on el-pagination |
5cb375940
![]() |
113 114 |
export default { |
04e55fcfe
![]() |
115 116 |
name: 'ArticleList', components: { Pagination }, |
5cb375940
![]() |
117 118 119 120 121 122 123 124 125 126 127 128 129 |
filters: { statusFilter(status) { const statusMap = { published: 'success', draft: 'info', deleted: 'danger' } return statusMap[status] } }, data() { return { list: null, |
04e55fcfe
![]() |
130 |
total: 0, |
5cb375940
![]() |
131 132 133 |
listLoading: true, listQuery: { page: 1, |
04e55fcfe
![]() |
134 135 |
limit: 20 } |
5cb375940
![]() |
136 137 138 139 140 141 |
} }, created() { this.getList() }, methods: { |
04e55fcfe
![]() |
142 |
getList() { |
5cb375940
![]() |
143 |
this.listLoading = true |
04e55fcfe
![]() |
144 145 146 147 |
fetchList(this.listQuery).then(response => { this.list = response.data.items this.total = response.data.total this.listLoading = false |
5cb375940
![]() |
148 149 150 151 152 |
}) } } } </script> |
5cb375940
![]() |
153 |
<style scoped> |
04e55fcfe
![]() |
154 155 |
.edit-input { padding-right: 100px; |
5cb375940
![]() |
156 |
} |
04e55fcfe
![]() |
157 158 159 160 |
.cancel-btn { position: absolute; right: 15px; top: 10px; |
5cb375940
![]() |
161 162 |
} </style> |