前台微調,後台新增報修申請與廠商

This commit is contained in:
larry2701 2025-05-20 15:38:08 +08:00
parent 78afb69396
commit 43a0a8ac93
10 changed files with 504 additions and 38 deletions

View File

@ -10,7 +10,19 @@
<div class="container mt-4">
<div class="d-flex justify-content-between mb-3">
<h2>居民訊息列表</h2>
<button class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#searchModal">搜尋居民</button>
<!-- 右上搜尋按鈕已移除 -->
</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-3 col-lg-2">
<input type="text" id="searchroom" class="form-control" placeholder="搜尋 房號">
</div>
<div class="col-6 col-md-2 col-lg-2">
<button class="btn btn-outline-primary w-100 rounded-pill" onclick="window.alert('依據查詢關鍵字列出');">搜尋</button>
</div>
</div>
<table class="table table-bordered table-hover">
@ -35,21 +47,7 @@
</div>
</div>
<!-- 搜尋浮框 -->
<div class="modal fade" id="searchModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">搜尋居民</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<input type="text" id="searchInput" class="form-control" placeholder="輸入姓名或房號">
<ul class="list-group mt-2" id="searchResult"></ul>
</div>
</div>
</div>
</div>
<!-- 原先搜尋浮框 modal 已完全移除 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
@ -117,22 +115,7 @@
}
});
document.getElementById("searchInput").addEventListener("input", function() {
const keyword = this.value.trim().toLowerCase();
const results = residents.filter(r =>
r.name.toLowerCase().includes(keyword) ||
r.room.toLowerCase().includes(keyword)
);
const resultList = document.getElementById("searchResult");
resultList.innerHTML = "";
results.forEach(r => {
const li = document.createElement("li");
li.className = "list-group-item list-group-item-action";
li.textContent = `${r.name} (${r.room})`;
li.onclick = () => window.location.href = `message.html?id=${r.id}`;
resultList.appendChild(li);
});
});
// 已移除 searchInput 的事件監聽與功能
renderTable();
</script>

View File

@ -0,0 +1,67 @@
<!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>
/* 只針對狀態欄位中的 badge 進行字體放大 */
.status-badge {
font-size: 1rem;
padding: 0.6em 0.9em;
}
</style>
</head>
<body>
<div class="container mt-4">
<div class="d-flex justify-content-between mb-3">
<h2>水電報修列表</h2>
</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-3 col-lg-2">
<input type="text" id="searchroom" class="form-control" placeholder="搜尋 房號">
</div>
<div class="col-6 col-md-2 col-lg-2">
<button class="btn btn-outline-primary w-100 rounded-pill" onclick="window.alert('依據查詢關鍵字列出');">搜尋</button>
</div>
</div>
<table class="table table-bordered table-hover">
<thead class="table-light">
<tr>
<th>報修類型</th>
<th>住戶姓名</th>
<th>房號</th>
<th>報修說明</th>
<th>送出時間</th>
<th>狀態</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>水管漏水</td>
<td>王小明</td>
<th>C2C</th>
<td>廚房水管滴水不止</td>
<td>2025-05-20 10:15</td>
<td><span class="badge bg-warning text-dark status-badge">待處理</span></td>
<td><a href="repair_edit.html?id=1" class="btn btn-outline-secondary btn-sm">查看 / 編輯</a></td>
</tr>
<!-- 更多資料列可依照實際情況加上 -->
</tbody>
</table>
<div class="d-flex justify-content-between align-items-center">
<div><span>1</span> 頁,共 <span>1</span></div>
<div>
<button class="btn btn-sm btn-outline-secondary me-1">上一頁</button>
<button class="btn btn-sm btn-outline-secondary">下一頁</button>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,55 @@
<!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">
</head>
<body>
<div class="container mt-5">
<h2 class="mb-4">報修詳情</h2>
<form>
<div class="mb-3">
<label class="form-label">報修類型</label>
<input type="text" class="form-control" value="水管漏水" disabled>
</div>
<div class="mb-3">
<label class="form-label">住戶姓名</label>
<input type="text" class="form-control" value="王小明" disabled>
</div>
<div class="mb-3">
<label class="form-label">報修說明</label>
<textarea class="form-control" rows="4" disabled>廚房水管滴水不止</textarea>
</div>
<div class="mb-3">
<label class="form-label">報修圖片</label>
<div class="border rounded p-2" style="max-width: 300px;">
<img src="https://plumberwang.com.tw/wp-content/uploads/2021/07/%E6%B0%B4%E7%AE%A1%E6%BC%8F%E6%B0%B4.png" class="img-fluid rounded" alt="報修圖片">
</div>
</div>
<div class="mb-3">
<label for="costInput" class="form-label">維修費用(元)</label>
<input type="number" class="form-control" id="costInput" name="cost" value="0" min="0" step="1" placeholder="例如500">
</div>
<div class="mb-3">
<label for="statusSelect" class="form-label">狀態</label>
<select id="statusSelect" class="form-select">
<option value="待處理" selected>待處理</option>
<option value="已報修">已報修</option>
<option value="處理中">處理中</option>
<option value="已完成">已完成</option>
</select>
</div>
<button type="submit" class="btn btn-primary">儲存</button>
<a href="repair-list.html" class="btn btn-secondary ms-2">返回列表</a>
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,55 @@
<!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="createVendorForm">
<div class="mb-3">
<label for="vendorName" class="form-label">廠商名稱</label>
<input type="text" class="form-control" id="vendorName" required>
</div>
<div class="mb-3">
<label for="contact" class="form-label">聯絡人</label>
<input type="text" class="form-control" id="contact" 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="address" class="form-label">地址</label>
<input type="text" class="form-control" id="address" required>
</div>
<div class="mb-3">
<label for="service" class="form-label">服務項目</label>
<input type="text" class="form-control" id="service" required>
</div>
<button type="submit" class="btn btn-success">新增廠商</button>
<a href="repair_firm_list.html" class="btn btn-secondary ms-2">取消</a>
</form>
</div>
<script>
document.getElementById("createVendorForm").addEventListener("submit", function (e) {
e.preventDefault();
const newVendor = {
name: document.getElementById("vendorName").value,
contact: document.getElementById("contact").value,
phone: document.getElementById("phone").value,
address: document.getElementById("address").value,
service: document.getElementById("service").value
};
console.log("新增的廠商資料:", newVendor);
alert("資料已新增(實際需串接 API");
window.location.href = "vendor_list.html";
});
</script>
</body>
</html>

View File

@ -0,0 +1,71 @@
<!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="editVendorForm">
<div class="mb-3">
<label for="vendorName" class="form-label">廠商名稱</label>
<input type="text" class="form-control" id="vendorName" required>
</div>
<div class="mb-3">
<label for="contact" class="form-label">聯絡人</label>
<input type="text" class="form-control" id="contact" 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="address" class="form-label">地址</label>
<input type="text" class="form-control" id="address" required>
</div>
<div class="mb-3">
<label for="service" class="form-label">服務項目</label>
<input type="text" class="form-control" id="service" required>
</div>
<button type="submit" class="btn btn-primary">儲存變更</button>
<a href="repair_firm_list.html" class="btn btn-secondary ms-2">取消</a>
</form>
</div>
<script>
// 假資料,實際請根據 URL 的 ID 撈資料
const vendor = {
name: "台灣電機行",
contact: "陳先生",
phone: "0988-888-123",
address: "台北市信義區光復南路99號",
service: "電力檢修、設備維修"
};
// 將資料帶入表單
document.getElementById("vendorName").value = vendor.name;
document.getElementById("contact").value = vendor.contact;
document.getElementById("phone").value = vendor.phone;
document.getElementById("address").value = vendor.address;
document.getElementById("service").value = vendor.service;
document.getElementById("editVendorForm").addEventListener("submit", function (e) {
e.preventDefault();
const updatedVendor = {
name: document.getElementById("vendorName").value,
contact: document.getElementById("contact").value,
phone: document.getElementById("phone").value,
address: document.getElementById("address").value,
service: document.getElementById("service").value
};
console.log("更新後的廠商資料:", updatedVendor);
alert("資料已更新(實際需串接 API");
window.location.href = "vendor_list.html";
});
</script>
</body>
</html>

View 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="repair_firm_list.html" class="btn btn-secondary ms-2">返回列表</a>
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,171 @@
<!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; }
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; }
.btn {
font-weight: 500; font-size: 1rem;
padding: 0.5rem 0.75rem; transition: all 0.2s ease-in-out;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
</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="repair_firm_add.html" class="btn btn-outline-success w-100 rounded-pill">新增</a>
</div>
<div class="col-4 col-md-2 col-lg-1">
<a href="repair_firm_import.html" class="btn btn-outline-info w-100 rounded-pill">匯入</a>
</div>
<div class="col-4 col-md-2 col-lg-1">
<button class="btn btn-outline-secondary w-100 rounded-pill" onclick="exportVendors()">匯出</button>
</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="searchAddress" class="form-control" placeholder="搜尋地址">
</div>
<div class="col-6 col-md-2 col-lg-2">
<button class="btn btn-outline-primary w-100 rounded-pill" onclick="search()">搜尋</button>
</div>
<div class="col-6 col-md-2 col-lg-1">
<button class="btn btn-outline-danger w-100 rounded-pill" onclick="deleteSelected()">刪除勾選</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>聯絡人</th>
<th>聯絡電話</th>
<th>地址</th>
<th>服務項目</th>
<th>操作</th>
</tr>
</thead>
<tbody id="vendorTable"></tbody>
</table>
</div>
<nav class="pagination-fixed">
<ul class="pagination justify-content-center" id="pagination"></ul>
</nav>
<script>
const pageSize = 10;
let currentPage = 1;
let vendors = [
{ id: 1, name: "好修電器", contact: "陳先生", phone: "0912-111-222", address: "台北市大安區仁愛路一段1號", service: "家電維修" },
{ id: 2, name: "強力水電", contact: "林小姐", phone: "0988-333-444", address: "新北市板橋區文化路二段88號", service: "水電工程" },
{ id: 3, name: "快速冷氣", contact: "張先生", phone: "0922-555-666", address: "桃園市中壢區中正路100號", service: "冷氣維修" },
{ id: 4, name: "安全消防", contact: "李經理", phone: "0966-777-888", address: "台中市西屯區市政北七路22號", service: "消防設備" }
];
function renderTable(data) {
const tbody = document.getElementById("vendorTable");
tbody.innerHTML = "";
const start = (currentPage - 1) * pageSize;
const pageData = data.slice(start, start + pageSize);
pageData.forEach(v => {
const row = document.createElement("tr");
row.innerHTML = `
<td><input type="checkbox" class="row-checkbox" data-id="${v.id}"></td>
<td>${v.id}</td>
<td>${v.name}</td>
<td>${v.contact}</td>
<td>${v.phone}</td>
<td>${v.address || '-'}</td>
<td>${v.service || '-'}</td>
<td>
<a href="repair_firm_edit.html?id=${v.id}" class="btn btn-warning btn-sm me-1 rounded-pill">編輯</a>
<button class="btn btn-outline-danger btn-sm rounded-pill" onclick="deleteVendor(${v.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 addressInput = document.getElementById("searchAddress").value.toLowerCase();
const filtered = vendors.filter(v =>
v.name.toLowerCase().includes(nameInput) &&
v.address.toLowerCase().includes(addressInput)
);
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));
vendors = vendors.filter(v => !idsToDelete.includes(v.id));
currentPage = 1;
search();
document.getElementById("selectAll").checked = false;
}
function deleteVendor(id) {
if (!confirm("確定要刪除此筆資料嗎?")) return;
vendors = vendors.filter(v => v.id !== id);
search();
}
function exportVendors() {
alert("匯出搜尋結果(若無搜尋條件則匯出全部)");
}
search(); // 初始載入
</script>
</body>
</html>

View File

@ -172,9 +172,6 @@
<li onclick="requestNavigation('resident_list.html', this)">居民列表</li>
</ul>
</li>
<li onclick="requestNavigation('some_page1.html', this)">出入管理</li>
<li class="has-submenu">
<div class="submenu-toggle" onclick="toggleSubmenu(this)">
<span>警急通報</span>
@ -192,15 +189,41 @@
</ul>
</li>
<li class="has-submenu">
<div class="submenu-toggle" onclick="toggleSubmenu(this)">
<span>廣告</span>
<span class="parent-badge"></span>
<span class="submenu-arrow"></span>
</div>
<ul>
<li onclick="requestNavigation('CCCCC.html', this)">首頁輪播廣告</li>
<li onclick="requestNavigation('CCCCC.html', this)">跑馬登廣告</li>
</ul>
</li>
<li onclick="requestNavigation('some_page1.html', this)">出入管理</li>
<li onclick="requestNavigation('message_list.html', this)">
<div class="li-content">
<span>訊息通知</span>
<span class="badge" data-count="99">99</span>
</div>
</li>
<li onclick="requestNavigation('some_page4.html', this)">水電服務</li>
<li onclick="requestNavigation('some_page5.html', this)">佈告欄</li>
<li class="has-submenu">
<div class="submenu-toggle" onclick="toggleSubmenu(this)">
<span>水電報修</span>
<span class="parent-badge"></span>
<span class="submenu-arrow"></span>
</div>
<ul>
<li onclick="requestNavigation('repair-list.html', this)">
<div class="li-content">
<span>報修申請</span>
<span class="badge" data-count="99">99</span>
</div>
</li>
<li onclick="requestNavigation('repair_firm_list.html', this)">報修廠商</li>
</ul>
</li>
<li onclick="requestNavigation('some_page6.html', this)">報表匯出</li>
<li onclick="requestNavigation('some_page7.html', this)">設定</li>
</ul>

View File

@ -45,6 +45,16 @@
</div>
</div>
<nav class="navbar fixed-bottom navbar-light bg-light border-top">
<div class="container justify-content-around">
<a class="nav-link text-center" href="main.html"><div>🏠<br>首頁</div></a>
<a class="nav-link text-center" href="#"><div>🚪<br>出入</div></a>
<a class="nav-link text-center" href="message.html"><div>💬<br>訊息</div></a>
<a class="nav-link text-center" href="#"><div>👤<br>住戶</div></a>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
const activities = {

View File

@ -55,6 +55,16 @@
</form>
</div>
<nav class="navbar fixed-bottom navbar-light bg-light border-top">
<div class="container justify-content-around">
<a class="nav-link text-center" href="main.html"><div>🏠<br>首頁</div></a>
<a class="nav-link text-center" href="#"><div>🚪<br>出入</div></a>
<a class="nav-link text-center" href="message.html"><div>💬<br>訊息</div></a>
<a class="nav-link text-center" href="#"><div>👤<br>住戶</div></a>
</div>
</nav>
<script>
function submitActivity(event) {
event.preventDefault();