Align trade record verify/edit UX with Binance instance single-row prompts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-30 22:02:48 +08:00
parent b6b7bfb248
commit 32838daae0
5 changed files with 259 additions and 139 deletions
+71 -106
View File
@@ -7,11 +7,14 @@
{% block content %}
{% macro trade_detail_json(t) -%}
{{ {
"id": t.id,
"symbol": t.symbol_name or t.symbol,
"symbol_code": t.symbol,
"symbol_name": t.symbol_name or t.symbol,
"monitor_type": t.monitor_type,
"source": "柜台" if t.source == "ctp" else "本地",
"direction": "做多" if t.direction == "long" else "做空",
"direction_code": t.direction,
"entry_price": t.entry_price,
"close_price": t.close_price,
"stop_loss": t.stop_loss,
@@ -47,31 +50,42 @@
{% macro trade_pnl_cell(v) %}
{% if v is not none %}{% set n = v|float %}<span class="{% if n > 0 %}pnl-pos{% elif n < 0 %}pnl-neg{% endif %}">{{ ('+' if n > 0 else '') ~ ('%.2f'|format(n)) }} 元</span>{% else %}—{% endif %}
{% endmacro %}
{% macro trade_edit_json(t) -%}
{{ {
"id": t.id,
"symbol_name": t.symbol_name or t.symbol,
"monitor_type": t.monitor_type,
"direction": t.direction,
"entry_price": t.entry_price,
"close_price": t.close_price,
"stop_loss": t.stop_loss,
"take_profit": t.take_profit,
"lots": t.lots,
"margin": t.margin,
"holding_minutes": t.holding_minutes or 0,
"open_time": t.open_time,
"close_time": t.close_time,
"pnl": t.pnl,
"result": t.result,
}|tojson }}
{%- endmacro %}
{% macro trade_review_edit_btn(t) %}
<button
type="button"
class="btn-records-action review-edit-btn"
data-trade-edit='{{ trade_edit_json(t)|trim }}'
disabled
>核对修改</button>
{% endmacro %}
{% macro trade_verify_form(t) %}
<form method="post" action="{{ url_for('update_trade', tid=t.id) }}" class="records-trade-verify-form">
<input type="hidden" name="symbol_name" value="{{ t.symbol_name or t.symbol }}">
<input type="hidden" name="monitor_type" value="{{ t.monitor_type }}">
<input type="hidden" name="direction" value="{{ t.direction }}">
<input type="hidden" name="entry_price" value="{{ t.entry_price }}">
<input type="hidden" name="stop_loss" value="{{ t.stop_loss }}">
<input type="hidden" name="take_profit" value="{{ t.take_profit }}">
<input type="hidden" name="close_price" value="{{ t.close_price or '' }}">
<input type="hidden" name="lots" value="{{ t.lots }}">
<input type="hidden" name="margin" value="{{ t.margin or '' }}">
<input type="hidden" name="holding_minutes" value="{{ t.holding_minutes or 0 }}">
<input type="hidden" name="open_time" value="{{ t.open_time or '' }}">
<input type="hidden" name="close_time" value="{{ t.close_time or '' }}">
<input type="hidden" name="pnl" value="{{ t.pnl or '' }}">
<input type="hidden" name="result" value="{{ t.result }}">
<button type="submit" class="btn-verify" {% if t.verified %}disabled{% endif %}>核对修改</button>
</form>
{{ trade_review_edit_btn(t) }}
{% endmacro %}
{% macro trade_row_actions(t, detail_class) %}
<div class="trade-actions records-trade-row-actions">
<button type="button" class="btn-link {{ detail_class }}">详情</button>
<a href="{{ url_for('fill_review_from_trade', tid=t.id) }}" class="btn-fill">填入复盘</a>
{{ trade_verify_form(t) }}
<a href="{{ url_for('del_trade', tid=t.id) }}" class="btn-del" onclick="return confirm('删除?')">删除</a>
<a href="{{ url_for('fill_review_from_trade', tid=t.id) }}" class="btn-records-action">填入复盘</a>
{{ trade_review_edit_btn(t) }}
<a href="{{ url_for('del_trade', tid=t.id) }}" class="btn-records-del" onclick="return confirm('删除?')">删除</a>
</div>
{% endmacro %}
<div class="records-page">
@@ -96,9 +110,9 @@
<p class="hint" style="margin-top:0;margin-bottom:.75rem">
跨日持仓的盈亏以<strong>平仓价</strong>与柜台结算为准;表格中「开仓价」为程序记录,「平仓价」为成交回报,二者不一致时请以平仓价核对净盈亏。
</p>
<label class="trade-switch-label records-desktop-only">
<label class="trade-switch-label records-verify-toggle">
<input type="checkbox" id="trade-edit-switch">
<span>修改/核对开关(开启后可编辑关键字段</span>
<span>修改/核对开关(开启后可点击各行「核对修改」</span>
</label>
<div class="records-mobile-list records-phone-only" id="records-trade-mobile">
{% for t in trades %}
@@ -181,106 +195,57 @@
</thead>
<tbody>
{% for t in trades %}
<tr data-trade-id="{{ t.id }}">
<tr id="trade-row-{{ t.id }}" data-trade-id="{{ t.id }}">
<td><span class="cell-readonly">{{ t.symbol_name or t.symbol }}</span></td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.monitor_type }}</span>
<span class="cell-readonly">{{ t.monitor_type }}</span>
{% if t.source == 'ctp' %}
<span class="badge" style="margin-left:.25rem;font-size:.65rem">柜台</span>
<span class="badge records-src-badge">柜台</span>
{% else %}
<span class="text-muted" style="margin-left:.25rem;font-size:.65rem">本地</span>
<span class="text-muted records-src-badge">本地</span>
{% endif %}
<input class="cell-edit-show" type="hidden" name="monitor_type" value="{{ t.monitor_type }}">
</td>
<td>
<span class="cell-readonly cell-edit-hide">
<span class="badge dir">{{ '做多' if t.direction == 'long' else '做空' }}</span>
</span>
<select class="cell-edit-show" name="direction" style="display:none">
<option value="long" {% if t.direction=='long' %}selected{% endif %}>做多</option>
<option value="short" {% if t.direction=='short' %}selected{% endif %}>做空</option>
</select>
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.entry_price if t.entry_price is not none else '-' }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="entry_price" value="{{ t.entry_price }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.close_price if t.close_price is not none else '-' }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="close_price" value="{{ t.close_price or '' }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.stop_loss }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="stop_loss" value="{{ t.stop_loss }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.take_profit }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="take_profit" value="{{ t.take_profit }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.lots }}</span>
<input class="cell-edit-show" type="number" step="0.01" name="lots" value="{{ t.lots }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.margin if t.margin is not none else '-' }}</span>
<input class="cell-edit-show" type="number" step="0.01" name="margin" value="{{ t.margin or '' }}" placeholder="保证金" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">
{% if t.margin_pct is not none %}{{ t.margin_pct }}%{% else %}-{% endif %}
<span class="badge dir {% if t.direction == 'long' %}dir-long{% else %}dir-short{% endif %}">
{{ '做多' if t.direction == 'long' else '做空' }}
</span>
</td>
<td>{% if t.entry_price is not none %}{{ '%.2f'|format(t.entry_price|float) }}{% else %}—{% endif %}</td>
<td>{% if t.close_price is not none %}{{ '%.2f'|format(t.close_price|float) }}{% else %}—{% endif %}</td>
<td>{% if t.stop_loss is not none %}{{ '%.2f'|format(t.stop_loss|float) }}{% else %}—{% endif %}</td>
<td>{% if t.take_profit is not none %}{{ '%.2f'|format(t.take_profit|float) }}{% else %}—{% endif %}</td>
<td>{% if t.lots is not none %}{{ '%.2f'|format(t.lots|float) }}{% else %}—{% endif %}</td>
<td>{% if t.margin is not none %}{{ '%.2f'|format(t.margin|float) }}{% else %}—{% endif %}</td>
<td>{% if t.margin_pct is not none %}{{ t.margin_pct }}%{% else %}—{% endif %}</td>
<td>{{ t.holding_minutes or 0 }}</td>
<td>{{ (t.open_time or '')[:16].replace('T',' ') or '—' }}</td>
<td>{{ (t.close_time or '')[:16].replace('T',' ') or '—' }}</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.holding_minutes or 0 }}</span>
<input class="cell-edit-show" type="number" name="holding_minutes" value="{{ t.holding_minutes or 0 }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ (t.open_time or '')[:16].replace('T',' ') }}</span>
<input class="cell-edit-show" type="text" name="open_time" value="{{ t.open_time or '' }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ (t.close_time or '')[:16].replace('T',' ') }}</span>
<input class="cell-edit-show" type="text" name="close_time" value="{{ t.close_time or '' }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide {% if t.pnl and t.pnl > 0 %}text-profit{% elif t.pnl and t.pnl < 0 %}text-loss{% endif %}">
{{ t.pnl if t.pnl is not none else '-' }}
</span>
<input class="cell-edit-show" type="number" step="0.01" name="pnl" value="{{ t.pnl or '' }}" style="display:none">
<input type="hidden" name="symbol_name" value="{{ t.symbol_name or t.symbol }}">
</td>
<td><span class="cell-readonly text-muted">{{ t.fee if t.fee is not none else '-' }}</span></td>
<td>
<span class="cell-readonly {% if t.pnl_net and t.pnl_net > 0 %}text-profit{% elif t.pnl_net and t.pnl_net < 0 %}text-loss{% endif %}">
{{ t.pnl_net if t.pnl_net is not none else '-' }}
<span class="{% if t.pnl and t.pnl > 0 %}text-profit{% elif t.pnl and t.pnl < 0 %}text-loss{% endif %}">
{{ t.pnl if t.pnl is not none else '—' }}
</span>
</td>
<td><span class="text-muted">{{ t.fee if t.fee is not none else '—' }}</span></td>
<td>
<span class="cell-readonly">{{ t.equity_after if t.equity_after is not none else '-' }}</span>
</td>
<td>
<span class="cell-readonly cell-edit-hide">
{% if t.result == '止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '止损' %}<span class="badge loss">{{ t.result }}</span>
{% elif t.result == '移动止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '保本止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '手动平仓' %}<span class="badge result-manual">{{ t.result }}</span>
{% else %}<span class="badge result-external">{{ t.result }}</span>{% endif %}
{% if t.verified %}<span class="badge active" style="margin-left:.25rem">已核对</span>{% endif %}
<span class="{% if t.pnl_net and t.pnl_net > 0 %}text-profit{% elif t.pnl_net and t.pnl_net < 0 %}text-loss{% endif %}">
{{ t.pnl_net if t.pnl_net is not none else '—' }}
</span>
<select class="cell-edit-show" name="result" style="display:none">
<option value="手动平仓" {% if t.result=='手动平仓' %}selected{% endif %}>手动平仓</option>
<option value="止盈" {% if t.result=='止盈' %}selected{% endif %}>止盈</option>
<option value="止损" {% if t.result=='止损' %}selected{% endif %}>止损</option>
<option value="移动止盈" {% if t.result=='移动止盈' %}selected{% endif %}>移动止盈</option>
<option value="保本止盈" {% if t.result=='保本止盈' %}selected{% endif %}>保本止盈</option>
</select>
</td>
<td>{{ t.equity_after if t.equity_after is not none else '—' }}</td>
<td>
{% if t.result == '止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '止损' %}<span class="badge loss">{{ t.result }}</span>
{% elif t.result == '移动止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '保本止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '手动平仓' %}<span class="badge result-manual">{{ t.result }}</span>
{% else %}<span class="badge result-external">{{ t.result }}</span>{% endif %}
{% if t.verified %}<span class="badge active records-verified-inline">已核对</span>{% endif %}
</td>
<td>
<div class="trade-actions">
<a href="{{ url_for('fill_review_from_trade', tid=t.id) }}" class="btn-fill">填入复盘</a>
<button type="button" class="btn-verify trade-save-btn" disabled>核对修改</button>
<a href="{{ url_for('del_trade', tid=t.id) }}" class="btn-del" onclick="return confirm('删除?')">删除</a>
<div class="trade-actions records-trade-actions">
<a href="{{ url_for('fill_review_from_trade', tid=t.id) }}" class="btn-records-action">填入复盘</a>
{{ trade_review_edit_btn(t) }}
<a href="{{ url_for('del_trade', tid=t.id) }}" class="btn-records-del" onclick="return confirm('删除?')">删除</a>
</div>
</td>
</tr>