feature/xinhan-branch #2
@@ -0,0 +1,83 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Xinhan 查询</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
|
||||
<style>
|
||||
body { font-family: Arial, Helvetica, sans-serif; background: #f7f7f7; margin: 0; }
|
||||
.container { max-width: 1000px; margin: 20px auto; padding: 16px; }
|
||||
.card { background: #fff; 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-fit, 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: #1a73e8; color: white; border: none; border-radius: 6px; 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; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<h1>Xinhan 查询</h1>
|
||||
<div class="form-row">
|
||||
<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>
|
||||
|
||||
<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 term = 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>';
|
||||
|
||||
let q = sb.from('xinhan').select('*');
|
||||
if (term) q = q.or(`recipient.ilike.%${term}%,content.ilike.%${term}%`);
|
||||
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 || []);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
document.getElementById('searchBtn').addEventListener('click', handleSearch);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user