align(查询ASIN): 回退参考纵向 rowspan 布局(序号/分组/店铺/操作合并+逐国ASIN行点击复制)、补新增ASIN弹窗(分组→店铺联动100/页聚合→国家→ASIN)、去更新时间列(对齐 admin.js renderQueryAsinRows/btnCreateQueryAsin/loadAsinShopNameOptions)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
/** 查询 ASIN 列表查询适配(任务 71):GET /api/admin/query-asins + 分页/筛选归一与 camel 序列化。 */
|
||||
import { http } from '@/api/http'
|
||||
import { unwrap } from '@/api/envelope'
|
||||
import { fetchShopManageList } from '../shop/shop-manage-api.ts'
|
||||
import { parseQueryAsinPage, type QueryAsinPageResult } from './query-asin-model'
|
||||
import {
|
||||
normalizeQueryAsinParams,
|
||||
@@ -14,3 +16,38 @@ export async function fetchQueryAsinList(params: Partial<QueryAsinListParams> =
|
||||
const { data } = await http.get<unknown>(QUERY_ASIN_ENDPOINT, { params: toQueryAsinQuery(normalized) })
|
||||
return parseQueryAsinPage(data)
|
||||
}
|
||||
|
||||
/** 新增/覆盖查询 ASIN 载荷(对齐 Java QueryAsinCreateRequest camelCase)。 */
|
||||
export interface QueryAsinCreatePayload {
|
||||
groupId: number
|
||||
shopName: string
|
||||
countries: string[]
|
||||
asin: string
|
||||
asinMappings: Record<string, string>
|
||||
}
|
||||
|
||||
/** 新增或覆盖查询 ASIN:POST /api/admin/query-asins,返回后端成功消息。 */
|
||||
export async function createQueryAsin(payload: QueryAsinCreatePayload): Promise<string> {
|
||||
const { data } = await http.post<unknown>(QUERY_ASIN_ENDPOINT, payload)
|
||||
const record = unwrap<unknown>(data) as Record<string, unknown> | null | undefined
|
||||
const message = record && typeof record.message === 'string' ? record.message : ''
|
||||
return message || '保存成功'
|
||||
}
|
||||
|
||||
/** 按分组加载店铺名列表(对齐 admin.js loadAsinShopNameOptions:100/页翻页聚合去重,上限 20 页)。 */
|
||||
export async function fetchShopNamesByGroup(groupId: number): Promise<string[]> {
|
||||
const names: string[] = []
|
||||
const seen = new Set<string>()
|
||||
for (let page = 1; page <= 20; page += 1) {
|
||||
const result = await fetchShopManageList({ page, pageSize: 100, groupId })
|
||||
for (const shop of result.items) {
|
||||
const name = (shop.shopName || '').trim()
|
||||
if (name && !seen.has(name)) {
|
||||
seen.add(name)
|
||||
names.push(name)
|
||||
}
|
||||
}
|
||||
if (page * result.pageSize >= result.total) break
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user