From 2cb3e9d8942d1543baa54e7fb31ef1b571037ad5 Mon Sep 17 00:00:00 2001 From: Default User Date: Thu, 22 Jan 2026 13:18:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E9=A1=B5=E9=9D=A2=E6=8E=92=E5=BA=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E6=8C=89=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=80=92=E5=BA=8F=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reject.html | 20 ++++++++++++++++++++ Reject.js | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Reject.html b/Reject.html index 5e7915b..58546fa 100644 --- a/Reject.html +++ b/Reject.html @@ -1857,6 +1857,16 @@ 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(); renderSupplies(suppliesList); @@ -3013,6 +3023,16 @@ 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); renderPagination(totalCount, currentPage, Math.ceil(totalCount / pageSize)); diff --git a/Reject.js b/Reject.js index ba9b1aa..0a8dd35 100644 --- a/Reject.js +++ b/Reject.js @@ -1711,11 +1711,11 @@ app.get('/api/suppliers', async (req, res) => { const offset = (page - 1) * pageSize; params.push(parseInt(pageSize), offset); - // 查询供应商列表 + // 查询供应商列表,按创建时间倒序排序,确保最新创建的在前面 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 FROM users${whereClause} - ORDER BY audit_time DESC LIMIT ? OFFSET ?`, + ORDER BY created_at DESC LIMIT ? OFFSET ?`, params );