191e5f9102
撞款控制台整页复刻 reference 观感:引入页面独立 reference 令牌(#2E5BE6 主蓝/#D63A4A 红/#F2F4F8 底)落到 KPI 色点/矩阵单元格/撞款卡/台账 chips;撞款覆盖矩阵与全部ASIN台账改原生表格(台账20条/页+共N条/上一页/下一页/跳至N页分页条,列头服务端排序▲/▼);筛选改原生 input/select/date;明细抽屉+底部 toast 复刻 reference(原生 mask/drawer/d-table 汇总徽章);分组说明只读(归属来自店铺管理)。 数据源保持自家 /api/admin/shop-data-crawl/duplicate-check-console|-ledger|-export 不变。 验收:mock-admin-server 补 console/ledger 夹具;新增 e2e dup-console.spec(渲染/台账切换/令牌色值/矩阵台账结构断言+截图);align-dup-console/align-column-width 断言随原生表格调整;前端 1552 测试全绿 + vue-tsc/build 通过。
66 lines
2.7 KiB
TypeScript
66 lines
2.7 KiB
TypeScript
/** 撞款控制台/台账适配:/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)
|
||
}
|
||
|
||
/** 导出 Excel(撞款 view=monitor / 台账 view=all):GET /duplicate-check-export → xlsx Blob。 */
|
||
export async function requestDuplicateExportBlob(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
|
||
}
|