TransactionTable.vue 1.2 KB
Newer Older
P
Pan 已提交
1
<template>
P
Pan 已提交
2
  <el-table :data="list" style="width: 100%;padding-top: 15px;">
P
Pan 已提交
3
    <el-table-column label="Order_No" min-width="200">
P
Pan 已提交
4
      <template slot-scope="scope">
5
        {{ scope.row.order_no | orderNoFilter }}
P
Pan 已提交
6 7 8 9
      </template>
    </el-table-column>
    <el-table-column label="Price" width="195" align="center">
      <template slot-scope="scope">
P
Pan 已提交
10
        ¥{{ scope.row.price | toThousandFilter }}
P
Pan 已提交
11 12
      </template>
    </el-table-column>
P
Pan 已提交
13
    <el-table-column label="Status" width="100" align="center">
P
Pan 已提交
14
      <template slot-scope="scope">
J
Jere 已提交
15 16 17
        <el-tag :type="scope.row.status | statusFilter">
          {{ scope.row.status }}
        </el-tag>
P
Pan 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { fetchList } from '@/api/transaction'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        success: 'success',
        pending: 'danger'
      }
      return statusMap[status]
花裤衩 已提交
34 35 36
    },
    orderNoFilter(str) {
      return str.substring(0, 30)
P
Pan 已提交
37 38
    }
  },
39 40 41 42 43
  data() {
    return {
      list: null
    }
  },
P
Pan 已提交
44 45 46 47 48 49
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      fetchList().then(response => {
P
Pan 已提交
50
        this.list = response.data.items.slice(0, 8)
P
Pan 已提交
51
      })
花裤衩 已提交
52 53
    }
  }
P
Pan 已提交
54 55
}
</script>