Paginate review list (10/page); show open/close/hold duration in BJT.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-17 22:21:12 +08:00
parent 3164a21348
commit dbfddeedcb
4 changed files with 133 additions and 27 deletions
+5 -2
View File
@@ -11,8 +11,11 @@
<tr><th>账户</th><td>{{ trade.account_name or '—' }}</td></tr>
<tr><th>机器</th><td>{{ trade.machine_name or '—' }}</td></tr>
<tr><th>手数</th><td>{{ trade.volume }}</td></tr>
<tr><th>开仓</th><td>{{ trade.open_price }} / {{ trade.open_time }}</td></tr>
<tr><th>平仓</th><td>{{ trade.close_price }} / {{ trade.close_time }}</td></tr>
<tr><th>开仓价</th><td>{{ trade.open_price }}</td></tr>
<tr><th>平仓价</th><td>{{ trade.close_price if trade.close_price is not none else '—' }}</td></tr>
<tr><th>开仓时间</th><td>{{ trade.open_time_fmt }} <span class="muted">北京时间</span></td></tr>
<tr><th>平仓时间</th><td>{{ trade.close_time_fmt }} <span class="muted">北京时间</span></td></tr>
<tr><th>持仓时间</th><td style="font-weight:700;color:var(--accent)">{{ trade.hold_duration }}</td></tr>
<tr><th>盈亏</th><td>{{ trade.profit }}</td></tr>
<tr><th>SL / TP</th><td>{{ trade.sl }} / {{ trade.tp }}</td></tr>
<tr><th>单号</th><td>{{ trade.ticket or '—' }}</td></tr>
+42 -8
View File
@@ -2,12 +2,12 @@
{% block title %}交易复盘 · {{ app_name }}{% endblock %}
{% block content %}
<h2 style="margin:0 0 6px">交易记录与复盘</h2>
<p class="muted" style="margin:0 0 14px">列表可按机器筛选 → 点开详情 → 四周期 K 线 + 入场形式标注。</p>
<p class="muted" style="margin:0 0 14px">按机器筛选 · 每页 {{ per_page }} 条 · 时间均为北京时间</p>
<div class="card" style="margin-bottom:14px">
<form method="get" action="{{ url_for('records_page') }}" style="display:flex;gap:10px;align-items:center;flex-wrap:wrap">
<label class="muted" for="machine_id">机器</label>
<select name="machine_id" id="machine_id" style="min-width:200px">
<label class="muted" for="machine_id" style="margin:0">机器</label>
<select name="machine_id" id="machine_id" style="min-width:200px;width:auto">
<option value="">全部机器</option>
{% for m in machines %}
<option value="{{ m.id }}" {% if selected_machine_id == m.id %}selected{% endif %}>
@@ -15,20 +15,33 @@
</option>
{% endfor %}
</select>
<input type="hidden" name="page" value="1">
<button type="submit" class="btn">筛选</button>
{% if selected_machine_id %}
<a class="btn secondary" href="{{ url_for('records_page') }}">清除</a>
{% endif %}
<span class="muted">共 {{ trades|length }} 条</span>
<span class="muted">共 {{ total }} 条 · 第 {{ page }}/{{ total_pages }} 页</span>
</form>
</div>
<div class="card">
<div class="card" style="overflow-x:auto">
<table>
<thead>
<tr>
<th>ID</th><th>品种</th><th>方向</th><th>手数</th><th>开仓价</th><th>平仓价</th>
<th>盈亏</th><th>账户</th><th>机器</th><th>入场形式</th><th></th>
<th>ID</th>
<th>品种</th>
<th>方向</th>
<th>手数</th>
<th>开仓价</th>
<th>平仓价</th>
<th>盈亏</th>
<th>开仓时间</th>
<th>平仓时间</th>
<th>持仓时间</th>
<th>账户</th>
<th>机器</th>
<th>入场形式</th>
<th></th>
</tr>
</thead>
<tbody>
@@ -43,15 +56,36 @@
<td style="color:{% if t.profit and t.profit>0 %}var(--green){% elif t.profit and t.profit<0 %}var(--red){% else %}inherit{% endif %}">
{{ t.profit if t.profit is not none else '—' }}
</td>
<td class="muted" style="white-space:nowrap">{{ t.open_time_fmt }}</td>
<td class="muted" style="white-space:nowrap">{{ t.close_time_fmt }}</td>
<td style="white-space:nowrap;font-weight:600;color:var(--accent)">{{ t.hold_duration }}</td>
<td>{{ t.account_name or '—' }}</td>
<td>{{ t.machine_name or '—' }}</td>
<td>{{ t.entry_style or '—' }}</td>
<td><a href="{{ url_for('record_detail', tid=t.id) }}">打开复盘</a></td>
</tr>
{% else %}
<tr><td colspan="11" class="muted">暂无数据。{% if selected_machine_id %}当前机器下没有成交。{% else %}客户端上报成交后出现在此。{% endif %}</td></tr>
<tr><td colspan="14" class="muted">暂无数据。{% if selected_machine_id %}当前机器下没有成交。{% else %}客户端上报成交后出现在此。{% endif %}</td></tr>
{% endfor %}
</tbody>
</table>
{% if total_pages > 1 %}
{% set q = {'page': page} %}
{% if selected_machine_id %}{% set _ = q.update({'machine_id': selected_machine_id}) %}{% endif %}
<div style="display:flex;gap:10px;align-items:center;justify-content:flex-end;margin-top:14px;flex-wrap:wrap">
{% if page > 1 %}
<a class="btn secondary" href="{{ url_for('records_page', page=page-1, machine_id=selected_machine_id) if selected_machine_id else url_for('records_page', page=page-1) }}">上一页</a>
{% else %}
<span class="btn secondary" style="opacity:.4;pointer-events:none">上一页</span>
{% endif %}
<span class="muted">{{ page }} / {{ total_pages }}</span>
{% if page < total_pages %}
<a class="btn secondary" href="{{ url_for('records_page', page=page+1, machine_id=selected_machine_id) if selected_machine_id else url_for('records_page', page=page+1) }}">下一页</a>
{% else %}
<span class="btn secondary" style="opacity:.4;pointer-events:none">下一页</span>
{% endif %}
</div>
{% endif %}
</div>
{% endblock %}