条件单拆成进行中与已结束两表,并展示开仓时间。
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) {
|
||||
const exit = orderExitText(o);
|
||||
const meta = [];
|
||||
@@ -176,6 +187,9 @@
|
||||
escapeHtml(orderTriggerText(o)) +
|
||||
"</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>" : "") +
|
||||
(actions ? '<div class="hub-phone-cond-actions">' + actions + "</div>" : "") +
|
||||
"</article>"
|
||||
@@ -274,67 +288,90 @@
|
||||
renderCandidateGroup("", other, checkedIds);
|
||||
}
|
||||
|
||||
async function loadOrders() {
|
||||
const box = document.getElementById("cond-list");
|
||||
function renderDesktopRows(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;
|
||||
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 d = await r.json();
|
||||
const list = d.orders || [];
|
||||
if (!list.length) {
|
||||
box.innerHTML = '<div class="cond-empty">暂无条件单</div>';
|
||||
return;
|
||||
}
|
||||
if (isHubPhone()) {
|
||||
box.innerHTML =
|
||||
'<div class="hub-phone-cond-list">' +
|
||||
list.map(renderPhoneOrderCard).join("") +
|
||||
"</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);
|
||||
const active = [];
|
||||
const done = [];
|
||||
list.forEach(function (o) {
|
||||
if (isActiveOrder(o)) active.push(o);
|
||||
else done.push(o);
|
||||
});
|
||||
fillOrderBox(activeBox, active, "暂无进行中的条件单");
|
||||
fillOrderBox(doneBox, done, "暂无已结束的条件单");
|
||||
}
|
||||
|
||||
async function createOrder() {
|
||||
|
||||
Reference in New Issue
Block a user