/* Js for , Version=1785138794 */
 v.lang = {"confirmDelete":"\u60a8\u786e\u5b9a\u8981\u6267\u884c\u5220\u9664\u64cd\u4f5c\u5417\uff1f","deleteing":"\u5220\u9664\u4e2d","doing":"\u5904\u7406\u4e2d","loading":"\u52a0\u8f7d\u4e2d","updating":"\u66f4\u65b0\u4e2d...","timeout":"\u7f51\u7edc\u8d85\u65f6,\u8bf7\u91cd\u8bd5","errorThrown":"<h4>\u6267\u884c\u51fa\u9519\uff1a<\/h4>","continueShopping":"\u7ee7\u7eed\u8d2d\u7269","required":"\u5fc5\u586b","back":"\u8fd4\u56de","continue":"\u7ee7\u7eed","importTip":"\u53ea\u5bfc\u5165\u4e3b\u9898\u7684\u98ce\u683c\u548c\u6837\u5f0f","fullImportTip":"\u5c06\u4f1a\u5bfc\u5165\u6d4b\u8bd5\u6570\u636e\u4ee5\u53ca\u66ff\u6362\u7ad9\u70b9\u6587\u7ae0\u3001\u4ea7\u54c1\u7b49\u6570\u636e"};;v.pageID = 297;;
;v.pageLayout = "object";;
        // 全局变量
        let currentUser = '';
        
        // 初始化登录用户选项
        function initUserSelect() {
            const userSelect = document.getElementById('userSelect');
            for (let i = 1; i <= 20; i++) {
                const num = i.toString().padStart(3, '0');
                const option = document.createElement('option');
                option.value = `宾至嘉宁${num}`;
                option.textContent = `宾至嘉宁${num}`;
                userSelect.appendChild(option);
            }
        }

        // 获取今日日期（YYYY-MM-DD）
        function getTodayDate() {
            const today = new Date();
            return today.toISOString().split('T')[0];
        }

        // 格式化显示日期时间
        function formatDateTime(datetimeStr) {
            if (!datetimeStr) return '';
            // 将YYYY-MM-DDTHH:MM格式转为YYYY-MM-DD HH:MM
            return datetimeStr.replace('T', ' ');
        }

        // 更新今日数据汇总
        function updateTodaySummary() {
            const today = getTodayDate();
            
            // 统计今日保洁记录
            const cleanKey = getStorageKey('cleaning');
            const cleanData = JSON.parse(localStorage.getItem(cleanKey)) || [];
            const todayClean = cleanData.filter(item => item.date.startsWith(today)).length;
            
            // 统计今日绿化记录
            const greenKey = getStorageKey('greening');
            const greenData = JSON.parse(localStorage.getItem(greenKey)) || [];
            const todayGreen = greenData.filter(item => item.date.startsWith(today)).length;
            
            // 更新显示
            document.getElementById('todayCleanCount').textContent = todayClean;
            document.getElementById('todayGreenCount').textContent = todayGreen;
            
            // 设置当前日期显示
            const options = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
            document.getElementById('currentDate').textContent = new Date().toLocaleDateString('zh-CN', options);
        }

        // 登录验证
        function login() {
            const selectedUser = document.getElementById('userSelect').value;
            const password = document.getElementById('passwordInput').value;
            const errorDiv = document.getElementById('loginError');
            
            // 生成对应密码：bzjn + 后三位数字
            const userNum = selectedUser.slice(-3);
            const correctPwd = `bzjn${userNum}`;
            
            if (password === correctPwd) {
                currentUser = selectedUser;
                document.getElementById('loginPage').classList.add('hidden');
                document.getElementById('mainPage').classList.remove('hidden');
                document.getElementById('currentUser').textContent = currentUser;
                
                // 加载用户数据和今日汇总
                loadAllData();
                updateTodaySummary();
            } else {
                errorDiv.classList.remove('hidden');
                errorDiv.textContent = '密码错误，请重新输入！';
            }
        }

        // 退出登录
        function logout() {
            document.getElementById('mainPage').classList.add('hidden');
            document.getElementById('loginPage').classList.remove('hidden');
            document.getElementById('passwordInput').value = '';
            document.getElementById('loginError').classList.add('hidden');
            currentUser = '';
        }

        // 切换标签页
        function switchTab(tabId) {
            // 隐藏所有标签内容
            document.querySelectorAll('.tabContent').forEach(tab => {
                tab.classList.add('hidden');
            });
            // 移除所有导航按钮激活状态
            document.querySelectorAll('.navBtn').forEach(btn => {
                btn.classList.remove('active', 'bg-blue-100', 'font-bold');
            });
            // 显示选中标签
            document.getElementById(`${tabId}Tab`).classList.remove('hidden');
            // 激活导航按钮
            event.target.classList.add('active', 'bg-blue-100', 'font-bold');
            
            // 切换标签时刷新人员下拉选项
            if (tabId === 'cleaning') loadPersonOptions('clean', '保洁员');
            if (tabId === 'greening') loadPersonOptions('green', '绿化员');
            if (tabId === 'goods') loadPersonOptions('goods', '');
        }

        // 数据存储键名生成
        function getStorageKey(module) {
            return `bzjn_${currentUser.replace('宾至嘉宁', '')}_${module}`;
        }

        // 加载所有模块数据
        function loadAllData() {
            loadPersonnelData();
            loadCleaningData();
            loadGreeningData();
            loadGoodsData();
        }

        // 加载人员下拉选项
        function loadPersonOptions(type, postFilter = '') {
            const key = getStorageKey('personnel');
            const personnel = JSON.parse(localStorage.getItem(key)) || [];
            const selectElement = document.getElementById(`${type}Person`);
            const filterElement = document.getElementById(`filter${type.charAt(0).toUpperCase() + type.slice(1)}Person`);
            
            // 清空现有选项（保留默认选项）
            selectElement.innerHTML = '<option value="">请选择人员</option>';
            if (filterElement) filterElement.innerHTML = '<option value="">全部人员</option>';
            
            // 筛选并添加人员选项
            const filteredPersonnel = postFilter ? personnel.filter(p => p.post === postFilter) : personnel;
            filteredPersonnel.forEach(person => {
                const option = document.createElement('option');
                option.value = person.name;
                option.textContent = person.name;
                selectElement.appendChild(option);
                
                if (filterElement) {
                    const filterOption = document.createElement('option');
                    filterOption.value = person.name;
                    filterOption.textContent = person.name;
                    filterElement.appendChild(filterOption);
                }
            });
        }

        // --------------------- 人员管理模块 ---------------------
        function loadPersonnelData() {
            const key = getStorageKey('personnel');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            renderTable('personnelTable', data, 'personnel');
            
            // 人员数据更新后刷新其他模块的下拉框
            loadPersonOptions('clean', '保洁员');
            loadPersonOptions('green', '绿化员');
            loadPersonOptions('goods', '');
        }

        function addPersonnel() {
            const name = document.getElementById('personName').value;
            const post = document.getElementById('personPost').value;
            const phone = document.getElementById('personPhone').value;
            const date = document.getElementById('personDate').value;
            
            if (!name || !phone || !date) {
                alert('请填写完整信息！');
                return;
            }
            
            const key = getStorageKey('personnel');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            data.push({ id: Date.now(), name, post, phone, date });
            localStorage.setItem(key, JSON.stringify(data));
            
            // 清空表单
            document.getElementById('personName').value = '';
            document.getElementById('personPhone').value = '';
            document.getElementById('personDate').value = '';
            
            loadPersonnelData();
        }

        function deletePersonnel(id) {
            const key = getStorageKey('personnel');
            let data = JSON.parse(localStorage.getItem(key)) || [];
            data = data.filter(item => item.id !== id);
            localStorage.setItem(key, JSON.stringify(data));
            loadPersonnelData();
        }

        function searchPersonnel() {
            const keyword = document.getElementById('searchPerson').value.toLowerCase();
            const key = getStorageKey('personnel');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            const filtered = data.filter(item => 
                item.name.toLowerCase().includes(keyword) || 
                item.post.toLowerCase().includes(keyword)
            );
            renderTable('personnelTable', filtered, 'personnel');
        }

        // --------------------- 保洁记录模块 ---------------------
        function loadCleaningData() {
            const key = getStorageKey('cleaning');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            renderTable('cleaningTable', data, 'cleaning');
            loadPersonOptions('clean', '保洁员');
            updateTodaySummary();
        }

        function addCleaning() {
            const area = document.getElementById('cleanArea').value;
            const date = document.getElementById('cleanDate').value;
            const person = document.getElementById('cleanPerson').value;
            const content = document.getElementById('cleanContent').value;
            
            if (!area || !date || !person || !content) {
                alert('请填写完整信息！');
                return;
            }
            
            const key = getStorageKey('cleaning');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            data.push({ id: Date.now(), area, date, person, content });
            localStorage.setItem(key, JSON.stringify(data));
            
            // 清空表单
            document.getElementById('cleanArea').value = '';
            document.getElementById('cleanDate').value = '';
            document.getElementById('cleanPerson').value = '';
            document.getElementById('cleanContent').value = '';
            
            loadCleaningData();
        }

        function deleteCleaning(id) {
            const key = getStorageKey('cleaning');
            let data = JSON.parse(localStorage.getItem(key)) || [];
            data = data.filter(item => item.id !== id);
            localStorage.setItem(key, JSON.stringify(data));
            loadCleaningData();
        }

        function filterCleaning() {
            const filterPerson = document.getElementById('filterCleanPerson').value;
            const filterDate = document.getElementById('filterCleanDate').value;
            const key = getStorageKey('cleaning');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            
            const filtered = data.filter(item => {
                const matchPerson = filterPerson ? item.person === filterPerson : true;
                const matchDate = filterDate ? item.date.startsWith(filterDate) : true;
                return matchPerson && matchDate;
            });
            
            renderTable('cleaningTable', filtered, 'cleaning');
        }

        // --------------------- 绿化记录模块 ---------------------
        function loadGreeningData() {
            const key = getStorageKey('greening');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            renderTable('greeningTable', data, 'greening');
            loadPersonOptions('green', '绿化员');
            updateTodaySummary();
        }

        function addGreening() {
            const area = document.getElementById('greenArea').value;
            const date = document.getElementById('greenDate').value;
            const person = document.getElementById('greenPerson').value;
            const content = document.getElementById('greenContent').value;
            
            if (!area || !date || !person || !content) {
                alert('请填写完整信息！');
                return;
            }
            
            const key = getStorageKey('greening');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            data.push({ id: Date.now(), area, date, person, content });
            localStorage.setItem(key, JSON.stringify(data));
            
            // 清空表单
            document.getElementById('greenArea').value = '';
            document.getElementById('greenDate').value = '';
            document.getElementById('greenPerson').value = '';
            document.getElementById('greenContent').value = '';
            
            loadGreeningData();
        }

        function deleteGreening(id) {
            const key = getStorageKey('greening');
            let data = JSON.parse(localStorage.getItem(key)) || [];
            data = data.filter(item => item.id !== id);
            localStorage.setItem(key, JSON.stringify(data));
            loadGreeningData();
        }

        function filterGreening() {
            const filterPerson = document.getElementById('filterGreenPerson').value;
            const filterDate = document.getElementById('filterGreenDate').value;
            const key = getStorageKey('greening');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            
            const filtered = data.filter(item => {
                const matchPerson = filterPerson ? item.person === filterPerson : true;
                const matchDate = filterDate ? item.date.startsWith(filterDate) : true;
                return matchPerson && matchDate;
            });
            
            renderTable('greeningTable', filtered, 'greening');
        }

        // --------------------- 物品领用模块 ---------------------
        function loadGoodsData() {
            const key = getStorageKey('goods');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            renderTable('goodsTable', data, 'goods');
            loadPersonOptions('goods', '');
        }

        function addGoods() {
            const name = document.getElementById('goodsName').value;
            const num = document.getElementById('goodsNum').value;
            const date = document.getElementById('goodsDate').value;
            const person = document.getElementById('goodsPerson').value;
            
            if (!name || !num || !date || !person) {
                alert('请填写完整信息！');
                return;
            }
            
            const key = getStorageKey('goods');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            data.push({ id: Date.now(), name, num, date, person });
            localStorage.setItem(key, JSON.stringify(data));
            
            // 清空表单
            document.getElementById('goodsName').value = '';
            document.getElementById('goodsNum').value = '';
            document.getElementById('goodsDate').value = '';
            document.getElementById('goodsPerson').value = '';
            
            loadGoodsData();
        }

        function deleteGoods(id) {
            const key = getStorageKey('goods');
            let data = JSON.parse(localStorage.getItem(key)) || [];
            data = data.filter(item => item.id !== id);
            localStorage.setItem(key, JSON.stringify(data));
            loadGoodsData();
        }

        function filterGoods() {
            const filterPerson = document.getElementById('filterGoodsPerson').value;
            const filterDate = document.getElementById('filterGoodsDate').value;
            const key = getStorageKey('goods');
            const data = JSON.parse(localStorage.getItem(key)) || [];
            
            const filtered = data.filter(item => {
                const matchPerson = filterPerson ? item.person === filterPerson : true;
                const matchDate = filterDate ? item.date.startsWith(filterDate) : true;
                return matchPerson && matchDate;
            });
            
            renderTable('goodsTable', filtered, 'goods');
        }

        // 渲染表格通用函数
        function renderTable(tableId, data, module) {
            const table = document.getElementById(tableId);
            table.innerHTML = '';
            
            if (data.length === 0) {
                table.innerHTML = '<tr><td colspan="5" class="px-3 py-4 text-center text-gray-500">暂无数据</td></tr>';
                return;
            }
            
            data.forEach(item => {
                const tr = document.createElement('tr');
                tr.className = 'border-b border-gray-200';
                
                switch(module) {
                    case 'personnel':
                        tr.innerHTML = `
                            <td class="px-3 py-2">${item.name}</td>
                            <td class="px-3 py-2">${item.post}</td>
                            <td class="px-3 py-2">${item.phone}</td>
                            <td class="px-3 py-2">${item.date}</td>
                            <td class="px-3 py-2 text-center">
                                <button onclick="deletePersonnel(${item.id})" class="bg-red-500 text-white px-2 py-1 rounded-md hover:bg-red-600">删除</button>
                            </td>
                        `;
                        break;
                    case 'cleaning':
                        tr.innerHTML = `
                            <td class="px-3 py-2">${item.area}</td>
                            <td class="px-3 py-2">${formatDateTime(item.date)}</td>
                            <td class="px-3 py-2">${item.person}</td>
                            <td class="px-3 py-2">${item.content}</td>
                            <td class="px-3 py-2 text-center">
                                <button onclick="deleteCleaning(${item.id})" class="bg-red-500 text-white px-2 py-1 rounded-md hover:bg-red-600">删除</button>
                            </td>
                        `;
                        break;
                    case 'greening':
                        tr.innerHTML = `
                            <td class="px-3 py-2">${item.area}</td>
                            <td class="px-3 py-2">${formatDateTime(item.date)}</td>
                            <td class="px-3 py-2">${item.person}</td>
                            <td class="px-3 py-2">${item.content}</td>
                            <td class="px-3 py-2 text-center">
                                <button onclick="deleteGreening(${item.id})" class="bg-red-500 text-white px-2 py-1 rounded-md hover:bg-red-600">删除</button>
                            </td>
                        `;
                        break;
                    case 'goods':
                        tr.innerHTML = `
                            <td class="px-3 py-2">${item.name}</td>
                            <td class="px-3 py-2">${item.num}</td>
                            <td class="px-3 py-2">${formatDateTime(item.date)}</td>
                            <td class="px-3 py-2">${item.person}</td>
                            <td class="px-3 py-2 text-center">
                                <button onclick="deleteGoods(${item.id})" class="bg-red-500 text-white px-2 py-1 rounded-md hover:bg-red-600">删除</button>
                            </td>
                        `;
                        break;
                }
                
                table.appendChild(tr);
            });
        }

        // 页面加载初始化
        window.onload = function() {
            initUserSelect();
            
            // 登录事件
            document.getElementById('loginBtn').addEventListener('click', login);
            
            // 退出事件
            document.getElementById('logoutBtn').addEventListener('click', logout);
            
            // 导航切换事件
            document.querySelectorAll('.navBtn').forEach(btn => {
                btn.addEventListener('click', function() {
                    switchTab(this.dataset.tab);
                });
            });
            
            // 人员管理事件
            document.getElementById('addPersonBtn').addEventListener('click', addPersonnel);
            document.getElementById('searchPerson').addEventListener('input', searchPersonnel);
            
            // 保洁记录事件
            document.getElementById('addCleanBtn').addEventListener('click', addCleaning);
            document.getElementById('filterCleanPerson').addEventListener('change', filterCleaning);
            document.getElementById('filterCleanDate').addEventListener('change', filterCleaning);
            
            // 绿化记录事件
            document.getElementById('addGreenBtn').addEventListener('click', addGreening);
            document.getElementById('filterGreenPerson').addEventListener('change', filterGreening);
            document.getElementById('filterGreenDate').addEventListener('change', filterGreening);
            
            // 物品领用事件
            document.getElementById('addGoodsBtn').addEventListener('click', addGoods);
            document.getElementById('filterGoodsPerson').addEventListener('change', filterGoods);
            document.getElementById('filterGoodsDate').addEventListener('change', filterGoods);
            
            // 设置默认激活的导航按钮样式
            document.querySelector('.navBtn.active').classList.add('bg-blue-100', 'font-bold');
            
            // 设置当前日期显示（登录页也显示）
            const options = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
            document.getElementById('currentDate').textContent = new Date().toLocaleDateString('zh-CN', options);
        };
    ;// 确保DOM加载完成后再执行此脚本  
document.addEventListener('DOMContentLoaded', function() {  
    // 获取具有特定ID的链接  
    var noJumpLink = document.getElementById('block260');  
      
    // 为链接添加点击事件监听器  
    noJumpLink.addEventListener('click', function(event) {  
        // 阻止链接的默认跳转行为  
        event.preventDefault();  
        // 可以在这里添加其他处理逻辑，例如显示一个提示或执行其他操作  
        return false;  
    });  
});  ;$().ready(function() { $('#execIcon').tooltip({title:$('#execInfoBar').html(), html:true, placement:'right'}); }); ;$(document).ready(function()
{
    $('.nav-page-' + v.pageID + ':first').addClass('active');
});

;
var hash = window.location.hash.substring(1);
var browserLanguage = navigator.language || navigator.userLanguage; 
var resolution      = screen.availWidth + ' X ' + screen.availHeight;
$.get(createLink('log', 'record', "hash=" + hash), {browserLanguage:browserLanguage, resolution:resolution});
