|
@@ -1718,7 +1718,15 @@ function getSelectionItemId(record: any): number | null {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function sweepRowKey(record: any) {
|
|
function sweepRowKey(record: any) {
|
|
|
- if (record?.id != null) return record.id
|
|
|
|
|
|
|
+ // 优先使用 listing_id 作为唯一行键(每个购买记录的唯一标识)
|
|
|
|
|
+ if (record?.listing_id) {
|
|
|
|
|
+ return record.listing_id
|
|
|
|
|
+ }
|
|
|
|
|
+ // 其次使用 selection_item_id + created_at 组合(选品ID + 购买时间)
|
|
|
|
|
+ if (record?.selection_item_id && record?.created_at) {
|
|
|
|
|
+ return `${record.selection_item_id}-${record.created_at}`
|
|
|
|
|
+ }
|
|
|
|
|
+ // 兜底方案:使用 goods_id + created_at + purchase_price_usd
|
|
|
if (record?.goods_id) {
|
|
if (record?.goods_id) {
|
|
|
return `${record.goods_id}-${record.created_at ?? ''}-${record.purchase_price_usd ?? ''}`
|
|
return `${record.goods_id}-${record.created_at ?? ''}-${record.purchase_price_usd ?? ''}`
|
|
|
}
|
|
}
|
|
@@ -2682,9 +2690,13 @@ async function fetchSweepResult(showLoading = false): Promise<string | null> {
|
|
|
if (res.code === 200 && res.data) {
|
|
if (res.code === 200 && res.data) {
|
|
|
const nextItemsRaw = Array.isArray(res.data.items) ? res.data.items : []
|
|
const nextItemsRaw = Array.isArray(res.data.items) ? res.data.items : []
|
|
|
const nextItems = [...nextItemsRaw].sort((a: any, b: any) => {
|
|
const nextItems = [...nextItemsRaw].sort((a: any, b: any) => {
|
|
|
|
|
+ // 主要排序:按 created_at 时间倒序(最新在前)
|
|
|
const byTime = parseLogTimestamp(b?.created_at) - parseLogTimestamp(a?.created_at)
|
|
const byTime = parseLogTimestamp(b?.created_at) - parseLogTimestamp(a?.created_at)
|
|
|
if (byTime !== 0) return byTime
|
|
if (byTime !== 0) return byTime
|
|
|
- return Number(b?.id ?? 0) - Number(a?.id ?? 0)
|
|
|
|
|
|
|
+ // 次要排序:按 listing_id 倒序(字符串比较,保持顺序一致性)
|
|
|
|
|
+ const idA = a?.listing_id ?? ''
|
|
|
|
|
+ const idB = b?.listing_id ?? ''
|
|
|
|
|
+ return idB.localeCompare(idA)
|
|
|
})
|
|
})
|
|
|
// 与选品列表一致:每次拉取后整体替换,轮询时 showLoading=false,表格无整表 loading 闪烁。
|
|
// 与选品列表一致:每次拉取后整体替换,轮询时 showLoading=false,表格无整表 loading 闪烁。
|
|
|
// 限制数组大小,防止内存泄漏
|
|
// 限制数组大小,防止内存泄漏
|