数据管理页面的完善
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
table{width:100%;border-collapse:collapse;margin-top:20px}
|
||||
th,td{border-bottom:1px solid #eee;padding:12px 8px;text-align:left;vertical-align:top}
|
||||
th{background:#f8f9fa;font-weight:600}
|
||||
.inner-table { width: 100%; margin: 0; border: 1px solid #e0e0e0; border-collapse: collapse; }
|
||||
.inner-table th, .inner-table td { border: 1px solid #e0e0e0; padding: 6px; font-size: 12px; }
|
||||
.inner-table th { background-color: #f9f9f9; }
|
||||
img{max-width:120px;border:1px solid #eee;border-radius:6px;cursor:pointer}
|
||||
.btn{padding:6px 10px;border:none;border-radius:6px;cursor:pointer;font-size:14px;margin:2px}
|
||||
.btn-primary{background:#1677ff;color:#fff}
|
||||
@@ -86,7 +89,6 @@
|
||||
<table id="dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>图片</th>
|
||||
<th>数据</th>
|
||||
<th>录入人</th>
|
||||
@@ -320,18 +322,28 @@ function renderTable(data) {
|
||||
let displayData = item.data || '';
|
||||
try {
|
||||
const parsed = JSON.parse(item.data);
|
||||
displayData = JSON.stringify(parsed, null, 2);
|
||||
displayData = `
|
||||
<table class="inner-table">
|
||||
<tbody>
|
||||
${Object.entries(parsed).map(([key, value]) => `
|
||||
<tr>
|
||||
<td>${escapeHtml(key)}</td>
|
||||
<td>${escapeHtml(typeof value === 'object' ? JSON.stringify(value, null, 2) : value)}</td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
} catch (e) {
|
||||
// 如果不是JSON,直接显示原字符串
|
||||
displayData = `<pre style="white-space:pre-wrap; word-wrap:break-word; max-height: 100px; overflow-y: auto; font-size: 12px; margin: 0;">${escapeHtml(displayData)}</pre>`;
|
||||
}
|
||||
|
||||
row.innerHTML = `
|
||||
<td style="max-width:140px; word-break:break-all; font-size: 12px;">${item._id || item.id || ''}</td>
|
||||
<td>
|
||||
<div style="display:flex;gap:6px;flex-wrap:wrap;">${buildImageCell(item)}</div>
|
||||
</td>
|
||||
<td>
|
||||
<pre style="white-space:pre-wrap; word-wrap:break-word; max-height: 100px; overflow-y: auto; font-size: 12px; margin: 0;">${escapeHtml(displayData)}</pre>
|
||||
${displayData}
|
||||
</td>
|
||||
<td style="font-size: 12px;">${item.writer_name || item.writer_id || ''}</td>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user