fix(跟价勾选): 兜底只喂载荷不许锁界面——在售必须能被取消
上线当天用户当场指出::checked 绑到了兜底值上,于是「先取消在售、再勾自己要的状态」 这条最自然的路劲走不通(取消最后一格立刻弹回在售)。改为勾选框只认原始勾选, 空勾选的在售兜底留在提交期(载荷/建单/摘要三处不变),界面不再替用户做主。 摘要在空勾选时明写「在售」的(一个状态都没勾=按默认的在售跑),显示与实跑一字不差。 新增用例钉住这两条:isListingStatusSelected 必须读原始勾选、不许再往事件目标写回 checked。 验证:price-track-listing-statuses 10/10、用户端整量 865 passed、vue-tsc 干净。 同文件另一路「移除清除勾选记忆」的在飞 diff 仍按 hunk 留在工作区未卷。
This commit is contained in:
@@ -369,27 +369,27 @@ const asinModeEnabled = ref(false) // 按指定ASIN文档(自定义)
|
||||
const listingStatusRows = PRICE_TRACK_LISTING_STATUSES
|
||||
const selectedListingStatuses = ref<string[]>([...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 `「在售」的(一个状态都没勾=按默认的在售跑)`
|
||||
})
|
||||
|
||||
// 上传文件
|
||||
|
||||
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user