对冲管理新增品种筛选,合约下拉去掉品种前缀

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-26 11:37:40 +08:00
parent d44e93dd4f
commit e3f288083c
3 changed files with 41 additions and 8 deletions
+27 -6
View File
@@ -16,15 +16,21 @@
<div class="form-card" style="margin-bottom:28px;">
<form method="post" action="/positions/round">
<div style="display:flex;gap:12px;align-items:flex-end;flex-wrap:wrap;">
<div class="form-group" style="margin-bottom:0;flex:1;min-width:140px;">
<label>合约</label>
<select name="contract_code" required>
<option value="">-- 选择合约 --</option>
{% for c in contracts %}
<option value="{{ c }}">{{ c }}</option>
<div class="form-group" style="margin-bottom:0;flex:1;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:1;min-width:120px;">
<label>合约</label>
<select name="contract_code" id="contractSelect" required disabled>
<option value="">-- 先选品种 --</option>
</select>
</div>
<div class="form-group" style="margin-bottom:0;flex:1;min-width:100px;">
<label>每日手数 N</label>
<input type="number" name="daily_hands" value="1" min="1" max="10" required>
@@ -161,4 +167,19 @@
</div>
{% endfor %}
<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) {
var display = c.startsWith(prod) ? c.substring(prod.length) : c;
sel.innerHTML += '<option value="' + c + '">' + display + '</option>';
});
}
}
</script>
{% endblock %}
+2 -1
View File
@@ -211,7 +211,8 @@ function filterContracts() {
sel.disabled = !prod;
if (prod && productContracts[prod]) {
productContracts[prod].forEach(function(c) {
sel.innerHTML += '<option value="' + c + '">' + c + '</option>';
var display = c.startsWith(prod) ? c.substring(prod.length) : c;
sel.innerHTML += '<option value="' + c + '">' + display + '</option>';
});
}
}