Blame view

src/views/table/index.vue 2.57 KB
80a28914e   吉鹏   init
1
2
3
4
5
6
7
8
9
10
  <template>
    <div class="app-container">
      <el-table
        v-loading="listLoading"
        :data="list"
        element-loading-text="Loading"
        border
        fit
        highlight-current-row
      >
1172ebb79   Adam   auto commit the c...
11
12
13
14
15
16
        <el-table-column align="center" label="用户id">
          <template slot-scope="scope">{{ scope.$index }}</template>
        </el-table-column>
  
        <el-table-column label="openid">
          <template slot-scope="scope">{{ scope.row.openid }}</template>
80a28914e   吉鹏   init
17
        </el-table-column>
1172ebb79   Adam   auto commit the c...
18
19
  
        <el-table-column label="昵称" width="110" align="center">
80a28914e   吉鹏   init
20
          <template slot-scope="scope">
1172ebb79   Adam   auto commit the c...
21
            <span>{{ scope.row.username }}</span>
80a28914e   吉鹏   init
22
23
          </template>
        </el-table-column>
1172ebb79   Adam   auto commit the c...
24
25
26
27
28
29
  
        <el-table-column label="头像" width="110" align="center">
          <template slot-scope="scope">{{ scope.row.avatar }}</template>
        </el-table-column>
  
        <el-table-column class-name="status-col" label="状态" align="center">
80a28914e   吉鹏   init
30
          <template slot-scope="scope">
1172ebb79   Adam   auto commit the c...
31
            <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
80a28914e   吉鹏   init
32
33
          </template>
        </el-table-column>
1172ebb79   Adam   auto commit the c...
34
35
  
        <el-table-column align="center" prop="created_at" label="注册时间">
80a28914e   吉鹏   init
36
          <template slot-scope="scope">
1172ebb79   Adam   auto commit the c...
37
38
            <i class="el-icon-time" />
            <span>{{ scope.row.create_at }}</span>
80a28914e   吉鹏   init
39
40
          </template>
        </el-table-column>
1172ebb79   Adam   auto commit the c...
41
        <el-table-column align="center" prop="created_at" label="成交记录">
80a28914e   吉鹏   init
42
          <template slot-scope="scope">
1172ebb79   Adam   auto commit the c...
43
44
            <i class="el-icon-time" />
            <span>{{ scope.row.pageviews }}</span>
80a28914e   吉鹏   init
45
46
          </template>
        </el-table-column>
1172ebb79   Adam   auto commit the c...
47
        <el-table-column align="center" prop="created_at" label="引流图">
80a28914e   吉鹏   init
48
          <template slot-scope="scope">
1172ebb79   Adam   auto commit the c...
49
50
51
            <span>
              <el-button type="primary">子用户{{scope.row.pageviews}}</el-button>
            </span>
80a28914e   吉鹏   init
52
53
54
          </template>
        </el-table-column>
      </el-table>
1172ebb79   Adam   auto commit the c...
55
      <el-pagination background layout="prev, pager, next" :total="100"></el-pagination>
80a28914e   吉鹏   init
56
57
58
59
    </div>
  </template>
  
  <script>
1172ebb79   Adam   auto commit the c...
60
  import { getList } from "@/api/table";
80a28914e   吉鹏   init
61
62
63
64
65
  
  export default {
    filters: {
      statusFilter(status) {
        const statusMap = {
1172ebb79   Adam   auto commit the c...
66
67
68
69
70
          published: "success",
          draft: "gray",
          deleted: "danger"
        };
        return statusMap[status];
80a28914e   吉鹏   init
71
72
73
74
75
76
      }
    },
    data() {
      return {
        list: null,
        listLoading: true
1172ebb79   Adam   auto commit the c...
77
      };
80a28914e   吉鹏   init
78
79
    },
    created() {
1172ebb79   Adam   auto commit the c...
80
      this.fetchData();
80a28914e   吉鹏   init
81
82
83
    },
    methods: {
      fetchData() {
1172ebb79   Adam   auto commit the c...
84
        this.listLoading = true;
80a28914e   吉鹏   init
85
        getList().then(response => {
1172ebb79   Adam   auto commit the c...
86
87
88
89
          console.log("----getList---", response);
          this.list = response.data.items;
          this.listLoading = false;
        });
80a28914e   吉鹏   init
90
91
      }
    }
1172ebb79   Adam   auto commit the c...
92
  };
80a28914e   吉鹏   init
93
  </script>