u
This commit is contained in:
parent
a83000075c
commit
24a77796d1
@ -460,12 +460,6 @@
|
||||
@click="switchTab('positions')">
|
||||
交易所持仓 ({{ exchangePositions.length }})
|
||||
</button>
|
||||
<button
|
||||
class="tab"
|
||||
:class="{ active: currentTab === 'trades' }"
|
||||
@click="switchTab('trades')">
|
||||
成交记录 ({{ tradeHistory.length }})
|
||||
</button>
|
||||
<button
|
||||
class="tab"
|
||||
:class="{ active: currentTab === 'orders' }"
|
||||
@ -488,13 +482,6 @@
|
||||
<p>暂无持仓</p>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentTab === 'trades' && tradeHistory.length === 0" class="empty-state">
|
||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
||||
</svg>
|
||||
<p>暂无成交记录</p>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentTab === 'orders' && orderHistory.length === 0" class="empty-state">
|
||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
||||
@ -516,16 +503,6 @@
|
||||
<th>盈亏比例</th>
|
||||
<th>强平价格</th>
|
||||
</tr>
|
||||
<tr v-else-if="currentTab === 'trades'">
|
||||
<th>交易对</th>
|
||||
<th>方向</th>
|
||||
<th>价格</th>
|
||||
<th>数量</th>
|
||||
<th>成交金额</th>
|
||||
<th>手续费</th>
|
||||
<th>盈亏</th>
|
||||
<th>时间</th>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<th>交易对</th>
|
||||
<th>方向</th>
|
||||
@ -561,53 +538,8 @@
|
||||
<td>${{ pos.liquidationPrice ? parseFloat(pos.liquidationPrice).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) : '-' }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
<!-- 成交记录表格 -->
|
||||
<template v-if="currentTab === 'trades'">
|
||||
<tr v-for="trade in displayOrders" :key="trade.id">
|
||||
<td><strong>{{ formatSymbol(trade.symbol) }}</strong></td>
|
||||
<td>
|
||||
<span class="side-badge" :class="trade.side === 'buy' ? 'side-long' : 'side-short'">
|
||||
{{ trade.side === 'buy' ? '买入' : '卖出' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>${{ trade.price ? parseFloat(trade.price).toLocaleString() : '-' }}</td>
|
||||
<td>{{ trade.amount || trade.filled || '0' }}</td>
|
||||
<td>${{ trade.cost ? parseFloat(trade.cost).toFixed(2) : '-' }}</td>
|
||||
<td>
|
||||
<span :class="getFeeClass(trade)">
|
||||
{{ trade.fee && parseFloat(trade.fee) !== 0 ? (trade.fee > 0 ? '+' : '') + parseFloat(trade.fee).toFixed(4) : '-' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="trade.return !== undefined" :class="parseFloat(trade.return || 0) >= 0 ? 'pnl-positive' : 'pnl-negative'">
|
||||
{{ parseFloat(trade.return || 0) >= 0 ? '+' : '' }}${{ parseFloat(trade.return || 0).toFixed(2) }}
|
||||
</span>
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
<td>{{ formatTime(trade.datetime || trade.timestamp) }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
<!-- 历史订单表格 -->
|
||||
<template v-else-if="currentTab === 'orders'">
|
||||
<tr v-for="order in displayOrders" :key="order.id">
|
||||
<td><strong>{{ formatSymbol(order.symbol) }}</strong></td>
|
||||
<td>
|
||||
<span class="side-badge" :class="order.side === 'buy' ? 'side-long' : 'side-short'">
|
||||
{{ order.side === 'buy' ? '买入' : '卖出' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ order.type || 'market' }}</td>
|
||||
<td>${{ order.price ? parseFloat(order.price).toLocaleString() : '市价' }}</td>
|
||||
<td>{{ order.amount || '0' }}</td>
|
||||
<td>{{ order.filled || '0' }}</td>
|
||||
<td>
|
||||
<span class="status-badge" :class="'status-' + order.status">
|
||||
{{ formatOrderStatus(order.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ formatTime(order.datetime || order.timestamp) }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
<template v-else>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -635,7 +567,6 @@
|
||||
total_position_value: 0
|
||||
},
|
||||
stats: null,
|
||||
tradeHistory: [],
|
||||
orderHistory: [],
|
||||
exchangePositions: [],
|
||||
autoRefreshInterval: null
|
||||
@ -643,7 +574,6 @@
|
||||
},
|
||||
computed: {
|
||||
displayOrders() {
|
||||
if (this.currentTab === 'trades') return this.tradeHistory;
|
||||
if (this.currentTab === 'orders') return this.orderHistory;
|
||||
if (this.currentTab === 'positions') return this.exchangePositions;
|
||||
return [];
|
||||
@ -657,9 +587,7 @@
|
||||
// 切换标签时加载对应数据
|
||||
this.loading = true;
|
||||
try {
|
||||
if (tab === 'trades') {
|
||||
await this.fetchTradeHistory();
|
||||
} else if (tab === 'orders') {
|
||||
if (tab === 'orders') {
|
||||
await this.fetchOrderHistory();
|
||||
}
|
||||
} finally {
|
||||
@ -678,9 +606,7 @@
|
||||
]);
|
||||
|
||||
// 根据当前标签页获取对应数据
|
||||
if (this.currentTab === 'trades') {
|
||||
await this.fetchTradeHistory();
|
||||
} else if (this.currentTab === 'orders') {
|
||||
if (this.currentTab === 'orders') {
|
||||
await this.fetchOrderHistory();
|
||||
}
|
||||
} finally {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user