feat(跟价勾选): 默认只勾在售、一个都不勾=按在售跑不再拦启动、续跑先选在跑的那份循环
用户 2026-10-17 定口径。三件事: 1) 默认只勾在售、另两项不默认勾——本来就是现状,没动,只在用例里钉住; 2) 取消「一个状态都没勾就拦住启动」:不勾的语义就是上线前的「只跑在售」,拦它只会让用户 以为跑不了。改为提交前经 withDefaultListingStatuses 兜底回在售,与客户端 price_match_new.resolve_listing_statuses 同一口径,两边不许分叉。顺手补掉一个 Vue 坑: 取消最后一格时 :checked 新旧值都是 true、Vue 不回写 DOM,不手动复位就会出现 「框看着没勾、实际按在售在跑」的错位,故在 onListingStatusToggle 里显式复位。 3) 「会先选在跑的」:setLoopRun 首次拿到在跑循环时用其落库 listingStatuses 预填勾选, 只在「之前没有循环在位」时填(免得轮询冲掉正在改的勾选),asin-only 循环与空清单不填。 orderListingStatuses/withDefaultListingStatuses 从组件里提到 listingFilters.ts 变成可直接 断言的纯函数,不再只靠源码正则。验证:price-track-listing-statuses 9/9、用户端整量 npm test 864 passed、vue-tsc --noEmit 干净。 本提交只含上述改动:同文件里另一路「移除清除勾选记忆入口」的在飞 diff 按 §1 铁律 4 留在工作区,没卷进来。
This commit is contained in:
@@ -242,6 +242,8 @@ import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.v
|
||||
import {
|
||||
PRICE_TRACK_DEFAULT_LISTING_STATUSES,
|
||||
PRICE_TRACK_LISTING_STATUSES,
|
||||
orderListingStatuses,
|
||||
withDefaultListingStatuses,
|
||||
} from './listingFilters'
|
||||
import ModuleTemplateDownload from '@/shared/components/ModuleTemplateDownload.vue'
|
||||
import FileUploadZone from '@/shared/components/FileUploadZone.vue'
|
||||
@@ -367,24 +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 的空清单兜底同一口径)
|
||||
const effectiveListingStatuses = computed(() => withDefaultListingStatuses(selectedListingStatuses.value))
|
||||
|
||||
function isListingStatusSelected(value: string) {
|
||||
return selectedListingStatuses.value.includes(value)
|
||||
return effectiveListingStatuses.value.includes(value)
|
||||
}
|
||||
|
||||
function onListingStatusToggle(value: string, event: Event) {
|
||||
const checked = (event.target as HTMLInputElement).checked
|
||||
const input = event.target as HTMLInputElement
|
||||
const next = new Set(selectedListingStatuses.value)
|
||||
if (checked) next.add(value)
|
||||
if (input.checked) next.add(value)
|
||||
else next.delete(value)
|
||||
// 按目录顺序回写:这个顺序就是客户端逐状态筛选、逐页跑的顺序,不能跟着点击次序漂
|
||||
selectedListingStatuses.value = listingStatusRows.filter((row) => next.has(row.value)).map((row) => row.value)
|
||||
selectedListingStatuses.value = orderListingStatuses([...next])
|
||||
// 取消最后一个勾选时,:checked 的新旧值都是 true,Vue 不回写 DOM,
|
||||
// 不手动复位就会出现「框看着没勾、实际按在售在跑」的错位
|
||||
input.checked = effectiveListingStatuses.value.includes(value)
|
||||
}
|
||||
|
||||
const hasValidListingStatuses = computed(() => selectedListingStatuses.value.length > 0)
|
||||
|
||||
const listingStatusSummaryText = computed(() => {
|
||||
const labels = listingStatusRows.filter((row) => isListingStatusSelected(row.value)).map((row) => row.label)
|
||||
return labels.length ? `「${labels.join(' / ')}」的` : '(一个状态都没勾,无法启动)'
|
||||
return `「${labels.join(' / ')}」的`
|
||||
})
|
||||
|
||||
// 上传文件
|
||||
@@ -969,7 +974,7 @@ function listingStatusesForPayload(child?: PriceTrackCreateTaskRequest | null) {
|
||||
const fromDispatch = (child?.listingStatuses || []).filter((item) => !!item)
|
||||
// 派发值优先(循环建单时勾的那几个状态要一路跑到最后一轮,不随界面中途改勾选而变);
|
||||
// 老循环没存这个字段(后端加列前的记录)时退回本地勾选。
|
||||
return fromDispatch.length ? fromDispatch : [...selectedListingStatuses.value]
|
||||
return fromDispatch.length ? fromDispatch : effectiveListingStatuses.value
|
||||
}
|
||||
|
||||
function buildMinimumPriceByCountryAndAsin(rowsByCountry: Record<string, PriceTrackAsinParsedRow[]>) {
|
||||
@@ -1227,9 +1232,16 @@ async function waitForTaskTerminal(taskId: number) {
|
||||
}
|
||||
|
||||
function setLoopRun(next: PriceTrackLoopRunVo | null) {
|
||||
const hadLoop = !!activeLoopRun.value
|
||||
activeLoopRun.value = next
|
||||
activeLoopRunId.value = next?.id ?? null
|
||||
saveActiveLoopRunId()
|
||||
// 刷新/重开页面自动续跑时,勾选态跟着「在跑的那份循环」走:它每一轮真正跑的就是落库的这几个
|
||||
// 状态,界面停在默认值会让人误判在跑的范围。已有循环在位时不覆盖,免得轮询冲掉正在改的勾选。
|
||||
if (next && !hadLoop && next.statusMode !== false) {
|
||||
const running = orderListingStatuses((next.listingStatuses || []).filter(Boolean))
|
||||
if (running.length) selectedListingStatuses.value = running
|
||||
}
|
||||
}
|
||||
|
||||
function clearLoopRunIfTerminal() {
|
||||
@@ -1416,11 +1428,6 @@ async function pushToPythonLoopQueue() {
|
||||
ElMessage.warning('请至少选择一个跟价模式')
|
||||
return
|
||||
}
|
||||
if (statusModeEnabled.value && !hasValidListingStatuses.value) {
|
||||
// 空清单投出去会被客户端退回"在售",用户勾的其它状态就静默不跑,所以在这里就拦住
|
||||
ElMessage.warning('按商品状态跟价时请至少勾选一个商品状态')
|
||||
return
|
||||
}
|
||||
if (asinModeEnabled.value && !asinFiles.value.length) {
|
||||
ElMessage.warning('请先选择 ASIN 文件')
|
||||
return
|
||||
@@ -1437,7 +1444,7 @@ async function pushToPythonLoopQueue() {
|
||||
userId: 0,
|
||||
statusMode: statusModeEnabled.value,
|
||||
// 勾了哪些状态随循环落库:每一轮子任务都从这里回读,界面中途改勾选不影响已启动的循环
|
||||
listingStatuses: statusModeEnabled.value ? [...selectedListingStatuses.value] : [],
|
||||
listingStatuses: statusModeEnabled.value ? effectiveListingStatuses.value : [],
|
||||
asinMode: asinModeEnabled.value,
|
||||
items: matchedRows,
|
||||
asinFiles: resolveAsinRequestPaths(),
|
||||
|
||||
@@ -28,3 +28,22 @@ export type PriceTrackListingStatusValue = (typeof PRICE_TRACK_LISTING_STATUSES)
|
||||
|
||||
/** 默认只勾在售=本功能上线前的行为,存量用户不勾也不会多跑状态。 */
|
||||
export const PRICE_TRACK_DEFAULT_LISTING_STATUSES: PriceTrackListingStatusValue[] = ['Active']
|
||||
|
||||
/**
|
||||
* 按目录顺序回写勾选。这个顺序就是客户端逐状态筛选、逐页跑的顺序,不能跟着点击次序漂;
|
||||
* 目录外的取值(脏数据/老版本存的键)在这里被摘掉,不投给客户端。
|
||||
* 返回 string[] 而不是联合类型:调用方拿到的清单本来就来自后端载荷(string[]),
|
||||
* 在这里假装严格没有意义,目录一致性由测试钉。
|
||||
*/
|
||||
export function orderListingStatuses(values: readonly string[]): string[] {
|
||||
const picked = new Set(values)
|
||||
return PRICE_TRACK_LISTING_STATUSES.filter((row) => picked.has(row.value)).map((row) => row.value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个状态都没勾=兜底回在售。与客户端 price_match_new.resolve_listing_statuses
|
||||
* 的空清单兜底同一口径,两边都得是「不勾=只跑在售」,否则界面显示的范围和真跑的范围会分叉。
|
||||
*/
|
||||
export function withDefaultListingStatuses(values: readonly string[]): string[] {
|
||||
return orderListingStatuses(values.length ? values : PRICE_TRACK_DEFAULT_LISTING_STATUSES)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user