@@ -0,0 +1,47 @@
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
|
||||
const sb = window.supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
|
||||
function formatDate(d){
|
||||
return new Date(d).toLocaleString('zh-CN');
|
||||
}
|
||||
|
||||
function updateWatermark(customerName) {
|
||||
const now = new Date().toLocaleString('zh-CN');
|
||||
|
||||
const watermarkText = `BISS · ${customerName || 'Unknown'} · ${now}`;
|
||||
|
||||
document.getElementById('watermark').innerText = watermarkText;
|
||||
}
|
||||
|
||||
async function load() {
|
||||
const id = new URLSearchParams(location.search).get('id');
|
||||
|
||||
const { data } = await sb.from('tickets').select('*').eq('id', id).single();
|
||||
|
||||
if (!data) return;
|
||||
|
||||
document.getElementById('ticket_number').innerText = data.ticket_number || '';
|
||||
document.getElementById('customer_name').innerText = data.customer_name || '';
|
||||
document.getElementById('reason').innerText = data.reason || '';
|
||||
document.getElementById('amount').innerText = '¥' + (data.amount || 0).toFixed(2);
|
||||
document.getElementById('issuer').innerText = data.issuer || '';
|
||||
document.getElementById('created_at').innerText = formatDate(data.created_at);
|
||||
document.getElementById('processed').innerText = data.processed ? '已办结' : '未办结';
|
||||
document.getElementById('processed_at').innerText = data.processed_at ? formatDate(data.processed_at) : '暂无';
|
||||
document.getElementById('remarks').innerText = data.remarks || '无';
|
||||
|
||||
// 打印时间
|
||||
document.getElementById('print_time').innerText =
|
||||
new Date().toLocaleString('zh-CN');
|
||||
|
||||
updateWatermark(data.customer_name);
|
||||
|
||||
// 自动打印
|
||||
setTimeout(() => {
|
||||
window.print();
|
||||
}, 300);
|
||||
}
|
||||
|
||||
load();
|
||||
Reference in New Issue
Block a user