調整前台欄位、後台新增居民功能
This commit is contained in:
parent
14af35f674
commit
6194430f3c
@ -1,188 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hant">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>未開通居民列表</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
#qrcodeModal .modal-body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-4">
|
||||
<h2 class="mb-4">未開通居民列表</h2>
|
||||
|
||||
<!-- 搜尋列 -->
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-3">
|
||||
<input type="text" id="searchName" class="form-control" placeholder="搜尋姓名">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<input type="text" id="searchEmail" class="form-control" placeholder="搜尋 Email">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-primary w-100" onclick="search()">搜尋</button>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-danger w-100" onclick="deleteSelected()">刪除勾選</button>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-secondary w-100" onclick="scanResident()">掃描住戶</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th><input type="checkbox" id="selectAll" onclick="toggleAll(this)"></th>
|
||||
<th>編號</th>
|
||||
<th>姓名</th>
|
||||
<th>Email</th>
|
||||
<th>聯絡電話</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="residentTable">
|
||||
<!-- 動態資料列 -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- 分頁 -->
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center" id="pagination"></ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<!-- Modal 彈出 QR Code -->
|
||||
<div class="modal fade" id="qrcodeModal" tabindex="-1" aria-labelledby="qrcodeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">開通 QR Code</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="關閉"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="qrcode"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap + QRCode.js -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/qrcodejs/qrcode.min.js"></script>
|
||||
|
||||
<script>
|
||||
const pageSize = 5;
|
||||
let currentPage = 1;
|
||||
let residents = [
|
||||
{ id: 1, name: "王小明", email: "xiaoming@example.com", phone: "0912-345-678" },
|
||||
{ id: 2, name: "林美麗", email: "meili@example.com", phone: "0987-654-321" },
|
||||
{ id: 3, name: "張大雄", email: "daxiong@example.com", phone: "0912-333-444" },
|
||||
{ id: 4, name: "李小龍", email: "dragon@example.com", phone: "0900-111-222" },
|
||||
{ id: 5, name: "周杰倫", email: "jay@example.com", phone: "0988-888-888" },
|
||||
{ id: 6, name: "蔡依林", email: "jolin@example.com", phone: "0977-777-777"},
|
||||
{ id: 7, name: "林志玲", email: "lin@example.com", phone: "0966-666-666" },
|
||||
{ id: 8, name: "王力宏", email: "leehom@example.com", phone: "0955-555-555" }
|
||||
];
|
||||
|
||||
function renderTable(data) {
|
||||
const tbody = document.getElementById("residentTable");
|
||||
tbody.innerHTML = "";
|
||||
|
||||
const start = (currentPage - 1) * pageSize;
|
||||
const pageData = data.slice(start, start + pageSize);
|
||||
|
||||
pageData.forEach(r => {
|
||||
const row = document.createElement("tr");
|
||||
row.innerHTML = `
|
||||
<td><input type="checkbox" class="row-checkbox" data-id="${r.id}"></td>
|
||||
<td>${r.id}</td>
|
||||
<td>${r.name}</td>
|
||||
<td>${r.email}</td>
|
||||
<td>${r.phone}</td>
|
||||
<td><button class="btn btn-success btn-sm" onclick="showQRCode('https://yourdomain.com/activate?id=${r.id}')">開通</button></td>
|
||||
`;
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
|
||||
renderPagination(data.length);
|
||||
}
|
||||
|
||||
function renderPagination(totalItems) {
|
||||
const totalPages = Math.ceil(totalItems / pageSize);
|
||||
const pagination = document.getElementById("pagination");
|
||||
pagination.innerHTML = "";
|
||||
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
const li = document.createElement("li");
|
||||
li.className = "page-item" + (i === currentPage ? " active" : "");
|
||||
li.innerHTML = `<a class="page-link" href="#" onclick="goToPage(${i})">${i}</a>`;
|
||||
pagination.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
||||
function goToPage(page) {
|
||||
currentPage = page;
|
||||
search(); // 重新篩選並渲染
|
||||
}
|
||||
|
||||
function search() {
|
||||
const nameInput = document.getElementById("searchName").value.toLowerCase();
|
||||
const emailInput = document.getElementById("searchEmail").value.toLowerCase();
|
||||
|
||||
const filtered = residents.filter(r =>
|
||||
r.name.toLowerCase().includes(nameInput) &&
|
||||
r.email.toLowerCase().includes(emailInput)
|
||||
);
|
||||
|
||||
renderTable(filtered);
|
||||
}
|
||||
|
||||
function toggleAll(source) {
|
||||
const checkboxes = document.querySelectorAll(".row-checkbox");
|
||||
checkboxes.forEach(cb => cb.checked = source.checked);
|
||||
}
|
||||
|
||||
function deleteSelected() {
|
||||
if (!confirm("確定要刪除勾選的資料嗎?")) return;
|
||||
|
||||
const selected = document.querySelectorAll(".row-checkbox:checked");
|
||||
const idsToDelete = Array.from(selected).map(cb => parseInt(cb.dataset.id));
|
||||
|
||||
residents = residents.filter(r => !idsToDelete.includes(r.id));
|
||||
currentPage = 1;
|
||||
search();
|
||||
document.getElementById("selectAll").checked = false;
|
||||
}
|
||||
|
||||
function showQRCode(url) {
|
||||
const qrContainer = document.getElementById("qrcode");
|
||||
qrContainer.innerHTML = "";
|
||||
new QRCode(qrContainer, {
|
||||
text: url,
|
||||
width: 200,
|
||||
height: 200
|
||||
});
|
||||
|
||||
const modal = new bootstrap.Modal(document.getElementById("qrcodeModal"));
|
||||
modal.show();
|
||||
}
|
||||
|
||||
function scanResident() {
|
||||
alert("這裡可以接掃描裝置或開啟相機功能");
|
||||
// 若你想改成開 QRCode 掃描,可在這裡整合 JS 掃描工具
|
||||
}
|
||||
|
||||
// 初次載入
|
||||
search();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -26,7 +26,7 @@
|
||||
position: fixed;
|
||||
top: 50px;
|
||||
left: 0;
|
||||
width: 200px;
|
||||
width: 240px; /* <--- 將這裡從 200px 修改為 250px (或其他您想要的值) */
|
||||
height: calc(100vh - 50px);
|
||||
z-index: 998;
|
||||
background-color: white; /* Fallback background for the container */
|
||||
@ -38,7 +38,7 @@
|
||||
border: none;
|
||||
}
|
||||
.main-content-area-wrapper {
|
||||
margin-left: 200px; /* Width of sidebar */
|
||||
margin-left: 240px; /* <--- 將這裡也從 200px 修改為 250px (與上面 .sidebar-container 的寬度一致) */
|
||||
padding-top: 50px; /* Height of header */
|
||||
height: calc(100vh - 50px);
|
||||
overflow: hidden; /* Contains the iframe properly */
|
||||
|
218
Backstage/resident_activation.html
Normal file
218
Backstage/resident_activation.html
Normal file
@ -0,0 +1,218 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hant">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>未開通居民列表</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh; /* 確保 body 至少和視窗一樣高 */
|
||||
margin: 0; /* 移除預設 margin */
|
||||
}
|
||||
|
||||
.container.mt-4 {
|
||||
flex-grow: 1; /* 讓主要內容區域填滿剩餘空間 */
|
||||
padding-bottom: 70px; /* 重要:為固定的分頁條預留空間,避免遮擋內容 */
|
||||
/* 這個值可以根據分頁條的實際高度進行調整 */
|
||||
}
|
||||
|
||||
#qrcodeModal .modal-body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* 固定分頁條的樣式 */
|
||||
nav.pagination-fixed {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
background-color: #f8f9fa; /* 給分頁條一個背景色,避免透明 */
|
||||
padding: 10px 0; /* 給分頁條一些上下內邊距 */
|
||||
border-top: 1px solid #dee2e6; /* 可選:給分頁條頂部加個邊框 */
|
||||
z-index: 1000; /* 確保分頁條在其他內容之上 */
|
||||
}
|
||||
|
||||
/* 確保分頁本身在固定容器內正確對齊 */
|
||||
nav.pagination-fixed .pagination {
|
||||
margin-bottom: 0; /* 移除 Bootstrap 分頁的預設下邊距 */
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-4">
|
||||
<h2 class="mb-4">未開通居民列表</h2>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-3">
|
||||
<input type="text" id="searchName" class="form-control" placeholder="搜尋姓名">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<input type="text" id="searchEmail" class="form-control" placeholder="搜尋 Email">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-primary w-100" onclick="search()">搜尋</button>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-danger w-100" onclick="deleteSelected()">刪除勾選</button>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-secondary w-100" onclick="scanResident()">掃描住戶</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th><input type="checkbox" id="selectAll" onclick="toggleAll(this)"></th>
|
||||
<th>編號</th>
|
||||
<th>姓名</th>
|
||||
<th>Email</th>
|
||||
<th>聯絡電話</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="residentTable">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<nav class="pagination-fixed">
|
||||
<ul class="pagination justify-content-center" id="pagination"></ul>
|
||||
</nav>
|
||||
|
||||
<div class="modal fade" id="qrcodeModal" tabindex="-1" aria-labelledby="qrcodeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">開通 QR Code</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="關閉"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="qrcode"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/qrcodejs/qrcode.min.js"></script>
|
||||
|
||||
<script>
|
||||
const pageSize = 10;
|
||||
let currentPage = 1;
|
||||
let residents = [
|
||||
{ id: 1, name: "王小明", email: "xiaoming@example.com", phone: "0912-345-678" },
|
||||
{ id: 2, name: "林美麗", email: "meili@example.com", phone: "0987-654-321" },
|
||||
{ id: 3, name: "張大雄", email: "daxiong@example.com", phone: "0912-333-444" },
|
||||
{ id: 4, name: "李小龍", email: "dragon@example.com", phone: "0900-111-222" },
|
||||
{ id: 5, name: "周杰倫", email: "jay@example.com", phone: "0988-888-888" },
|
||||
{ id: 6, name: "蔡依林", email: "jolin@example.com", phone: "0977-777-777"},
|
||||
{ id: 7, name: "林志玲", email: "lin@example.com", phone: "0966-666-666" },
|
||||
{ id: 8, name: "王力宏", email: "leehom@example.com", phone: "0955-555-555" },
|
||||
// 為了測試滾動效果,可以增加更多數據
|
||||
{ id: 9, name: "陳小春", email: "chen@example.com", phone: "0911-111-111" },
|
||||
{ id: 10, name: "五月天", email: "mayday@example.com", phone: "0922-222-222" },
|
||||
{ id: 11, name: "田馥甄", email: "hebe@example.com", phone: "0933-333-333" },
|
||||
{ id: 12, name: "鄧紫棋", email: "gem@example.com", phone: "0944-444-444" }
|
||||
];
|
||||
|
||||
function renderTable(data) {
|
||||
const tbody = document.getElementById("residentTable");
|
||||
tbody.innerHTML = "";
|
||||
|
||||
const start = (currentPage - 1) * pageSize;
|
||||
const pageData = data.slice(start, start + pageSize);
|
||||
|
||||
pageData.forEach(r => {
|
||||
const row = document.createElement("tr");
|
||||
row.innerHTML = `
|
||||
<td><input type="checkbox" class="row-checkbox" data-id="${r.id}"></td>
|
||||
<td>${r.id}</td>
|
||||
<td>${r.name}</td>
|
||||
<td>${r.email}</td>
|
||||
<td>${r.phone}</td>
|
||||
<td><button class="btn btn-success btn-sm" onclick="showQRCode('https://yourdomain.com/activate?id=${r.id}')">開通</button></td>
|
||||
`;
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
|
||||
renderPagination(data.length);
|
||||
}
|
||||
|
||||
function renderPagination(totalItems) {
|
||||
const totalPages = Math.ceil(totalItems / pageSize);
|
||||
const pagination = document.getElementById("pagination");
|
||||
pagination.innerHTML = "";
|
||||
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
const li = document.createElement("li");
|
||||
li.className = "page-item" + (i === currentPage ? " active" : "");
|
||||
li.innerHTML = `<a class="page-link" href="#" onclick="goToPage(${i})">${i}</a>`;
|
||||
pagination.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
||||
function goToPage(page) {
|
||||
currentPage = page;
|
||||
search(); // 重新篩選並渲染
|
||||
window.scrollTo(0, 0); // 換頁時滾動到頁面頂部 (可選)
|
||||
}
|
||||
|
||||
function search() {
|
||||
const nameInput = document.getElementById("searchName").value.toLowerCase();
|
||||
const emailInput = document.getElementById("searchEmail").value.toLowerCase();
|
||||
|
||||
const filtered = residents.filter(r =>
|
||||
r.name.toLowerCase().includes(nameInput) &&
|
||||
r.email.toLowerCase().includes(emailInput)
|
||||
);
|
||||
|
||||
renderTable(filtered);
|
||||
}
|
||||
|
||||
function toggleAll(source) {
|
||||
const checkboxes = document.querySelectorAll(".row-checkbox");
|
||||
checkboxes.forEach(cb => cb.checked = source.checked);
|
||||
}
|
||||
|
||||
function deleteSelected() {
|
||||
if (!confirm("確定要刪除勾選的資料嗎?")) return;
|
||||
|
||||
const selected = document.querySelectorAll(".row-checkbox:checked");
|
||||
const idsToDelete = Array.from(selected).map(cb => parseInt(cb.dataset.id));
|
||||
|
||||
residents = residents.filter(r => !idsToDelete.includes(r.id));
|
||||
currentPage = 1;
|
||||
search();
|
||||
document.getElementById("selectAll").checked = false;
|
||||
}
|
||||
|
||||
function showQRCode(url) {
|
||||
const qrContainer = document.getElementById("qrcode");
|
||||
qrContainer.innerHTML = "";
|
||||
new QRCode(qrContainer, {
|
||||
text: url,
|
||||
width: 200,
|
||||
height: 200
|
||||
});
|
||||
|
||||
const modal = new bootstrap.Modal(document.getElementById("qrcodeModal"));
|
||||
modal.show();
|
||||
}
|
||||
|
||||
function scanResident() {
|
||||
alert("這裡可以接掃描裝置或開啟相機功能");
|
||||
}
|
||||
|
||||
// 初次載入
|
||||
search();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
75
Backstage/resident_add.html
Normal file
75
Backstage/resident_add.html
Normal file
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hant">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>新增居民資料</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<h2 class="mb-4">新增居民資料</h2>
|
||||
<form id="createForm">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">姓名</label>
|
||||
<input type="text" class="form-control" id="name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">密碼</label>
|
||||
<input type="password" class="form-control" id="password" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="gender" class="form-label">性別</label>
|
||||
<select class="form-select" id="gender" required>
|
||||
<option value="">請選擇</option>
|
||||
<option value="男">男</option>
|
||||
<option value="女">女</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="birthday" class="form-label">生日</label>
|
||||
<input type="date" class="form-control" id="birthday" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="phone" class="form-label">手機號碼</label>
|
||||
<input type="text" class="form-control" id="phone" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">電子郵件</label>
|
||||
<input type="email" class="form-control" id="email" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="room" class="form-label">房號 / 室別</label>
|
||||
<input type="text" class="form-control" id="room" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="car" class="form-label">車牌號碼</label>
|
||||
<input type="text" class="form-control" id="car" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">新增居民</button>
|
||||
<a href="resident_list.html" class="btn btn-secondary ms-2">取消</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById("createForm").addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
// 這裡應該串接實際 API 儲存資料
|
||||
const newResident = {
|
||||
name: document.getElementById("name").value,
|
||||
password: document.getElementById("password").value,
|
||||
gender: document.getElementById("gender").value,
|
||||
birthday: document.getElementById("birthday").value,
|
||||
phone: document.getElementById("phone").value,
|
||||
email: document.getElementById("email").value,
|
||||
room: document.getElementById("room").value,
|
||||
car: document.getElementById("car").value
|
||||
};
|
||||
|
||||
console.log("新增的居民資料:", newResident);
|
||||
alert("資料已新增(實際需串接 API)");
|
||||
window.location.href = "resident_list.html";
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
106
Backstage/resident_edit.html
Normal file
106
Backstage/resident_edit.html
Normal file
@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hant">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>編輯居民資料</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<h2 class="mb-4">編輯居民資料</h2>
|
||||
<form id="editForm">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">姓名</label>
|
||||
<input type="text" class="form-control" id="name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">密碼</label>
|
||||
<input type="password" class="form-control" id="password" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="gender" class="form-label">性別</label>
|
||||
<select class="form-select" id="gender" required>
|
||||
<option value="">請選擇</option>
|
||||
<option value="男">男</option>
|
||||
<option value="女">女</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="birthday" class="form-label">生日</label>
|
||||
<input type="date" class="form-control" id="birthday" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="phone" class="form-label">手機號碼</label>
|
||||
<input type="text" class="form-control" id="phone" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">電子郵件</label>
|
||||
<input type="email" class="form-control" id="email" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="room" class="form-label">房號 / 室別</label>
|
||||
<input type="text" class="form-control" id="room" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="car" class="form-label">車牌號碼</label>
|
||||
<input type="text" class="form-control" id="car" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">儲存變更</button>
|
||||
<a href="resident_list.html" class="btn btn-secondary ms-2">取消</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 模擬資料(實際應從後端取)
|
||||
const residents = [
|
||||
{
|
||||
id: 1,
|
||||
name: "王小明",
|
||||
password: "1234",
|
||||
gender: "男",
|
||||
birthday: "1990-01-01",
|
||||
phone: "0912-345-678",
|
||||
email: "xiaoming@example.com",
|
||||
room: "A101",
|
||||
car: "ABC-1234"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "林美麗",
|
||||
password: "5678",
|
||||
gender: "女",
|
||||
birthday: "1995-05-15",
|
||||
phone: "0987-654-321",
|
||||
email: "meili@example.com",
|
||||
room: "B202",
|
||||
car: "XYZ-8888"
|
||||
}
|
||||
];
|
||||
|
||||
function getParam(key) {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.get(key);
|
||||
}
|
||||
|
||||
const id = parseInt(getParam("id"));
|
||||
const resident = residents.find(r => r.id === id);
|
||||
|
||||
if (resident) {
|
||||
document.getElementById("name").value = resident.name;
|
||||
document.getElementById("password").value = resident.password;
|
||||
document.getElementById("gender").value = resident.gender;
|
||||
document.getElementById("birthday").value = resident.birthday;
|
||||
document.getElementById("phone").value = resident.phone;
|
||||
document.getElementById("email").value = resident.email;
|
||||
document.getElementById("room").value = resident.room;
|
||||
document.getElementById("car").value = resident.car;
|
||||
}
|
||||
|
||||
document.getElementById("editForm").addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
alert("資料已儲存(實際需串接 API)");
|
||||
window.location.href = "resident_list.html";
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
21
Backstage/resident_import.html
Normal file
21
Backstage/resident_import.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hant">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>匯入資料</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<h2 class="mb-4">匯入居民資料</h2>
|
||||
<form>
|
||||
<div class="mb-3">
|
||||
<label for="fileInput" class="form-label">選擇 CSV 或 Excel 檔案</label>
|
||||
<input type="file" class="form-control" id="fileInput" accept=".csv, .xls, .xlsx">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">匯入</button>
|
||||
<a href="resident_list.html" class="btn btn-secondary ms-2">返回列表</a>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
227
Backstage/resident_list.html
Normal file
227
Backstage/resident_list.html
Normal file
@ -0,0 +1,227 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hant">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>居民列表</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.container.mt-4 {
|
||||
flex-grow: 1;
|
||||
padding-bottom: 70px;
|
||||
}
|
||||
|
||||
#qrcodeModal .modal-body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
nav.pagination-fixed {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
background-color: #f8f9fa;
|
||||
padding: 10px 0;
|
||||
border-top: 1px solid #dee2e6;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
nav.pagination-fixed .pagination {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-4">
|
||||
<h2 class="mb-4">居民列表</h2>
|
||||
<div class="row g-2 mb-3">
|
||||
<div class="col-4 col-md-2 col-lg-1">
|
||||
<a href="resident_add.html" class="btn btn-success w-100">新增</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-2 mb-3">
|
||||
<div class="col-sm-6 col-md-3 col-lg-2">
|
||||
<input type="text" id="searchName" class="form-control" placeholder="搜尋姓名">
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<input type="text" id="searchEmail" class="form-control" placeholder="搜尋 Email">
|
||||
</div>
|
||||
<div class="col-6 col-md-2 col-lg-2">
|
||||
<button class="btn btn-primary w-100" onclick="search()">搜尋</button>
|
||||
</div>
|
||||
<div class="col-6 col-md-3 col-lg-2">
|
||||
<button class="btn btn-danger w-100" onclick="deleteSelected()">刪除勾選</button>
|
||||
</div>
|
||||
<div class="col-4 col-md-2 col-lg-1">
|
||||
<a href="resident_import.html" class="btn btn-info w-100">匯入</a>
|
||||
</div>
|
||||
<div class="col-4 col-md-2 col-lg-1">
|
||||
<button class="btn btn-secondary w-100" onclick="exportResidents()">匯出</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th><input type="checkbox" id="selectAll" onclick="toggleAll(this)"></th>
|
||||
<th>編號</th>
|
||||
<th>姓名</th>
|
||||
<th>Email</th>
|
||||
<th>聯絡電話</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="residentTable"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<nav class="pagination-fixed">
|
||||
<ul class="pagination justify-content-center" id="pagination"></ul>
|
||||
</nav>
|
||||
|
||||
<div class="modal fade" id="qrcodeModal" tabindex="-1" aria-labelledby="qrcodeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">開通 QR Code</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="關閉"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="qrcode"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/qrcodejs/qrcode.min.js"></script>
|
||||
<script>
|
||||
const pageSize = 10;
|
||||
let currentPage = 1;
|
||||
let residents = [
|
||||
{ id: 1, name: "王小明", email: "xiaoming@example.com", phone: "0912-345-678" },
|
||||
{ id: 2, name: "林美麗", email: "meili@example.com", phone: "0987-654-321" },
|
||||
{ id: 3, name: "張大雄", email: "daxiong@example.com", phone: "0912-333-444" },
|
||||
{ id: 4, name: "李小龍", email: "dragon@example.com", phone: "0900-111-222" },
|
||||
{ id: 5, name: "周杰倫", email: "jay@example.com", phone: "0988-888-888" },
|
||||
{ id: 6, name: "蔡依林", email: "jolin@example.com", phone: "0977-777-777" },
|
||||
{ id: 7, name: "林志玲", email: "lin@example.com", phone: "0966-666-666" },
|
||||
{ id: 8, name: "王力宏", email: "leehom@example.com", phone: "0955-555-555" },
|
||||
{ id: 9, name: "陳小春", email: "chen@example.com", phone: "0911-111-111" },
|
||||
{ id: 10, name: "五月天", email: "mayday@example.com", phone: "0922-222-222" },
|
||||
{ id: 11, name: "田馥甄", email: "hebe@example.com", phone: "0933-333-333" },
|
||||
{ id: 12, name: "鄧紫棋", email: "gem@example.com", phone: "0944-444-444" }
|
||||
];
|
||||
|
||||
function renderTable(data) {
|
||||
const tbody = document.getElementById("residentTable");
|
||||
tbody.innerHTML = "";
|
||||
|
||||
const start = (currentPage - 1) * pageSize;
|
||||
const pageData = data.slice(start, start + pageSize);
|
||||
|
||||
pageData.forEach(r => {
|
||||
const row = document.createElement("tr");
|
||||
row.innerHTML = `
|
||||
<td><input type="checkbox" class="row-checkbox" data-id="${r.id}"></td>
|
||||
<td>${r.id}</td>
|
||||
<td>${r.name}</td>
|
||||
<td>${r.email}</td>
|
||||
<td>${r.phone}</td>
|
||||
<td>
|
||||
<a href="resident_edit.html?id=${r.id}" class="btn btn-warning btn-sm me-1">編輯</a>
|
||||
<button class="btn btn-danger btn-sm" onclick="deleteResident(${r.id})">刪除</button>
|
||||
</td>
|
||||
`;
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
|
||||
renderPagination(data.length);
|
||||
}
|
||||
|
||||
function renderPagination(totalItems) {
|
||||
const totalPages = Math.ceil(totalItems / pageSize);
|
||||
const pagination = document.getElementById("pagination");
|
||||
pagination.innerHTML = "";
|
||||
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
const li = document.createElement("li");
|
||||
li.className = "page-item" + (i === currentPage ? " active" : "");
|
||||
li.innerHTML = `<a class="page-link" href="#" onclick="goToPage(${i})">${i}</a>`;
|
||||
pagination.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
||||
function goToPage(page) {
|
||||
currentPage = page;
|
||||
search();
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
function search() {
|
||||
const nameInput = document.getElementById("searchName").value.toLowerCase();
|
||||
const emailInput = document.getElementById("searchEmail").value.toLowerCase();
|
||||
|
||||
const filtered = residents.filter(r =>
|
||||
r.name.toLowerCase().includes(nameInput) &&
|
||||
r.email.toLowerCase().includes(emailInput)
|
||||
);
|
||||
|
||||
renderTable(filtered);
|
||||
}
|
||||
|
||||
function toggleAll(source) {
|
||||
const checkboxes = document.querySelectorAll(".row-checkbox");
|
||||
checkboxes.forEach(cb => cb.checked = source.checked);
|
||||
}
|
||||
|
||||
function deleteSelected() {
|
||||
if (!confirm("確定要刪除勾選的資料嗎?")) return;
|
||||
|
||||
const selected = document.querySelectorAll(".row-checkbox:checked");
|
||||
const idsToDelete = Array.from(selected).map(cb => parseInt(cb.dataset.id));
|
||||
|
||||
residents = residents.filter(r => !idsToDelete.includes(r.id));
|
||||
currentPage = 1;
|
||||
search();
|
||||
document.getElementById("selectAll").checked = false;
|
||||
}
|
||||
|
||||
function deleteResident(id) {
|
||||
if (!confirm("確定要刪除此筆資料嗎?")) return;
|
||||
residents = residents.filter(r => r.id !== id);
|
||||
search();
|
||||
}
|
||||
|
||||
function showQRCode(url) {
|
||||
const qrContainer = document.getElementById("qrcode");
|
||||
qrContainer.innerHTML = "";
|
||||
new QRCode(qrContainer, {
|
||||
text: url,
|
||||
width: 200,
|
||||
height: 200
|
||||
});
|
||||
|
||||
const modal = new bootstrap.Modal(document.getElementById("qrcodeModal"));
|
||||
modal.show();
|
||||
}
|
||||
|
||||
function exportResidents() {
|
||||
alert("直接匯出搜尋查出的結果,如果沒有搜尋就全部匯出");
|
||||
}
|
||||
|
||||
// 初始化
|
||||
search();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -74,7 +74,7 @@
|
||||
|
||||
.has-submenu.open ul {
|
||||
padding-top: 5px;
|
||||
max-height: 200px;
|
||||
max-height: 200px; /* 您可以根據需要調整子選單展開的最大高度 */
|
||||
}
|
||||
|
||||
.has-submenu ul li {
|
||||
@ -111,7 +111,19 @@
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sidebar ul li .li-content span {
|
||||
/* ---- 這部分是為了讓 "未開通居民" 完整顯示而調整的樣式 ---- */
|
||||
.sidebar ul li .li-content > span:first-child {
|
||||
flex-grow: 1; /* 允許文字部分伸展以佔用可用空間 */
|
||||
min-width: 0; /* 在flex佈局中,這有助於正確處理溢出和 ellipsis */
|
||||
/* white-space, overflow, text-overflow 將從下面的通用規則繼承 */
|
||||
}
|
||||
|
||||
.sidebar ul li .li-content .badge {
|
||||
flex-shrink: 0; /* 防止徽章被壓縮 */
|
||||
}
|
||||
/* ---- 調整結束 ---- */
|
||||
|
||||
.sidebar ul li .li-content span { /* 此規則同時應用於文字 span 和徽章 span */
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@ -130,14 +142,13 @@
|
||||
<span class="submenu-arrow">▼</span>
|
||||
</div>
|
||||
<ul>
|
||||
<li onclick="requestNavigation('Activation.html', this)">
|
||||
<li onclick="requestNavigation('resident_activation.html', this)">
|
||||
<div class="li-content">
|
||||
<span>未開通居民</span>
|
||||
<span class="badge">8</span>
|
||||
</div>
|
||||
</li>
|
||||
<li onclick="requestNavigation('Activation.html', this)">居民列表</li>
|
||||
</ul>
|
||||
<li onclick="requestNavigation('resident_list.html', this)">居民列表</li></ul>
|
||||
</li>
|
||||
|
||||
<li onclick="requestNavigation('some_page1.html', this)">出入管理</li>
|
||||
@ -155,10 +166,42 @@
|
||||
console.log('Sidebar: 發送導航請求 ->', url);
|
||||
parent.postMessage({ type: 'navigate', url: url }, '*');
|
||||
|
||||
const listItems = document.querySelectorAll('.sidebar ul > li');
|
||||
listItems.forEach(item => item.classList.remove('active'));
|
||||
if (!clickedElement.closest('.has-submenu')) {
|
||||
clickedElement.classList.add('active');
|
||||
// 移除所有主項目和子項目的 active class
|
||||
const allItems = document.querySelectorAll('.sidebar ul li, .sidebar ul ul li');
|
||||
allItems.forEach(item => item.classList.remove('active'));
|
||||
|
||||
// 為當前點擊的項目添加 active class
|
||||
// 如果點擊的是子選單項,也將其父選單項目標記為 (視覺上) active (如果需要)
|
||||
clickedElement.classList.add('active');
|
||||
|
||||
// 如果點擊的是子選單中的項目,並且希望父選單也保持某種 'active' 或 'open' 的視覺提示
|
||||
// 目前的邏輯是點擊主選單項時移除其他 active,子選單項點擊時,父選單的 active 狀態會被移除
|
||||
// 如果希望父選單在子選單 active 時也高亮,需要調整 class 邏輯
|
||||
// 例如,只移除頂層 li 的 active,然後再設定。
|
||||
// 但目前的 active class 主要是用於頂層 li,子選單項本身高亮。
|
||||
// 如果父選單本身不是導航目標,只是個切換器,那它不應該有 active 狀態,除非子項被選中時特別標記
|
||||
if (!clickedElement.closest('.has-submenu > .submenu-toggle')) { // 確保不是點擊 submenu-toggle 本身
|
||||
const parentLi = clickedElement.closest('.sidebar > ul > li'); // 直接父 li
|
||||
if (parentLi && parentLi !== clickedElement) { // 如果點擊的是子選單項
|
||||
// 可以考慮不移除父 li 的 active,或者給父 li 一個不同的 "parent-active" class
|
||||
// 目前邏輯:如果點擊的是子項,父項(如"住戶居民"的li)的 active 會被移除,然後子項獲得 active
|
||||
// 為了清晰,讓頂層選單項(非子選單展開器)和子選單項競爭 active
|
||||
const topLevelListItems = document.querySelectorAll('.sidebar > ul > li');
|
||||
topLevelListItems.forEach(item => {
|
||||
if(item !== parentLi || !parentLi.classList.contains('has-submenu')){ // 非 submenu 的父級 li
|
||||
item.classList.remove('active');
|
||||
}
|
||||
});
|
||||
if (parentLi && !parentLi.classList.contains('has-submenu')){
|
||||
parentLi.classList.add('active');
|
||||
} else if (!clickedElement.closest('.has-submenu ul')) { // 如果點擊的是頂層且非 submenu-toggle
|
||||
clickedElement.classList.add('active');
|
||||
}
|
||||
} else if (clickedElement.closest('.sidebar > ul > li')) { // 點擊的是頂層 li
|
||||
const topLevelListItems = document.querySelectorAll('.sidebar > ul > li');
|
||||
topLevelListItems.forEach(item => item.classList.remove('active'));
|
||||
clickedElement.classList.add('active');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,7 +213,19 @@
|
||||
if (arrow) {
|
||||
arrow.textContent = parentLi.classList.contains('open') ? '▲' : '▼';
|
||||
}
|
||||
|
||||
// 當展開/收起子選單時,不要改變父選單項的 active 狀態
|
||||
// 也不要觸發 requestNavigation
|
||||
// event.stopPropagation(); // 如果 toggleSubmenu 是由事件直接調用且需要阻止冒泡
|
||||
}
|
||||
|
||||
// 初始化:確保第一個 'active' 的項目在加載時是正確的
|
||||
// 或者,您可以根據載入的頁面來動態設定 active class
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// 假設 'dashboard.html' 是首頁,它已經有 active class
|
||||
// 如果需要更複雜的邏輯來根據當前 URL 設定 active class,可以在這裡添加
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -155,6 +155,11 @@
|
||||
<input type="email" class="form-control" id="email" value="linxiaoan@gmail.com">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="room" class="form-label">房號 / 室別</label>
|
||||
<input type="text" class="form-control" id="room" value="A棟 5F-2" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="carPlate" class="form-label">車牌號碼</label>
|
||||
<input type="text" class="form-control" id="carPlate" value="ABC-1234">
|
||||
|
Loading…
x
Reference in New Issue
Block a user