|
| 1 | +<template> |
| 2 | + <div class="app-container calendar-list-container"> |
| 3 | + |
| 4 | + <el-table :data="list" v-loading.body="listLoading" border fit highlight-current-row style="width: 100%"> |
| 5 | + |
| 6 | + <el-table-column align="center" label="序号" width="80"> |
| 7 | + <template scope="scope"> |
| 8 | + <span>{{scope.row.id}}</span> |
| 9 | + </template> |
| 10 | + </el-table-column> |
| 11 | + |
| 12 | + <el-table-column width="180px" align="center" label="时间"> |
| 13 | + <template scope="scope"> |
| 14 | + <span>{{scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}')}}</span> |
| 15 | + </template> |
| 16 | + </el-table-column> |
| 17 | + |
| 18 | + <el-table-column width="120px" align="center" label="作者"> |
| 19 | + <template scope="scope"> |
| 20 | + <span>{{scope.row.author}}</span> |
| 21 | + </template> |
| 22 | + </el-table-column> |
| 23 | + |
| 24 | + <el-table-column width="100px" label="重要性"> |
| 25 | + <template scope="scope"> |
| 26 | + <wscn-icon-svg v-for="n in +scope.row.importance" icon-class="wujiaoxing" class="meta-item__icon" :key="n" /> |
| 27 | + </template> |
| 28 | + </el-table-column> |
| 29 | + |
| 30 | + <el-table-column class-name="status-col" label="状态" width="100"> |
| 31 | + <template scope="scope"> |
| 32 | + <el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag> |
| 33 | + </template> |
| 34 | + </el-table-column> |
| 35 | + |
| 36 | + <el-table-column min-width="300px" label="标题"> |
| 37 | + <template scope="scope"> |
| 38 | + <el-input v-show="scope.row.edit" size="small" v-model="scope.row.title"></el-input> |
| 39 | + <span v-show="!scope.row.edit">{{ scope.row.title }}</span> |
| 40 | + </template> |
| 41 | + </el-table-column> |
| 42 | + |
| 43 | + <el-table-column align="center" label="编辑" width="120"> |
| 44 | + <template scope="scope"> |
| 45 | + <el-button v-show='!scope.row.edit' type="primary" @click='scope.row.edit=true' size="small" icon="edit">编辑</el-button> |
| 46 | + <el-button v-show='scope.row.edit' type="success" @click='scope.row.edit=false' size="small" icon="check">完成</el-button> |
| 47 | + </template> |
| 48 | + </el-table-column> |
| 49 | + |
| 50 | + </el-table> |
| 51 | + </div> |
| 52 | +</template> |
| 53 | + |
| 54 | +<script> |
| 55 | + import { fetchList } from 'api/article_table'; |
| 56 | +
|
| 57 | + export default { |
| 58 | + name: 'inline_edit-table_demo', |
| 59 | + data() { |
| 60 | + return { |
| 61 | + list: null, |
| 62 | + total: null, |
| 63 | + listLoading: true, |
| 64 | + listQuery: { |
| 65 | + page: 1, |
| 66 | + limit: 10 |
| 67 | + } |
| 68 | + } |
| 69 | + }, |
| 70 | + created() { |
| 71 | + this.getList(); |
| 72 | + }, |
| 73 | + filters: { |
| 74 | + statusFilter(status) { |
| 75 | + const statusMap = { |
| 76 | + published: 'success', |
| 77 | + draft: 'gray', |
| 78 | + deleted: 'danger' |
| 79 | + }; |
| 80 | + return statusMap[status] |
| 81 | + } |
| 82 | + }, |
| 83 | + methods: { |
| 84 | + getList() { |
| 85 | + this.listLoading = true; |
| 86 | + fetchList(this.listQuery).then(response => { |
| 87 | + this.list = response.items.map(v => { |
| 88 | + v.edit = false; |
| 89 | + return v |
| 90 | + }); |
| 91 | + this.total = response.total; |
| 92 | + this.listLoading = false; |
| 93 | + }) |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | +</script> |
| 98 | + |
| 99 | +<style > |
| 100 | +
|
| 101 | +</style> |
0 commit comments