2025-05-09 13:25:31 +08:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="zh-Hant">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8" />
|
2025-05-19 17:06:28 +08:00
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
2025-05-09 13:25:31 +08:00
|
|
|
|
<title>功能列</title>
|
|
|
|
|
<style>
|
2025-05-13 17:49:03 +08:00
|
|
|
|
html, body {
|
|
|
|
|
height: 100%;
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
font-family: Arial, sans-serif;
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
* {
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background-color: #f8f9fa;
|
|
|
|
|
border-right: 1px solid #ddd;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar img {
|
|
|
|
|
display: block;
|
|
|
|
|
margin: 20px auto;
|
|
|
|
|
width: 60px;
|
|
|
|
|
height: 60px;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar ul {
|
|
|
|
|
list-style: none;
|
|
|
|
|
padding: 0;
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar ul li {
|
|
|
|
|
color: #333;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
padding: 12px 20px;
|
|
|
|
|
transition: background 0.2s ease;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar ul li:hover,
|
|
|
|
|
.sidebar ul li.active {
|
|
|
|
|
background-color: #e6f0f8;
|
|
|
|
|
color: #007bff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.has-submenu > .submenu-toggle {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2025-05-19 17:06:28 +08:00
|
|
|
|
gap: 6px;
|
|
|
|
|
user-select: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.has-submenu > .submenu-toggle > span:first-child {
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.parent-badge {
|
|
|
|
|
min-width: 20px;
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
color: white;
|
|
|
|
|
background-color: red;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.submenu-arrow {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
user-select: none;
|
2025-05-13 17:49:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.has-submenu ul {
|
|
|
|
|
list-style: none;
|
|
|
|
|
padding-left: 15px;
|
|
|
|
|
margin: 0;
|
|
|
|
|
max-height: 0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
transition: max-height 0.3s ease, padding 0.3s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.has-submenu.open ul {
|
|
|
|
|
padding-top: 5px;
|
2025-05-19 17:06:28 +08:00
|
|
|
|
max-height: 200px;
|
2025-05-13 17:49:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.has-submenu ul li {
|
|
|
|
|
padding: 10px 20px;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
color: #444;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.has-submenu ul li:hover {
|
|
|
|
|
background-color: #deeaf6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.badge {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
min-width: 20px;
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
color: white;
|
|
|
|
|
background-color: red;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
vertical-align: middle;
|
2025-05-19 17:06:28 +08:00
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
flex-shrink: 0;
|
2025-05-13 17:49:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar ul li .li-content {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-19 17:06:28 +08:00
|
|
|
|
/* ---- 讓 "未開通居民" 等文字完整顯示 ---- */
|
2025-05-14 17:21:10 +08:00
|
|
|
|
.sidebar ul li .li-content > span:first-child {
|
2025-05-19 17:06:28 +08:00
|
|
|
|
flex-grow: 1;
|
|
|
|
|
min-width: 0;
|
2025-05-14 17:21:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-19 17:06:28 +08:00
|
|
|
|
.sidebar ul li .li-content span {
|
2025-05-13 17:49:03 +08:00
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
2025-05-09 13:25:31 +08:00
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="sidebar">
|
2025-05-12 17:29:54 +08:00
|
|
|
|
<img src="https://cdn-icons-png.freepik.com/512/4873/4873262.png" alt="Logo" />
|
2025-05-09 13:25:31 +08:00
|
|
|
|
<ul>
|
2025-05-12 17:29:54 +08:00
|
|
|
|
<li class="active" onclick="requestNavigation('dashboard.html', this)">首頁</li>
|
2025-05-13 17:49:03 +08:00
|
|
|
|
|
|
|
|
|
<li class="has-submenu">
|
|
|
|
|
<div class="submenu-toggle" onclick="toggleSubmenu(this)">
|
|
|
|
|
<span>住戶居民</span>
|
2025-05-19 17:06:28 +08:00
|
|
|
|
<span class="parent-badge"></span>
|
2025-05-13 17:49:03 +08:00
|
|
|
|
<span class="submenu-arrow">▼</span>
|
|
|
|
|
</div>
|
|
|
|
|
<ul>
|
2025-05-14 17:21:10 +08:00
|
|
|
|
<li onclick="requestNavigation('resident_activation.html', this)">
|
2025-05-13 17:49:03 +08:00
|
|
|
|
<div class="li-content">
|
|
|
|
|
<span>未開通居民</span>
|
2025-05-19 17:06:28 +08:00
|
|
|
|
<span class="badge" data-count="8">8</span>
|
2025-05-13 17:49:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
</li>
|
2025-05-19 17:06:28 +08:00
|
|
|
|
<li onclick="requestNavigation('resident_list.html', this)">居民列表</li>
|
|
|
|
|
</ul>
|
2025-05-13 17:49:03 +08:00
|
|
|
|
</li>
|
2025-05-19 17:06:28 +08:00
|
|
|
|
<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('notification.html', this)">發送通報</li>
|
|
|
|
|
<li onclick="requestNavigation('notice_list.html', this)">
|
|
|
|
|
<div class="li-content">
|
|
|
|
|
<span>居民通報</span>
|
|
|
|
|
<span class="badge" data-count="99">99</span>
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
|
2025-05-20 15:38:08 +08:00
|
|
|
|
<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>
|
2025-05-19 17:06:28 +08:00
|
|
|
|
<li onclick="requestNavigation('message_list.html', this)">
|
|
|
|
|
<div class="li-content">
|
|
|
|
|
<span>訊息通知</span>
|
|
|
|
|
<span class="badge" data-count="99">99</span>
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
2025-05-20 15:38:08 +08:00
|
|
|
|
<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>
|
2025-05-12 17:29:54 +08:00
|
|
|
|
<li onclick="requestNavigation('some_page6.html', this)">報表匯出</li>
|
|
|
|
|
<li onclick="requestNavigation('some_page7.html', this)">設定</li>
|
2025-05-13 17:49:03 +08:00
|
|
|
|
</ul>
|
2025-05-09 13:25:31 +08:00
|
|
|
|
</div>
|
2025-05-12 17:29:54 +08:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
function requestNavigation(url, clickedElement) {
|
|
|
|
|
console.log('Sidebar: 發送導航請求 ->', url);
|
|
|
|
|
parent.postMessage({ type: 'navigate', url: url }, '*');
|
|
|
|
|
|
2025-05-14 17:21:10 +08:00
|
|
|
|
// 移除所有主項目和子項目的 active class
|
|
|
|
|
const allItems = document.querySelectorAll('.sidebar ul li, .sidebar ul ul li');
|
|
|
|
|
allItems.forEach(item => item.classList.remove('active'));
|
|
|
|
|
|
|
|
|
|
// 為當前點擊的項目添加 active class
|
|
|
|
|
clickedElement.classList.add('active');
|
|
|
|
|
|
2025-05-19 17:06:28 +08:00
|
|
|
|
// 處理父層active標示(僅當點擊子選單時)
|
|
|
|
|
if (clickedElement.closest('.has-submenu ul')) {
|
|
|
|
|
const parentLi = clickedElement.closest('.has-submenu');
|
|
|
|
|
if (parentLi) {
|
|
|
|
|
// 移除所有頂層 active,改由父層設定 active
|
|
|
|
|
document.querySelectorAll('.sidebar > ul > li').forEach(li => li.classList.remove('active'));
|
|
|
|
|
parentLi.classList.add('active');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 點擊頂層 li
|
|
|
|
|
document.querySelectorAll('.sidebar > ul > li').forEach(li => li.classList.remove('active'));
|
|
|
|
|
clickedElement.classList.add('active');
|
2025-05-12 17:29:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-13 17:49:03 +08:00
|
|
|
|
|
|
|
|
|
function toggleSubmenu(toggleElement) {
|
|
|
|
|
const parentLi = toggleElement.closest('.has-submenu');
|
|
|
|
|
parentLi.classList.toggle('open');
|
|
|
|
|
|
|
|
|
|
const arrow = toggleElement.querySelector('.submenu-arrow');
|
|
|
|
|
if (arrow) {
|
|
|
|
|
arrow.textContent = parentLi.classList.contains('open') ? '▲' : '▼';
|
|
|
|
|
}
|
2025-05-14 17:21:10 +08:00
|
|
|
|
|
2025-05-19 17:06:28 +08:00
|
|
|
|
updateParentBadges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateParentBadges() {
|
|
|
|
|
const submenuParents = document.querySelectorAll('.has-submenu');
|
|
|
|
|
|
|
|
|
|
submenuParents.forEach(parent => {
|
|
|
|
|
const isOpen = parent.classList.contains('open');
|
|
|
|
|
const badgeContainer = parent.querySelector('.parent-badge');
|
|
|
|
|
|
|
|
|
|
const subBadges = parent.querySelectorAll('ul .badge');
|
|
|
|
|
let total = 0;
|
|
|
|
|
|
|
|
|
|
subBadges.forEach(badge => {
|
|
|
|
|
const raw = badge.getAttribute('data-count');
|
|
|
|
|
const val = parseInt(raw, 10);
|
|
|
|
|
if (!isNaN(val)) {
|
|
|
|
|
total += val;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!isOpen && total > 0) {
|
|
|
|
|
badgeContainer.textContent = total;
|
|
|
|
|
badgeContainer.style.display = 'inline-block';
|
|
|
|
|
} else {
|
|
|
|
|
badgeContainer.style.display = 'none';
|
|
|
|
|
badgeContainer.textContent = '';
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-05-13 17:49:03 +08:00
|
|
|
|
}
|
2025-05-14 17:21:10 +08:00
|
|
|
|
|
2025-05-19 17:06:28 +08:00
|
|
|
|
// 初始化
|
2025-05-14 17:21:10 +08:00
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
2025-05-19 17:06:28 +08:00
|
|
|
|
updateParentBadges();
|
2025-05-14 17:21:10 +08:00
|
|
|
|
});
|
2025-05-12 17:29:54 +08:00
|
|
|
|
</script>
|
2025-05-09 13:25:31 +08:00
|
|
|
|
</body>
|
|
|
|
|
</html>
|