条件单拆成进行中与已结束两表,并展示开仓时间。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+94
-57
@@ -152,6 +152,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isActiveOrder(o) {
|
||||||
|
const st = String((o && o.status) || "");
|
||||||
|
return st === "armed" || st === "triggering" || st === "open";
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatOpenTime(o) {
|
||||||
|
const raw = String((o && o.opened_at) || "").trim();
|
||||||
|
if (!raw) return "—";
|
||||||
|
return raw.replace("T", " ").slice(0, 19);
|
||||||
|
}
|
||||||
|
|
||||||
function renderPhoneOrderCard(o) {
|
function renderPhoneOrderCard(o) {
|
||||||
const exit = orderExitText(o);
|
const exit = orderExitText(o);
|
||||||
const meta = [];
|
const meta = [];
|
||||||
@@ -176,6 +187,9 @@
|
|||||||
escapeHtml(orderTriggerText(o)) +
|
escapeHtml(orderTriggerText(o)) +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
(meta.length ? '<div class="hub-phone-cond-meta muted">' + escapeHtml(meta.join(" · ")) + "</div>" : "") +
|
(meta.length ? '<div class="hub-phone-cond-meta muted">' + escapeHtml(meta.join(" · ")) + "</div>" : "") +
|
||||||
|
'<div class="hub-phone-cond-meta muted">开仓 ' +
|
||||||
|
escapeHtml(formatOpenTime(o)) +
|
||||||
|
"</div>" +
|
||||||
(o.message ? '<div class="hub-phone-cond-msg muted">' + escapeHtml(o.message) + "</div>" : "") +
|
(o.message ? '<div class="hub-phone-cond-msg muted">' + escapeHtml(o.message) + "</div>" : "") +
|
||||||
(actions ? '<div class="hub-phone-cond-actions">' + actions + "</div>" : "") +
|
(actions ? '<div class="hub-phone-cond-actions">' + actions + "</div>" : "") +
|
||||||
"</article>"
|
"</article>"
|
||||||
@@ -274,67 +288,90 @@
|
|||||||
renderCandidateGroup("", other, checkedIds);
|
renderCandidateGroup("", other, checkedIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadOrders() {
|
function renderDesktopRows(list) {
|
||||||
const box = document.getElementById("cond-list");
|
return list
|
||||||
|
.map(function (o) {
|
||||||
|
return (
|
||||||
|
"<tr>" +
|
||||||
|
"<td>" +
|
||||||
|
escapeHtml(o.instance_name || "") +
|
||||||
|
"</td>" +
|
||||||
|
'<td><span class="cond-st ' +
|
||||||
|
statusClass(o) +
|
||||||
|
'">' +
|
||||||
|
escapeHtml(statusLabel(o)) +
|
||||||
|
"</span></td>" +
|
||||||
|
"<td>" +
|
||||||
|
escapeHtml((o.underlying || "") + " " + (o.opt_type || "")) +
|
||||||
|
"</td>" +
|
||||||
|
"<td>" +
|
||||||
|
escapeHtml(orderTriggerText(o).replace("≤", " ≤ ").replace("≥", " ≥ ")) +
|
||||||
|
"</td>" +
|
||||||
|
"<td>" +
|
||||||
|
escapeHtml(o.deviation_pct != null ? o.deviation_pct + "%" : "—") +
|
||||||
|
"</td>" +
|
||||||
|
"<td>" +
|
||||||
|
escapeHtml(o.min_expiry_hours != null ? String(o.min_expiry_hours) : "—") +
|
||||||
|
"</td>" +
|
||||||
|
"<td>" +
|
||||||
|
escapeHtml(orderExitText(o) || "—") +
|
||||||
|
"</td>" +
|
||||||
|
'<td class="cond-td-time">' +
|
||||||
|
escapeHtml(formatOpenTime(o)) +
|
||||||
|
"</td>" +
|
||||||
|
'<td class="muted">' +
|
||||||
|
escapeHtml(o.message || "") +
|
||||||
|
"</td>" +
|
||||||
|
'<td><div class="overview-actions">' +
|
||||||
|
orderActionHtml(o) +
|
||||||
|
"</div></td>" +
|
||||||
|
"</tr>"
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderDesktopTable(list, emptyText) {
|
||||||
|
if (!list.length) {
|
||||||
|
return '<div class="cond-empty">' + escapeHtml(emptyText) + "</div>";
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
'<div class="overview-table-wrap cond-table-wrap"><table class="overview-table"><thead><tr>' +
|
||||||
|
"<th>客户端</th><th>状态</th><th>标的</th><th>触发</th><th>偏离</th><th>到期h</th><th>出场</th><th>开仓时间</th><th>说明</th><th>操作</th>" +
|
||||||
|
"</tr></thead><tbody>" +
|
||||||
|
renderDesktopRows(list) +
|
||||||
|
"</tbody></table></div>"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPhoneList(list, emptyText) {
|
||||||
|
if (!list.length) {
|
||||||
|
return '<div class="cond-empty">' + escapeHtml(emptyText) + "</div>";
|
||||||
|
}
|
||||||
|
return '<div class="hub-phone-cond-list">' + list.map(renderPhoneOrderCard).join("") + "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillOrderBox(box, list, emptyText) {
|
||||||
if (!box) return;
|
if (!box) return;
|
||||||
|
box.innerHTML = isHubPhone() ? renderPhoneList(list, emptyText) : renderDesktopTable(list, emptyText);
|
||||||
|
bindOrderActions(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadOrders() {
|
||||||
|
const activeBox = document.getElementById("cond-list-active");
|
||||||
|
const doneBox = document.getElementById("cond-list-done");
|
||||||
|
if (!activeBox && !doneBox) return;
|
||||||
const r = await fetch("/api/cond_orders");
|
const r = await fetch("/api/cond_orders");
|
||||||
const d = await r.json();
|
const d = await r.json();
|
||||||
const list = d.orders || [];
|
const list = d.orders || [];
|
||||||
if (!list.length) {
|
const active = [];
|
||||||
box.innerHTML = '<div class="cond-empty">暂无条件单</div>';
|
const done = [];
|
||||||
return;
|
list.forEach(function (o) {
|
||||||
}
|
if (isActiveOrder(o)) active.push(o);
|
||||||
if (isHubPhone()) {
|
else done.push(o);
|
||||||
box.innerHTML =
|
});
|
||||||
'<div class="hub-phone-cond-list">' +
|
fillOrderBox(activeBox, active, "暂无进行中的条件单");
|
||||||
list.map(renderPhoneOrderCard).join("") +
|
fillOrderBox(doneBox, done, "暂无已结束的条件单");
|
||||||
"</div>";
|
|
||||||
bindOrderActions(box);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
box.innerHTML =
|
|
||||||
'<div class="overview-table-wrap cond-table-wrap"><table class="overview-table"><thead><tr>' +
|
|
||||||
"<th>客户端</th><th>状态</th><th>标的</th><th>触发</th><th>偏离</th><th>到期h</th><th>出场</th><th>说明</th><th>操作</th>" +
|
|
||||||
"</tr></thead><tbody>" +
|
|
||||||
list
|
|
||||||
.map(function (o) {
|
|
||||||
return (
|
|
||||||
"<tr>" +
|
|
||||||
"<td>" +
|
|
||||||
escapeHtml(o.instance_name || "") +
|
|
||||||
"</td>" +
|
|
||||||
'<td><span class="cond-st ' +
|
|
||||||
statusClass(o) +
|
|
||||||
'">' +
|
|
||||||
escapeHtml(statusLabel(o)) +
|
|
||||||
"</span></td>" +
|
|
||||||
"<td>" +
|
|
||||||
escapeHtml((o.underlying || "") + " " + (o.opt_type || "")) +
|
|
||||||
"</td>" +
|
|
||||||
"<td>" +
|
|
||||||
escapeHtml(orderTriggerText(o).replace("≤", " ≤ ").replace("≥", " ≥ ")) +
|
|
||||||
"</td>" +
|
|
||||||
"<td>" +
|
|
||||||
escapeHtml(o.deviation_pct != null ? o.deviation_pct + "%" : "—") +
|
|
||||||
"</td>" +
|
|
||||||
"<td>" +
|
|
||||||
escapeHtml(o.min_expiry_hours != null ? String(o.min_expiry_hours) : "—") +
|
|
||||||
"</td>" +
|
|
||||||
"<td>" +
|
|
||||||
escapeHtml(orderExitText(o) || "—") +
|
|
||||||
"</td>" +
|
|
||||||
'<td class="muted">' +
|
|
||||||
escapeHtml(o.message || "") +
|
|
||||||
"</td>" +
|
|
||||||
'<td><div class="overview-actions">' +
|
|
||||||
orderActionHtml(o) +
|
|
||||||
"</div></td>" +
|
|
||||||
"</tr>"
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.join("") +
|
|
||||||
"</tbody></table></div>";
|
|
||||||
bindOrderActions(box);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createOrder() {
|
async function createOrder() {
|
||||||
|
|||||||
@@ -1562,6 +1562,11 @@ input.readonly {
|
|||||||
.cond-st.st-open { color: var(--ok); background: rgba(52, 211, 153, 0.12); }
|
.cond-st.st-open { color: var(--ok); background: rgba(52, 211, 153, 0.12); }
|
||||||
.cond-st.st-done { color: var(--muted); background: rgba(138, 160, 184, 0.12); }
|
.cond-st.st-done { color: var(--muted); background: rgba(138, 160, 184, 0.12); }
|
||||||
.cond-table-wrap { margin-top: 0; }
|
.cond-table-wrap { margin-top: 0; }
|
||||||
|
.cond-td-time {
|
||||||
|
white-space: nowrap;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
}
|
||||||
|
|
||||||
/* —— 数据统计 —— */
|
/* —— 数据统计 —— */
|
||||||
.stats-head {
|
.stats-head {
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
<link rel="icon" href="{{ url_for('static', filename='icons/favicon.ico') }}?v=2" sizes="any">
|
<link rel="icon" href="{{ url_for('static', filename='icons/favicon.ico') }}?v=2" sizes="any">
|
||||||
<link rel="apple-touch-icon" href="{{ url_for('static', filename='icons/apple-touch-icon.png') }}?v=2">
|
<link rel="apple-touch-icon" href="{{ url_for('static', filename='icons/apple-touch-icon.png') }}?v=2">
|
||||||
<link rel="manifest" href="/manifest.webmanifest">
|
<link rel="manifest" href="/manifest.webmanifest">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=43">
|
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=44">
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -79,13 +79,20 @@
|
|||||||
|
|
||||||
<section class="panel cond-card">
|
<section class="panel cond-card">
|
||||||
<div class="cond-card-head">
|
<div class="cond-card-head">
|
||||||
<h2>条件单历史</h2>
|
<h2>进行中</h2>
|
||||||
</div>
|
</div>
|
||||||
<div id="cond-list" class="muted">加载中…</div>
|
<div id="cond-list-active" class="muted">加载中…</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel cond-card">
|
||||||
|
<div class="cond-card-head">
|
||||||
|
<h2>已结束</h2>
|
||||||
|
</div>
|
||||||
|
<div id="cond-list-done" class="muted">加载中…</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ url_for('static', filename='cond_orders.js') }}?v=3"></script>
|
<script src="{{ url_for('static', filename='cond_orders.js') }}?v=4"></script>
|
||||||
<script>HubCondOrders.boot();</script>
|
<script>HubCondOrders.boot();</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user