refine: table demo add status

This commit is contained in:
Pan 2017-09-15 13:50:00 +08:00
parent 3f4e9cc50f
commit ee35d1c0a4
1 changed files with 15 additions and 1 deletions

View File

@ -11,7 +11,6 @@
{{scope.row.title}} {{scope.row.title}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="Author" width="110" align="center"> <el-table-column label="Author" width="110" align="center">
<template scope="scope"> <template scope="scope">
<span>{{scope.row.author}}</span> <span>{{scope.row.author}}</span>
@ -22,6 +21,11 @@
{{scope.row.pageviews}} {{scope.row.pageviews}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column class-name="status-col" label="Status" width="110" align="center">
<template scope="scope">
<el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" prop="created_at" label="Display_time" width="200"> <el-table-column align="center" prop="created_at" label="Display_time" width="200">
<template scope="scope"> <template scope="scope">
<i class="el-icon-time"></i> <i class="el-icon-time"></i>
@ -42,6 +46,16 @@ export default {
listLoading: true listLoading: true
} }
}, },
filters: {
statusFilter(status) {
const statusMap = {
published: 'success',
draft: 'gray',
deleted: 'danger'
}
return statusMap[status]
}
},
created() { created() {
this.fetchData() this.fetchData()
}, },