+2
-122
@@ -61,7 +61,7 @@
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
<section class="detail-panel" id="info-card" style="display: none; margin-top: 18px;">
|
||||
<section class="detail-panel is-hidden mt-18" id="info-card">
|
||||
<div class="section-kicker">Certificate Detail</div>
|
||||
<h2 class="section-heading">证书明细信息</h2>
|
||||
<p class="section-copy">以下信息由证书数据库实时读取,用于核验与归档展示。</p>
|
||||
@@ -84,127 +84,7 @@
|
||||
<p>© 2026 BI Intelligent Query Interface</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
const sbClient = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
|
||||
async function loadData() {
|
||||
const id = new URLSearchParams(window.location.search).get('id');
|
||||
if (!id) return;
|
||||
|
||||
try {
|
||||
const { data, error } = await sbClient
|
||||
.from('certificates')
|
||||
.select('*')
|
||||
.eq('id', id)
|
||||
.single();
|
||||
|
||||
if (error || !data) throw error || new Error('未找到证书信息');
|
||||
|
||||
const verifyTime = new Date().toLocaleString('zh-CN');
|
||||
document.getElementById('info-card').style.display = 'block';
|
||||
document.getElementById('d-cert-number').innerText = data.cert_number || '-';
|
||||
document.getElementById('d-holder-name').innerText = data.holder_name || '-';
|
||||
document.getElementById('d-honor-title').innerText = data.honor_title || '-';
|
||||
document.getElementById('d-issue-date').innerText = data.issue_date || '-';
|
||||
document.getElementById('d-issuer').innerText = data.issuer || '官方授权机构';
|
||||
document.getElementById('d-desc').innerText = data.description || '官方荣誉认证';
|
||||
document.getElementById('d-remarks').innerText = data.remarks || '无';
|
||||
document.getElementById('d-verify-time').innerText = verifyTime;
|
||||
|
||||
document.getElementById('summary-cert-number').innerText = data.cert_number || '-';
|
||||
document.getElementById('summary-holder-name').innerText = data.holder_name || '-';
|
||||
document.getElementById('summary-verify-time').innerText = verifyTime;
|
||||
|
||||
if (data.status === 'valid') {
|
||||
document.getElementById('display-status').innerHTML = '<span class="status-pill done">有效</span>';
|
||||
} else if (data.status === 'invalid') {
|
||||
document.getElementById('display-status').innerHTML = '<span class="status-pill pending">无效</span>';
|
||||
} else {
|
||||
document.getElementById('display-status').innerHTML = '<span class="status-pill pending">待核验</span>';
|
||||
}
|
||||
|
||||
window.currentCertNumber = data.cert_number;
|
||||
} catch (e) {
|
||||
console.error('加载失败:', e);
|
||||
alert('证书信息检索失败。');
|
||||
}
|
||||
}
|
||||
|
||||
function loadCertificateImage() {
|
||||
const certNumber = window.currentCertNumber;
|
||||
if (!certNumber) return;
|
||||
|
||||
const img = document.getElementById('cert-img');
|
||||
const hint = document.getElementById('click-hint');
|
||||
|
||||
if (img.src && img.complete && img.naturalWidth > 0) {
|
||||
img.style.display = 'block';
|
||||
if (hint) hint.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
if (hint) {
|
||||
hint.innerHTML = '<span class="hint-orb">载</span><strong>图片加载中</strong><span>正在读取证书原件,请稍候。</span>';
|
||||
}
|
||||
|
||||
img.src = `https://s3.biss.click/CERTS/${encodeURIComponent(certNumber)}.svg`;
|
||||
img.onload = () => {
|
||||
img.style.display = 'block';
|
||||
if (hint) hint.style.display = 'none';
|
||||
};
|
||||
img.onerror = () => {
|
||||
if (hint) {
|
||||
hint.innerHTML = '<span class="hint-orb">!</span><strong>图片加载失败</strong><span>未找到对应证书图片文件</span>';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function ensureCertificateImageLoaded() {
|
||||
const certNumber = window.currentCertNumber;
|
||||
const img = document.getElementById('cert-img');
|
||||
const hint = document.getElementById('click-hint');
|
||||
|
||||
if (!certNumber) {
|
||||
throw new Error('未找到证书编号');
|
||||
}
|
||||
|
||||
if (img.src && img.complete && img.naturalWidth > 0) {
|
||||
img.style.display = 'block';
|
||||
if (hint) hint.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
if (hint) {
|
||||
hint.innerHTML = '<span class="hint-orb">载</span><strong>图片加载中</strong><span>正在为打印准备证书原件,请稍候。</span>';
|
||||
}
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
img.onload = () => {
|
||||
img.style.display = 'block';
|
||||
if (hint) hint.style.display = 'none';
|
||||
resolve();
|
||||
};
|
||||
img.onerror = () => {
|
||||
reject(new Error('证书图片加载失败'));
|
||||
};
|
||||
img.src = `https://s3.biss.click/CERTS/${encodeURIComponent(certNumber)}.svg`;
|
||||
});
|
||||
}
|
||||
|
||||
async function printCertificate() {
|
||||
try {
|
||||
await ensureCertificateImageLoaded();
|
||||
window.print();
|
||||
} catch (error) {
|
||||
console.error('打印前加载证书失败:', error);
|
||||
alert('证书原件加载失败,无法打印。');
|
||||
}
|
||||
}
|
||||
|
||||
loadData();
|
||||
</script>
|
||||
<script src="../js/certs-certificate.js"></script>
|
||||
<script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script>
|
||||
<script src="../js/notice-banner.js"></script>
|
||||
</body>
|
||||
|
||||
+1
-248
@@ -89,254 +89,7 @@
|
||||
<p>© 2026 BI Intelligent Query Interface</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
const sbClient = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
|
||||
const html5QrCode = new Html5Qrcode("reader");
|
||||
const scannerOverlay = document.getElementById('scanner-overlay');
|
||||
|
||||
document.getElementById('startScanBtn').addEventListener('click', async () => {
|
||||
scannerOverlay.style.display = 'flex';
|
||||
|
||||
const config = {
|
||||
fps: 15,
|
||||
qrbox: { width: 320, height: 140 },
|
||||
aspectRatio: 1.0
|
||||
};
|
||||
|
||||
if (typeof Html5QrcodeSupportedFormats !== 'undefined') {
|
||||
config.formatsToSupport = [
|
||||
Html5QrcodeSupportedFormats.CODE_128,
|
||||
Html5QrcodeSupportedFormats.CODE_39,
|
||||
Html5QrcodeSupportedFormats.CODE_93,
|
||||
Html5QrcodeSupportedFormats.EAN_13,
|
||||
Html5QrcodeSupportedFormats.EAN_8,
|
||||
Html5QrcodeSupportedFormats.UPC_A,
|
||||
Html5QrcodeSupportedFormats.UPC_E,
|
||||
Html5QrcodeSupportedFormats.ITF,
|
||||
Html5QrcodeSupportedFormats.CODABAR
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
await html5QrCode.start(
|
||||
{ facingMode: "environment" },
|
||||
config,
|
||||
(decodedText) => {
|
||||
document.getElementById('searchTerm').value = decodedText;
|
||||
closeScanner();
|
||||
handleSearch();
|
||||
},
|
||||
() => {}
|
||||
);
|
||||
} catch (err) {
|
||||
alert("无法启动摄像头,请检查 HTTPS 权限或设备连接。");
|
||||
scannerOverlay.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
async function closeScanner() {
|
||||
if (html5QrCode.isScanning) {
|
||||
await html5QrCode.stop();
|
||||
}
|
||||
scannerOverlay.style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('stopScanBtn').addEventListener('click', closeScanner);
|
||||
|
||||
async function handleSearch() {
|
||||
const term = document.getElementById('searchTerm').value.trim();
|
||||
const start = document.getElementById('dateStart').value;
|
||||
const end = document.getElementById('dateEnd').value;
|
||||
const display = document.getElementById('resultsArea');
|
||||
|
||||
if (!term) {
|
||||
alert("请输入证书编号、持有人姓名或奖项名。");
|
||||
return;
|
||||
}
|
||||
|
||||
display.innerHTML = '<div class="loading-state">正在连接证书数据库并执行检索...</div>';
|
||||
|
||||
try {
|
||||
let query = sbClient.from('certificates').select('*');
|
||||
query = query.or(`cert_number.ilike.%${term}%,holder_name.ilike.%${term}%,honor_title.ilike.%${term}%`);
|
||||
|
||||
if (start) query = query.gte('issue_date', start);
|
||||
if (end) query = query.lte('issue_date', end);
|
||||
|
||||
const { data, error } = await query.order('issue_date', { ascending: false });
|
||||
if (error) throw error;
|
||||
|
||||
const awardRecipientCounts = await loadAwardRecipientCounts(data);
|
||||
renderResults(data, awardRecipientCounts);
|
||||
} catch (err) {
|
||||
display.innerHTML = `<div class="error-state">检索失败:${err.message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAwardRecipientCounts(data) {
|
||||
const awardTitles = [...new Set((data || []).map(item => item.honor_title).filter(Boolean))];
|
||||
if (awardTitles.length === 0) return {};
|
||||
|
||||
const countPairs = await Promise.all(awardTitles.map(async title => {
|
||||
const { count, error } = await sbClient
|
||||
.from('certificates')
|
||||
.select('id', { count: 'exact', head: true })
|
||||
.eq('honor_title', title);
|
||||
|
||||
if (error) throw error;
|
||||
return [title, count || 0];
|
||||
}));
|
||||
|
||||
return Object.fromEntries(countPairs);
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value ?? '').replace(/[&<>"']/g, char => ({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
}[char]));
|
||||
}
|
||||
|
||||
function renderAwardStats(data, awardRecipientCounts) {
|
||||
const holderCounts = (data || []).reduce((counts, item) => {
|
||||
const holderName = item.holder_name || '未填写';
|
||||
counts[holderName] = (counts[holderName] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
|
||||
const holderStats = Object.entries(holderCounts)
|
||||
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0], 'zh-CN'));
|
||||
const maxHolderCount = Math.max(...holderStats.map(([, count]) => count), 1);
|
||||
|
||||
const awardStats = [...new Set((data || []).map(item => item.honor_title).filter(Boolean))]
|
||||
.map(title => ({
|
||||
title,
|
||||
count: awardRecipientCounts[title] || 0
|
||||
}))
|
||||
.sort((a, b) => b.count - a.count || a.title.localeCompare(b.title, 'zh-CN'));
|
||||
|
||||
const holderBars = holderStats.map(([name, count]) => `
|
||||
<div class="chart-row">
|
||||
<div class="chart-row-label" title="${escapeHtml(name)}">${escapeHtml(name)}</div>
|
||||
<div class="chart-bar-track">
|
||||
<div class="chart-bar-fill" style="width: ${Math.max((count / maxHolderCount) * 100, 6)}%;"></div>
|
||||
</div>
|
||||
<div class="chart-row-value">${count} 项</div>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
const awardChips = awardStats.map(item => `
|
||||
<div class="award-count-chip">
|
||||
<span class="award-count-title" title="${escapeHtml(item.title)}">${escapeHtml(item.title)}</span>
|
||||
<strong>${item.count}</strong>
|
||||
<span>人获得</span>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
return `
|
||||
<div class="results-summary">
|
||||
<div class="summary-stat-tile">
|
||||
<span>查询结果</span>
|
||||
<strong>${data.length}</strong>
|
||||
</div>
|
||||
<div class="summary-stat-tile">
|
||||
<span>涉及人员</span>
|
||||
<strong>${holderStats.length}</strong>
|
||||
</div>
|
||||
<div class="summary-stat-tile">
|
||||
<span>奖项种类</span>
|
||||
<strong>${awardStats.length}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stats-grid">
|
||||
<section class="stats-panel">
|
||||
<div class="stats-panel-title">个人奖项数量</div>
|
||||
<div class="bar-chart">${holderBars}</div>
|
||||
</section>
|
||||
<section class="stats-panel">
|
||||
<div class="stats-panel-title">查询奖项获得人数</div>
|
||||
<div class="award-count-grid">${awardChips || '<div class="muted-note">暂无奖项名称</div>'}</div>
|
||||
</section>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderResults(data, awardRecipientCounts = {}) {
|
||||
const display = document.getElementById('resultsArea');
|
||||
if (!data || data.length === 0) {
|
||||
display.innerHTML = '<div class="empty-state">未找到匹配的证书记录。</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = `
|
||||
${renderAwardStats(data, awardRecipientCounts)}
|
||||
<div class="table-wrapper">
|
||||
<table class="result-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>证书编号</th>
|
||||
<th>持有人</th>
|
||||
<th>荣誉标题</th>
|
||||
<th>颁发日期</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
data.forEach(item => {
|
||||
html += `
|
||||
<tr>
|
||||
<td class="table-highlight">${escapeHtml(item.cert_number || '-')}</td>
|
||||
<td>${escapeHtml(item.holder_name || '-')}</td>
|
||||
<td>${escapeHtml(item.honor_title || '-')}</td>
|
||||
<td>${escapeHtml(item.issue_date || '-')}</td>
|
||||
<td><button class="tech-link-button secondary" type="button" onclick="goToDetail('${item.id}')">查看详情</button></td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
html += '</tbody></table></div>';
|
||||
display.innerHTML = html;
|
||||
}
|
||||
|
||||
function goToDetail(id) {
|
||||
window.location.href = `certificate.html?id=${id}`;
|
||||
}
|
||||
|
||||
function initializeSearchTermFromUrl() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const presetTerm =
|
||||
params.get('searchTerm') ||
|
||||
params.get('term') ||
|
||||
params.get('keyword') ||
|
||||
params.get('cert_number') ||
|
||||
params.get('certNumber') ||
|
||||
params.get('number') ||
|
||||
params.get('awardName') ||
|
||||
params.get('honor_title') ||
|
||||
params.get('honorTitle') ||
|
||||
params.get('award') ||
|
||||
params.get('q') ||
|
||||
'';
|
||||
|
||||
if (presetTerm) {
|
||||
document.getElementById('searchTerm').value = presetTerm;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('searchBtn').addEventListener('click', handleSearch);
|
||||
document.getElementById('searchTerm').addEventListener('keypress', e => {
|
||||
if (e.key === 'Enter') handleSearch();
|
||||
});
|
||||
initializeSearchTermFromUrl();
|
||||
</script>
|
||||
<script src="../js/certs-index.js"></script>
|
||||
<script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script>
|
||||
<script src="../js/notice-banner.js"></script>
|
||||
</body>
|
||||
|
||||
+5
-1
@@ -71,6 +71,10 @@ body {
|
||||
font-family: var(--font-family-sig);
|
||||
}
|
||||
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* ===========================================
|
||||
2. 原始场景皮肤 (Modern, Traditional, Vintage)
|
||||
=========================================== */
|
||||
@@ -179,4 +183,4 @@ body {
|
||||
.theme-wabi .salutation { font-weight: normal; font-size: 1.2rem; color: #333; }
|
||||
.theme-wabi .content p { text-indent: 2em; line-height: 2; color: #666; font-size: 0.95rem; }
|
||||
.theme-wabi .wish-suffix { font-weight: normal; color: #777; }
|
||||
.theme-wabi .signature { font-family: "Zhi Mang Xing", cursive; font-size: 1.8rem; color: #333; } /* 使用Google Font书法字体 */
|
||||
.theme-wabi .signature { font-family: "Zhi Mang Xing", cursive; font-size: 1.8rem; color: #333; } /* 使用Google Font书法字体 */
|
||||
|
||||
@@ -72,6 +72,14 @@ a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.is-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mt-18 {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.page-shell {
|
||||
width: min(calc(100% - 32px), var(--content-width));
|
||||
margin: 0 auto;
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
body {
|
||||
font-family: Arial, "Microsoft YaHei";
|
||||
background: white;
|
||||
}
|
||||
|
||||
/* ===== A4 容器 ===== */
|
||||
.page {
|
||||
width: 210mm;
|
||||
min-height: 297mm;
|
||||
margin: auto;
|
||||
padding: 20mm;
|
||||
position: relative;
|
||||
background: white;
|
||||
}
|
||||
|
||||
/* ===== 水印 ===== */
|
||||
.watermark {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%) rotate(-30deg);
|
||||
font-size: 50px;
|
||||
color: rgba(0, 0, 0, 0.08);
|
||||
white-space: nowrap;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ===== 标题 ===== */
|
||||
.title {
|
||||
text-align: center;
|
||||
font-size: 22px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* ===== 信息表格 ===== */
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 10px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.table td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 25%;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
/* ===== 页脚 ===== */
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 20mm;
|
||||
left: 20mm;
|
||||
right: 20mm;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* ===== 打印优化 ===== */
|
||||
@media print {
|
||||
.no-print {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.page {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
const sbClient = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
|
||||
async function loadData() {
|
||||
const id = new URLSearchParams(window.location.search).get('id');
|
||||
if (!id) return;
|
||||
|
||||
try {
|
||||
const { data, error } = await sbClient
|
||||
.from('certificates')
|
||||
.select('*')
|
||||
.eq('id', id)
|
||||
.single();
|
||||
|
||||
if (error || !data) throw error || new Error('未找到证书信息');
|
||||
|
||||
const verifyTime = new Date().toLocaleString('zh-CN');
|
||||
document.getElementById('info-card').style.display = 'block';
|
||||
document.getElementById('d-cert-number').innerText = data.cert_number || '-';
|
||||
document.getElementById('d-holder-name').innerText = data.holder_name || '-';
|
||||
document.getElementById('d-honor-title').innerText = data.honor_title || '-';
|
||||
document.getElementById('d-issue-date').innerText = data.issue_date || '-';
|
||||
document.getElementById('d-issuer').innerText = data.issuer || '官方授权机构';
|
||||
document.getElementById('d-desc').innerText = data.description || '官方荣誉认证';
|
||||
document.getElementById('d-remarks').innerText = data.remarks || '无';
|
||||
document.getElementById('d-verify-time').innerText = verifyTime;
|
||||
|
||||
document.getElementById('summary-cert-number').innerText = data.cert_number || '-';
|
||||
document.getElementById('summary-holder-name').innerText = data.holder_name || '-';
|
||||
document.getElementById('summary-verify-time').innerText = verifyTime;
|
||||
|
||||
if (data.status === 'valid') {
|
||||
document.getElementById('display-status').innerHTML = '<span class="status-pill done">有效</span>';
|
||||
} else if (data.status === 'invalid') {
|
||||
document.getElementById('display-status').innerHTML = '<span class="status-pill pending">无效</span>';
|
||||
} else {
|
||||
document.getElementById('display-status').innerHTML = '<span class="status-pill pending">待核验</span>';
|
||||
}
|
||||
|
||||
window.currentCertNumber = data.cert_number;
|
||||
} catch (e) {
|
||||
console.error('加载失败:', e);
|
||||
alert('证书信息检索失败。');
|
||||
}
|
||||
}
|
||||
|
||||
function loadCertificateImage() {
|
||||
const certNumber = window.currentCertNumber;
|
||||
if (!certNumber) return;
|
||||
|
||||
const img = document.getElementById('cert-img');
|
||||
const hint = document.getElementById('click-hint');
|
||||
|
||||
if (img.src && img.complete && img.naturalWidth > 0) {
|
||||
img.style.display = 'block';
|
||||
if (hint) hint.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
if (hint) {
|
||||
hint.innerHTML = '<span class="hint-orb">载</span><strong>图片加载中</strong><span>正在读取证书原件,请稍候。</span>';
|
||||
}
|
||||
|
||||
img.src = `https://s3.biss.click/CERTS/${encodeURIComponent(certNumber)}.svg`;
|
||||
img.onload = () => {
|
||||
img.style.display = 'block';
|
||||
if (hint) hint.style.display = 'none';
|
||||
};
|
||||
img.onerror = () => {
|
||||
if (hint) {
|
||||
hint.innerHTML = '<span class="hint-orb">!</span><strong>图片加载失败</strong><span>未找到对应证书图片文件</span>';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function ensureCertificateImageLoaded() {
|
||||
const certNumber = window.currentCertNumber;
|
||||
const img = document.getElementById('cert-img');
|
||||
const hint = document.getElementById('click-hint');
|
||||
|
||||
if (!certNumber) {
|
||||
throw new Error('未找到证书编号');
|
||||
}
|
||||
|
||||
if (img.src && img.complete && img.naturalWidth > 0) {
|
||||
img.style.display = 'block';
|
||||
if (hint) hint.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
if (hint) {
|
||||
hint.innerHTML = '<span class="hint-orb">载</span><strong>图片加载中</strong><span>正在为打印准备证书原件,请稍候。</span>';
|
||||
}
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
img.onload = () => {
|
||||
img.style.display = 'block';
|
||||
if (hint) hint.style.display = 'none';
|
||||
resolve();
|
||||
};
|
||||
img.onerror = () => {
|
||||
reject(new Error('证书图片加载失败'));
|
||||
};
|
||||
img.src = `https://s3.biss.click/CERTS/${encodeURIComponent(certNumber)}.svg`;
|
||||
});
|
||||
}
|
||||
|
||||
async function printCertificate() {
|
||||
try {
|
||||
await ensureCertificateImageLoaded();
|
||||
window.print();
|
||||
} catch (error) {
|
||||
console.error('打印前加载证书失败:', error);
|
||||
alert('证书原件加载失败,无法打印。');
|
||||
}
|
||||
}
|
||||
|
||||
loadData();
|
||||
@@ -0,0 +1,246 @@
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
const sbClient = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
|
||||
const html5QrCode = new Html5Qrcode("reader");
|
||||
const scannerOverlay = document.getElementById('scanner-overlay');
|
||||
|
||||
document.getElementById('startScanBtn').addEventListener('click', async () => {
|
||||
scannerOverlay.style.display = 'flex';
|
||||
|
||||
const config = {
|
||||
fps: 15,
|
||||
qrbox: { width: 320, height: 140 },
|
||||
aspectRatio: 1.0
|
||||
};
|
||||
|
||||
if (typeof Html5QrcodeSupportedFormats !== 'undefined') {
|
||||
config.formatsToSupport = [
|
||||
Html5QrcodeSupportedFormats.CODE_128,
|
||||
Html5QrcodeSupportedFormats.CODE_39,
|
||||
Html5QrcodeSupportedFormats.CODE_93,
|
||||
Html5QrcodeSupportedFormats.EAN_13,
|
||||
Html5QrcodeSupportedFormats.EAN_8,
|
||||
Html5QrcodeSupportedFormats.UPC_A,
|
||||
Html5QrcodeSupportedFormats.UPC_E,
|
||||
Html5QrcodeSupportedFormats.ITF,
|
||||
Html5QrcodeSupportedFormats.CODABAR
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
await html5QrCode.start(
|
||||
{ facingMode: "environment" },
|
||||
config,
|
||||
(decodedText) => {
|
||||
document.getElementById('searchTerm').value = decodedText;
|
||||
closeScanner();
|
||||
handleSearch();
|
||||
},
|
||||
() => {}
|
||||
);
|
||||
} catch (err) {
|
||||
alert("无法启动摄像头,请检查 HTTPS 权限或设备连接。");
|
||||
scannerOverlay.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
async function closeScanner() {
|
||||
if (html5QrCode.isScanning) {
|
||||
await html5QrCode.stop();
|
||||
}
|
||||
scannerOverlay.style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('stopScanBtn').addEventListener('click', closeScanner);
|
||||
|
||||
async function handleSearch() {
|
||||
const term = document.getElementById('searchTerm').value.trim();
|
||||
const start = document.getElementById('dateStart').value;
|
||||
const end = document.getElementById('dateEnd').value;
|
||||
const display = document.getElementById('resultsArea');
|
||||
|
||||
if (!term) {
|
||||
alert("请输入证书编号、持有人姓名或奖项名。");
|
||||
return;
|
||||
}
|
||||
|
||||
display.innerHTML = '<div class="loading-state">正在连接证书数据库并执行检索...</div>';
|
||||
|
||||
try {
|
||||
let query = sbClient.from('certificates').select('*');
|
||||
query = query.or(`cert_number.ilike.%${term}%,holder_name.ilike.%${term}%,honor_title.ilike.%${term}%`);
|
||||
|
||||
if (start) query = query.gte('issue_date', start);
|
||||
if (end) query = query.lte('issue_date', end);
|
||||
|
||||
const { data, error } = await query.order('issue_date', { ascending: false });
|
||||
if (error) throw error;
|
||||
|
||||
const awardRecipientCounts = await loadAwardRecipientCounts(data);
|
||||
renderResults(data, awardRecipientCounts);
|
||||
} catch (err) {
|
||||
display.innerHTML = `<div class="error-state">检索失败:${err.message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAwardRecipientCounts(data) {
|
||||
const awardTitles = [...new Set((data || []).map(item => item.honor_title).filter(Boolean))];
|
||||
if (awardTitles.length === 0) return {};
|
||||
|
||||
const countPairs = await Promise.all(awardTitles.map(async title => {
|
||||
const { count, error } = await sbClient
|
||||
.from('certificates')
|
||||
.select('id', { count: 'exact', head: true })
|
||||
.eq('honor_title', title);
|
||||
|
||||
if (error) throw error;
|
||||
return [title, count || 0];
|
||||
}));
|
||||
|
||||
return Object.fromEntries(countPairs);
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value ?? '').replace(/[&<>"']/g, char => ({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
}[char]));
|
||||
}
|
||||
|
||||
function renderAwardStats(data, awardRecipientCounts) {
|
||||
const holderCounts = (data || []).reduce((counts, item) => {
|
||||
const holderName = item.holder_name || '未填写';
|
||||
counts[holderName] = (counts[holderName] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
|
||||
const holderStats = Object.entries(holderCounts)
|
||||
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0], 'zh-CN'));
|
||||
const maxHolderCount = Math.max(...holderStats.map(([, count]) => count), 1);
|
||||
|
||||
const awardStats = [...new Set((data || []).map(item => item.honor_title).filter(Boolean))]
|
||||
.map(title => ({
|
||||
title,
|
||||
count: awardRecipientCounts[title] || 0
|
||||
}))
|
||||
.sort((a, b) => b.count - a.count || a.title.localeCompare(b.title, 'zh-CN'));
|
||||
|
||||
const holderBars = holderStats.map(([name, count]) => `
|
||||
<div class="chart-row">
|
||||
<div class="chart-row-label" title="${escapeHtml(name)}">${escapeHtml(name)}</div>
|
||||
<div class="chart-bar-track">
|
||||
<div class="chart-bar-fill" style="width: ${Math.max((count / maxHolderCount) * 100, 6)}%;"></div>
|
||||
</div>
|
||||
<div class="chart-row-value">${count} 项</div>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
const awardChips = awardStats.map(item => `
|
||||
<div class="award-count-chip">
|
||||
<span class="award-count-title" title="${escapeHtml(item.title)}">${escapeHtml(item.title)}</span>
|
||||
<strong>${item.count}</strong>
|
||||
<span>人获得</span>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
return `
|
||||
<div class="results-summary">
|
||||
<div class="summary-stat-tile">
|
||||
<span>查询结果</span>
|
||||
<strong>${data.length}</strong>
|
||||
</div>
|
||||
<div class="summary-stat-tile">
|
||||
<span>涉及人员</span>
|
||||
<strong>${holderStats.length}</strong>
|
||||
</div>
|
||||
<div class="summary-stat-tile">
|
||||
<span>奖项种类</span>
|
||||
<strong>${awardStats.length}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stats-grid">
|
||||
<section class="stats-panel">
|
||||
<div class="stats-panel-title">个人奖项数量</div>
|
||||
<div class="bar-chart">${holderBars}</div>
|
||||
</section>
|
||||
<section class="stats-panel">
|
||||
<div class="stats-panel-title">查询奖项获得人数</div>
|
||||
<div class="award-count-grid">${awardChips || '<div class="muted-note">暂无奖项名称</div>'}</div>
|
||||
</section>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderResults(data, awardRecipientCounts = {}) {
|
||||
const display = document.getElementById('resultsArea');
|
||||
if (!data || data.length === 0) {
|
||||
display.innerHTML = '<div class="empty-state">未找到匹配的证书记录。</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = `
|
||||
${renderAwardStats(data, awardRecipientCounts)}
|
||||
<div class="table-wrapper">
|
||||
<table class="result-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>证书编号</th>
|
||||
<th>持有人</th>
|
||||
<th>荣誉标题</th>
|
||||
<th>颁发日期</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
data.forEach(item => {
|
||||
html += `
|
||||
<tr>
|
||||
<td class="table-highlight">${escapeHtml(item.cert_number || '-')}</td>
|
||||
<td>${escapeHtml(item.holder_name || '-')}</td>
|
||||
<td>${escapeHtml(item.honor_title || '-')}</td>
|
||||
<td>${escapeHtml(item.issue_date || '-')}</td>
|
||||
<td><button class="tech-link-button secondary" type="button" onclick="goToDetail('${item.id}')">查看详情</button></td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
html += '</tbody></table></div>';
|
||||
display.innerHTML = html;
|
||||
}
|
||||
|
||||
function goToDetail(id) {
|
||||
window.location.href = `certificate.html?id=${id}`;
|
||||
}
|
||||
|
||||
function initializeSearchTermFromUrl() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const presetTerm =
|
||||
params.get('searchTerm') ||
|
||||
params.get('term') ||
|
||||
params.get('keyword') ||
|
||||
params.get('cert_number') ||
|
||||
params.get('certNumber') ||
|
||||
params.get('number') ||
|
||||
params.get('awardName') ||
|
||||
params.get('honor_title') ||
|
||||
params.get('honorTitle') ||
|
||||
params.get('award') ||
|
||||
params.get('q') ||
|
||||
'';
|
||||
|
||||
if (presetTerm) {
|
||||
document.getElementById('searchTerm').value = presetTerm;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('searchBtn').addEventListener('click', handleSearch);
|
||||
document.getElementById('searchTerm').addEventListener('keypress', e => {
|
||||
if (e.key === 'Enter') handleSearch();
|
||||
});
|
||||
initializeSearchTermFromUrl();
|
||||
@@ -0,0 +1,70 @@
|
||||
(function () {
|
||||
fetch("../notices.json?v=" + Math.floor(Date.now() / 300000), { cache: "no-store" })
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
throw new Error("notice source unavailable");
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(function (payload) {
|
||||
var notices = Array.isArray(payload) ? payload : payload.notices;
|
||||
var notice = Array.isArray(notices) && notices.find(function (item) {
|
||||
return item && item.enabled !== false;
|
||||
});
|
||||
|
||||
if (notice) {
|
||||
renderNotice(notice);
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
|
||||
function renderNotice(notice) {
|
||||
setText("noticeTitle", notice.title || "重要通知");
|
||||
setText("noticeSummary", notice.message || "");
|
||||
setText("noticeBadge", notice.badge || "通知");
|
||||
setText("noticeLevel", String(notice.level || "info").toUpperCase());
|
||||
setText("articleTitle", notice.title || "重要通知");
|
||||
setText("articleMessage", notice.message || "");
|
||||
setText("noticeDate", formatDate(notice.startsAt) || "未设置开始时间");
|
||||
setText("noticeWindow", formatWindow(notice.startsAt, notice.endsAt));
|
||||
}
|
||||
|
||||
function setText(id, text) {
|
||||
var node = document.getElementById(id);
|
||||
if (node) {
|
||||
node.textContent = text;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(value) {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return date.toLocaleDateString("zh-CN", {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit"
|
||||
});
|
||||
}
|
||||
|
||||
function formatWindow(start, end) {
|
||||
var startText = formatDate(start);
|
||||
var endText = formatDate(end);
|
||||
|
||||
if (startText && endText) {
|
||||
return startText + " 至 " + endText;
|
||||
}
|
||||
|
||||
if (startText) {
|
||||
return startText + " 起生效";
|
||||
}
|
||||
|
||||
return "长期有效";
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,100 @@
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
|
||||
if (!window._sbClient) {
|
||||
window._sbClient = window.supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
}
|
||||
const sbClient = window._sbClient;
|
||||
|
||||
async function loadTicketDetail() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const ticketId = urlParams.get('id');
|
||||
|
||||
if (!ticketId) {
|
||||
showError('未提供单据 ID。');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const { data: ticket, error } = await sbClient
|
||||
.from('tickets')
|
||||
.select('*')
|
||||
.eq('id', ticketId)
|
||||
.single();
|
||||
|
||||
if (error) throw error;
|
||||
if (!ticket) {
|
||||
showError('未找到该单据。');
|
||||
return;
|
||||
}
|
||||
|
||||
displayTicketDetail(ticket);
|
||||
} catch (error) {
|
||||
showError(error.message || '加载失败');
|
||||
}
|
||||
}
|
||||
|
||||
function displayTicketDetail(ticket) {
|
||||
const el = document.getElementById('detailContent');
|
||||
const processedLabel = ticket.processed ? '已处理' : '未处理';
|
||||
const completionLabel = ticket.status ? '已办结' : '未办结';
|
||||
const amount = Number(ticket.amount || 0).toLocaleString('zh-CN', {
|
||||
style: 'currency',
|
||||
currency: 'CNY'
|
||||
});
|
||||
|
||||
el.classList.remove('feedback-card');
|
||||
el.innerHTML = `
|
||||
<div class="ticket-header">
|
||||
<div>
|
||||
<div class="section-kicker">Ticket Detail</div>
|
||||
<h1 class="ticket-title">${ticket.ticket_number || '-'} / ${ticket.customer_name || '-'}</h1>
|
||||
<p class="ticket-subtitle">单据全量信息、处理状态与打印操作在此统一展示。</p>
|
||||
</div>
|
||||
<div class="top-actions-group">
|
||||
<span class="status-pill ${ticket.processed ? 'done' : 'pending'}">${processedLabel}</span>
|
||||
<span class="status-pill ${ticket.status ? 'done' : 'pending'}">${completionLabel}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ticket-detail-grid">
|
||||
${item('编号', ticket.ticket_number)}
|
||||
${item('姓名', ticket.customer_name)}
|
||||
${item('事由', ticket.reason)}
|
||||
${item('处理结果', ticket.result)}
|
||||
${item('金额', amount, 'money')}
|
||||
${item('开具人', ticket.issuer)}
|
||||
${item('创建时间', formatDate(ticket.created_at))}
|
||||
${item('办结日期', formatDate(ticket.processed_at))}
|
||||
${item('处理状态', `<span class="status-pill ${ticket.processed ? 'done' : 'pending'}">${processedLabel}</span>`, '', true)}
|
||||
${item('办结状态', `<span class="status-pill ${ticket.status ? 'done' : 'pending'}">${completionLabel}</span>`, '', true)}
|
||||
${item('备注', ticket.remarks || '无', '', false, true)}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function item(label, value, extraClass = '', isHTML = false, isWide = false) {
|
||||
return `
|
||||
<div class="detail-item${isWide ? ' wide' : ''}">
|
||||
<span class="detail-label">${label}</span>
|
||||
<div class="detail-value${extraClass ? ` ${extraClass}` : ''}">${isHTML ? value : (value || '无')}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function goPrint() {
|
||||
window.open(`print.html?id=${new URLSearchParams(location.search).get('id')}`, '_blank');
|
||||
}
|
||||
|
||||
function formatDate(dateString) {
|
||||
if (!dateString) return '暂无';
|
||||
return new Date(dateString).toLocaleString('zh-CN');
|
||||
}
|
||||
|
||||
function showError(msg) {
|
||||
const el = document.getElementById('detailContent');
|
||||
el.classList.add('feedback-card');
|
||||
el.innerHTML = `<div class="error-state">${msg}</div>`;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', loadTicketDetail);
|
||||
@@ -0,0 +1,132 @@
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
const sbClient = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
|
||||
let html5QrCode = null;
|
||||
|
||||
document.getElementById('startScanBtn').addEventListener('click', async () => {
|
||||
document.getElementById('scanner-overlay').style.display = 'flex';
|
||||
if (html5QrCode) {
|
||||
try {
|
||||
await html5QrCode.stop();
|
||||
} catch (e) {}
|
||||
}
|
||||
html5QrCode = new Html5Qrcode("reader");
|
||||
const config = { fps: 15, qrbox: { width: 250, height: 250 }, aspectRatio: 1.0 };
|
||||
try {
|
||||
await html5QrCode.start({ facingMode: "environment" }, config, (text) => {
|
||||
document.getElementById('searchTerm').value = text;
|
||||
closeScanner();
|
||||
handleSearch();
|
||||
});
|
||||
} catch (err) {
|
||||
alert("摄像头启动失败。");
|
||||
closeScanner();
|
||||
}
|
||||
});
|
||||
|
||||
async function closeScanner() {
|
||||
if (html5QrCode && html5QrCode.isScanning) {
|
||||
await html5QrCode.stop();
|
||||
}
|
||||
document.getElementById('scanner-overlay').style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('stopScanBtn').addEventListener('click', closeScanner);
|
||||
|
||||
async function handleSearch() {
|
||||
const searchTerm = document.getElementById('searchTerm').value.trim();
|
||||
const dateFrom = document.getElementById('dateFrom').value;
|
||||
const dateTo = document.getElementById('dateTo').value;
|
||||
const resultsDiv = document.getElementById('searchResults');
|
||||
|
||||
resultsDiv.innerHTML = '<div class="loading-state">正在连接单据数据库并执行检索...</div>';
|
||||
|
||||
try {
|
||||
let query = sbClient.from('tickets').select('*');
|
||||
if (searchTerm) {
|
||||
query = query.or(`ticket_number.ilike.%${searchTerm}%,customer_name.ilike.%${searchTerm}%`);
|
||||
}
|
||||
if (dateFrom) query = query.gte('created_at', dateFrom);
|
||||
if (dateTo) query = query.lte('created_at', dateTo);
|
||||
|
||||
const { data, error } = await query.order('created_at', { ascending: false });
|
||||
if (error) throw error;
|
||||
|
||||
displayResults(data);
|
||||
} catch (error) {
|
||||
resultsDiv.innerHTML = `<div class="error-state">查询失败:${error.message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
function displayResults(tickets) {
|
||||
const resultsDiv = document.getElementById('searchResults');
|
||||
if (!tickets || tickets.length === 0) {
|
||||
resultsDiv.innerHTML = '<div class="empty-state">未找到符合条件的单据记录。</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = `
|
||||
<div class="table-wrapper">
|
||||
<table class="result-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>编号</th>
|
||||
<th>姓名</th>
|
||||
<th>事由</th>
|
||||
<th>金额</th>
|
||||
<th>日期</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
tickets.forEach(ticket => {
|
||||
const amount = (ticket.amount || 0).toLocaleString('zh-CN', { style: 'currency', currency: 'CNY' });
|
||||
const reason = ticket.reason || '';
|
||||
const displayReason = reason.length > 18
|
||||
? `<span class="text-truncate" title="${reason}">${reason}</span>`
|
||||
: reason;
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td class="table-highlight">${ticket.ticket_number || ''}</td>
|
||||
<td>${ticket.customer_name || ''}</td>
|
||||
<td>${displayReason}</td>
|
||||
<td class="table-highlight">${amount}</td>
|
||||
<td>${ticket.created_at ? new Date(ticket.created_at).toLocaleDateString('zh-CN') : '-'}</td>
|
||||
<td>
|
||||
<span class="status-pill ${ticket.processed ? 'done' : 'pending'}">
|
||||
${ticket.processed ? '已处理' : '未处理'}
|
||||
</span>
|
||||
</td>
|
||||
<td><button class="tech-link-button secondary" type="button" onclick="location.href='detail.html?id=${ticket.id}'">查看详情</button></td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
html += '</tbody></table></div>';
|
||||
resultsDiv.innerHTML = html;
|
||||
}
|
||||
|
||||
function initializeSearchTermFromUrl() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const presetTerm =
|
||||
params.get('searchTerm') ||
|
||||
params.get('term') ||
|
||||
params.get('keyword') ||
|
||||
params.get('ticket_number') ||
|
||||
params.get('ticketNumber') ||
|
||||
params.get('number') ||
|
||||
params.get('q') ||
|
||||
'';
|
||||
|
||||
if (presetTerm) {
|
||||
document.getElementById('searchTerm').value = presetTerm;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('searchBtn').addEventListener('click', handleSearch);
|
||||
initializeSearchTermFromUrl();
|
||||
@@ -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();
|
||||
@@ -0,0 +1,73 @@
|
||||
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);
|
||||
+1
-72
@@ -65,77 +65,6 @@
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
fetch("../notices.json?v=" + Math.floor(Date.now() / 300000), { cache: "no-store" })
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
throw new Error("notice source unavailable");
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(function (payload) {
|
||||
var notices = Array.isArray(payload) ? payload : payload.notices;
|
||||
var notice = Array.isArray(notices) && notices.find(function (item) {
|
||||
return item && item.enabled !== false;
|
||||
});
|
||||
|
||||
if (notice) {
|
||||
renderNotice(notice);
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
|
||||
function renderNotice(notice) {
|
||||
setText("noticeTitle", notice.title || "重要通知");
|
||||
setText("noticeSummary", notice.message || "");
|
||||
setText("noticeBadge", notice.badge || "通知");
|
||||
setText("noticeLevel", String(notice.level || "info").toUpperCase());
|
||||
setText("articleTitle", notice.title || "重要通知");
|
||||
setText("articleMessage", notice.message || "");
|
||||
setText("noticeDate", formatDate(notice.startsAt) || "未设置开始时间");
|
||||
setText("noticeWindow", formatWindow(notice.startsAt, notice.endsAt));
|
||||
}
|
||||
|
||||
function setText(id, text) {
|
||||
var node = document.getElementById(id);
|
||||
if (node) {
|
||||
node.textContent = text;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(value) {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return date.toLocaleDateString("zh-CN", {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit"
|
||||
});
|
||||
}
|
||||
|
||||
function formatWindow(start, end) {
|
||||
var startText = formatDate(start);
|
||||
var endText = formatDate(end);
|
||||
|
||||
if (startText && endText) {
|
||||
return startText + " 至 " + endText;
|
||||
}
|
||||
|
||||
if (startText) {
|
||||
return startText + " 起生效";
|
||||
}
|
||||
|
||||
return "长期有效";
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script src="../js/notice-index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
<p><center>2026年1月6日更新</center></p>
|
||||
<p>我又来更新了,因为最近又开始忙了,所以这个网页版的更新也就搁置了,今天发现你已经收到信了,所以只能又急匆匆得更新这个东西(失败了,不知道写什么)。</p>
|
||||
<p>希望你喜欢这个小小的惊喜吧,虽然不是什么大项目,但是我还是希望你能喜欢。这里的部分属于客制化内容,我写的水平也不怎么样,见谅!</p>
|
||||
<p style="text-align: right;">—— 你的老友</p>
|
||||
<p style="text-align: right;">2026年1月5日</p>
|
||||
<p class="text-right">—— 你的老友</p>
|
||||
<p class="text-right">2026年1月5日</p>
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
<p>自从高中毕业之后感觉时间越来越快,又是一年年底了,今年下半年天天都很累,但感觉又没什么意义,可能是我没有找到对我来说真正有意义的事吧❓</p>
|
||||
<p>最后祝你新年快乐,万事如意!</p>
|
||||
<p>记得在后面的留言墙给我写留言哦,不过这个留言墙是公用的,你也可以看出来,,所以还是微信聊吧。我会适时把这一系列网页发布出去,你可以先看看,给我提提意见,我去压榨AI😊。</p>
|
||||
<p style="text-align: right;">—— 你的老友</p>
|
||||
<p style="text-align: right;">2025年12月30日</p>
|
||||
<p class="text-right">—— 你的老友</p>
|
||||
<p class="text-right">2025年12月30日</p>
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
<p>不知道你对于我这次的来信有没有惊喜,这应该是第二次吧(或许、应该、可能?)。虽然这次没有怎么准备(原谅我,下半年太忙了,直到12月底我才有空闲时间),怎么说,我已经编不下去了,就这样吧。</p>
|
||||
<p>最后,祝您在新的一年里:身体健康,万事如意,学业进步,心想事成!</p>
|
||||
<p>最后,再次祝你新年快乐!也祝愿我们友谊长青,期待我们能早日相见!(后面的留言板是新年祝福公开留言板,要是有其他想法微信联系哦😁)</p>
|
||||
<p style="text-align: right;">—— 你的老友</p>
|
||||
<p style="text-align: right;">2025年12月31日</p>
|
||||
<p class="text-right">—— 你的老友</p>
|
||||
<p class="text-right">2025年12月31日</p>
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
<p>好像没什么写的了,就这样吧,寒假估计还能见面,寒假见!有什么事见面再说。</p>
|
||||
<p>无论世界如何变迁,希望你始终保持龙马精神,眼里有光,心中有爱,脚下有路。</p>
|
||||
<p>让我们一起在2026年,跑出属于我们的精彩轨迹!</p>
|
||||
<p style="text-align: right;">—— 你的老友</p>
|
||||
<p style="text-align: right;">2026年1月4日</p>
|
||||
<p class="text-right">—— 你的老友</p>
|
||||
<p class="text-right">2026年1月4日</p>
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
<p>最后,愿你在2026年里,爱情甜蜜,友情长存!希望你能够遇到那个对的人,共同奔向幸福的未来。同时,也希望你能够珍惜身边的朋友,像马儿一样,忠诚可靠。</p>
|
||||
<p>无论世界如何变迁,希望你始终保持龙马精神,眼里有光,心中有爱,脚下有路。</p>
|
||||
<p>让我们一起在2026年,跑出属于我们的精彩轨迹!</p>
|
||||
<p style="text-align: right;">—— 你的老友</p>
|
||||
<p class="text-right">—— 你的老友</p>
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
<p>最近过得还好吗,行了,编不下去了了,就这样吧!不服就打死我😊</p>
|
||||
<p><img src="https://pic.biss.click/i/2026/01/06/vn0zxi.jpg" width="auto" height="auto" alt="137721b2825dc3e48046c416e7de92fe" /></p>
|
||||
<p>祝你新年快乐!</p>
|
||||
<p style="text-align: right;">—— 你的老友</p>
|
||||
<p style="text-align: right;">2026年1月5日</p>
|
||||
<p class="text-right">—— 你的老友</p>
|
||||
<p class="text-right">2026年1月5日</p>
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
<p>愿你在这奔腾的时代里,既有策马扬鞭的勇气,也有信马由缰的从容。不仅要在事业上马到成功,更要在生活中寻得那一抹属于自己的宁静草场。</p>
|
||||
<p>无论世界如何变迁,希望你始终保持龙马精神,眼里有光,心中有爱,脚下有路。</p>
|
||||
<p>让我们一起在2026年,跑出属于我们的精彩轨迹!</p>
|
||||
<p style="text-align: right;">—— 你的老友</p>
|
||||
<p class="text-right">—— 你的老友</p>
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
<p>似乎高中毕业后的联系就很少了,其实和大部分人的联系都少了,估计都是差不多的情况,毕竟天下没有不散的宴席。</p>
|
||||
<p>这次呢是把之前之前给我联系方式的人全都秘密寄了一封信,这封信应该可以算贺年信,也没怎么好好准备,里面应该有一封信和一张特殊的卡片,本来想弄红色的,结果太贵了,就想着紫色的也不错,寓意紫气东来嘛。至于信的内容呢就不要细看了,纯瞎写的(感觉说迟了,毕竟这个链接是附在这封信的末尾的)</p>
|
||||
<p>接下来就感觉没有什么了,提前祝你新年快乐!同时也祝愿友谊长青!当然,如果有机会的话,期待寒假重逢。</p>
|
||||
<p style="text-align: right;">—— 你的老友</p>
|
||||
<p style="text-align: right;">2026年1月5日</p>
|
||||
<p class="text-right">—— 你的老友</p>
|
||||
<p class="text-right">2026年1月5日</p>
|
||||
|
||||
+1
-102
@@ -30,108 +30,7 @@
|
||||
<p>© 2026 BI Intelligent Query Interface</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
|
||||
if (!window._sbClient) {
|
||||
window._sbClient = window.supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
}
|
||||
const sbClient = window._sbClient;
|
||||
|
||||
async function loadTicketDetail() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const ticketId = urlParams.get('id');
|
||||
|
||||
if (!ticketId) {
|
||||
showError('未提供单据 ID。');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const { data: ticket, error } = await sbClient
|
||||
.from('tickets')
|
||||
.select('*')
|
||||
.eq('id', ticketId)
|
||||
.single();
|
||||
|
||||
if (error) throw error;
|
||||
if (!ticket) {
|
||||
showError('未找到该单据。');
|
||||
return;
|
||||
}
|
||||
|
||||
displayTicketDetail(ticket);
|
||||
} catch (error) {
|
||||
showError(error.message || '加载失败');
|
||||
}
|
||||
}
|
||||
|
||||
function displayTicketDetail(ticket) {
|
||||
const el = document.getElementById('detailContent');
|
||||
const processedLabel = ticket.processed ? '已处理' : '未处理';
|
||||
const completionLabel = ticket.status ? '已办结' : '未办结';
|
||||
const amount = Number(ticket.amount || 0).toLocaleString('zh-CN', {
|
||||
style: 'currency',
|
||||
currency: 'CNY'
|
||||
});
|
||||
|
||||
el.classList.remove('feedback-card');
|
||||
el.innerHTML = `
|
||||
<div class="ticket-header">
|
||||
<div>
|
||||
<div class="section-kicker">Ticket Detail</div>
|
||||
<h1 class="ticket-title">${ticket.ticket_number || '-'} / ${ticket.customer_name || '-'}</h1>
|
||||
<p class="ticket-subtitle">单据全量信息、处理状态与打印操作在此统一展示。</p>
|
||||
</div>
|
||||
<div class="top-actions-group">
|
||||
<span class="status-pill ${ticket.processed ? 'done' : 'pending'}">${processedLabel}</span>
|
||||
<span class="status-pill ${ticket.status ? 'done' : 'pending'}">${completionLabel}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ticket-detail-grid">
|
||||
${item('编号', ticket.ticket_number)}
|
||||
${item('姓名', ticket.customer_name)}
|
||||
${item('事由', ticket.reason)}
|
||||
${item('处理结果', ticket.result)}
|
||||
${item('金额', amount, 'money')}
|
||||
${item('开具人', ticket.issuer)}
|
||||
${item('创建时间', formatDate(ticket.created_at))}
|
||||
${item('办结日期', formatDate(ticket.processed_at))}
|
||||
${item('处理状态', `<span class="status-pill ${ticket.processed ? 'done' : 'pending'}">${processedLabel}</span>`, '', true)}
|
||||
${item('办结状态', `<span class="status-pill ${ticket.status ? 'done' : 'pending'}">${completionLabel}</span>`, '', true)}
|
||||
${item('备注', ticket.remarks || '无', '', false, true)}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function item(label, value, extraClass = '', isHTML = false, isWide = false) {
|
||||
return `
|
||||
<div class="detail-item${isWide ? ' wide' : ''}">
|
||||
<span class="detail-label">${label}</span>
|
||||
<div class="detail-value${extraClass ? ` ${extraClass}` : ''}">${isHTML ? value : (value || '无')}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function goPrint() {
|
||||
window.open(`print.html?id=${new URLSearchParams(location.search).get('id')}`, '_blank');
|
||||
}
|
||||
|
||||
function formatDate(dateString) {
|
||||
if (!dateString) return '暂无';
|
||||
return new Date(dateString).toLocaleString('zh-CN');
|
||||
}
|
||||
|
||||
function showError(msg) {
|
||||
const el = document.getElementById('detailContent');
|
||||
el.classList.add('feedback-card');
|
||||
el.innerHTML = `<div class="error-state">${msg}</div>`;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', loadTicketDetail);
|
||||
</script>
|
||||
<script src="../js/ticket-detail.js"></script>
|
||||
<script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script>
|
||||
<script src="../js/notice-banner.js"></script>
|
||||
</body>
|
||||
|
||||
+1
-134
@@ -90,140 +90,7 @@
|
||||
<p>© 2026 BI Intelligent Query Interface</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
|
||||
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
|
||||
const sbClient = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||
|
||||
let html5QrCode = null;
|
||||
|
||||
document.getElementById('startScanBtn').addEventListener('click', async () => {
|
||||
document.getElementById('scanner-overlay').style.display = 'flex';
|
||||
if (html5QrCode) {
|
||||
try {
|
||||
await html5QrCode.stop();
|
||||
} catch (e) {}
|
||||
}
|
||||
html5QrCode = new Html5Qrcode("reader");
|
||||
const config = { fps: 15, qrbox: { width: 250, height: 250 }, aspectRatio: 1.0 };
|
||||
try {
|
||||
await html5QrCode.start({ facingMode: "environment" }, config, (text) => {
|
||||
document.getElementById('searchTerm').value = text;
|
||||
closeScanner();
|
||||
handleSearch();
|
||||
});
|
||||
} catch (err) {
|
||||
alert("摄像头启动失败。");
|
||||
closeScanner();
|
||||
}
|
||||
});
|
||||
|
||||
async function closeScanner() {
|
||||
if (html5QrCode && html5QrCode.isScanning) {
|
||||
await html5QrCode.stop();
|
||||
}
|
||||
document.getElementById('scanner-overlay').style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('stopScanBtn').addEventListener('click', closeScanner);
|
||||
|
||||
async function handleSearch() {
|
||||
const searchTerm = document.getElementById('searchTerm').value.trim();
|
||||
const dateFrom = document.getElementById('dateFrom').value;
|
||||
const dateTo = document.getElementById('dateTo').value;
|
||||
const resultsDiv = document.getElementById('searchResults');
|
||||
|
||||
resultsDiv.innerHTML = '<div class="loading-state">正在连接单据数据库并执行检索...</div>';
|
||||
|
||||
try {
|
||||
let query = sbClient.from('tickets').select('*');
|
||||
if (searchTerm) {
|
||||
query = query.or(`ticket_number.ilike.%${searchTerm}%,customer_name.ilike.%${searchTerm}%`);
|
||||
}
|
||||
if (dateFrom) query = query.gte('created_at', dateFrom);
|
||||
if (dateTo) query = query.lte('created_at', dateTo);
|
||||
|
||||
const { data, error } = await query.order('created_at', { ascending: false });
|
||||
if (error) throw error;
|
||||
|
||||
displayResults(data);
|
||||
} catch (error) {
|
||||
resultsDiv.innerHTML = `<div class="error-state">查询失败:${error.message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
function displayResults(tickets) {
|
||||
const resultsDiv = document.getElementById('searchResults');
|
||||
if (!tickets || tickets.length === 0) {
|
||||
resultsDiv.innerHTML = '<div class="empty-state">未找到符合条件的单据记录。</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = `
|
||||
<div class="table-wrapper">
|
||||
<table class="result-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>编号</th>
|
||||
<th>姓名</th>
|
||||
<th>事由</th>
|
||||
<th>金额</th>
|
||||
<th>日期</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
tickets.forEach(ticket => {
|
||||
const amount = (ticket.amount || 0).toLocaleString('zh-CN', { style: 'currency', currency: 'CNY' });
|
||||
const reason = ticket.reason || '';
|
||||
const displayReason = reason.length > 18
|
||||
? `<span class="text-truncate" title="${reason}">${reason}</span>`
|
||||
: reason;
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td class="table-highlight">${ticket.ticket_number || ''}</td>
|
||||
<td>${ticket.customer_name || ''}</td>
|
||||
<td>${displayReason}</td>
|
||||
<td class="table-highlight">${amount}</td>
|
||||
<td>${ticket.created_at ? new Date(ticket.created_at).toLocaleDateString('zh-CN') : '-'}</td>
|
||||
<td>
|
||||
<span class="status-pill ${ticket.processed ? 'done' : 'pending'}">
|
||||
${ticket.processed ? '已处理' : '未处理'}
|
||||
</span>
|
||||
</td>
|
||||
<td><button class="tech-link-button secondary" type="button" onclick="location.href='detail.html?id=${ticket.id}'">查看详情</button></td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
html += '</tbody></table></div>';
|
||||
resultsDiv.innerHTML = html;
|
||||
}
|
||||
|
||||
function initializeSearchTermFromUrl() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const presetTerm =
|
||||
params.get('searchTerm') ||
|
||||
params.get('term') ||
|
||||
params.get('keyword') ||
|
||||
params.get('ticket_number') ||
|
||||
params.get('ticketNumber') ||
|
||||
params.get('number') ||
|
||||
params.get('q') ||
|
||||
'';
|
||||
|
||||
if (presetTerm) {
|
||||
document.getElementById('searchTerm').value = presetTerm;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('searchBtn').addEventListener('click', handleSearch);
|
||||
initializeSearchTermFromUrl();
|
||||
</script>
|
||||
<script src="../js/ticket-index.js"></script>
|
||||
<script src="../js/notice-banner.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-134
@@ -6,91 +6,7 @@
|
||||
|
||||
<link rel="stylesheet" href="../css/notice-banner.css">
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, "Microsoft YaHei";
|
||||
background: white;
|
||||
}
|
||||
|
||||
/* ===== A4 容器 ===== */
|
||||
.page {
|
||||
width: 210mm;
|
||||
min-height: 297mm;
|
||||
margin: auto;
|
||||
padding: 20mm;
|
||||
position: relative;
|
||||
background: white;
|
||||
}
|
||||
|
||||
/* ===== 水印 ===== */
|
||||
.watermark {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%) rotate(-30deg);
|
||||
font-size: 50px;
|
||||
color: rgba(0, 0, 0, 0.08);
|
||||
white-space: nowrap;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ===== 标题 ===== */
|
||||
.title {
|
||||
text-align: center;
|
||||
font-size: 22px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* ===== 信息表格 ===== */
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 10px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.table td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 25%;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
/* ===== 页脚 ===== */
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 20mm;
|
||||
left: 20mm;
|
||||
right: 20mm;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* ===== 打印优化 ===== */
|
||||
@media print {
|
||||
.no-print {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.page {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../css/ticket-print.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -123,55 +39,7 @@ body {
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
|
||||
|
||||
<script>
|
||||
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();
|
||||
</script>
|
||||
<script src="../js/ticket-print.js"></script>
|
||||
<script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script>
|
||||
<script src="../js/notice-banner.js"></script>
|
||||
</body>
|
||||
|
||||
+1
-75
@@ -78,81 +78,7 @@
|
||||
<p>© 2026 BI Intelligent Query Interface</p>
|
||||
</footer>
|
||||
|
||||
<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>
|
||||
<script src="../js/xinhan-index.js"></script>
|
||||
<script src="../js/notice-banner.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user