Kaynağa Gözat

refine: table demo add status

Pan 7 yıl önce
ebeveyn
işleme
ee35d1c0a4
1 değiştirilmiş dosya ile 15 ekleme ve 1 silme
  1. 15 1
      src/views/table/index.vue

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

@@ -11,7 +11,6 @@
11
           {{scope.row.title}}
11
           {{scope.row.title}}
12
         </template>
12
         </template>
13
       </el-table-column>
13
       </el-table-column>
14
-
15
       <el-table-column label="Author" width="110" align="center">
14
       <el-table-column label="Author" width="110" align="center">
16
         <template scope="scope">
15
         <template scope="scope">
17
           <span>{{scope.row.author}}</span>
16
           <span>{{scope.row.author}}</span>
@@ -22,6 +21,11 @@
22
           {{scope.row.pageviews}}
21
           {{scope.row.pageviews}}
23
         </template>
22
         </template>
24
       </el-table-column>
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
       <el-table-column align="center" prop="created_at" label="Display_time" width="200">
29
       <el-table-column align="center" prop="created_at" label="Display_time" width="200">
26
         <template scope="scope">
30
         <template scope="scope">
27
           <i class="el-icon-time"></i>
31
           <i class="el-icon-time"></i>
@@ -42,6 +46,16 @@ export default {
42
       listLoading: true
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
   created() {
59
   created() {
46
     this.fetchData()
60
     this.fetchData()
47
   },
61
   },