|
|
|
@ -1764,7 +1764,7 @@ app.get('/api/suppliers', async (req, res) => { |
|
|
|
console.log('收到供应商列表查询请求:', req.query); |
|
|
|
try { |
|
|
|
const connection = await pool.getConnection(); |
|
|
|
const { page = 1, pageSize = 10, status = '', keyword = '', phoneNumber = '' } = req.query; |
|
|
|
const { page = 1, pageSize = 10, status = '', keyword = '', phoneNumber = '', currentUserName = '', currentUserPhone = '' } = req.query; |
|
|
|
|
|
|
|
// 构建查询条件
|
|
|
|
let whereClause = ''; |
|
|
|
@ -1790,6 +1790,13 @@ app.get('/api/suppliers', async (req, res) => { |
|
|
|
params.push(`%${phoneNumber}%`); |
|
|
|
} |
|
|
|
|
|
|
|
// 添加对接人匹配逻辑,只显示当前登录者对接的供应商
|
|
|
|
if (currentUserName || currentUserPhone) { |
|
|
|
whereClause += (status || keyword || phoneNumber) ? ' AND' : ' WHERE'; |
|
|
|
whereClause += ` (liaison LIKE ? OR liaison LIKE ?)`; |
|
|
|
params.push(`%${currentUserName}%`, `%${currentUserPhone}%`); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取总数
|
|
|
|
const [totalResult] = await connection.query( |
|
|
|
`SELECT COUNT(*) as total FROM users${whereClause}`, |
|
|
|
@ -1803,7 +1810,7 @@ app.get('/api/suppliers', async (req, res) => { |
|
|
|
|
|
|
|
// 查询供应商列表,按创建时间倒序排序,确保最新创建的在前面
|
|
|
|
const [suppliers] = await connection.query( |
|
|
|
`SELECT userId, phoneNumber, province, city, district, detailedaddress, company, collaborationid, cooperation, businesslicenseurl, proofurl, brandurl, partnerstatus, reasonforfailure, reject_reason, terminate_reason, audit_time, created_at
|
|
|
|
`SELECT userId, phoneNumber, province, city, district, detailedaddress, company, collaborationid, cooperation, businesslicenseurl, proofurl, brandurl, partnerstatus, reasonforfailure, reject_reason, terminate_reason, audit_time, created_at, liaison
|
|
|
|
FROM users${whereClause} |
|
|
|
ORDER BY created_at DESC LIMIT ? OFFSET ?`,
|
|
|
|
params |
|
|
|
|