dcc
2024-06-13 3616db170333df7d668c97323344335b52c4153c
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!-- 资产 -->
<template>
  <div class="right-view">
    <!-- 头部 -->
    <div class="right-header">
      <div class="right-header-box">
        <div>{{ $t("message.user.zichanzonglan") }}</div>
      </div>
    </div>
    <div class="padding-left-right20">
      <!-- 资产 -->
      <el-table
        :data="assetData"
        class="width100"
        :header-cell-style="getRowClass"
        :row-style="rowStyles"
        style="margin: 20px 0"
        :empty-text="$t('message.home.noData')"
      >
        <el-table-column
          prop="create_time_ts"
          :label="$t('message.hangqing.bizhong')"
        >
          <template #default="scope">
            <div class="flex items-center">
              <img
                class="symbol-img"
                :src="handleSymbolImg(scope.row.symbol)"
              />
              {{ scope.row.symbol.toUpperCase() }}
            </div>
          </template>
        </el-table-column>
 
        <el-table-column prop="name" :label="$t('message.jiaoyi.qianbaoyue')">
          <template #default="scope">
            <div>{{ Number(scope.row.volume).toFixed(8) }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="amount" :label="$t('message.user.xian14')">
          <template #default="scope">
            <div>{{ Number(scope.row.usable).toFixed(8) }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="trade_avg_price"
          :label="$t('message.jiaoyi.suocang')"
        >
          <template #default="scope">
            <div>{{ Number(scope.row.lock_amount).toFixed(8) }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="fee" :label="$t('message.jiaoyi.dongjiejine')">
          <template #default="scope">
            <div>{{ Number(scope.row.freeze_amount).toFixed(8) }}</div>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <Pagination
        style="margin: 20px 0"
        :noPre="noPre"
        :noNext="noNext"
        :pageNum="pageNum"
        @changePageNum="changePageNum"
      />
    </div>
  </div>
</template>
 
<script>
import { handleSymbolImg, mergeSort } from "@/utils";
import Pagination from "@/components/common/pagination.vue";
import quotesAxios from "@/api/quotes.js";
 
export default {
  components: { Pagination },
  name: "AssetOverview",
  data() {
    return {
      assetData: [],
      pageNum: 1,
      noNext: false,
      noPre: false,
      totalPageNum: 0,
    };
  },
  mounted() {
    this.getAssets();
  },
  methods: {
    handleSymbolImg,
    //总账户资产
    getAssets() {
      const params = {
        pageNum: this.pageNum,
      };
      quotesAxios.getPairsWallet(params).then((res) => {
        const assetList = res.data.extends;
        let list = [];
        if (assetList.length) {
          list = assetList.filter((it) => it.symbol && it.volume > 0);
        }
 
        this.assetData = list;
      });
    },
    //给表头设置背景颜色
    getRowClass({ rowIndex, columnIndex }) {
      if (rowIndex == 0) {
        return { background: "#f8f8f9" };
      }
    },
    //行高修改,需以对象形式返回
    rowStyles({ row, rowIndex }) {
      let styleJson = {
        height: "50px",
      };
      return styleJson;
    },
 
    //分页
    changePageNum(type) {
      if (type == "next") {
        if (!this.noNext) {
          this.pageNum = this.pageNum + 1;
          this.getAssets();
        }
      } else {
        if (!this.noPre && this.pageNum > 1) {
          this.pageNum = this.pageNum - 1;
          this.getAssetst();
        }
      }
    },
  },
};
</script>
 
<style scoped lang="css">
.img-style {
  width: 20px;
  height: 20px;
}
 
.symbol-img {
  width: 20px;
  margin-right: 5px;
}
</style>