feat条件单候选展示交易户资金,并支持打开实例划转。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+56
-1
@@ -202,6 +202,36 @@
|
||||
return m === "sim" || m === "live" ? m : "";
|
||||
}
|
||||
|
||||
function fmtTradingU(v) {
|
||||
if (v == null || v === "") return "—";
|
||||
const n = Number(v);
|
||||
if (Number.isNaN(n)) return "—";
|
||||
return n.toFixed(2) + "U";
|
||||
}
|
||||
|
||||
function openInstanceTab(instanceId, tab) {
|
||||
if (!instanceId) return;
|
||||
const q = tab ? "?tab=" + encodeURIComponent(tab) : "";
|
||||
fetch("/api/instances/" + encodeURIComponent(instanceId) + "/open_url" + q)
|
||||
.then(function (r) {
|
||||
return r.json();
|
||||
})
|
||||
.then(function (d) {
|
||||
const url =
|
||||
d && d.url
|
||||
? d.url
|
||||
: "/desk?id=" + encodeURIComponent(instanceId);
|
||||
window.open(url, "_blank", "noopener,noreferrer");
|
||||
})
|
||||
.catch(function () {
|
||||
window.open(
|
||||
"/desk?id=" + encodeURIComponent(instanceId),
|
||||
"_blank",
|
||||
"noopener,noreferrer"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function renderCandidateCard(it, checkedIds) {
|
||||
const disabled = !it.selectable;
|
||||
const tip = disabled
|
||||
@@ -215,7 +245,14 @@
|
||||
: "可选";
|
||||
const id = String(it.id);
|
||||
const checked = !disabled && checkedIds.indexOf(id) >= 0;
|
||||
const fundsTip =
|
||||
it.funding_usdt != null
|
||||
? "资金户 " + fmtTradingU(it.funding_usdt)
|
||||
: "";
|
||||
return (
|
||||
'<div class="cond-inst-row' +
|
||||
(disabled ? " is-off" : "") +
|
||||
'">' +
|
||||
'<label class="cond-inst' +
|
||||
(disabled ? " is-off" : "") +
|
||||
'" title="' +
|
||||
@@ -232,7 +269,17 @@
|
||||
"</span>" +
|
||||
'<span class="cond-inst-tag">' +
|
||||
escapeHtml(tip) +
|
||||
"</span></label>"
|
||||
"</span>" +
|
||||
'<span class="cond-inst-funds" title="' +
|
||||
escapeHtml(fundsTip || "交易账户可用") +
|
||||
'">交易 ' +
|
||||
escapeHtml(fmtTradingU(it.trading_usdt)) +
|
||||
"</span>" +
|
||||
"</label>" +
|
||||
'<button type="button" class="btn btn-sm cond-inst-open" data-inst-id="' +
|
||||
encodeURIComponent(id) +
|
||||
'" title="新标签打开期权实例(可划转)">打开</button>' +
|
||||
"</div>"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -287,6 +334,14 @@
|
||||
renderCandidateGroup("sim", sim, checkedIds) +
|
||||
renderCandidateGroup("live", live, checkedIds) +
|
||||
renderCandidateGroup("", other, checkedIds);
|
||||
box.querySelectorAll(".cond-inst-open").forEach(function (btn) {
|
||||
btn.addEventListener("click", function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
const iid = decodeURIComponent(btn.getAttribute("data-inst-id") || "");
|
||||
openInstanceTab(iid, "options");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function renderDesktopRows(list) {
|
||||
|
||||
Reference in New Issue
Block a user