diff --git a/frontend-vue/src/pages/brand/components/BrandPriceTrackTab.vue b/frontend-vue/src/pages/brand/components/BrandPriceTrackTab.vue index e56694377..25f229946 100644 --- a/frontend-vue/src/pages/brand/components/BrandPriceTrackTab.vue +++ b/frontend-vue/src/pages/brand/components/BrandPriceTrackTab.vue @@ -369,27 +369,27 @@ const asinModeEnabled = ref(false) // 按指定ASIN文档(自定义) const listingStatusRows = PRICE_TRACK_LISTING_STATUSES const selectedListingStatuses = ref([...PRICE_TRACK_DEFAULT_LISTING_STATUSES]) -// 一个状态都没勾=兜底回在售(与客户端 resolve_listing_statuses 的空清单兜底同一口径) +// 一个状态都没勾=兜底回在售(与客户端 resolve_listing_statuses 的空清单兜底同一口径)。 +// ⚠ 这份兜底只喂载荷与摘要,不许回头去勾界面:曾经把 :checked 也绑到它上面, +// 结果「先取消在售、再勾自己要的状态」这条最自然的路径被锁死(取消最后一格会立刻弹回在售)。 const effectiveListingStatuses = computed(() => withDefaultListingStatuses(selectedListingStatuses.value)) function isListingStatusSelected(value: string) { - return effectiveListingStatuses.value.includes(value) + return selectedListingStatuses.value.includes(value) } function onListingStatusToggle(value: string, event: Event) { - const input = event.target as HTMLInputElement + const checked = (event.target as HTMLInputElement).checked const next = new Set(selectedListingStatuses.value) - if (input.checked) next.add(value) + if (checked) next.add(value) else next.delete(value) selectedListingStatuses.value = orderListingStatuses([...next]) - // 取消最后一个勾选时,:checked 的新旧值都是 true,Vue 不回写 DOM, - // 不手动复位就会出现「框看着没勾、实际按在售在跑」的错位 - input.checked = effectiveListingStatuses.value.includes(value) } const listingStatusSummaryText = computed(() => { const labels = listingStatusRows.filter((row) => isListingStatusSelected(row.value)).map((row) => row.label) - return `「${labels.join(' / ')}」的` + if (labels.length) return `「${labels.join(' / ')}」的` + return `「在售」的(一个状态都没勾=按默认的在售跑)` }) // 上传文件 diff --git a/frontend-vue/tests/price-track-listing-statuses.test.ts b/frontend-vue/tests/price-track-listing-statuses.test.ts index 6df366fb0..d83a90e98 100644 --- a/frontend-vue/tests/price-track-listing-statuses.test.ts +++ b/frontend-vue/tests/price-track-listing-statuses.test.ts @@ -57,6 +57,15 @@ test('一个状态都没勾=兜底回在售,不拦启动', () => { '又恢复了"空勾选拦启动":不勾的语义就是只跑在售,拦它只会让用户以为跑不了') }) +test('兜底只喂载荷,不许回头锁界面:在售必须能被取消', () => { + // 2026-10-17 上线后被用户当场指出::checked 绑到兜底值上,「先取消在售、再勾自己要的状态」 + // 这条最自然的路径就死了(取消最后一格立刻弹回在售)。兜底是提交期的事,不是界面的事。 + assert.match(source, /function isListingStatusSelected\(value: string\) \{\n\s+return selectedListingStatuses\.value\.includes\(value\)/, + '勾选框又绑回兜底值:在售取消不掉') + assert.doesNotMatch(source, /input\.checked = effectiveListingStatuses/, + '又往事件目标上写回兜底勾选') +}) + test('回写按目录顺序、目录外的值被摘掉', () => { assert.deepEqual(orderListingStatuses(['PricingIssue', 'Active', 'SearchSuppressed', '']), ['Active', 'PricingIssue'],