This commit is contained in:
dhr
2025-09-24 16:37:09 +08:00
parent 80cca114a9
commit 9913a7854c
15 changed files with 1943 additions and 435 deletions

View File

@ -482,36 +482,13 @@ const getUsersList = async () => {
try {
const response = await xunjianUserlist({});
if (response.code === 200) {
// 从任务数据中提取用户信息
const usersMap = new Map(); // 使用Map确保id唯一
const tasks = response.rows || [];
// 直接从接口返回的用户列表中提取信息
const users = response.rows || [];
tasks.forEach((task) => {
// 提取personInfo中的用户信息
if (task.personInfo && task.personInfo.id && task.personInfo.userName) {
usersMap.set(task.personInfo.id, {
id: task.personInfo.id,
userName: task.personInfo.userName
});
}
// 提取testPlan.persons中的用户信息
if (task.testPlan && task.testPlan.persons && Array.isArray(task.testPlan.persons)) {
task.testPlan.persons.forEach((person) => {
if (person.id && person.userName) {
usersMap.set(person.id, {
id: person.id,
userName: person.userName
});
}
});
}
});
// 将Map转换为下拉选择器需要的格式{ label, value }
userList.value = Array.from(usersMap.values()).map((user) => ({
label: user.userName, // 显示在下拉框中的文本
value: user.id // 选中后的值
// 将用户数据转换为所需格式包含id和userName以适配模板和getUserById函数
userList.value = users.map((user) => ({
id: user.userId, // 用于标识和查找
userName: user.userName // 显示名称
}));
// 调试信息,确认数据格式正确