Browse Source

隐藏Colleague类型客户在前端显示

master
Trae AI 2 months ago
parent
commit
705e4db2d0
  1. 73
      src/main/resources/static/sells.html
  2. 89
      src/main/resources/static/supply.html

73
src/main/resources/static/sells.html

@ -5297,8 +5297,9 @@
const recentTbody = document.getElementById('recent-customers-table').querySelector('tbody');
recentTbody.innerHTML = ''; // 清空现有内容
// 按时间排序(最新在前),取前5条
// 按时间排序(最新在前),取前5条,过滤掉Colleague类型的客户
const sortedCustomers = Object.values(customerData)
.filter(customer => customer.type !== 'Colleague') // 过滤掉Colleague类型的客户
.sort((a, b) => (b.id || '').localeCompare(a.id || '')) // 按ID降序排序,处理空值
.slice(0, 5);
@ -5314,7 +5315,7 @@
// 确定按钮文本和类型
const followLevels = ['important', 'regular', 'low-value', 'logistics', 'unclassified'];
const isFollowCustomer = followLevels.includes(customer.level);
const isFollowCustomer = followLevels.includes(customer.level) && customer.type !== 'Colleague';
const buttonText = isFollowCustomer ? '跟进' : '详情';
const buttonClass = isFollowCustomer ? 'follow-customer' : 'detail-customer';
@ -5357,6 +5358,10 @@
* @param {Object} customer - 新增的客户数据
*/
function updateCustomerTable(customer) {
// 如果客户类型是Colleague,不显示
if (customer.type === 'Colleague') {
return;
}
let level = customer.level;
// 映射客户等级到正确的HTML ID
@ -5403,7 +5408,7 @@
// 确定按钮文本和类型
const followLevels = ['important', 'regular', 'low-value', 'logistics', 'unclassified'];
const isFollowCustomer = followLevels.includes(customer.level);
const isFollowCustomer = followLevels.includes(customer.level) && customer.type !== 'Colleague';
const buttonText = isFollowCustomer ? '跟进' : '详情';
const buttonClass = isFollowCustomer ? 'follow-customer' : 'detail-customer';
@ -5682,9 +5687,43 @@
const typeMap = {
'seller': '供应商',
'buyer': '客户',
'both': 'both'
'both': 'both',
'Colleague': '同事'
};
document.getElementById('detail-type').textContent = typeMap[customer.type] || customer.type || "-";
// 当客户类型为Colleague时,不显示隐藏相关的所有内容
if (customer.type === 'Colleague') {
// 隐藏跟进相关的所有内容
const followUpElements = document.querySelectorAll('.follow-up-related, .follow-up-section');
followUpElements.forEach(el => el.style.display = 'none');
// 隐藏编辑按钮(同事不需要编辑)
const editSaveBtn = document.getElementById('editSaveBtn');
if (editSaveBtn) {
editSaveBtn.style.display = 'none';
}
// 隐藏其他不需要的内容
const addDetailBtn = document.getElementById('addDetailBtn');
if (addDetailBtn) {
addDetailBtn.style.display = 'none';
}
} else {
// 恢复正常显示
const followUpElements = document.querySelectorAll('.follow-up-related, .follow-up-section');
followUpElements.forEach(el => el.style.display = '');
const editSaveBtn = document.getElementById('editSaveBtn');
if (editSaveBtn) {
editSaveBtn.style.display = '';
}
const addDetailBtn = document.getElementById('addDetailBtn');
if (addDetailBtn) {
addDetailBtn.style.display = '';
}
}
document.getElementById('detail-demand').textContent = customer.demand || "-";
document.getElementById('detail-spec').textContent = customer.spec || "-";
document.getElementById('detail-manager').textContent = customer.userName || "-";
@ -6712,11 +6751,28 @@
return;
}
// 检查SockJS和Stomp是否可用
if (typeof SockJS === 'undefined' || typeof Stomp === 'undefined') {
console.warn('WebSocket库加载失败,跳过WebSocket初始化');
return;
}
try {
// 创建SockJS连接
const socket = new SockJS('/DL/ws');
// 创建STOMP客户端
stompClient = Stomp.over(socket);
// 设置连接错误处理
socket.onerror = function(error) {
console.error('WebSocket连接错误:', error);
};
// 设置连接关闭处理
socket.onclose = function(event) {
console.log('WebSocket连接关闭:', event);
};
// 连接到WebSocket服务器
stompClient.connect({}, function (frame) {
console.log('已连接到WebSocket服务器:', frame);
@ -6754,6 +6810,9 @@
// 尝试重新连接
setTimeout(initWebSocket, 5000);
});
} catch (error) {
console.error('初始化WebSocket时出错:', error);
}
}
@ -6796,9 +6855,13 @@
console.log('过滤后的客户数据:', filteredCustomers);
// 更新客户数据
// 更新客户数据,过滤掉Colleague类型的客户
const newCustomerData = {};
filteredCustomers.forEach(customer => {
// 过滤掉Colleague类型的客户
if (customer.type === 'Colleague') {
return;
}
// 确保客户数据包含notice字段和dataSource字段
if (customer.notice === undefined || customer.notice === null) {
customer.notice = 'old'; // 默认设置为老客户

89
src/main/resources/static/supply.html

@ -5334,8 +5334,9 @@
const recentTbody = document.getElementById('recent-customers-table').querySelector('tbody');
recentTbody.innerHTML = ''; // 清空现有内容
// 按时间排序(最新在前),取前5条
// 按时间排序(最新在前),取前5条,过滤掉Colleague类型的客户
const sortedCustomers = Object.values(customerData)
.filter(customer => customer.type !== 'Colleague') // 过滤掉Colleague类型的客户
.sort((a, b) => (b.id || '').localeCompare(a.id || '')) // 按ID降序排序,处理空值
.slice(0, 5);
@ -5351,7 +5352,7 @@
// 确定按钮文本和类型
const followLevels = ['important', 'regular', 'low-value', 'logistics', 'unclassified'];
const isFollowCustomer = followLevels.includes(customer.level);
const isFollowCustomer = followLevels.includes(customer.level) && customer.type !== 'Colleague';
const buttonText = isFollowCustomer ? '跟进' : '详情';
const buttonClass = isFollowCustomer ? 'follow-customer' : 'detail-customer';
@ -5394,6 +5395,10 @@
* @param {Object} customer - 新增的客户数据
*/
function updateCustomerTable(customer) {
// 如果客户类型是Colleague,不显示
if (customer.type === 'Colleague') {
return;
}
let level = customer.level;
// 映射客户等级到正确的HTML ID
@ -5440,7 +5445,7 @@
// 确定按钮文本和类型
const followLevels = ['important', 'regular', 'low-value', 'logistics', 'unclassified'];
const isFollowCustomer = followLevels.includes(customer.level);
const isFollowCustomer = followLevels.includes(customer.level) && customer.type !== 'Colleague';
const buttonText = isFollowCustomer ? '跟进' : '详情';
const buttonClass = isFollowCustomer ? 'follow-customer' : 'detail-customer';
@ -5719,9 +5724,43 @@
const typeMap = {
'seller': '供应商',
'buyer': '客户',
'both': 'both'
'both': 'both',
'Colleague': '同事'
};
document.getElementById('detail-type').textContent = typeMap[customer.type] || customer.type || "-";
// 当客户类型为Colleague时,不显示隐藏相关的所有内容
if (customer.type === 'Colleague') {
// 隐藏跟进相关的所有内容
const followUpElements = document.querySelectorAll('.follow-up-related, .follow-up-section');
followUpElements.forEach(el => el.style.display = 'none');
// 隐藏编辑按钮(同事不需要编辑)
const editSaveBtn = document.getElementById('editSaveBtn');
if (editSaveBtn) {
editSaveBtn.style.display = 'none';
}
// 隐藏其他不需要的内容
const addDetailBtn = document.getElementById('addDetailBtn');
if (addDetailBtn) {
addDetailBtn.style.display = 'none';
}
} else {
// 恢复正常显示
const followUpElements = document.querySelectorAll('.follow-up-related, .follow-up-section');
followUpElements.forEach(el => el.style.display = '');
const editSaveBtn = document.getElementById('editSaveBtn');
if (editSaveBtn) {
editSaveBtn.style.display = '';
}
const addDetailBtn = document.getElementById('addDetailBtn');
if (addDetailBtn) {
addDetailBtn.style.display = '';
}
}
document.getElementById('detail-demand').textContent = customer.demand || "-";
document.getElementById('detail-spec').textContent = customer.spec || "-";
document.getElementById('detail-manager').textContent = customer.userName || "-";
@ -6774,20 +6813,39 @@
function initWebSocket() {
console.log('初始化WebSocket连接...');
// 检查SockJS和Stomp是否可用
if (typeof SockJS === 'undefined' || typeof Stomp === 'undefined') {
console.warn('WebSocket库加载失败,跳过WebSocket初始化');
return;
}
try {
// 创建SockJS连接
const socket = new SockJS('/DL/ws');
// 创建STOMP客户端
stompClient = Stomp.over(socket);
// 设置连接错误处理
socket.onerror = function(error) {
console.error('WebSocket连接错误:', error);
};
// 设置连接关闭处理
socket.onclose = function(event) {
console.log('WebSocket连接关闭:', event);
};
// 连接到服务器
stompClient.connect({}, function(frame) {
console.log('已连接到WebSocket服务器: ' + frame);
try {
// 获取登录信息,只声明一次
const loginInfo = getLoginInfo();
// 订阅部门公海池主题(带seller角色)
stompClient.subscribe('/topic/departmentSeaPool/seller', function(response) {
try {
const customers = JSON.parse(response.body);
console.log('收到部门公海池数据:', customers);
@ -6816,10 +6874,14 @@
departmentSeaPoolData = finalFilteredCustomers;
renderDepartmentSeaPool(finalFilteredCustomers);
} catch (error) {
console.error('处理部门公海池数据时出错:', error);
}
});
// 订阅组织公海池主题(带seller角色)
stompClient.subscribe('/topic/organizationSeaPool/seller', function(response) {
try {
const customers = JSON.parse(response.body);
console.log('收到组织公海池数据:', customers);
@ -6848,10 +6910,14 @@
organizationSeaPoolData = finalFilteredCustomers;
renderOrganizationSeaPool(finalFilteredCustomers);
} catch (error) {
console.error('处理组织公海池数据时出错:', error);
}
});
// 订阅seller角色数据(supply.html页面显示seller类型客户)
stompClient.subscribe('/topic/role/seller', function(response) {
try {
const customers = JSON.parse(response.body);
console.log('收到seller角色数据:', customers);
@ -6864,9 +6930,13 @@
console.log('过滤后的客户数据:', filteredCustomers);
// 更新客户数据 - 以客户ID为键
// 更新客户数据 - 以客户ID为键,过滤掉Colleague类型的客户
const newCustomerData = {};
filteredCustomers.forEach(customer => {
// 过滤掉Colleague类型的客户
if (customer.type === 'Colleague') {
return;
}
// 确保客户数据包含notice字段和dataSource字段
if (customer.notice === undefined || customer.notice === null) {
customer.notice = 'old'; // 默认设置为老客户
@ -6927,6 +6997,9 @@
}
}
});
} catch (error) {
console.error('处理seller角色数据时出错:', error);
}
});
console.log('发送登录信息获取数据:', loginInfo);
@ -6939,11 +7012,17 @@
stompClient.send("/app/customer/organizationSeaPool/seller", {}, JSON.stringify(loginInfo));
// 请求seller角色数据
stompClient.send("/app/customer/role/seller", {}, JSON.stringify(loginInfo));
} catch (error) {
console.error('处理WebSocket连接成功后的逻辑时出错:', error);
}
}, function(error) {
console.error('WebSocket连接失败: ' + error);
// 尝试重新连接
setTimeout(initWebSocket, 5000);
});
} catch (error) {
console.error('初始化WebSocket时出错:', error);
}
}
// 处理客户数据,按照等级分组

Loading…
Cancel
Save