task-280(验收反馈): 重复检测对齐reference P0(分组筛选生效/抽屉聚合+汇总徽章/台账计数预载/total_dup计数/矩阵表头吸顶;后端含工作区在途console化代码)
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/** 撞款控制台/台账适配:/api/admin/shop-data-crawl/duplicate-check-console、-ledger、-export。 */
|
||||
import { http } from '@/api/http'
|
||||
import { toDuplicateItemsQuery, type DuplicateFilter } from './duplicate-filter.ts'
|
||||
import {
|
||||
parseDuplicateConsole,
|
||||
parseLedgerPage,
|
||||
type DuplicateConsole,
|
||||
type LedgerPage,
|
||||
} from './duplicate-console-model.ts'
|
||||
|
||||
export const DUPLICATE_CHECK_ENDPOINT = '/api/admin/shop-data-crawl'
|
||||
|
||||
/** console 端点吃 asin/shop_name/group/country/site/date_from/date_to;多余分页参数后端忽略。 */
|
||||
function toConsoleQuery(filter: DuplicateFilter): Record<string, string> {
|
||||
const query: Record<string, string> = {}
|
||||
const asin = (filter.asin || '').trim()
|
||||
if (asin) query.asin = asin
|
||||
const shopName = (filter.shopName || '').trim()
|
||||
if (shopName) query.shop_name = shopName
|
||||
const group = (filter.group || '').trim()
|
||||
if (group) query.group = group
|
||||
const country = (filter.country || '').trim()
|
||||
if (country) query.country = country
|
||||
const site = (filter.site || '').trim()
|
||||
if (site) query.site = site
|
||||
const dateFrom = (filter.dateFrom || '').trim()
|
||||
if (dateFrom) query.date_from = dateFrom
|
||||
const dateTo = (filter.dateTo || '').trim()
|
||||
if (dateTo) query.date_to = dateTo
|
||||
return query
|
||||
}
|
||||
|
||||
export type LedgerSortKey = 'asin' | 'brand' | 'store_count' | 'record_count' | 'earliest' | 'latest'
|
||||
|
||||
/** 加载撞款控制台快照:GET /duplicate-check-console。 */
|
||||
export async function fetchDuplicateConsole(filter: DuplicateFilter): Promise<DuplicateConsole> {
|
||||
const { data } = await http.get<unknown>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-console`, {
|
||||
params: toConsoleQuery(filter),
|
||||
})
|
||||
return parseDuplicateConsole(data)
|
||||
}
|
||||
|
||||
/** 加载全部 ASIN 台账分页(含未撞款):GET /duplicate-check-ledger。 */
|
||||
export async function fetchDuplicateLedger(
|
||||
filter: DuplicateFilter,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
sortKey: LedgerSortKey | '',
|
||||
sortDir: 'asc' | 'desc',
|
||||
): Promise<LedgerPage> {
|
||||
const params: Record<string, string | number> = { ...toConsoleQuery(filter), page, page_size: pageSize }
|
||||
if (sortKey) params.sort_key = sortKey
|
||||
params.sort_dir = sortDir
|
||||
const { data } = await http.get<unknown>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-ledger`, { params })
|
||||
return parseLedgerPage(data)
|
||||
}
|
||||
|
||||
/** 导出 CSV(撞款 view=monitor / 台账 view=all):GET /duplicate-check-export → Blob。 */
|
||||
export async function requestDuplicateCsvBlob(filter: DuplicateFilter, view: string): Promise<Blob> {
|
||||
const { data } = await http.get<Blob>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-export`, {
|
||||
params: toDuplicateItemsQuery({ ...filter, view }, 1, 100),
|
||||
responseType: 'blob',
|
||||
})
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user