diff --git a/ft-app/app/templates/contract.html b/ft-app/app/templates/contract.html
index 11b2817..f76281c 100644
--- a/ft-app/app/templates/contract.html
+++ b/ft-app/app/templates/contract.html
@@ -46,7 +46,7 @@
— |
— |
— |
- {{ next_amp }} |
+ {{ next_amp }} |
{% endif %}
{% for row in rows %}
@@ -84,32 +84,44 @@ document.querySelectorAll('.amp-cell').forEach(function(cell) {
cell.addEventListener('click', function() {
var row = cell.parentElement.parentElement;
var tbl = document.getElementById('bars-table');
- // Only rows with data-index (skip header + next-day row)
var dataRows = tbl.querySelectorAll('tr[data-index]');
+
+ // Next-day row: use latest 5 data rows
+ if (cell.dataset.next) {
+ if (dataRows.length < 5) return;
+ showDrawer(cell, '{{ contract }}', dataRows, 0, 5);
+ return;
+ }
+
var idx = parseInt(row.dataset.index);
// Need 5 older rows (higher index, since newest first)
if (idx + 5 >= dataRows.length) return;
-
- document.getElementById('drawer-title').textContent = '{{ contract }}';
- document.getElementById('drawer-date').textContent = '目标: ' + row.dataset.date + ' ' + row.dataset.weekday + ' 振幅 ' + cell.textContent.trim();
-
- var html = '| 日期 | 最高−最低 |
';
- var sum = 0;
- for (var j = idx + 1; j <= idx + 5; j++) {
- var r = dataRows[j];
- html += '| ' + r.dataset.date + ' ' + r.dataset.weekday + ' | ' + r.dataset.diff + ' |
';
- sum += parseInt(r.dataset.diff);
- }
- document.getElementById('drawer-table').innerHTML = html;
- document.getElementById('drawer-result').innerHTML = '合计 ' + sum + ' ÷ 5 = ' + (sum / 5).toFixed(1) + '
四舍五入 → ' + Math.round(sum / 5) + '';
-
- document.getElementById('overlay').classList.add('show');
- document.getElementById('drawer').classList.add('show');
-
- if (activeRow) activeRow.classList.remove('active');
- row.classList.add('active');
- activeRow = row;
+ showDrawer(cell, '{{ contract }}', dataRows, idx + 1, idx + 5);
});
});
+
+function showDrawer(cell, product, dataRows, fromIdx, toIdx) {
+ document.getElementById('drawer-title').textContent = product;
+ var label = cell.dataset.next ? '次日预测' : '目标';
+ document.getElementById('drawer-date').textContent = label + ' 振幅 ' + cell.textContent.trim();
+
+ var html = '| 日期 | 最高−最低 |
';
+ var sum = 0;
+ for (var j = fromIdx; j <= toIdx; j++) {
+ var r = dataRows[j];
+ html += '| ' + r.dataset.date + ' ' + r.dataset.weekday + ' | ' + r.dataset.diff + ' |
';
+ sum += parseInt(r.dataset.diff);
+ }
+ document.getElementById('drawer-table').innerHTML = html;
+ document.getElementById('drawer-result').innerHTML = '合计 ' + sum + ' ÷ 5 = ' + (sum / 5).toFixed(1) + '
四舍五入 → ' + Math.round(sum / 5) + '';
+
+ document.getElementById('overlay').classList.add('show');
+ document.getElementById('drawer').classList.add('show');
+
+ var row = cell.parentElement.parentElement;
+ if (activeRow) activeRow.classList.remove('active');
+ row.classList.add('active');
+ activeRow = row;
+}
{% endblock %}