Browse Source

修复简道云按钮状态、分页问题和Colleague类型数据过滤

pull/1/head
Trae AI 2 months ago
parent
commit
2ab9c774a6
  1. 19
      web/src/main/java/com/example/web/entity/Users.java
  2. 40
      web/src/main/resources/mapper/UsersMapper.xml
  3. 153
      web/src/main/resources/static/index.html
  4. 2
      web/src/main/resources/static/login.html

19
web/src/main/java/com/example/web/entity/Users.java

@ -33,10 +33,11 @@ public class Users {
private String demand;//客户需求
private String spec;//规格
private String followup;//跟进信息
private LocalDateTime followup_at;//跟进时间
private String notice;//通知状态(new/old/banold)
private String userlog;//用户操作日志
private Integer sync_statuss;//同步状态
private String managerName;//负责人姓名
public Integer getId() {
@ -207,6 +208,14 @@ public class Users {
this.followup = followup;
}
public LocalDateTime getFollowup_at() {
return followup_at;
}
public void setFollowup_at(LocalDateTime followup_at) {
this.followup_at = followup_at;
}
public String getNotice() {
return notice;
}
@ -230,4 +239,12 @@ public class Users {
public void setSync_statuss(Integer sync_statuss) {
this.sync_statuss = sync_statuss;
}
public String getManagerName() {
return managerName;
}
public void setManagerName(String managerName) {
this.managerName = managerName;
}
}

40
web/src/main/resources/mapper/UsersMapper.xml

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.web.mapper.UsersMapper">
<select id="findWithPagination" resultType="com.example.web.entity.Users">
SELECT u.* FROM users u
SELECT u.*, um.userName as managerName FROM users u
JOIN usermanagements um ON u.userId = um.userId
<where>
<if test="followup != null and followup != ''">
@ -27,7 +27,9 @@
AND um.role = #{role}
</if>
AND (u.sync_statuss IS NULL OR u.sync_statuss NOT IN (0, 1))
AND u.type != 'Colleague'
</where>
ORDER BY u.created_at DESC
LIMIT #{offset}, #{limit}
</select>
<select id="count" resultType="java.lang.Integer">
@ -56,11 +58,13 @@
AND um.role = #{role}
</if>
AND (u.sync_statuss IS NULL OR u.sync_statuss NOT IN (0, 1))
AND u.type != 'Colleague'
</where>
</select>
<select id="findByUserIds" resultType="com.example.web.entity.Users">
SELECT * FROM users
WHERE userId IN
SELECT u.*, (SELECT um.userName FROM usermanagements um WHERE um.userId = u.userId LIMIT 1) as managerName
FROM users u
WHERE u.userId IN
(
SELECT userId FROM usermanagements
WHERE userName = #{userName}
@ -69,7 +73,9 @@
AND organization = #{organization}
AND role = #{role}
)
AND (sync_statuss IS NULL OR sync_statuss NOT IN (0, 1))
AND (u.sync_statuss IS NULL OR u.sync_statuss NOT IN (0, 1))
AND u.type != 'Colleague'
ORDER BY u.created_at DESC
LIMIT #{offset}, #{limit}
</select>
<select id="countByUserIds" resultType="java.lang.Integer">
@ -84,22 +90,26 @@
AND role = #{role}
)
AND (sync_statuss IS NULL OR sync_statuss NOT IN (0, 1))
AND type != 'Colleague'
</select>
<select id="findPublicWithPagination" resultType="com.example.web.entity.Users">
SELECT u.* FROM users u
JOIN usermanagements um ON u.userId = um.userId
WHERE (um.managercompany IS NULL OR um.managercompany = '')
WHERE u.type != 'Colleague'
AND (um.managercompany IS NULL OR um.managercompany = '')
AND (um.managerdepartment IS NULL OR um.managerdepartment = '')
AND (um.organization IS NULL OR um.organization = '')
AND (um.role IS NULL OR um.role = '')
AND (um.userName IS NULL OR um.userName = '')
ORDER BY u.created_at DESC
LIMIT #{offset}, #{limit}
</select>
<select id="countPublic" resultType="java.lang.Integer">
SELECT COUNT(*) FROM users u
JOIN usermanagements um ON u.userId = um.userId
WHERE (um.managercompany IS NULL OR um.managercompany = '')
WHERE u.type != 'Colleague'
AND (um.managercompany IS NULL OR um.managercompany = '')
AND (um.managerdepartment IS NULL OR um.managerdepartment = '')
AND (um.organization IS NULL OR um.organization = '')
AND (um.role IS NULL OR um.role = '')
@ -107,18 +117,25 @@
</select>
<select id="findAllWithPagination" resultType="com.example.web.entity.Users">
SELECT * FROM users
SELECT u.*, um.userName as managerName FROM users u
JOIN usermanagements um ON u.userId = um.userId
ORDER BY u.created_at DESC
LIMIT #{offset}, #{limit}
</select>
<select id="countAll" resultType="java.lang.Integer">
SELECT COUNT(*) FROM users
SELECT COUNT(*) FROM users u
JOIN usermanagements um ON u.userId = um.userId
WHERE (u.sync_statuss IS NULL OR u.sync_statuss NOT IN (0, 1))
AND u.type != 'Colleague'
</select>
<select id="findPersonalWithPagination" resultType="com.example.web.entity.Users">
SELECT * FROM users
WHERE followup IS NOT NULL AND followup != ''
AND (sync_statuss IS NULL OR sync_statuss NOT IN (0, 1))
AND type != 'Colleague'
AND type != 'Colleague'
LIMIT #{offset}, #{limit}
</select>
@ -131,18 +148,21 @@
<select id="findPublicAllWithPagination" resultType="com.example.web.entity.Users">
SELECT u.* FROM users u
JOIN usermanagements um ON u.userId = um.userId
WHERE (um.managercompany IS NULL OR um.managercompany = '')
WHERE u.type != 'Colleague'
AND (um.managercompany IS NULL OR um.managercompany = '')
AND (um.managerdepartment IS NULL OR um.managerdepartment = '')
AND (um.organization IS NULL OR um.organization = '')
AND (um.role IS NULL OR um.role = '')
AND (um.userName IS NULL OR um.userName = '')
ORDER BY u.created_at DESC
LIMIT #{offset}, #{limit}
</select>
<select id="countPublicAll" resultType="java.lang.Integer">
SELECT COUNT(*) FROM users u
JOIN usermanagements um ON u.userId = um.userId
WHERE (um.managercompany IS NULL OR um.managercompany = '')
WHERE u.type != 'Colleague'
AND (um.managercompany IS NULL OR um.managercompany = '')
AND (um.managerdepartment IS NULL OR um.managerdepartment = '')
AND (um.organization IS NULL OR um.organization = '')
AND (um.role IS NULL OR um.role = '')

153
web/src/main/resources/static/index.html

@ -217,6 +217,47 @@
width: 100%;
border-collapse: collapse;
font-size: 14px;
table-layout: fixed;
}
th:nth-child(1), td:nth-child(1) {
max-width: 120px;
width: 120px;
}
th:nth-child(2), td:nth-child(2) {
max-width: 100px;
width: 100px;
}
th:nth-child(3), td:nth-child(3) {
max-width: 80px;
width: 80px;
}
th:nth-child(4), td:nth-child(4) {
max-width: 130px;
width: 130px;
}
th:nth-child(5), td:nth-child(5) {
max-width: 100px;
width: 100px;
}
th:nth-child(6), td:nth-child(6) {
max-width: 100px;
width: 100px;
}
th:nth-child(7), td:nth-child(7) {
max-width: 100px;
width: 100px;
}
th:nth-child(8), td:nth-child(8) {
max-width: 120px;
width: 120px;
}
th {
@ -232,6 +273,8 @@
padding: 12px;
border-bottom: 1px solid #f0f0f0;
color: #666;
word-wrap: break-word;
word-break: break-all;
}
tr:hover {
@ -398,6 +441,9 @@
<div id="personal" class="tab-content active">
<div class="filter-bar">
<button onclick="loadPersonalData()">刷新数据</button>
<button onclick="filterPersonalData('all')" style="background-color: #52c41a;">全部</button>
<button onclick="filterPersonalData('followed')" style="background-color: #faad14;">已跟进</button>
<button onclick="filterPersonalData('unfollowed')" style="background-color: #ff4d4f;">未跟进</button>
<select id="personalPageSize" onchange="changePersonalPageSize()">
<option value="10">10条/页</option>
<option value="50">50条/页</option>
@ -413,6 +459,7 @@
<th>创建时间</th>
<th>跟进内容</th>
<th>响应时间</th>
<th id="managerHeader">负责人</th>
<th>操作</th>
</tr>
</thead>
@ -443,6 +490,7 @@
<th>创建时间</th>
<th>跟进内容</th>
<th>响应时间</th>
<th id="publicManagerHeader">负责人</th>
<th>操作</th>
</tr>
</thead>
@ -463,6 +511,7 @@
var publicPage = 1;
var personalPageSize = 10;
var publicPageSize = 10;
var personalFilter = 'all'; // all, followed, unfollowed
function init() {
var savedUserInfo = localStorage.getItem('userInfo');
@ -557,7 +606,7 @@
role: usersManagements.role || ''
};
var url = 'http://localhost:8083/KH/api/users?' + objectToQueryString(params);
var url = 'http://8.137.125.67:8083/KH/api/users?' + objectToQueryString(params);
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
@ -571,6 +620,12 @@
xhr.send();
}
function filterPersonalData(filter) {
personalFilter = filter;
personalPage = 1; // 重置为第一页
loadPersonalData();
}
function loadPublicData() {
var userRole = userInfo.loginInfo.projectName;
var usersManagements = userInfo.usersManagements;
@ -587,7 +642,7 @@
role: usersManagements.role || ''
};
var url = 'http://localhost:8083/KH/api/users/public?' + objectToQueryString(params);
var url = 'http://8.137.125.67:8083/KH/api/users/public?' + objectToQueryString(params);
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
@ -709,9 +764,9 @@
}
function calculateResponseTime(createdAt, followupAt) {
if (!createdAt) return '-';
if (!createdAt || !followupAt) return '-';
var createTime = new Date(createdAt);
var followupTime = followupAt ? new Date(followupAt) : new Date();
var followupTime = new Date(followupAt);
var diffMs = followupTime - createTime;
var diffMins = Math.floor(diffMs / 60000);
var diffHours = Math.floor(diffMins / 60);
@ -731,8 +786,18 @@
function displayPersonalData(data) {
var personalBody = document.getElementById('personalBody');
var personalEmpty = document.getElementById('personalEmpty');
var managerHeader = document.getElementById('managerHeader');
var personalPagination = document.getElementById('personalPagination');
personalBody.innerHTML = '';
// 检查用户角色,只对管理员显示负责人列
var userRole = userInfo.loginInfo.projectName;
if (userRole === '管理员') {
managerHeader.style.display = 'table-cell';
} else {
managerHeader.style.display = 'none';
}
console.log('后端返回的数据量:', data.users ? data.users.length : 0);
console.log('总记录数:', data.total);
console.log('当前页码:', data.page);
@ -742,7 +807,19 @@
if (data.users && data.users.length > 0) {
personalEmpty.style.display = 'none';
var filteredUsers = data.users.filter(function(user) {
return user.type !== 'Colleague';
// 过滤掉同事类型
if (user.type === 'Colleague') {
return false;
}
// 根据筛选条件过滤
if (personalFilter === 'followed') {
return user.followup && user.followup !== '';
} else if (personalFilter === 'unfollowed') {
return !user.followup || user.followup === '';
}
// 'all' 或其他情况,不过滤
return true;
});
console.log('过滤后的数据量:', filteredUsers.length);
@ -751,30 +828,67 @@
for (var i = 0; i < filteredUsers.length; i++) {
var user = filteredUsers[i];
var responseTime = calculateResponseTime(user.created_at, user.followup_at);
var managerCell = '';
// 只对管理员显示负责人信息
if (userRole === '管理员') {
managerCell = '<td>' + (user.managerName || user.followup || '-') + '</td>';
} else {
managerCell = '<td style="display: none;"></td>';
}
// 生成简道云按钮,根据sync_statuss字段决定状态
var jianDaoYunButton = '';
if (user.sync_statuss === 0 || user.sync_statuss === 1) {
// 已写入简道云,显示灰色不可点击按钮
jianDaoYunButton = '<button style="padding: 4px 8px; background-color: #ccc; color: #666; border: none; border-radius: 4px; font-size: 12px; cursor: not-allowed;" disabled>已写入简道云</button>';
} else {
// 未写入简道云,显示正常按钮
jianDaoYunButton = '<button onclick="openJianDaoYunModal(\'' + (user.userId || '') + '\', \'' + (user.nickName || '') + '\')" style="padding: 4px 8px; background-color: #52c41a; color: white; border: none; border-radius: 4px; font-size: 12px;">简道云</button>';
}
var row = '<tr>' +
'<td>' + (user.nickName || '-') + '</td>' +
'<td>' + (user.phoneNumber || '-') + '</td>' +
'<td>' + mapUserType(user.type) + '</td>' +
'<td>' + formatDateTime(user.created_at) + '</td>' +
'<td>' + (user.followup || '-') + '</td>' +
'<td>' + responseTime + '</td>' +
'<td><button onclick="openFollowupModal(\'' + (user.userId || '') + '\', \'' + (user.nickName || '') + '\', \'' + (user.phoneNumber || '') + '\')" style="padding: 4px 8px; background-color: #1890ff; color: white; border: none; border-radius: 4px; font-size: 12px;">跟进</button> <button onclick="openReturnModal(\'' + (user.userId || '') + '\', \'' + (user.nickName || '') + '\', \'' + (user.phoneNumber || '') + '\', \'' + (user.type || '') + '\')" style="padding: 4px 8px; background-color: #faad14; color: white; border: none; border-radius: 4px; font-size: 12px;">归还</button> <button onclick="openJianDaoYunModal(\'' + (user.userId || '') + '\', \'' + (user.nickName || '') + '\')" style="padding: 4px 8px; background-color: #52c41a; color: white; border: none; border-radius: 4px; font-size: 12px;">简道云</button></td>' +
'<td>' + responseTime + '</td>' +
managerCell +
'<td><button onclick="openFollowupModal(\'' + (user.userId || '') + '\', \'' + (user.nickName || '') + '\', \'' + (user.phoneNumber || '') + '\')" style="padding: 4px 8px; background-color: #1890ff; color: white; border: none; border-radius: 4px; font-size: 12px;">跟进</button> <button onclick="openReturnModal(\'' + (user.userId || '') + '\', \'' + (user.nickName || '') + '\', \'' + (user.phoneNumber || '') + '\', \'' + (user.type || '') + '\')" style="padding: 4px 8px; background-color: #faad14; color: white; border: none; border-radius: 4px; font-size: 12px;">归还</button> ' + jianDaoYunButton + '</td>' +
'</tr>';
personalBody.innerHTML += row;
// 有数据时显示分页控件
personalPagination.style.display = 'flex';
}
} else {
personalEmpty.style.display = 'block';
// 没有数据时隐藏分页控件
personalPagination.style.display = 'none';
}
} else {
personalEmpty.style.display = 'block';
// 没有数据时隐藏分页控件
personalPagination.style.display = 'none';
}
}
function displayPublicData(data) {
var publicBody = document.getElementById('publicBody');
var publicEmpty = document.getElementById('publicEmpty');
var publicManagerHeader = document.getElementById('publicManagerHeader');
var publicPagination = document.getElementById('publicPagination'); // New: Get pagination element
publicBody.innerHTML = '';
// 检查用户角色,只对管理员显示负责人列
var userRole = userInfo.loginInfo.projectName;
if (userRole === '管理员') {
publicManagerHeader.style.display = 'table-cell';
} else {
publicManagerHeader.style.display = 'none';
}
if (data.users && data.users.length > 0) {
publicEmpty.style.display = 'none';
var filteredUsers = data.users.filter(function(user) {
@ -785,6 +899,15 @@
for (var i = 0; i < filteredUsers.length; i++) {
var user = filteredUsers[i];
var responseTime = calculateResponseTime(user.created_at, user.followup_at);
var managerCell = '';
// 只对管理员显示负责人信息
if (userRole === '管理员') {
managerCell = '<td>' + (user.managerName || '-') + '</td>';
} else {
managerCell = '<td style="display: none;"></td>';
}
var row = '<tr>' +
'<td>' + (user.nickName || '-') + '</td>' +
'<td>' + (user.phoneNumber || '-') + '</td>' +
@ -792,15 +915,23 @@
'<td>' + formatDateTime(user.created_at) + '</td>' +
'<td>' + (user.followup || '-') + '</td>' +
'<td>' + responseTime + '</td>' +
managerCell +
'<td><button onclick="claimCustomer(\'' + (user.userId || '') + '\', \'' + (user.nickName || '') + '\', \'' + (user.phoneNumber || '') + '\')" style="padding: 4px 8px; background-color: #52c41a; color: white; border: none; border-radius: 4px; font-size: 12px;">认领</button></td>' +
'</tr>';
publicBody.innerHTML += row;
// 有数据时显示分页控件
publicPagination.style.display = 'flex';
}
} else {
publicEmpty.style.display = 'block';
// 没有数据时隐藏分页控件
publicPagination.style.display = 'none';
}
} else {
publicEmpty.style.display = 'block';
// 没有数据时隐藏分页控件
publicPagination.style.display = 'none';
}
}
@ -816,7 +947,7 @@
role: usersManagements.role || ''
};
var url = 'http://localhost:8083/KH/api/users/claim';
var url = 'http://8.137.125.67:8083/KH/api/users/claim';
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
@ -869,7 +1000,7 @@
role: usersManagements.role || ''
};
var url = 'http://localhost:8083/KH/api/users/followup';
var url = 'http://8.137.125.67:8083/KH/api/users/followup';
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
@ -922,7 +1053,7 @@
userId: userId
};
var url = 'http://localhost:8083/KH/api/users/jianDaoYun';
var url = 'http://8.137.125.67:8083/KH/api/users/jianDaoYun';
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
@ -952,7 +1083,7 @@
type: type
};
var url = 'http://localhost:8083/KH/api/users/return';
var url = 'http://8.137.125.67:8083/KH/api/users/return';
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);

2
web/src/main/resources/static/login.html

@ -116,7 +116,7 @@
errorMessage.textContent = '';
// 发送登录请求
fetch('http://localhost:8083/KH/api/login', {
fetch('http://8.137.125.67:8083/KH/api/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'

Loading…
Cancel
Save