Show tablet trade records as close-record table with action column.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-17
@@ -12,11 +12,6 @@
|
||||
return String(v).replace('T', ' ').slice(0, 16);
|
||||
}
|
||||
|
||||
function isTabletLayout() {
|
||||
var root = document.documentElement;
|
||||
return root.dataset.layout === 'tablet' || root.classList.contains('layout-tablet');
|
||||
}
|
||||
|
||||
function showTradeModal(data) {
|
||||
var mask = document.getElementById('trade-detail-modal');
|
||||
var body = document.getElementById('trade-detail-modal-body');
|
||||
@@ -53,7 +48,7 @@
|
||||
|
||||
html += '<div class="records-detail-actions">';
|
||||
if (data.fill_review_url) {
|
||||
html += '<a href="' + data.fill_review_url + '" class="btn-fill">复盘</a>';
|
||||
html += '<a href="' + data.fill_review_url + '" class="btn-fill">填入复盘</a>';
|
||||
}
|
||||
if (data.del_url) {
|
||||
html += '<a href="' + data.del_url + '" class="btn-del" onclick="return confirm(\'删除?\')">删除</a>';
|
||||
@@ -64,6 +59,13 @@
|
||||
mask.classList.add('show');
|
||||
}
|
||||
|
||||
function openRowDetail(row) {
|
||||
if (!row) return;
|
||||
try {
|
||||
showTradeModal(JSON.parse(row.getAttribute('data-trade')));
|
||||
} catch (err) { /* ignore */ }
|
||||
}
|
||||
|
||||
function bindTradeModal() {
|
||||
var mask = document.getElementById('trade-detail-modal');
|
||||
if (!mask) return;
|
||||
@@ -77,18 +79,20 @@
|
||||
if (e.target === mask) mask.classList.remove('show');
|
||||
});
|
||||
|
||||
var list = document.getElementById('records-trade-mobile');
|
||||
if (!list) return;
|
||||
var phoneList = document.getElementById('records-trade-mobile');
|
||||
if (phoneList) {
|
||||
phoneList.addEventListener('click', function (e) {
|
||||
openRowDetail(e.target.closest('.records-trade-row'));
|
||||
});
|
||||
}
|
||||
|
||||
list.addEventListener('click', function (e) {
|
||||
if (e.target.closest('.records-trade-actions')) return;
|
||||
var row = e.target.closest('.records-trade-row');
|
||||
if (!row) return;
|
||||
if (isTabletLayout() && !e.target.closest('.records-trade-detail-btn')) return;
|
||||
try {
|
||||
showTradeModal(JSON.parse(row.getAttribute('data-trade')));
|
||||
} catch (err) { /* ignore */ }
|
||||
});
|
||||
var tabletWrap = document.querySelector('.records-trade-table-wrap');
|
||||
if (tabletWrap) {
|
||||
tabletWrap.addEventListener('click', function (e) {
|
||||
if (!e.target.closest('.records-tablet-detail-btn')) return;
|
||||
openRowDetail(e.target.closest('tr[data-trade]'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function bootRecordsPage() {
|
||||
|
||||
Reference in New Issue
Block a user