Compare commits

..

No commits in common. "1f4510b82bdadfbf83c76646b33601e5085c3ef9" and "fc428269edea2c128c0ff5143117bf1ec824cce4" have entirely different histories.

2 changed files with 61 additions and 92 deletions

View File

@ -14,6 +14,7 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 100vh;
} }
.container { .container {
@ -24,13 +25,6 @@
padding: 20px 30px; padding: 20px 30px;
} }
@media (max-width: 576px) {
.container {
padding: 20px 15px;
max-width: 100%;
}
}
h1 { h1 {
text-align: center; text-align: center;
color: #333; color: #333;

View File

@ -4,70 +4,56 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Information</title> <title>Order Information</title>
<!-- 引入 Google Fonts 和 Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
<style> <style>
body { body {
font-family: 'Inter', sans-serif; font-family: Arial, sans-serif;
background: linear-gradient(135deg, #e0eafc, #cfdef3);
color: #333;
margin: 0; margin: 0;
padding: 0; padding: 0;
background-color: #f9f9f9;
} }
.container { .container {
margin: 40px auto; width: 80%;
background: #ffffff; margin: 20px auto;
padding: 20px 30px; background: #fff;
border-radius: 12px; padding: 20px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); border-radius: 8px;
max-width: 90%; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
} }
h2 { table {
width: 100%;
border-collapse: collapse;
}
table th, table td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
table th {
background-color: #f2f2f2;
}
.pagination {
margin: 20px 0;
text-align: center; text-align: center;
font-weight: 700;
margin-top: 0;
margin-bottom: 30px;
} }
.table { .pagination button {
margin-top: 20px; margin: 0 5px;
padding: 10px 20px;
border: none;
background-color: #007bff;
color: white;
cursor: pointer;
border-radius: 5px;
} }
.table th, .table td { .pagination button[disabled] {
vertical-align: middle; background-color: #ccc;
} cursor: not-allowed;
.table th {
background: #f7f9fc;
font-weight: 600;
}
.pagination-container {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20px;
}
.pagination-container span {
font-weight: 500;
color: #666;
}
.btn {
transition: background-color 0.3s ease, transform 0.2s ease;
}
.btn:hover {
background-color: #0056b3;
transform: scale(1.05);
}
.loading {
display: none;
text-align: center;
margin-top: 20px;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h2>Order Information</h2> <h2>Order Information</h2>
<div class="table-responsive"> <table id="orderTable">
<table class="table table-striped table-bordered">
<thead> <thead>
<tr> <tr>
<th>Order ID</th> <th>Order ID</th>
@ -82,20 +68,13 @@
<th>Status</th> <th>Status</th>
</tr> </tr>
</thead> </thead>
<tbody id="orderTableBody"> <tbody>
<!-- Orders will be dynamically inserted here --> <!-- Orders will be dynamically inserted here -->
</tbody> </tbody>
</table> </table>
</div> <div class="pagination">
<div class="pagination-container"> <button id="prevPageBtn" disabled>Previous</button>
<button class="btn btn-primary" id="prevPageBtn" disabled>Previous</button> <button id="nextPageBtn">Next</button>
<span id="currentPage">Page: 1</span>
<button class="btn btn-primary" id="nextPageBtn">Next</button>
</div>
<div class="loading" id="loading">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div> </div>
</div> </div>
@ -109,12 +88,9 @@
queryParams.page = queryParams.page || 1; queryParams.page = queryParams.page || 1;
queryParams.pageSize = queryParams.pageSize || 10; queryParams.pageSize = queryParams.pageSize || 10;
// 查询接口
const apiBaseUrl = 'http://127.0.0.1:5000'; const apiBaseUrl = 'http://127.0.0.1:5000';
async function queryOrder() { async function queryOrder() {
const loading = document.getElementById('loading');
loading.style.display = 'block'; // 显示加载动画
try { try {
const response = await fetch(`${apiBaseUrl}/queryOrder`, { const response = await fetch(`${apiBaseUrl}/queryOrder`, {
method: 'POST', method: 'POST',
@ -125,19 +101,16 @@
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to query orders'); throw new Error('Failed to query orders');
} }
const data = await response.json(); const data = await response.json();
renderTable(data.orders); renderTable(data.orders);
updatePaginationButtons(data.totalOrders); updatePaginationButtons(data.totalOrders);
} catch (error) { } catch (error) {
console.error('Network or server error:', error); console.error('Network or server error:', error);
} finally {
loading.style.display = 'none'; // 隐藏加载动画
} }
} }
function renderTable(orders) { function renderTable(orders) {
const tbody = document.getElementById('orderTableBody'); const tbody = document.querySelector('#orderTable tbody');
tbody.innerHTML = ''; // 清空表格内容 tbody.innerHTML = ''; // 清空表格内容
orders.forEach(order => { orders.forEach(order => {
const row = ` const row = `
@ -158,13 +131,14 @@
}); });
} }
// 更新分页按钮状态
function updatePaginationButtons(totalOrders) { function updatePaginationButtons(totalOrders) {
const totalPages = Math.ceil(totalOrders / queryParams.pageSize); const totalPages = Math.ceil(totalOrders / queryParams.pageSize);
document.getElementById('prevPageBtn').disabled = queryParams.page <= 1; document.getElementById('prevPageBtn').disabled = queryParams.page <= 1;
document.getElementById('nextPageBtn').disabled = queryParams.page >= totalPages; document.getElementById('nextPageBtn').disabled = queryParams.page >= totalPages;
document.getElementById('currentPage').textContent = `Page: ${queryParams.page}`;
} }
// 翻页操作
document.getElementById('prevPageBtn').addEventListener('click', () => { document.getElementById('prevPageBtn').addEventListener('click', () => {
if (queryParams.page > 1) { if (queryParams.page > 1) {
queryParams.page -= 1; queryParams.page -= 1;
@ -177,6 +151,7 @@
queryOrder(); queryOrder();
}); });
// 页面加载时查询第一页
queryOrder(); queryOrder();
</script> </script>
</body> </body>