@@ -3621,7 +4091,7 @@
let showAll = false;
// 时间筛选相关变量
let currentTimeFilterType = 'dynamic';
- let currentTimeFilterContent = 'yesterday';
+ let currentTimeFilterContent = 'today';
let customStartDate = '';
let customEndDate = '';
@@ -3833,6 +4303,11 @@
if (currentTimeFilterType === 'dynamic') {
switch (currentTimeFilterContent) {
+ case 'today':
+ startDate = new Date(now);
+ startDate.setHours(0, 0, 0, 0);
+ endDate = now;
+ break;
case 'yesterday':
startDate = new Date(now);
startDate.setDate(startDate.getDate() - 1);
@@ -4252,7 +4727,7 @@
return currentPageRecords;
}
- const API_BASE_URL = 'http://localhost:8081/DL'; // 后端API基础地址
+ const API_BASE_URL = 'http://8.137.125.67:8080/DL'; // 后端API基础地址
// 获取登录用户信息函数
function getLoginUserInfo() {
@@ -4703,15 +5178,12 @@
// 生成通知列表HTML
const notificationsHTML = notifications.map(notification => `
-
+
- ${notification.customer.company} 有新客户:${notification.customer.contact}
-
-
${notification.time}
-
-
-
+ ${notification.customer.nickName || notification.customer.contact}
+ ${notification.customer.phoneNumber || notification.customer.phone}
+
${notification.time}
`).join('');
@@ -4721,7 +5193,10 @@
// 切换通知模态框显示
function toggleNotificationModal() {
const notificationModal = document.getElementById('notificationModal');
+ const notificationOverlay = document.getElementById('notificationModalOverlay');
+
notificationModal.classList.toggle('active');
+ notificationOverlay.classList.toggle('active');
// 如果打开模态框,标记所有通知为已读
if (notificationModal.classList.contains('active')) {
@@ -4735,7 +5210,11 @@
// 关闭通知模态框
function closeNotificationModal() {
- document.getElementById('notificationModal').classList.remove('active');
+ const notificationModal = document.getElementById('notificationModal');
+ const notificationOverlay = document.getElementById('notificationModalOverlay');
+
+ notificationModal.classList.remove('active');
+ notificationOverlay.classList.remove('active');
}
// 从通知弹窗查看客户详情
@@ -4957,6 +5436,26 @@
targetTbody.appendChild(row);
+ // 对当前等级的所有行按时间排序(优先使用修改时间,不存在则使用创建时间)
+ const rows = Array.from(targetTbody.querySelectorAll('tr'));
+ rows.sort((a, b) => {
+ // 获取修改时间,不存在则使用创建时间
+ const timeA = a.dataset.updatedAt || a.dataset.createdAt;
+ const timeB = b.dataset.updatedAt || b.dataset.createdAt;
+
+ // 如果都没有时间,保持原有顺序
+ if (!timeA && !timeB) return 0;
+ // 没有时间的行排在后面
+ if (!timeA) return 1;
+ if (!timeB) return -1;
+
+ // 按时间倒序排列(最新的在前面)
+ return new Date(timeB) - new Date(timeA);
+ });
+
+ // 重新添加排序后的行
+ rows.forEach(row => targetTbody.appendChild(row));
+
// 如果当前选中的等级是新增客户的等级,刷新分页
if (currentLevel === level) {
updatePagination();
@@ -5065,18 +5564,47 @@
console.log('认领客户结果:', data);
if (data.success) {
alert('客户认领成功!');
+
+ // 更新前端数据:从相应的公海池数据源中移除被认领的客户
+ if (customer.level === 'department-sea-pools') {
+ // 从部门公海池数据源中移除
+ departmentSeaPoolData = departmentSeaPoolData.filter(item => item.id !== customerId);
+ } else if (customer.level === 'organization-sea-pools') {
+ // 从组织公海池数据源中移除
+ organizationSeaPoolData = organizationSeaPoolData.filter(item => item.id !== customerId);
+ }
+
+ // 更新customerData中的客户等级
+ customer.level = 'unclassified'; // 认领后变为未分级客户
+
// 刷新公海池列表
- // 检查哪个公海池表格当前可见
+ // 根据当前选中的等级或表格显示状态来判断应该刷新哪个公海池
const departmentTable = document.getElementById('department-sea-pools-customers');
const organizationTable = document.getElementById('organization-sea-pools-customers');
- if (departmentTable && departmentTable.style.display === 'table-row-group') {
+ // 优先使用currentLevel变量判断当前显示的等级
+ if (currentLevel === 'department-sea-pools') {
+ // 如果当前选中的是部门公海池,直接更新部门公海池表格
+ updateDepartmentSeaPoolTable();
+ } else if (currentLevel === 'organization-sea-pools') {
+ // 如果当前选中的是组织公海池,直接更新组织公海池表格
+ updateOrganizationSeaPoolTable();
+ } else if (departmentTable && departmentTable.style.display === 'table-row-group') {
// 如果部门公海池表格可见,直接更新表格
updateDepartmentSeaPoolTable();
} else if (organizationTable && organizationTable.style.display === 'table-row-group') {
// 如果组织公海池表格可见,直接更新表格
updateOrganizationSeaPoolTable();
+ } else {
+ // 如果当前不在公海池视图,但可能在全部视图,两个表格都更新
+ updateDepartmentSeaPoolTable();
+ updateOrganizationSeaPoolTable();
}
+
+ // 同时更新全局客户列表和相关表格
+ updateRecentCustomers();
+ updateStatsCards();
+ updateCustomerTable(customer);
} else {
alert('客户认领失败: ' + (data.message || '未知错误'));
}
@@ -5179,38 +5707,114 @@
// 显示自定义详情
renderCustomDetails();
- // 处理公海需求部分显示
- const publicSeaDemandSection = document.getElementById('publicSeaDemandSection');
- console.log('公海需求区域元素:', publicSeaDemandSection);
+ // 处理公海池客户的特殊按钮设置
+ editSaveBtn = document.getElementById('editSaveBtn');
if (customer.level === 'department-sea-pools' || customer.level === 'organization-sea-pools') {
- console.log('显示公海需求区域');
- publicSeaDemandSection.style.display = 'block';
- // 填充公海需求数据,如果没有则显示默认值
- document.getElementById('detail-variety').textContent = customer.variety || '-';
- document.getElementById('detail-specification').textContent = customer.specification || '-';
- document.getElementById('detail-quantity').textContent = customer.quantity || '-';
- document.getElementById('detail-weight').textContent = customer.weight || '-';
-
// 公海池客户将编辑按钮改为认领按钮
- const editSaveBtn = document.getElementById('editSaveBtn');
- editSaveBtn.textContent = '认领';
- editSaveBtn.onclick = function() {
- claimCustomer(customer.id);
+ if (editSaveBtn) {
+ editSaveBtn.textContent = '认领';
+ // 移除之前的所有事件监听器,只保留当前需要的
+ editSaveBtn.onclick = function() {
+ claimCustomer(customer.id);
+ };
};
} else {
- console.log('隐藏公海需求区域');
- publicSeaDemandSection.style.display = 'none';
-
// 普通客户恢复编辑按钮功能
- const editSaveBtn = document.getElementById('editSaveBtn');
- editSaveBtn.textContent = '编辑';
- editSaveBtn.onclick = toggleEditMode;
+ if (editSaveBtn) {
+ editSaveBtn.textContent = '编辑';
+ // 统一使用onclick属性绑定事件,避免事件累积
+ editSaveBtn.onclick = toggleEditMode;
+ };
+ }
+
+ // 处理收藏夹显示
+ const favorites = customer.favorites || [];
+ const favoritesContainer = document.getElementById('favorites-container');
+ const favoriteFirstItem = document.getElementById('favorite-first-item');
+ const allFavorites = document.getElementById('all-favorites');
+ const noFavorites = document.getElementById('no-favorites');
+ const favoritesCardsContainer = document.getElementById('favorites-cards-container');
+
+ if (favorites && favorites.length > 0) {
+ // 有收藏数据
+ noFavorites.style.display = 'none';
+ favoriteFirstItem.style.display = 'block';
+ allFavorites.style.display = 'none';
+
+ // 显示第一个收藏项
+ const firstFavorite = favorites[0];
+ document.getElementById('favorite-product-name').textContent = firstFavorite.productName || '-';
+ document.getElementById('favorite-price').textContent = firstFavorite.price || '-';
+ document.getElementById('favorite-quantity').textContent = firstFavorite.quantity || '-';
+ document.getElementById('favorite-gross-weight').textContent = firstFavorite.grossWeight || '-';
+ document.getElementById('favorite-yolk').textContent = firstFavorite.yolk || '-';
+
+ // 绑定查看完整收藏事件
+ document.getElementById('view-all-favorites').onclick = function() {
+ favoriteFirstItem.style.display = 'none';
+ allFavorites.style.display = 'block';
+
+ // 生成收藏卡片
+ favoritesCardsContainer.innerHTML = '';
+ favorites.forEach((favorite, index) => {
+ const card = document.createElement('div');
+ card.className = 'favorite-card';
+ card.innerHTML = `
+
${favorite.productName || '未命名产品'}
+
+ 价格:
+ ${favorite.price || '-'}
+
+
+ 数量:
+ ${favorite.quantity || '-'}
+
+
+ 毛重:
+ ${favorite.grossWeight || '-'}
+
+
+ 蛋黄:
+ ${favorite.yolk || '-'}
+
+ ${favorite.assistant ? `
+ 助手:
+ ${favorite.assistant}
+
` : ''}
+ ${favorite.company ? `
+ 公司:
+ ${favorite.company}
+
` : ''}
+ `;
+ favoritesCardsContainer.appendChild(card);
+ });
+ };
+
+ // 绑定收起事件
+ document.getElementById('hide-all-favorites').onclick = function() {
+ allFavorites.style.display = 'none';
+ favoriteFirstItem.style.display = 'block';
+ };
+ } else {
+ // 无收藏数据
+ favoriteFirstItem.style.display = 'none';
+ allFavorites.style.display = 'none';
+ noFavorites.style.display = 'block';
}
document.getElementById('customerModal').classList.add('active');
document.body.style.overflow = 'hidden';
}
+ /**
+ * 客户详情编辑功能模块
+ * 实现客户详情的编辑、保存和取消功能
+ */
+ // 客户详情编辑功能相关变量
+ let isEditing = false; // 是否处于编辑状态
+ let originalCustomerData = null; // 原始客户数据,用于编辑时恢复或比较
+ let editSaveBtn = null;
+
// 切换编辑状态
function toggleEditMode() {
if (isEditing) {
@@ -5224,6 +5828,11 @@
}
}
+ // 页面加载完成后初始化编辑按钮事件 - 只初始化一次
+ document.addEventListener('DOMContentLoaded', function() {
+ // 只在页面加载时初始化editSaveBtn,后续在viewCustomerDetails中会重新获取和绑定事件
+ });
+
// 保存客户详情
function saveCustomerDetails() {
// 客户等级映射,与viewCustomerDetails函数中保持一致
@@ -5624,18 +6233,10 @@
}
}
- /**
- * 客户详情编辑功能模块
- * 实现客户详情的编辑、保存和取消功能
- */
- // 客户详情编辑功能相关变量
- let isEditing = false; // 是否处于编辑状态
- let originalCustomerData = null; // 原始客户数据,用于编辑时恢复或比较
-
+ // 客户详情弹窗相关元素
const viewButtons = document.querySelectorAll('.view-details');
const modal = document.getElementById('customerModal');
const closeModal = document.getElementById('closeModal');
- const editSaveBtn = document.getElementById('editSaveBtn');
const addDetailBtn = document.getElementById('addDetailBtn');
const addDetailModal = document.getElementById('addDetailModal');
const cancelAddDetail = document.getElementById('cancelAddDetail');
@@ -5697,91 +6298,117 @@
}
});
- // 编辑/确定按钮点击事件
- editSaveBtn.addEventListener('click', function () {
- toggleEditMode();
- });
+
- closeModal.addEventListener('click', function () {
- modal.classList.remove('active');
- document.body.style.overflow = 'auto';
- // 关闭弹窗时重置编辑状态
- if (isEditing) {
- isEditing = false;
- editSaveBtn.textContent = '编辑';
- disableEditing();
- }
- });
+ // 关闭弹窗按钮事件 - 添加空值检查
+ if (closeModal) {
+ closeModal.addEventListener('click', function () {
+ if (modal) {
+ modal.classList.remove('active');
+ document.body.style.overflow = 'auto';
+ // 关闭弹窗时重置编辑状态
+ if (isEditing && editSaveBtn) {
+ isEditing = false;
+ editSaveBtn.textContent = '编辑';
+ disableEditing();
+ }
+ }
+ });
+ }
- modal.addEventListener('click', function (e) {
- if (e.target === modal) {
- modal.classList.remove('active');
- document.body.style.overflow = 'auto';
- // 关闭弹窗时重置编辑状态
- if (isEditing) {
- isEditing = false;
- editSaveBtn.textContent = '编辑';
- disableEditing();
+ // 点击弹窗外部关闭事件 - 添加空值检查
+ if (modal) {
+ modal.addEventListener('click', function (e) {
+ if (e.target === modal) {
+ modal.classList.remove('active');
+ document.body.style.overflow = 'auto';
+ // 关闭弹窗时重置编辑状态
+ if (isEditing && editSaveBtn) {
+ isEditing = false;
+ editSaveBtn.textContent = '编辑';
+ disableEditing();
+ }
}
- }
- });
+ });
+ }
- // 关闭跟进详情弹窗
- closeFollowUpDetail.addEventListener('click', function () {
- followUpDetailModal.classList.remove('active');
- document.body.style.overflow = 'auto';
- });
+ // 关闭跟进详情弹窗 - 添加空值检查
+ if (closeFollowUpDetail) {
+ closeFollowUpDetail.addEventListener('click', function () {
+ if (followUpDetailModal) {
+ followUpDetailModal.classList.remove('active');
+ document.body.style.overflow = 'auto';
+ }
+ });
+ }
- followUpDetailModal.addEventListener('click', function (e) {
- if (e.target === followUpDetailModal) {
- followUpDetailModal.classList.remove('active');
- document.body.style.overflow = 'auto';
- }
- });
+ // 点击跟进弹窗外部关闭事件 - 添加空值检查
+ if (followUpDetailModal) {
+ followUpDetailModal.addEventListener('click', function (e) {
+ if (e.target === followUpDetailModal) {
+ followUpDetailModal.classList.remove('active');
+ document.body.style.overflow = 'auto';
+ }
+ });
+ }
- // 新增详情按钮事件
- addDetailBtn.addEventListener('click', function () {
- // 清空输入框
- document.getElementById('newContactName').value = '';
- document.getElementById('newContactPhone').value = '';
- document.getElementById('newContactAccount').value = '';
- document.getElementById('newContactAccountNumber').value = '';
- document.getElementById('newContactBank').value = '';
- document.getElementById('newContactAddress').value = '';
-
- // 显示新增详情弹窗
- addDetailModal.classList.add('active');
- });
+ // 新增详情按钮事件 - 添加空值检查
+ if (addDetailBtn) {
+ addDetailBtn.addEventListener('click', function () {
+ // 清空输入框
+ document.getElementById('newContactName').value = '';
+ document.getElementById('newContactPhone').value = '';
+ document.getElementById('newContactAccount').value = '';
+ document.getElementById('newContactAccountNumber').value = '';
+ document.getElementById('newContactBank').value = '';
+ document.getElementById('newContactAddress').value = '';
+
+ // 显示新增详情弹窗
+ if (addDetailModal) {
+ addDetailModal.classList.add('active');
+ }
+ });
+ }
- // 取消添加详情
- cancelAddDetail.addEventListener('click', function () {
- addDetailModal.classList.remove('active');
- });
+ // 取消添加详情 - 添加空值检查
+ if (cancelAddDetail) {
+ cancelAddDetail.addEventListener('click', function () {
+ if (addDetailModal) {
+ addDetailModal.classList.remove('active');
+ }
+ });
+ }
- // 确认添加详情
- confirmAddDetail.addEventListener('click', function () {
- const name = document.getElementById('newContactName').value.trim();
- const phone = document.getElementById('newContactPhone').value.trim();
- const account = document.getElementById('newContactAccount').value.trim();
- const accountNumber = document.getElementById('newContactAccountNumber').value.trim();
- const bank = document.getElementById('newContactBank').value.trim();
- const address = document.getElementById('newContactAddress').value.trim();
-
- if (!name) {
- alert('请输入联系人姓名');
- return;
- }
+ // 确认添加详情 - 添加空值检查
+ if (confirmAddDetail) {
+ confirmAddDetail.addEventListener('click', function () {
+ const name = document.getElementById('newContactName').value.trim();
+ const phone = document.getElementById('newContactPhone').value.trim();
+ const account = document.getElementById('newContactAccount').value.trim();
+ const accountNumber = document.getElementById('newContactAccountNumber').value.trim();
+ const bank = document.getElementById('newContactBank').value.trim();
+ const address = document.getElementById('newContactAddress').value.trim();
- addCustomDetail(name, phone, account, accountNumber, bank, address);
- addDetailModal.classList.remove('active');
- });
+ if (!name) {
+ alert('请输入联系人姓名');
+ return;
+ }
- // 点击弹窗外部关闭新增详情弹窗
- addDetailModal.addEventListener('click', function (e) {
- if (e.target === addDetailModal) {
- addDetailModal.classList.remove('active');
- }
- });
+ addCustomDetail(name, phone, account, accountNumber, bank, address);
+ if (addDetailModal) {
+ addDetailModal.classList.remove('active');
+ }
+ });
+ }
+
+ // 点击弹窗外部关闭新增详情弹窗 - 添加空值检查
+ if (addDetailModal) {
+ addDetailModal.addEventListener('click', function (e) {
+ if (e.target === addDetailModal) {
+ addDetailModal.classList.remove('active');
+ }
+ });
+ }
// 3D粒子特效
const scene = new THREE.Scene();
@@ -6363,6 +6990,10 @@
});
}
+ // 将公海池更新函数暴露到全局作用域,以便在外部调用
+ window.updateDepartmentSeaPoolTable = updateDepartmentSeaPoolTable;
+ window.updateOrganizationSeaPoolTable = updateOrganizationSeaPoolTable;
+
// 页面加载完成后初始化WebSocket
window.addEventListener('DOMContentLoaded', function () {
// 初始化WebSocket连接
@@ -6522,6 +7153,58 @@
// 页面加载完成后初始化通知指示器
window.addEventListener('load', initNotificationIndicators);
+ // 更新个人中心初始化函数,显示完整的登录者信息
+ function initUserProfile() {
+ // 从URL参数获取实际登录信息
+ const loginInfo = getLoginUserInfo();
+
+ // 更新页面上的个人信息
+ document.getElementById('profileName').textContent = loginInfo.userName || '请登录';
+ document.getElementById('profileRole').textContent = loginInfo.projectName || '未设置角色';
+
+ // 更新下拉菜单中的个人信息
+ document.getElementById('dropdownUsername').textContent = loginInfo.userName || '未设置用户名';
+ document.getElementById('dropdownRole').textContent = loginInfo.projectName || '未设置角色';
+ document.getElementById('dropdownDepartment').textContent = loginInfo.managerdepartment || '未设置部门';
+ }
+
+ // 切换用户菜单显示/隐藏
+ function toggleUserMenu() {
+ const profileHeader = document.querySelector('.profile-header');
+ const profileDropdown = document.getElementById('profileDropdown');
+
+ profileHeader.classList.toggle('active');
+ profileDropdown.classList.toggle('active');
+ }
+
+ // 退出登录功能
+ function logout() {
+ // 确认退出登录
+ if (confirm('确定要退出登录吗?')) {
+ // 这里可以添加实际的退出登录逻辑,比如清除本地存储、跳转到登录页等
+ alert('已退出登录');
+ // 关闭下拉菜单
+ toggleUserMenu();
+ // 跳转到登录页面
+ window.location.href = 'loginmm.html';
+ }
+ }
+
+ // 点击页面其他位置关闭用户菜单
+ document.addEventListener('click', function(event) {
+ const userProfile = document.getElementById('userProfile');
+ if (!userProfile.contains(event.target)) {
+ const profileHeader = document.querySelector('.profile-header');
+ const profileDropdown = document.getElementById('profileDropdown');
+
+ profileHeader.classList.remove('active');
+ profileDropdown.classList.remove('active');
+ }
+ });
+
+ // 初始化个人中心
+ initUserProfile();
+
animate();
@@ -6548,7 +7231,10 @@