|
|
|
@ -5022,11 +5022,15 @@ |
|
|
|
|
|
|
|
// 构建查询参数,获取所有数据 |
|
|
|
const queryParams = new URLSearchParams({ |
|
|
|
sellerId: userInfo.userId, |
|
|
|
page: 1, |
|
|
|
pageSize: 1000 // 设置较大的pageSize,确保获取所有记录 |
|
|
|
}); |
|
|
|
|
|
|
|
// 非管理员才添加sellerId参数,管理员获取所有货源 |
|
|
|
if (userInfo.projectName !== '管理员') { |
|
|
|
queryParams.append('sellerId', userInfo.userId); |
|
|
|
} |
|
|
|
|
|
|
|
const apiUrl = `/api/supplies?${queryParams}`; |
|
|
|
console.log('加载货源列表API请求:', apiUrl); |
|
|
|
|
|
|
|
@ -5050,13 +5054,21 @@ |
|
|
|
// 获取当前登录用户的userId,用于对比 |
|
|
|
const userInfo = JSON.parse(localStorage.getItem('userInfo')); |
|
|
|
const currentUserId = userInfo?.userId || userInfo?.id || '未获取到'; |
|
|
|
const isAdmin = userInfo?.projectName === '管理员'; |
|
|
|
|
|
|
|
console.log(`=== 处理货源数据 ===`); |
|
|
|
console.log(`当前登录用户ID: ${currentUserId}`); |
|
|
|
console.log(`当前用户是否是管理员: ${isAdmin}`); |
|
|
|
console.log(`API返回的货源总数: ${supplies.length}`); |
|
|
|
|
|
|
|
// 管理员保留所有货源,非管理员只保留当前用户的货源 |
|
|
|
let filteredSupplies; |
|
|
|
if (isAdmin) { |
|
|
|
console.log('管理员模式:保留所有货源'); |
|
|
|
filteredSupplies = supplies; |
|
|
|
} else { |
|
|
|
// 检查每个货源的sellerId,确保只包含当前用户的货源 |
|
|
|
const filteredSupplies = supplies.filter(supply => { |
|
|
|
filteredSupplies = supplies.filter(supply => { |
|
|
|
// 如果货源没有sellerId,默认包含 |
|
|
|
if (!supply.sellerId) { |
|
|
|
console.warn(`货源 ${supply.id || supply.productId} 没有sellerId,默认包含`); |
|
|
|
@ -5078,6 +5090,7 @@ |
|
|
|
} |
|
|
|
return match; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
console.log(`过滤后保留的货源数量: ${filteredSupplies.length}`); |
|
|
|
|
|
|
|
@ -5086,11 +5099,14 @@ |
|
|
|
|
|
|
|
// 按状态分类 |
|
|
|
supplyData.publishedSupplies = filteredSupplies.filter(item => item.status === 'published'); |
|
|
|
supplyData.pendingSupplies = filteredSupplies.filter(item => item.status === 'pending_review'); |
|
|
|
supplyData.pendingSupplies = filteredSupplies.filter(item => item.status === 'pending_review' || item.status === 'pending'); |
|
|
|
supplyData.rejectedSupplies = filteredSupplies.filter(item => item.status === 'rejected'); |
|
|
|
supplyData.draftSupplies = filteredSupplies.filter(item => item.status === 'hidden' || item.status === 'sold_out'); |
|
|
|
|
|
|
|
console.log(`分类后各状态货源数量: 已上架=${supplyData.publishedSupplies.length}, 审核中=${supplyData.pendingSupplies.length}, 审核失败=${supplyData.rejectedSupplies.length}, 下架=${supplyData.draftSupplies.length}`); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 渲染货源列表 |
|
|
|
function renderSupplyLists() { |
|
|
|
// 获取当前登录用户信息,用于调试 |
|
|
|
|