dcc
2024-06-13 cfdf967764dc6747a7b414b33fb993aeede1294d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
  <div class="right-padding">
    <div class="right-title">{{ $t("message.user.duihuanlishi") }}</div>
    <div class="margin-top-bottom20">
      <el-table
        :data="tableData"
        class="width100"
        :header-row-class-name="getRowClass"
        :empty-text="$t('message.home.noData')"
      >
        <el-table-column
          prop="create_time"
          :label="$t('message.user.shijian')"
        ></el-table-column>
        <el-table-column prop="symbol" :label="$t('message.user.maichu')">
          <template #default="scope">
            <div>
              {{ scope.row.amount }} {{ scope.row.symbol?.toUpperCase() }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="symbol_to" :label="$t('message.user.mairu')">
          <template #default="scope">
            <div>
              {{ scope.row.amount_to }} {{ scope.row.symbol_to?.toUpperCase() }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="state" :label="$t('message.user.zhuangtai')">
          <template #default="scope">
            <div
              :class="{
                green: scope.row.state == 'created',
                blue: scope.row.state == 'submitted',
                red: scope.row.state == 'canceled',
              }"
            >
              {{ status[scope.row.state] }}
            </div>
          </template>
        </el-table-column>
      </el-table>
 
      <!-- 分页 -->
      <el-pagination
        class="pagination-box"
        v-model:current-page="pageNum"
        default-page-size="20"
        layout="total, prev, pager, next, jumper"
        :total="tableLength"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>
<script>
// TODO 接口出参变了,兑换列表,
import { getExchangeOrder } from "@/api/order.js";
export default {
  name: "exchangeHistory",
  data() {
    return {
      tableData: [], //列表数组
      total: 0,
      pageNum: 1,
      tableLength: 0,
      isNext: false,
      status: {
        submitted: this.$t("message.user.yitijiao"),
        canceled: this.$t("message.user.yichexiao"),
        created: this.$t("message.user.yiwancheng"),
      },
    };
  },
  mounted() {
    let spToken = localStorage.getItem("spToken");
    if (spToken) {
      this.getList();
    }
  },
  methods: {
    //获取列表数据
    async getList() {
      const res = await getExchangeOrder({
        page_no: this.pageNum,
      });
      this.tableData = res.data;
      this.tableLength = res.data.length;
    },
 
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getList();
    },
 
    //给表头设置边框线
    getRowClass({ rowIndex, columnIndex }) {
      if (rowIndex == 0) {
        return "border-top:1px solid #EBEEF5";
      }
    },
  },
};
</script>
<style scoped>
.pagination-box {
  justify-content: center;
  display: flex;
  margin-top: 20px;
}
</style>