Browse Source

refine: table demo add status

Pan 7 years ago
parent
commit
ee35d1c0a4
1 changed files with 15 additions and 1 deletions
  1. 15 1
      src/views/table/index.vue

+ 15 - 1
src/views/table/index.vue

@@ -11,7 +11,6 @@
11 11
           {{scope.row.title}}
12 12
         </template>
13 13
       </el-table-column>
14
-
15 14
       <el-table-column label="Author" width="110" align="center">
16 15
         <template scope="scope">
17 16
           <span>{{scope.row.author}}</span>
@@ -22,6 +21,11 @@
22 21
           {{scope.row.pageviews}}
23 22
         </template>
24 23
       </el-table-column>
24
+      <el-table-column class-name="status-col" label="Status" width="110" align="center">
25
+        <template scope="scope">
26
+          <el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag>
27
+        </template>
28
+      </el-table-column>
25 29
       <el-table-column align="center" prop="created_at" label="Display_time" width="200">
26 30
         <template scope="scope">
27 31
           <i class="el-icon-time"></i>
@@ -42,6 +46,16 @@ export default {
42 46
       listLoading: true
43 47
     }
44 48
   },
49
+  filters: {
50
+    statusFilter(status) {
51
+      const statusMap = {
52
+        published: 'success',
53
+        draft: 'gray',
54
+        deleted: 'danger'
55
+      }
56
+      return statusMap[status]
57
+    }
58
+  },
45 59
   created() {
46 60
     this.fetchData()
47 61
   },