From 3a24674c9db89d521d7ec7b4e4c2d00afd4d02b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Sat, 21 Nov 2026 03:02:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(jd-collect):=20=E8=BF=9B=E5=BA=A6=E6=9D=A1?= =?UTF-8?q?=200=20=E8=A1=8C=E8=BF=9B=E8=A1=8C=E6=97=B6=E6=96=87=E6=A1=88?= =?UTF-8?q?=E2=80=94=E2=80=94=E9=A6=96=E6=89=B9=E5=88=86=E7=89=87=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E5=89=8D=E4=B8=8D=E5=86=8D=E6=8C=82=E3=80=8C=E5=B7=B2?= =?UTF-8?q?=E9=87=87=E9=9B=86=200=20=E4=B8=AA=E5=95=86=E5=93=81=E3=80=8D?= =?UTF-8?q?=E5=83=8F=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend-vue/src/pages/jd/JdCollectTab.vue | 8 +++++- .../mount/jd-collect-progress.mount.test.ts | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/frontend-vue/src/pages/jd/JdCollectTab.vue b/frontend-vue/src/pages/jd/JdCollectTab.vue index ac9394423..8d6f2693e 100644 --- a/frontend-vue/src/pages/jd/JdCollectTab.vue +++ b/frontend-vue/src/pages/jd/JdCollectTab.vue @@ -405,10 +405,16 @@ function progressPercent(item: JdCollectHistoryItemVo) { /** 计数文案:有 total 带分母和百分比「已采集 30/100 个商品(30%)」——TaskItemCard 的 * countLabel 会顶掉「总进度 X%」那行字,百分比只能随 countLabel 一起出; - * 没有 total 保持只报行数,不编造分母(与本页 progressPercent 同一口径)。 */ + * 没有 total 保持只报行数,不编造分母(与本页 progressPercent 同一口径)。 + * 2026-11-21 35089 实录补进行时档:首批分片被服务端收下前 itemsReceived 恒 0(页内 + * 详情采集要 1-3 分钟)、「已采集 0 个商品」像卡死,用户误以为失败点了删除(35088/ + * 35089/35090 三单都被这样删掉,数据采集成功但随删除清库)。0 行时改报进行时文案。 */ function progressCountLabel(item: JdCollectHistoryItemVo) { const received = collectedCount(item) const total = typeof item.total === 'number' && item.total > 0 ? item.total : null + if (!received && normalizeTaskStatus(item) !== 'SUCCESS') { + return total ? `已采 0/${total} 个商品(正在采集中…)` : '正在采集,首批数据确认后开始计数…' + } if (!total) return `已采集 ${received} 个商品` return `已采集 ${received}/${total} 个商品(${progressPercent(item)}%)` } diff --git a/frontend-vue/tests/mount/jd-collect-progress.mount.test.ts b/frontend-vue/tests/mount/jd-collect-progress.mount.test.ts index ad98d572f..324b85af6 100644 --- a/frontend-vue/tests/mount/jd-collect-progress.mount.test.ts +++ b/frontend-vue/tests/mount/jd-collect-progress.mount.test.ts @@ -246,6 +246,34 @@ describe('获取店铺数据:一键采集 + 任务面板', () => { expect(w.find('.file-progress-bar').attributes('style')).toContain('width: 0%') }) + it('0 行且无分母时报进行时文案,不把「已采集 0 个商品」挂出来像卡死(35089 误删实录)', async () => { + // 首批分片被服务端收下前 itemsReceived 恒 0(页内详情采集 1-3 分钟);「已采集 0 个」 + // 让用户以为失败点了删除——35088/35089/35090 三单采集成功但被这样清库(2026-11-21)。 + api.fetchJdCollectTaskProgressBatch.mockResolvedValue( + batchOf(historyItem({ total: null, page: null, itemsReceived: 0, rowCount: 0 })), + ) + const w = await mountPage() + await startCollect(w) + await flushPromises() + + const meta = w.find('.file-progress-meta') + expect(meta.exists()).toBe(true) + expect(meta.text()).toContain('正在采集,首批数据确认后开始计数…') + expect(meta.text()).not.toContain('已采集 0 个商品') + }) + + it('0 行但有分母时报「已采 0/N(正在采集中…)」而不是纯 0/N', async () => { + api.fetchJdCollectTaskProgressBatch.mockResolvedValue( + batchOf(historyItem({ total: 100, page: 1, itemsReceived: 0, rowCount: 0 })), + ) + const w = await mountPage() + await startCollect(w) + await flushPromises() + + expect(w.find('.file-progress-meta').text()).toContain('已采 0/100 个商品(正在采集中…)') + expect(w.find('.file-progress-meta').text()).not.toContain('已采集 0 个商品') + }) + it('分片被拒时进度行以落库 rowCount 为准(itemsReceived 低估不再与行数行自相矛盾)', async () => { // 34959 实录(2026-11-19):8 行已落京东数据库、分片回传 500 ⇒ 服务端 // itemsReceived=0、rowCount=8,extraLines 显示「已采集 8 个商品」而进度行显示 0。