统一样式
This commit is contained in:
+144
-87
@@ -1,99 +1,156 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>信函查询</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
|
||||
<style>
|
||||
:root { --bg: #f7f7f7; --card: #fff; --primary: #1a73e8; --text: #222; font-size: 14px; }
|
||||
html, body { margin: 0; padding: 0; height: 100%; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
|
||||
.container { max-width: 1000px; margin: 20px auto; padding: 0 12px; }
|
||||
.card { background: var(--card); border-radius: 8px; padding: 16px; box-shadow: 0 2px 6px rgba(0,0,0,.05); }
|
||||
h1 { font-size: 20px; margin: 0 0 12px; }
|
||||
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
|
||||
.form-control { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
|
||||
.btn { padding: 8px 14px; background: var(--primary); color: white; border-radius: 6px; border: none; font-weight: 600; cursor: pointer; }
|
||||
.table-wrapper { margin-top: 12px; overflow-x: auto; }
|
||||
table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
||||
th, td { padding: 10px 12px; border-bottom: 1px solid #eee; text-align: left; }
|
||||
th { background: #f6f7f9; }
|
||||
.loading { text-align: center; color: #666; padding: 20px; }
|
||||
@media (max-width: 900px) {
|
||||
.form-row { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
.form-row { grid-template-columns: 1fr; }
|
||||
}
|
||||
/* 更紧凑的表格在小屏上隐藏部分列,保持可读性,同时允许横向滚动查看完整信息 */
|
||||
@media (max-width: 600px) {
|
||||
table thead th:nth-child(4), table tbody td:nth-child(4),
|
||||
table thead th:nth-child(5), table tbody td:nth-child(5) { display: none; }
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>信函查询系统</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&family=Orbitron:wght@500;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../css/tech-query.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<h1>信函查询</h1>
|
||||
<div class="form-row">
|
||||
<div>
|
||||
<label>收件人</label><br />
|
||||
<input id="recipientTerm" class="form-control" placeholder="收件人" />
|
||||
</div>
|
||||
<div>
|
||||
<label>编号/关键词</label><br />
|
||||
<input id="searchTerm" class="form-control" placeholder="内容搜索" />
|
||||
</div>
|
||||
<div>
|
||||
<label>开始日期</label><br />
|
||||
<input id="dateFrom" type="date" class="form-control" />
|
||||
</div>
|
||||
<div>
|
||||
<label>结束日期</label><br />
|
||||
<input id="dateTo" type="date" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<button id="searchBtn" class="btn">立即查询</button>
|
||||
</div>
|
||||
<div id="searchResults" class="card table-wrapper"></div>
|
||||
</div>
|
||||
<main class="page-shell">
|
||||
<section class="page-header">
|
||||
<div class="hero-card">
|
||||
<span class="eyebrow">Letter Search</span>
|
||||
<h1>信函流转查询台</h1>
|
||||
<p>可按收件人、关键字与寄送时间进行检索,统一展示寄达信息与内容摘要,方便快速确认记录。</p>
|
||||
<div class="hero-meta">
|
||||
<span class="meta-chip">检索字段:收件人 / 内容关键字</span>
|
||||
<span class="meta-chip">输出内容:目的地 / 时间 / 摘要</span>
|
||||
</div>
|
||||
</div>
|
||||
<aside class="stat-card">
|
||||
<div>
|
||||
<div class="stat-label">Module</div>
|
||||
<div class="stat-value">LETTER</div>
|
||||
</div>
|
||||
<p></p>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
const sb = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
<section class="panel-card">
|
||||
<div class="panel-title-row">
|
||||
<div>
|
||||
<h2 class="panel-title">检索条件</h2>
|
||||
<div class="panel-subtitle">多字段组合查询,快速过滤信函记录</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
async function handleSearch(){
|
||||
const recipientTerm = document.getElementById('recipientTerm').value.trim();
|
||||
const contentTerm = document.getElementById('searchTerm').value.trim();
|
||||
const from = document.getElementById('dateFrom').value;
|
||||
const to = document.getElementById('dateTo').value;
|
||||
const out = document.getElementById('searchResults');
|
||||
out.innerHTML = '<div class="loading">正在查询...</div>';
|
||||
<div class="search-grid compact">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="recipientTerm">收件人</label>
|
||||
<input id="recipientTerm" class="tech-input" placeholder="输入收件人姓名">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="searchTerm">编号 / 关键字</label>
|
||||
<input id="searchTerm" class="tech-input" placeholder="输入内容关键字">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="dateFrom">开始日期</label>
|
||||
<input id="dateFrom" type="date" class="tech-input">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="dateTo">结束日期</label>
|
||||
<input id="dateTo" type="date" class="tech-input">
|
||||
</div>
|
||||
<button id="searchBtn" class="tech-button">执行查询</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
let q = sb.from('xinhan').select('*');
|
||||
if (recipientTerm) q = q.ilike('recipient', `%${recipientTerm}%`);
|
||||
if (contentTerm) q = q.ilike('content', `%${contentTerm}%`);
|
||||
if (from) q = q.gte('sent_date', from);
|
||||
if (to) q = q.lte('sent_date', to);
|
||||
const { data, error } = await q.order('sent_date', { ascending: false });
|
||||
if (error){ out.innerHTML = `<div class="loading" style="color:red">查询失败:${error.message}</div>`; return; }
|
||||
renderResults(data || []);
|
||||
}
|
||||
<section class="panel-card results-card">
|
||||
<div class="panel-title-row">
|
||||
<div>
|
||||
<h2 class="panel-title">查询结果</h2>
|
||||
<div class="panel-subtitle">寄送路径与摘要信息集中展示</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="searchResults" class="results-shell">
|
||||
<div class="empty-state">设置检索条件后即可查询信函流转记录。</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
function renderResults(rows){
|
||||
const c = document.getElementById('searchResults');
|
||||
if (!rows.length){ c.innerHTML = '<div class="loading">未找到符合条件的信函</div>'; return; }
|
||||
let html = '<div class="table-wrapper"><table><thead><tr><th>ID</th><th>收件人</th><th>寄达地</th><th>寄出日期</th><th>寄达日期</th><th>内容</th></tr></thead><tbody>';
|
||||
for (const r of rows){
|
||||
html += `<tr><td>${r.id}</td><td>${r.recipient||''}</td><td>${r.destination||''}</td><td>${r.sent_date||''}</td><td>${r.arrival_date||''}</td><td>${(r.content||'').slice(0,60)}${(r.content||'').length>60?'…':''}</td></tr>`;
|
||||
}
|
||||
html += '</tbody></table></div>';
|
||||
c.innerHTML = html;
|
||||
}
|
||||
<footer class="page-footer">
|
||||
<p>© 2026 BI Intelligent Query Interface</p>
|
||||
</footer>
|
||||
|
||||
document.getElementById('searchBtn').addEventListener('click', handleSearch);
|
||||
</script>
|
||||
<script>
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
const sb = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
|
||||
async function handleSearch() {
|
||||
const recipientTerm = document.getElementById('recipientTerm').value.trim();
|
||||
const contentTerm = document.getElementById('searchTerm').value.trim();
|
||||
const from = document.getElementById('dateFrom').value;
|
||||
const to = document.getElementById('dateTo').value;
|
||||
const out = document.getElementById('searchResults');
|
||||
|
||||
out.innerHTML = '<div class="loading-state">正在连接信函数据库并执行检索...</div>';
|
||||
|
||||
let q = sb.from('xinhan').select('*');
|
||||
if (recipientTerm) q = q.ilike('recipient', `%${recipientTerm}%`);
|
||||
if (contentTerm) q = q.ilike('content', `%${contentTerm}%`);
|
||||
if (from) q = q.gte('sent_date', from);
|
||||
if (to) q = q.lte('sent_date', to);
|
||||
|
||||
const { data, error } = await q.order('sent_date', { ascending: false });
|
||||
if (error) {
|
||||
out.innerHTML = `<div class="error-state">查询失败:${error.message}</div>`;
|
||||
return;
|
||||
}
|
||||
renderResults(data || []);
|
||||
}
|
||||
|
||||
function renderResults(rows) {
|
||||
const container = document.getElementById('searchResults');
|
||||
if (!rows.length) {
|
||||
container.innerHTML = '<div class="empty-state">未找到符合条件的信函记录。</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = `
|
||||
<div class="table-wrapper">
|
||||
<table class="result-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>收件人</th>
|
||||
<th>目的地</th>
|
||||
<th>寄出日期</th>
|
||||
<th>寄达日期</th>
|
||||
<th>内容摘要</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
rows.forEach(row => {
|
||||
const content = row.content || '';
|
||||
const summary = content.length > 60
|
||||
? `<span class="text-truncate" title="${content}">${content}</span>`
|
||||
: content;
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td class="table-highlight">${row.id}</td>
|
||||
<td>${row.recipient || ''}</td>
|
||||
<td>${row.destination || ''}</td>
|
||||
<td>${row.sent_date || ''}</td>
|
||||
<td>${row.arrival_date || ''}</td>
|
||||
<td>${summary}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
html += '</tbody></table></div>';
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
document.getElementById('searchBtn').addEventListener('click', handleSearch);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user