Some checks failed
CD Pipeline / deploy (push) Failing after 59s
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml) - 部署模式: rsync Python 檔案至 188 → docker restart (volume mount) - Dockerfile/requirements 變動時自動重建 Docker image - 部署通知: Telegram (開始/成功/失敗) - 健康檢查: https://mo.wooo.work/health (最多 5 次重試) - 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
432 lines
17 KiB
HTML
432 lines
17 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-TW">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
<title>郵件發送記錄 - 廠商缺貨系統</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
|
<style>
|
|
body {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
|
|
min-height: 100vh;
|
|
padding-top: 70px;
|
|
}
|
|
|
|
.navbar-dark.bg-primary {
|
|
background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%) !important;
|
|
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
|
|
}
|
|
|
|
.navbar-dark .navbar-brand {
|
|
color: #ffffff !important;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link {
|
|
color: rgba(255, 255, 255, 0.9) !important;
|
|
font-weight: 500;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link:hover {
|
|
color: #ffffff !important;
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.navbar-dark .navbar-nav .nav-link.active {
|
|
color: #ffffff !important;
|
|
background: rgba(255, 255, 255, 0.15);
|
|
border-radius: 6px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.navbar-dark .navbar-text {
|
|
color: rgba(255, 255, 255, 0.8) !important;
|
|
}
|
|
|
|
.navbar {
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
|
|
}
|
|
.stats-card {
|
|
border-radius: 12px;
|
|
border: none;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
transition: transform 0.2s;
|
|
}
|
|
.stats-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.12);
|
|
}
|
|
.status-badge {
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
}
|
|
.status-sent { background: #d4edda; color: #155724; }
|
|
.status-failed { background: #f8d7da; color: #721c24; }
|
|
.status-pending { background: #fff3cd; color: #856404; }
|
|
.table-container {
|
|
background: white;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
}
|
|
/* Custom Dark Gray Navbar */
|
|
.navbar.bg-custom-dark {
|
|
background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
border-bottom: 1px solid rgba(255,255,255,0.1);
|
|
}
|
|
|
|
.navbar.bg-custom-dark .navbar-brand {
|
|
color: #ffffff;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.navbar.bg-custom-dark .navbar-nav .nav-link {
|
|
color: rgba(255, 255, 255, 0.85);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.navbar.bg-custom-dark .navbar-nav .nav-link:hover {
|
|
color: #ffffff;
|
|
}
|
|
|
|
.navbar.bg-custom-dark .navbar-nav .nav-link.active {
|
|
color: #ffffff;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.navbar.bg-custom-dark .navbar-text {
|
|
color: rgba(255, 255, 255, 0.75);
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- 導航列 -->
|
|
{% include 'components/_navbar.html' %}
|
|
|
|
<div class="container-fluid" style="padding: 2rem;">
|
|
<!-- 標題 -->
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h2 class="mb-0">
|
|
<i class="fas fa-paper-plane text-primary me-3"></i>郵件發送記錄
|
|
</h2>
|
|
<a href="/vendor-stockout" class="btn btn-outline-secondary">
|
|
<i class="fas fa-home me-2"></i>返回主頁
|
|
</a>
|
|
</div>
|
|
|
|
<!-- 統計卡片 -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-3 mb-3">
|
|
<div class="card stats-card">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<div class="text-muted small">總發送數</div>
|
|
<h3 class="mb-0" id="statTotal">0</h3>
|
|
</div>
|
|
<div class="fs-1 text-primary">
|
|
<i class="fas fa-envelope"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3 mb-3">
|
|
<div class="card stats-card">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<div class="text-muted small">成功</div>
|
|
<h3 class="mb-0 text-success" id="statSuccess">0</h3>
|
|
</div>
|
|
<div class="fs-1 text-success">
|
|
<i class="fas fa-check-circle"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3 mb-3">
|
|
<div class="card stats-card">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<div class="text-muted small">失敗</div>
|
|
<h3 class="mb-0 text-danger" id="statFailed">0</h3>
|
|
</div>
|
|
<div class="fs-1 text-danger">
|
|
<i class="fas fa-times-circle"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3 mb-3">
|
|
<div class="card stats-card">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<div class="text-muted small">成功率</div>
|
|
<h3 class="mb-0 text-info" id="statRate">0%</h3>
|
|
</div>
|
|
<div class="fs-1 text-info">
|
|
<i class="fas fa-chart-line"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 篩選區 -->
|
|
<div class="card mb-3" style="border-radius: 12px;">
|
|
<div class="card-body">
|
|
<div class="row g-3">
|
|
<div class="col-md-3">
|
|
<label class="form-label small">狀態</label>
|
|
<select class="form-select" id="filterStatus">
|
|
<option value="">全部</option>
|
|
<option value="sent">成功</option>
|
|
<option value="failed">失敗</option>
|
|
<option value="pending">待發送</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label class="form-label small">廠商代碼</label>
|
|
<input type="text" class="form-control" id="filterVendor" placeholder="輸入廠商代碼">
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label small">開始日期</label>
|
|
<input type="date" class="form-control" id="filterDateFrom">
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label small">結束日期</label>
|
|
<input type="date" class="form-control" id="filterDateTo">
|
|
</div>
|
|
<div class="col-md-2 d-flex align-items-end">
|
|
<button class="btn btn-primary w-100" onclick="loadData()">
|
|
<i class="fas fa-search me-2"></i>查詢
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 資料表格 -->
|
|
<div class="table-container">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>批次編號</th>
|
|
<th>廠商</th>
|
|
<th>收件者</th>
|
|
<th>主旨</th>
|
|
<th>商品數</th>
|
|
<th>狀態</th>
|
|
<th>發送時間</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="tableBody">
|
|
<tr>
|
|
<td colspan="8" class="text-center text-muted">
|
|
<i class="fas fa-spinner fa-spin me-2"></i>載入中...
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- 分頁 -->
|
|
<div class="d-flex justify-content-between align-items-center mt-3">
|
|
<div class="text-muted">
|
|
共 <span id="totalCount">0</span> 筆記錄
|
|
</div>
|
|
<nav>
|
|
<ul class="pagination mb-0" id="pagination"></ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
let currentPage = 1;
|
|
const pageSize = 20;
|
|
|
|
// 載入統計資料
|
|
async function loadStats() {
|
|
try {
|
|
const response = await fetch('/vendor-stockout/api/email/stats');
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
const data = result.data;
|
|
document.getElementById('statTotal').textContent = data.total_sent;
|
|
document.getElementById('statSuccess').textContent = data.success_count;
|
|
document.getElementById('statFailed').textContent = data.failed_count;
|
|
document.getElementById('statRate').textContent = data.success_rate + '%';
|
|
}
|
|
} catch (error) {
|
|
console.error('載入統計資料失敗:', error);
|
|
}
|
|
}
|
|
|
|
// 載入郵件記錄
|
|
async function loadData(page = 1) {
|
|
currentPage = page;
|
|
|
|
const status = document.getElementById('filterStatus').value;
|
|
const vendor = document.getElementById('filterVendor').value;
|
|
const dateFrom = document.getElementById('filterDateFrom').value;
|
|
const dateTo = document.getElementById('filterDateTo').value;
|
|
|
|
const params = new URLSearchParams({
|
|
page: page,
|
|
page_size: pageSize
|
|
});
|
|
|
|
if (status) params.append('status', status);
|
|
if (vendor) params.append('vendor_code', vendor);
|
|
if (dateFrom) params.append('date_from', dateFrom);
|
|
if (dateTo) params.append('date_to', dateTo);
|
|
|
|
try {
|
|
const response = await fetch(`/vendor-stockout/api/email/logs?${params}`);
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
renderTable(result.data);
|
|
renderPagination(result.total, page);
|
|
document.getElementById('totalCount').textContent = result.total;
|
|
} else {
|
|
alert('查詢失敗: ' + result.message);
|
|
}
|
|
} catch (error) {
|
|
console.error('載入資料失敗:', error);
|
|
alert('載入資料失敗: ' + error.message);
|
|
}
|
|
}
|
|
|
|
// 渲染表格
|
|
function renderTable(data) {
|
|
const tbody = document.getElementById('tableBody');
|
|
|
|
if (data.length === 0) {
|
|
tbody.innerHTML = `
|
|
<tr>
|
|
<td colspan="8" class="text-center text-muted">
|
|
<i class="fas fa-inbox me-2"></i>沒有記錄
|
|
</td>
|
|
</tr>
|
|
`;
|
|
return;
|
|
}
|
|
|
|
tbody.innerHTML = data.map(item => {
|
|
const statusClass = item.status === 'sent' ? 'status-sent' :
|
|
item.status === 'failed' ? 'status-failed' : 'status-pending';
|
|
const statusText = item.status === 'sent' ? '成功' :
|
|
item.status === 'failed' ? '失敗' : '待發送';
|
|
|
|
return `
|
|
<tr>
|
|
<td>${item.id}</td>
|
|
<td><small>${item.batch_id}</small></td>
|
|
<td>
|
|
<div><strong>${item.vendor_name}</strong></div>
|
|
<small class="text-muted">${item.vendor_code}</small>
|
|
</td>
|
|
<td><small>${item.recipient_email}</small></td>
|
|
<td style="max-width: 300px;">
|
|
<small>${item.subject}</small>
|
|
${item.error_message ? `<div class="text-danger small mt-1">❌ ${item.error_message}</div>` : ''}
|
|
</td>
|
|
<td>${item.product_count}</td>
|
|
<td><span class="status-badge ${statusClass}">${statusText}</span></td>
|
|
<td><small>${item.sent_at || item.created_at}</small></td>
|
|
</tr>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
// 渲染分頁
|
|
function renderPagination(total, current) {
|
|
const totalPages = Math.ceil(total / pageSize);
|
|
const pagination = document.getElementById('pagination');
|
|
|
|
if (totalPages <= 1) {
|
|
pagination.innerHTML = '';
|
|
return;
|
|
}
|
|
|
|
let html = '';
|
|
|
|
// 上一頁
|
|
html += `
|
|
<li class="page-item ${current === 1 ? 'disabled' : ''}">
|
|
<a class="page-link" href="#" onclick="loadData(${current - 1}); return false;">上一頁</a>
|
|
</li>
|
|
`;
|
|
|
|
// 頁碼
|
|
for (let i = 1; i <= totalPages; i++) {
|
|
if (i === 1 || i === totalPages || (i >= current - 2 && i <= current + 2)) {
|
|
html += `
|
|
<li class="page-item ${i === current ? 'active' : ''}">
|
|
<a class="page-link" href="#" onclick="loadData(${i}); return false;">${i}</a>
|
|
</li>
|
|
`;
|
|
} else if (i === current - 3 || i === current + 3) {
|
|
html += '<li class="page-item disabled"><span class="page-link">...</span></li>';
|
|
}
|
|
}
|
|
|
|
// 下一頁
|
|
html += `
|
|
<li class="page-item ${current === totalPages ? 'disabled' : ''}">
|
|
<a class="page-link" href="#" onclick="loadData(${current + 1}); return false;">下一頁</a>
|
|
</li>
|
|
`;
|
|
|
|
pagination.innerHTML = html;
|
|
}
|
|
|
|
// 初始化
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
loadStats();
|
|
loadData(1);
|
|
|
|
// 每 30 秒自動重新整理統計資料
|
|
setInterval(loadStats, 30000);
|
|
});
|
|
</script>
|
|
<script>
|
|
// 更新導航列時鐘
|
|
function updateNavTime() {
|
|
const now = new Date();
|
|
const elem = document.getElementById('nav-time');
|
|
if (elem) {
|
|
elem.textContent = now.toLocaleString('zh-TW', {
|
|
year: 'numeric', month: '2-digit', day: '2-digit',
|
|
hour: '2-digit', minute: '2-digit', second: '2-digit'
|
|
});
|
|
}
|
|
}
|
|
updateNavTime();
|
|
setInterval(updateNavTime, 1000);
|
|
</script>
|
|
</body>
|
|
</html>
|