feature/xinhan-branch #2
+10
-7
@@ -24,9 +24,13 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h1>Xinhan 查询</h1>
|
<h1>Xinhan 查询</h1>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
|
<div>
|
||||||
|
<label>收件人</label><br />
|
||||||
|
<input id="recipientTerm" class="form-control" placeholder="收件人" />
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label>编号/关键词</label><br />
|
<label>编号/关键词</label><br />
|
||||||
<input id="searchTerm" class="form-control" placeholder="收件人/内容搜索" />
|
<input id="searchTerm" class="form-control" placeholder="内容搜索" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label>开始日期</label><br />
|
<label>开始日期</label><br />
|
||||||
@@ -48,21 +52,20 @@
|
|||||||
const sb = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
const sb = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||||
|
|
||||||
async function handleSearch(){
|
async function handleSearch(){
|
||||||
const term = document.getElementById('searchTerm').value.trim();
|
const recipientTerm = document.getElementById('recipientTerm').value.trim();
|
||||||
|
const contentTerm = document.getElementById('searchTerm').value.trim();
|
||||||
const from = document.getElementById('dateFrom').value;
|
const from = document.getElementById('dateFrom').value;
|
||||||
const to = document.getElementById('dateTo').value;
|
const to = document.getElementById('dateTo').value;
|
||||||
const out = document.getElementById('searchResults');
|
const out = document.getElementById('searchResults');
|
||||||
out.innerHTML = '<div class="loading">正在查询...</div>';
|
out.innerHTML = '<div class="loading">正在查询...</div>';
|
||||||
|
|
||||||
let q = sb.from('xinhan').select('*');
|
let q = sb.from('xinhan').select('*');
|
||||||
if (term) q = q.or(`recipient.ilike.%${term}%,content.ilike.%${term}%`);
|
if (recipientTerm) q = q.ilike('recipient', `%${recipientTerm}%`);
|
||||||
|
if (contentTerm) q = q.ilike('content', `%${contentTerm}%`);
|
||||||
if (from) q = q.gte('sent_date', from);
|
if (from) q = q.gte('sent_date', from);
|
||||||
if (to) q = q.lte('sent_date', to);
|
if (to) q = q.lte('sent_date', to);
|
||||||
const { data, error } = await q.order('sent_date', { ascending: false });
|
const { data, error } = await q.order('sent_date', { ascending: false });
|
||||||
if (error) {
|
if (error){ out.innerHTML = `<div class="loading" style="color:red">查询失败:${error.message}</div>`; return; }
|
||||||
out.innerHTML = `<div class="loading" style="color:red">查询失败:${error.message}</div>`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
renderResults(data || []);
|
renderResults(data || []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user