交易记录新建开仓改为先选品种再选合约

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-26 11:34:36 +08:00
parent 4db07bea59
commit d44e93dd4f
2 changed files with 35 additions and 5 deletions
+23 -5
View File
@@ -34,13 +34,19 @@
<div class="form-card" style="margin-bottom:28px;max-width:100%;">
<form method="post" action="/trades/open">
<div style="display:flex;gap:10px;align-items:flex-end;flex-wrap:wrap;">
<div class="form-group" style="margin-bottom:0;flex:0 0 auto;min-width:100px;">
<label>品种</label>
<select id="productSelect" required onchange="filterContracts()">
<option value="">--</option>
{% for pcode in product_contracts %}
<option value="{{ pcode }}">{{ pcode }}</option>
{% endfor %}
</select>
</div>
<div class="form-group" style="margin-bottom:0;flex:0 0 auto;min-width:120px;">
<label>合约</label>
<select name="contract_code" required>
<option value="">--</option>
{% for c in contracts %}
<option value="{{ c }}">{{ c }}</option>
{% endfor %}
<select name="contract_code" id="contractSelect" required disabled>
<option value="">-- 先选品种 --</option>
</select>
</div>
<div class="form-group" style="margin-bottom:0;flex:0 0 auto;min-width:70px;">
@@ -197,6 +203,18 @@
{% if view != 'closed' %}
<script>
var productContracts = {{ product_contracts | tojson }};
function filterContracts() {
var prod = document.getElementById('productSelect').value;
var sel = document.getElementById('contractSelect');
sel.innerHTML = '<option value="">-- 选择合约 --</option>';
sel.disabled = !prod;
if (prod && productContracts[prod]) {
productContracts[prod].forEach(function(c) {
sel.innerHTML += '<option value="' + c + '">' + c + '</option>';
});
}
}
function showCloseForm(tradeId) {
document.getElementById('closeForm').action = '/trades/' + tradeId + '/close';
document.getElementById('closeFormOverlay').style.display = 'block';