From 1c3395869e70ea0839ac53e742581977b5c0bde8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Sun, 15 Nov 2026 12:26:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(jd-collect):=20=E9=87=87=E9=9B=86=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E5=8D=A1=E7=89=87=E6=98=BE=E7=A4=BA=E7=99=BE=E5=88=86?= =?UTF-8?q?=E6=AF=94=E2=80=94=E2=80=94countLabel=20=E5=B8=A6=E5=88=86?= =?UTF-8?q?=E6=AF=8D=E3=80=8C=E5=B7=B2=E9=87=87=E9=9B=86=20N/M=20=E4=B8=AA?= =?UTF-8?q?=E5=95=86=E5=93=81=EF=BC=88X%=EF=BC=89=E3=80=8D=EF=BC=88TaskIte?= =?UTF-8?q?mCard=20=E6=9C=89=20countLabel=20=E5=B0=B1=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=80=BB=E8=BF=9B=E5=BA=A6=E8=A1=8C=EF=BC=8C=E7=99=BE?= =?UTF-8?q?=E5=88=86=E6=AF=94=E5=8F=AA=E8=83=BD=E9=9A=8F=20countLabel=20?= =?UTF-8?q?=E5=87=BA=EF=BC=9B=E6=97=A0=20total=20=E4=BB=8D=E4=B8=8D?= =?UTF-8?q?=E7=BC=96=E9=80=A0=E5=88=86=E6=AF=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend-vue/src/pages/jd/JdCollectTab.vue | 12 +++++++++++- .../tests/mount/jd-collect-progress.mount.test.ts | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend-vue/src/pages/jd/JdCollectTab.vue b/frontend-vue/src/pages/jd/JdCollectTab.vue index 49f920435..28f908ef3 100644 --- a/frontend-vue/src/pages/jd/JdCollectTab.vue +++ b/frontend-vue/src/pages/jd/JdCollectTab.vue @@ -109,7 +109,7 @@ function toJdTaskView(item: JdCollectHistoryItemVo): TaskItemView { : []), ...(item.errorMessage ? [`错误:${userNotice(item.errorMessage)}`] : []), ], - progress: showProgress ? { percent: progressPercent(item), countLabel: `已采集 ${item.itemsReceived ?? item.rowCount ?? 0} 个商品` } : null, + progress: showProgress ? { percent: progressPercent(item), countLabel: progressCountLabel(item) } : null, source: item, } } @@ -155,6 +155,16 @@ function progressPercent(item: JdCollectHistoryItemVo) { return Math.max(0, Math.min(99, Math.round((done * 100) / total))) } +/** 计数文案:有 total 带分母和百分比「已采集 30/100 个商品(30%)」——TaskItemCard 的 + * countLabel 会顶掉「总进度 X%」那行字,百分比只能随 countLabel 一起出; + * 没有 total 保持只报行数,不编造分母(与本页 progressPercent 同一口径)。 */ +function progressCountLabel(item: JdCollectHistoryItemVo) { + const received = item.itemsReceived ?? item.rowCount ?? 0 + const total = typeof item.total === 'number' && item.total > 0 ? item.total : null + if (!total) return `已采集 ${received} 个商品` + return `已采集 ${received}/${total} 个商品(${progressPercent(item)}%)` +} + /** 失败/已中断的任务能续跑:在原任务上复位(不新建任务),成功/进行中的任务不该出现这个按钮。 */ function canRetryTask(item: JdCollectHistoryItemVo | null | undefined): boolean { if (!item?.taskId) return false 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 dd882ff09..40170775c 100644 --- a/frontend-vue/tests/mount/jd-collect-progress.mount.test.ts +++ b/frontend-vue/tests/mount/jd-collect-progress.mount.test.ts @@ -172,7 +172,8 @@ describe('获取店铺数据:一键采集 + 任务面板', () => { const bar = w.find('.file-progress-bar') expect(bar.exists()).toBe(true) expect(bar.attributes('style')).toContain('width: 30%') - expect(w.find('.file-progress-meta').text()).toContain('已采集 30 个商品') + // 百分比文字随 countLabel 一起出(TaskItemCard 有 countLabel 就不显示「总进度 X%」) + expect(w.find('.file-progress-meta').text()).toContain('已采集 30/100 个商品(30%)') }) it('没有分母(total 缺失)时只显示已采集行数,不编造百分比', async () => {