Blame view
src/views/prod/list.vue
3.41 KB
5cb375940 auto commit the c... |
1 2 |
<template> <div class="app-container"> |
5cb375940 auto commit the c... |
3 |
<el-table |
5cb375940 auto commit the c... |
4 5 |
v-loading="listLoading" :data="list" |
5cb375940 auto commit the c... |
6 7 8 9 10 11 12 |
border fit highlight-current-row style="width: 100%" > <el-table-column align="center" |
04e55fcfe auto commit the c... |
13 14 |
label="ID" width="80" |
5cb375940 auto commit the c... |
15 |
> |
04e55fcfe auto commit the c... |
16 17 |
<template slot-scope="scope"> <span>{{ scope.row.id }}</span> |
5cb375940 auto commit the c... |
18 19 20 21 22 23 |
</template> </el-table-column> <el-table-column width="180px" align="center" |
04e55fcfe auto commit the c... |
24 |
label="Date" |
5cb375940 auto commit the c... |
25 |
> |
04e55fcfe auto commit the c... |
26 27 |
<template slot-scope="scope"> <span>{{ scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> |
5cb375940 auto commit the c... |
28 29 30 31 |
</template> </el-table-column> <el-table-column |
04e55fcfe auto commit the c... |
32 |
width="120px" |
5cb375940 auto commit the c... |
33 34 35 |
align="center" label="Author" > |
04e55fcfe auto commit the c... |
36 37 |
<template slot-scope="scope"> <span>{{ scope.row.author }}</span> |
5cb375940 auto commit the c... |
38 39 40 41 42 43 44 |
</template> </el-table-column> <el-table-column width="100px" label="Importance" > |
04e55fcfe auto commit the c... |
45 |
<template slot-scope="scope"> |
5cb375940 auto commit the c... |
46 |
<svg-icon |
04e55fcfe auto commit the c... |
47 |
v-for="n in +scope.row.importance" |
5cb375940 auto commit the c... |
48 49 |
:key="n" icon-class="star" |
04e55fcfe auto commit the c... |
50 |
class="meta-item__icon" |
5cb375940 auto commit the c... |
51 52 53 54 55 |
/> </template> </el-table-column> <el-table-column |
5cb375940 auto commit the c... |
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 auto commit the c... |
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 auto commit the c... |
82 |
align="center" |
04e55fcfe auto commit the c... |
83 84 |
label="Actions" width="120" |
5cb375940 auto commit the c... |
85 |
> |
04e55fcfe auto commit the c... |
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 auto commit the c... |
96 97 98 |
</template> </el-table-column> </el-table> |
04e55fcfe auto commit the c... |
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 auto commit the c... |
107 108 109 110 |
</div> </template> <script> |
04e55fcfe auto commit the c... |
111 112 |
import { fetchList } from '@/api/article' import Pagination from '@/components/Pagination' // Secondary package based on el-pagination |
5cb375940 auto commit the c... |
113 114 |
export default { |
04e55fcfe auto commit the c... |
115 116 |
name: 'ArticleList', components: { Pagination }, |
5cb375940 auto commit the c... |
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 auto commit the c... |
130 |
total: 0, |
5cb375940 auto commit the c... |
131 132 133 |
listLoading: true, listQuery: { page: 1, |
04e55fcfe auto commit the c... |
134 135 |
limit: 20 } |
5cb375940 auto commit the c... |
136 137 138 139 140 141 |
} }, created() { this.getList() }, methods: { |
04e55fcfe auto commit the c... |
142 |
getList() { |
5cb375940 auto commit the c... |
143 |
this.listLoading = true |
04e55fcfe auto commit the c... |
144 145 146 147 |
fetchList(this.listQuery).then(response => { this.list = response.data.items this.total = response.data.total this.listLoading = false |
5cb375940 auto commit the c... |
148 149 150 151 152 |
}) } } } </script> |
5cb375940 auto commit the c... |
153 |
<style scoped> |
04e55fcfe auto commit the c... |
154 155 |
.edit-input { padding-right: 100px; |
5cb375940 auto commit the c... |
156 |
} |
04e55fcfe auto commit the c... |
157 158 159 160 |
.cancel-btn { position: absolute; right: 15px; top: 10px; |
5cb375940 auto commit the c... |
161 162 |
} </style> |