Browse Source

修复供应商审核页面排序问题,按创建时间倒序排列

Boss3
Default User 1 month ago
parent
commit
2cb3e9d894
  1. 20
      Reject.html
  2. 4
      Reject.js

20
Reject.html

@ -1857,6 +1857,16 @@
totalCount: totalCount totalCount: totalCount
}); });
// 对货源列表进行排序,按照创建时间倒序排列(最新的在前)
suppliesList.sort((a, b) => {
// 获取创建时间,支持多种可能的字段名称
const aCreatedAt = a.createdAt || a.created_at || a.create_time || a.add_time || a.upload_time || new Date().toISOString();
const bCreatedAt = b.createdAt || b.created_at || b.create_time || b.add_time || b.upload_time || new Date().toISOString();
// 转换为时间戳并比较,降序排列
return new Date(bCreatedAt).getTime() - new Date(aCreatedAt).getTime();
});
// 先加载联系人数据,再渲染货源列表,确保联系人下拉框能正确显示选中状态 // 先加载联系人数据,再渲染货源列表,确保联系人下拉框能正确显示选中状态
await loadContacts(); await loadContacts();
renderSupplies(suppliesList); renderSupplies(suppliesList);
@ -3013,6 +3023,16 @@
totalCountEl.textContent = totalCount; totalCountEl.textContent = totalCount;
} }
// 对供应商列表进行排序,按照创建时间倒序排列(最新的在前)
suppliersList.sort((a, b) => {
// 获取创建时间,支持多种可能的字段名称
const aCreatedAt = a.created_at || a.create_time || a.createdAt || new Date().toISOString();
const bCreatedAt = b.created_at || b.create_time || b.createdAt || new Date().toISOString();
// 转换为时间戳并比较,降序排列
return new Date(bCreatedAt).getTime() - new Date(aCreatedAt).getTime();
});
// 渲染数据 // 渲染数据
renderSuppliers(suppliersList); renderSuppliers(suppliersList);
renderPagination(totalCount, currentPage, Math.ceil(totalCount / pageSize)); renderPagination(totalCount, currentPage, Math.ceil(totalCount / pageSize));

4
Reject.js

@ -1711,11 +1711,11 @@ app.get('/api/suppliers', async (req, res) => {
const offset = (page - 1) * pageSize; const offset = (page - 1) * pageSize;
params.push(parseInt(pageSize), offset); params.push(parseInt(pageSize), offset);
// 查询供应商列表 // 查询供应商列表,按创建时间倒序排序,确保最新创建的在前面
const [suppliers] = await connection.query( 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
FROM users${whereClause} FROM users${whereClause}
ORDER BY audit_time DESC LIMIT ? OFFSET ?`, ORDER BY created_at DESC LIMIT ? OFFSET ?`,
params params
); );

Loading…
Cancel
Save