diff --git a/web/src/main/resources/static/index.html b/web/src/main/resources/static/index.html index d17c8b1..2a59a9b 100644 --- a/web/src/main/resources/static/index.html +++ b/web/src/main/resources/static/index.html @@ -499,7 +499,7 @@ 创建时间 跟进内容 响应时间 - 负责人 + 负责人 操作 @@ -532,7 +532,7 @@ 创建时间 跟进内容 响应时间 - 负责人 + 负责人 操作 @@ -558,6 +558,8 @@ var managersList = []; var allPersonalData = []; var isLoadingAllData = false; + var currentManagerFilter = null; + var currentFilterTable = 'personal'; function init() { var savedUserInfo = localStorage.getItem('userInfo'); @@ -670,6 +672,11 @@ role: usersManagements.role || '' }; + // 添加负责人筛选参数 + if (currentManagerFilter) { + params.managerName = currentManagerFilter; + } + var url = '/KH/api/users?' + objectToQueryString(params); var xhr = new XMLHttpRequest(); @@ -708,6 +715,11 @@ role: usersManagements.role || '' }; + // 添加负责人筛选参数 + if (currentManagerFilter) { + params.managerName = currentManagerFilter; + } + var url = '/KH/api/users?' + objectToQueryString(params); var xhr = new XMLHttpRequest(); @@ -761,11 +773,21 @@ // 根据筛选条件过滤 if (personalFilter === 'followed') { - return user.followup && user.followup !== ''; + if (!(user.followup && user.followup !== '')) { + return false; + } } else if (personalFilter === 'unfollowed') { - return !user.followup || user.followup === ''; + if (!(!user.followup || user.followup === '')) { + return false; + } + } + + // 按负责人筛选 + if (currentManagerFilter) { + return user.managerName === currentManagerFilter; } - // 'all' 或其他情况,不过滤 + + // 其他情况,不过滤 return true; }); @@ -849,6 +871,151 @@ } } + function toggleManagerFilter(tableType) { + currentFilterTable = tableType || 'personal'; + + // 收集当前表格中的所有负责人名称 + var managers = new Set(); + var bodyElement = currentFilterTable === 'personal' ? + document.getElementById('personalBody') : + document.getElementById('publicBody'); + + var rows = bodyElement.getElementsByTagName('tr'); + for (var i = 0; i < rows.length; i++) { + var cells = rows[i].getElementsByTagName('td'); + // 找到负责人列(索引为7,因为从0开始计数) + if (cells.length > 7) { + var managerName = cells[7].textContent.trim(); + if (managerName && managerName !== '-') { + managers.add(managerName); + } + } + } + + // 如果没有负责人数据,显示提示 + if (managers.size === 0) { + showAlert('当前表格中没有负责人数据'); + return; + } + + // 创建筛选菜单 + createManagerFilterMenu(Array.from(managers)); + } + + function createManagerFilterMenu(managers) { + // 移除已存在的筛选菜单 + var existingMenu = document.getElementById('managerFilterMenu'); + if (existingMenu) { + existingMenu.remove(); + } + + // 创建筛选菜单 + var menu = document.createElement('div'); + menu.id = 'managerFilterMenu'; + menu.style.cssText = ` + position: absolute; + background-color: white; + border: 1px solid #d9d9d9; + border-radius: 4px; + box-shadow: 0 4px 12px rgba(0,0,0,0.15); + z-index: 1001; + padding: 8px 0; + min-width: 150px; + `; + + // 添加清除筛选选项 + var clearOption = document.createElement('div'); + clearOption.textContent = '清除筛选'; + clearOption.style.cssText = ` + padding: 8px 16px; + cursor: pointer; + font-size: 14px; + `; + clearOption.onmouseover = function() { + this.style.backgroundColor = '#f5f5f5'; + }; + clearOption.onmouseout = function() { + this.style.backgroundColor = 'white'; + }; + clearOption.onclick = function() { + currentManagerFilter = null; + applyManagerFilter(); + menu.remove(); + }; + menu.appendChild(clearOption); + + // 添加分隔线 + var divider = document.createElement('div'); + divider.style.cssText = ` + height: 1px; + background-color: #f0f0f0; + margin: 4px 0; + `; + menu.appendChild(divider); + + // 添加负责人选项 + managers.forEach(function(manager) { + var option = document.createElement('div'); + option.textContent = manager; + option.style.cssText = ` + padding: 8px 16px; + cursor: pointer; + font-size: 14px; + `; + option.onmouseover = function() { + this.style.backgroundColor = '#f5f5f5'; + }; + option.onmouseout = function() { + this.style.backgroundColor = 'white'; + }; + option.onclick = function() { + currentManagerFilter = manager; + applyManagerFilter(); + menu.remove(); + }; + menu.appendChild(option); + }); + + // 获取表头位置并显示菜单 + var headerElement = currentFilterTable === 'personal' ? + document.getElementById('managerHeader') : + document.getElementById('publicManagerHeader'); + + var rect = headerElement.getBoundingClientRect(); + menu.style.left = rect.left + 'px'; + menu.style.top = (rect.top + rect.height) + 'px'; + + // 添加到页面 + document.body.appendChild(menu); + + // 点击页面其他地方关闭菜单 + document.addEventListener('click', function closeMenu(event) { + if (!menu.contains(event.target) && event.target !== headerElement) { + menu.remove(); + document.removeEventListener('click', closeMenu); + } + }); + } + + function applyManagerFilter() { + if (currentFilterTable === 'personal') { + // 个人表格筛选 + personalPage = 1; + if (personalFilter === 'followed' || personalFilter === 'unfollowed') { + displayFilteredPersonalData(); + } else { + loadAllPersonalData(); // 加载所有数据以便筛选 + } + } else { + // 公海池表格筛选 + // 公海池数据需要重新加载,因为它可能有分页 + loadPublicData(); + } + + // 更新表头样式 + updateManagerHeaderStyle(); + } + function loadPublicData() { var userRole = userInfo.loginInfo.projectName; var usersManagements = userInfo.usersManagements; @@ -865,6 +1032,11 @@ role: usersManagements.role || '' }; + // 添加负责人筛选参数 + if (currentManagerFilter) { + params.managerName = currentManagerFilter; + } + var url = '/KH/api/users/public?' + objectToQueryString(params); var xhr = new XMLHttpRequest(); @@ -1575,11 +1747,21 @@ // 根据筛选条件过滤 if (personalFilter === 'followed') { - return user.followup && user.followup !== ''; + if (!(user.followup && user.followup !== '')) { + return false; + } } else if (personalFilter === 'unfollowed') { - return !user.followup || user.followup === ''; + if (!(!user.followup || user.followup === '')) { + return false; + } + } + + // 按负责人筛选 + if (currentManagerFilter) { + return user.managerName === currentManagerFilter; } - // 'all' 或其他情况,不过滤 + + // 其他情况,不过滤 return true; }); @@ -1686,7 +1868,16 @@ if (data.users && data.users.length > 0) { publicEmpty.style.display = 'none'; var filteredUsers = data.users.filter(function(user) { - return user.type !== 'Colleague'; + if (user.type === 'Colleague') { + return false; + } + + // 按负责人筛选 + if (currentManagerFilter) { + return user.managerName === currentManagerFilter; + } + + return true; }); if (filteredUsers.length > 0) { @@ -1898,6 +2089,28 @@ document.body.style.overflow = 'hidden'; } + function updateManagerHeaderStyle() { + // 更新个人表格表头样式 + var managerHeader = document.getElementById('managerHeader'); + if (currentFilterTable === 'personal' && currentManagerFilter) { + managerHeader.style.backgroundColor = '#e6f7ff'; + managerHeader.style.color = '#1890ff'; + } else { + managerHeader.style.backgroundColor = ''; + managerHeader.style.color = ''; + } + + // 更新公海池表格表头样式 + var publicManagerHeader = document.getElementById('publicManagerHeader'); + if (currentFilterTable === 'public' && currentManagerFilter) { + publicManagerHeader.style.backgroundColor = '#e6f7ff'; + publicManagerHeader.style.color = '#1890ff'; + } else { + publicManagerHeader.style.backgroundColor = ''; + publicManagerHeader.style.color = ''; + } + } + function closeAlertModal() { document.getElementById('alertModal').style.display = 'none'; // 恢复背景滚动