update
This commit is contained in:
parent
de07521465
commit
4a357b56c0
@ -1321,7 +1321,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 收益率图表 -->
|
<!-- 收益率图表 -->
|
||||||
<div v-if="activeTab === 'returns'">
|
<div v-show="activeTab === 'returns'">
|
||||||
<h3 style="color: var(--text-primary); font-weight: 300; margin-bottom: 16px;">每日收益率</h3>
|
<h3 style="color: var(--text-primary); font-weight: 300; margin-bottom: 16px;">每日收益率</h3>
|
||||||
|
|
||||||
<!-- 汇总卡片 -->
|
<!-- 汇总卡片 -->
|
||||||
@ -1399,7 +1399,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="day in dailyReturns" :key="day.date">
|
<tr v-for="day in displayedDailyReturns" :key="day.date">
|
||||||
<td>{{ day.date }}</td>
|
<td>{{ day.date }}</td>
|
||||||
<td :class="day.return_percent >= 0 ? 'positive' : 'negative'">
|
<td :class="day.return_percent >= 0 ? 'positive' : 'negative'">
|
||||||
{{ day.return_percent >= 0 ? '+' : '' }}{{ day.return_percent }}%
|
{{ day.return_percent >= 0 ? '+' : '' }}{{ day.return_percent }}%
|
||||||
@ -2147,13 +2147,25 @@
|
|||||||
if (tradingDays === 0) return 0;
|
if (tradingDays === 0) return 0;
|
||||||
const totalReturn = this.dailyReturns.reduce((sum, d) => sum + d.return_percent, 0);
|
const totalReturn = this.dailyReturns.reduce((sum, d) => sum + d.return_percent, 0);
|
||||||
return totalReturn / tradingDays;
|
return totalReturn / tradingDays;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 显示的每日收益率(倒序,前15条)
|
||||||
|
displayedDailyReturns() {
|
||||||
|
return [...this.dailyReturns].reverse().slice(0, 15);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// 监听标签页切换,加载收益率数据
|
// 监听标签页切换,加载收益率数据并渲染图表
|
||||||
activeTab(newTab) {
|
activeTab(newTab) {
|
||||||
if (newTab === 'returns' && this.dailyReturns.length === 0) {
|
if (newTab === 'returns') {
|
||||||
this.fetchDailyReturns();
|
if (this.dailyReturns.length === 0) {
|
||||||
|
this.fetchDailyReturns();
|
||||||
|
} else {
|
||||||
|
// 数据已存在,需要重新渲染图表
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.renderCharts();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user