feat(appearance-patent): 外观专利数据库改为按主管划分的一主管一卡(2026-11-11 客户「应该是只显示一个卡片的才对」「获取店铺那边是按店铺做成卡片 我们这边就是按主管划分」)——后端新增 GET /supervisors 主管聚合(组键=与「所属主管」列同源的归属表达式:主管本人取自己、普通账户取创建人、读不到归同一 NULL 组;返回条数/任务数/最近任务号/最近同步/国家集,total 是主管数),卡片[下载]走 /export 新增 supervisor_user_id 按同一表达式收窄(不近似成 user_id OR created_by_id);共享 cleanItemConds 前移到 i. 前缀并复用(铁律 20 SQL 下推);后管页面由「每明细一卡」改为「一主管一卡」(卡头主管名/条数/任务/国家/最新 + 下载,对齐店铺数据记录一店一卡),明细分页卡片下架(3488 条铺成几千张卡是客户不要的形态),明细仍走 /export 表格看;护栏台账同轮更新(XML_SELECT_TOTAL 105→109、XML_STATEMENT_TOTAL 151→155、PageDefaults 56→58、SourceScan 52→55/vo 11→14、wiring 新增 /supervisors 发送口);后端 test-compile rc=0、controller 22 例绿+6 支护栏绿,前端 vue-tsc rc=0、mount 13/13、三支 node --test 21/21
This commit is contained in:
@@ -1,31 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
||||
/** 外观专利无侵权数据 · 只读分页列表(v1.3)。展示形式 2026-11-11 客户改版:参照「店铺数据记录」页
|
||||
* (ShopDataTasksPage)——form-box 筛选条件 + panel-box 工具条[导出] + 卡片宫格(4/3/2/1 响应式)
|
||||
* + OldPagination 服务端分页,推翻 2026-11-10「参照去重库页自绘 table」的旧拍板。
|
||||
* 筛选面同日二次精简(客户「筛选条件只要…和获取店铺一样」「按账号对应的主管吧 不需要店铺」):
|
||||
* 只留 分组(下拉,主管=组长,选中按「组长本人+名下子账户」整集 SQL 下推过滤)/国家/同步起止
|
||||
* 时间,字段顺序对齐获取店铺页(分组→国家→时间);任务号/ASIN 输入框下架——后端 §3.2 参数契约
|
||||
* (task_id/asin)与前端过滤模块逐字对撞护栏原样保留,只是 UI 不再暴露。数据由出表成功点
|
||||
* 自动同步(后端 SyncService),本页零写操作:无编辑/导入;单条明细没有可下载文件,下载/导出
|
||||
* 统一走既有 /export 全量出 xlsx(带当前过滤面 + 公司 tab,含所属主管列)。分组下拉选项与去重页
|
||||
* 共用 GET /shop-manages/groups,选中后以 group_id 走同一过滤面(列表与导出同源)。
|
||||
* 同日三改(客户「要按主管分组显示」「价格 asin 无侵权 这些都不需要展示的」「到时候能下载
|
||||
* 表格看就行」):卡片按所属主管连续分组——组头=主管名+本页条数(grid 全宽一行),组内行序
|
||||
* 保持服务端 synced_at DESC 原样,不跨页聚合、不按名重排(跨主管交错时按行序出多个同名组头,
|
||||
* 忠实反映同步顺序;要只看一个主管用分组下拉过滤)。卡片字段同批精简:只留 标题(卡头,替下
|
||||
* 原 ASIN 卡头)/任务/国家/品牌/SKU/同步;价格、ASIN、结论徽章(无侵权)、所属主管行不再
|
||||
* 上卡——全量明细(含价格/ASIN/结论/主管列)仍走 /export xlsx。同日四改(客户反馈「选了
|
||||
* 主管应该只显示这一个主管的才对」):分组(主管)下拉选中即查——选完立刻按该主管过滤刷新
|
||||
* (回第一页),不必再点查询;国家/时间仍走查询按钮。 */
|
||||
/** 外观专利数据库 · 按主管划分的卡片列表(v1.3 后续,2026-11-11 客户三连拍板:
|
||||
* 「要按主管分组显示」→「应该是只显示一个卡片的才对」→「获取店铺那边是按店铺做成卡片
|
||||
* 我们这边就是按主管划分」)。
|
||||
*
|
||||
* 形态:一主管一卡(对齐「店铺数据记录」页的一店一卡),卡内是该主管名下的汇总——
|
||||
* 条数 / 任务(几个任务、最近任务号)/ 国家 / 最新同步时间 + [下载](导出该主管名下全量 xlsx)。
|
||||
* 明细分页卡片(每明细一卡)已下架:3488 条明细会铺成几千张卡,客户明确不要。
|
||||
* 数据来自 GET /supervisors(后端按「主管本人取自己、普通账户取创建人」的归属表达式聚合,
|
||||
* total 是主管数),与明细导出走同一过滤面(分组/国家/同步起止 + 公司 tab)。
|
||||
* 页签零写操作:明细本身仍走 /export xlsx 看(客户「到时候能下载表格看就行」)。
|
||||
* 分组(主管)下拉选中即查(同日四改):客户选了主管就该只看到这一位/这一组的主管卡片。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import {
|
||||
exportAppearancePatentCleanList,
|
||||
fetchAppearancePatentCleanList,
|
||||
fetchAppearancePatentCleanSupervisors,
|
||||
fetchDedupeTotalGroups,
|
||||
type DedupeGroupOption,
|
||||
} from './appearance-patent-clean-api.ts'
|
||||
import type { AppearancePatentCleanItem } from './appearance-patent-clean-model.ts'
|
||||
import type { AppearancePatentSupervisorCard } from './appearance-patent-clean-model.ts'
|
||||
import { createAppearancePatentCleanFilterState } from './appearance-patent-clean-filter.ts'
|
||||
import { ASIN_COUNTRY_CODES, asinCountryLabel } from '../asin/asin-country.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
@@ -38,12 +31,15 @@ const companyTab = useCompanyTabStore()
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<AppearancePatentCleanItem[]>([])
|
||||
const cards = ref<AppearancePatentSupervisorCard[]>([])
|
||||
/** 主管数(不是明细条数)。 */
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
/** 导出在途锁:避免连点导出把同一份过滤面重复请求两遍。 */
|
||||
const exporting = ref(false)
|
||||
/** 单卡下载在途标记(存 supervisorId,避免连点同一张卡)。 */
|
||||
const downloadingId = ref<number | null>(null)
|
||||
/** 同步台账是累计数据,日期初值故意留空(默认当天会让首屏只剩今天同步的行);见 date-filter-default-today 护栏的 EXEMPT。 */
|
||||
const filter = reactive(createAppearancePatentCleanFilterState())
|
||||
/** 分组(主管)下拉选项:公司 tab 切换时重取;选项失败不拦列表,只回空下拉(可见「全部分组」)。 */
|
||||
@@ -57,22 +53,8 @@ function clampDatePair(): void {
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
|
||||
/** 主管分组视图(2026-11-11 三改「要按主管分组显示」):按服务端下发顺序(synced_at DESC)把
|
||||
* 连续同主管的行切段,组头带本页条数;只在当前页窗口内分组——不跨页聚合、不按名重排,
|
||||
* 同名主管被别的主管隔开时按行序出多个同名组头。读不到主管名不猜,展示 -。 */
|
||||
const groupedRows = computed<{ name: string; items: AppearancePatentCleanItem[] }[]>(() => {
|
||||
const groups: { name: string; items: AppearancePatentCleanItem[] }[] = []
|
||||
for (const row of rows.value) {
|
||||
const name = row.supervisorName || '-'
|
||||
const last = groups[groups.length - 1]
|
||||
if (last && last.name === name) last.items.push(row)
|
||||
else groups.push({ name, items: [row] })
|
||||
}
|
||||
return groups
|
||||
})
|
||||
|
||||
/** 分组选项与去重页/店铺管理同源(GET /shop-manages/groups);失败静默回空——分组只是筛选项,
|
||||
* 不该让它把首屏行集一起拖死(列表失败有自己的 LoadFailureBar)。 */
|
||||
* 不该让它把首屏卡片一起拖死(列表失败有自己的 LoadFailureBar)。 */
|
||||
async function loadGroupOptions(): Promise<void> {
|
||||
try {
|
||||
groupOptions.value = await fetchDedupeTotalGroups(companyTab.requestCompanyId)
|
||||
@@ -85,18 +67,16 @@ async function load(): Promise<void> {
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchAppearancePatentCleanList({
|
||||
const result = await fetchAppearancePatentCleanSupervisors({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
taskId: filter.taskId,
|
||||
asin: filter.asin,
|
||||
country: filter.country,
|
||||
groupId: filter.groupId,
|
||||
startDate: filter.startDate,
|
||||
endDate: filter.endDate,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
rows.value = result.items
|
||||
cards.value = result.items
|
||||
total.value = result.total
|
||||
if (result.page >= 1) page.value = result.page
|
||||
} catch (error) {
|
||||
@@ -107,7 +87,7 @@ async function load(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出与页签同一过滤面(含公司 tab 与分组),服务端全量出 xlsx;成功后浏览器落盘,失败弹可读文案。 */
|
||||
/** 顶部导出:当前过滤面(含公司 tab 与分组)全量出 xlsx。 */
|
||||
async function exportAll(): Promise<void> {
|
||||
if (exporting.value) return
|
||||
exporting.value = true
|
||||
@@ -121,14 +101,7 @@ async function exportAll(): Promise<void> {
|
||||
endDate: filter.endDate,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
const url = URL.createObjectURL(result.blob)
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = url
|
||||
anchor.download = result.filename
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
anchor.remove()
|
||||
URL.revokeObjectURL(url)
|
||||
saveBlob(result.blob, result.filename)
|
||||
showAdminFeedback(`已导出 ${result.filename}`, 'success')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error && error.message ? error.message : '导出失败,请稍后重试'
|
||||
@@ -138,6 +111,43 @@ async function exportAll(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 单卡下载:只导出该主管名下明细(与卡片同一归属口径,supervisor_user_id 收窄)。
|
||||
* 读不到主管的那组没有 id,不给按钮(不猜是哪位主管)。 */
|
||||
async function downloadSupervisor(card: AppearancePatentSupervisorCard): Promise<void> {
|
||||
if (card.supervisorId == null || downloadingId.value !== null) return
|
||||
downloadingId.value = card.supervisorId
|
||||
try {
|
||||
const result = await exportAppearancePatentCleanList({
|
||||
taskId: '',
|
||||
asin: '',
|
||||
country: filter.country,
|
||||
groupId: filter.groupId,
|
||||
startDate: filter.startDate,
|
||||
endDate: filter.endDate,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
supervisorUserId: card.supervisorId,
|
||||
})
|
||||
saveBlob(result.blob, result.filename)
|
||||
showAdminFeedback(`已导出 ${card.supervisorName || '该主管'} 的数据`, 'success')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error && error.message ? error.message : '下载失败,请稍后重试'
|
||||
showAdminFeedback(message, 'error')
|
||||
} finally {
|
||||
downloadingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function saveBlob(blob: Blob, filename: string): void {
|
||||
const url = URL.createObjectURL(blob)
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = url
|
||||
anchor.download = filename
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
anchor.remove()
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
function apply(): void {
|
||||
page.value = 1
|
||||
void load()
|
||||
@@ -216,45 +226,49 @@ onMounted(() => {
|
||||
</button>
|
||||
</div>
|
||||
<div class="clean-toolbar-side">
|
||||
<span class="clean-summary">共 {{ total }} 条记录 · 本页 {{ rows.length }} 条</span>
|
||||
<span class="clean-summary">共 {{ total }} 位主管 · 本页 {{ cards.length }} 位</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clean-card-grid">
|
||||
<template v-if="groupedRows.length">
|
||||
<template v-for="(group, groupIndex) in groupedRows" :key="groupIndex">
|
||||
<div class="clean-group-head">
|
||||
<span class="clean-group-name" :title="group.name">{{ group.name }}</span>
|
||||
<span class="clean-group-count">本页 {{ group.items.length }} 条</span>
|
||||
<template v-if="cards.length">
|
||||
<article v-for="card in cards" :key="card.supervisorId ?? `unknown-${card.lastSyncedAt || ''}`" class="clean-card">
|
||||
<header class="clean-card-head">
|
||||
<span class="clean-card-supervisor" :title="card.supervisorName || '-'">{{ card.supervisorName || '-' }}</span>
|
||||
</header>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">条数</span>
|
||||
<span class="clean-card-value">{{ card.itemCount }} 条无侵权数据</span>
|
||||
</div>
|
||||
<article v-for="row in group.items" :key="row.id" class="clean-card">
|
||||
<header class="clean-card-head">
|
||||
<span class="clean-card-title" :title="row.title">{{ row.title || '-' }}</span>
|
||||
</header>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">任务</span>
|
||||
<span class="clean-card-value">{{ row.taskId ?? '-' }}</span>
|
||||
</div>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">国家</span>
|
||||
<span class="clean-card-value">
|
||||
<span class="country-chip">{{ asinCountryLabel(row.country || '') }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">品牌</span>
|
||||
<span class="clean-card-value">{{ row.brand || '-' }}</span>
|
||||
</div>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">SKU</span>
|
||||
<span class="clean-card-value mono">{{ row.sku || '-' }}</span>
|
||||
</div>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">同步</span>
|
||||
<span class="clean-card-value">{{ formatDateTime(row.syncedAt || '') || '-' }}</span>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">任务</span>
|
||||
<span class="clean-card-value">
|
||||
{{ card.taskCount }} 个任务<span v-if="card.lastTaskId != null"> · 最近 {{ card.lastTaskId }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">国家</span>
|
||||
<span class="clean-card-value">
|
||||
<span v-for="code in card.countryCodes" :key="code" class="country-chip">{{ asinCountryLabel(code) }}</span>
|
||||
<span v-if="!card.countryCodes.length">-</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="clean-card-row">
|
||||
<span class="clean-card-label">最新</span>
|
||||
<span class="clean-card-value">{{ formatDateTime(card.lastSyncedAt || '') || '-' }}</span>
|
||||
</div>
|
||||
<div class="clean-card-actions">
|
||||
<button
|
||||
class="btn btn-sm"
|
||||
type="button"
|
||||
:disabled="card.supervisorId == null || downloadingId !== null"
|
||||
:title="card.supervisorId == null ? '读不到主管账号,无法按主管导出(可用顶部导出)' : undefined"
|
||||
@click="downloadSupervisor(card)"
|
||||
>
|
||||
{{ downloadingId === card.supervisorId && card.supervisorId != null ? '下载中...' : '下载' }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
<div v-else-if="loading" class="empty-tip">加载中...</div>
|
||||
<div v-else class="empty-tip">暂无无侵权数据</div>
|
||||
@@ -266,10 +280,9 @@ onMounted(() => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 像素复刻参照「店铺数据记录」页(ShopDataTasksPage):form-box 筛选 + panel-box 工具条 +
|
||||
卡片宫格 + 旧式分页,蓝白末层;只读卡片无勾选/无单卡操作(本页零写操作)。
|
||||
2026-11-11 三改:卡片宫格按所属主管分段(.clean-group-head 全宽组头),卡头=标题;
|
||||
ASIN/结论徽章(st-pill)/价格/主管行的样式随下卡一并退役。 */
|
||||
/* 形态参照「店铺数据记录」页(ShopDataTasksPage):form-box 筛选 + panel-box 工具条 +
|
||||
卡片宫格 + 旧式分页,蓝白末层。2026-11-11 客户三连拍板后本页是<b>一主管一卡</b>:
|
||||
卡头=主管名,卡内条数/任务/国家/最新 + [下载];明细不再铺卡(几千条明细=几千张卡)。 */
|
||||
.clean-items-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
@@ -380,6 +393,10 @@ h3 {
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 14px;
|
||||
}
|
||||
.clean-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -425,10 +442,10 @@ h3 {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #e6edf4;
|
||||
}
|
||||
.clean-card-title {
|
||||
.clean-card-supervisor {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -442,7 +459,7 @@ h3 {
|
||||
}
|
||||
.clean-card-label {
|
||||
flex: none;
|
||||
width: 60px;
|
||||
width: 46px;
|
||||
color: #8293a5;
|
||||
}
|
||||
.clean-card-value {
|
||||
@@ -452,33 +469,11 @@ h3 {
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.mono {
|
||||
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.clean-group-head {
|
||||
grid-column: 1 / -1;
|
||||
.clean-card-actions {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
padding: 9px 14px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 10px;
|
||||
background: #f2f7fc;
|
||||
}
|
||||
.clean-group-name {
|
||||
font-weight: 650;
|
||||
font-size: 13.5px;
|
||||
color: #24384d;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.clean-group-count {
|
||||
flex: none;
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
padding: 8px 16px 14px;
|
||||
}
|
||||
.country-chip {
|
||||
padding: 1px 8px;
|
||||
|
||||
@@ -12,10 +12,14 @@ import {
|
||||
} from './appearance-patent-clean-filter.ts'
|
||||
import {
|
||||
parseAppearancePatentCleanPage,
|
||||
parseAppearancePatentSupervisorPage,
|
||||
type AppearancePatentCleanPageResult,
|
||||
type AppearancePatentSupervisorPageResult,
|
||||
} from './appearance-patent-clean-model.ts'
|
||||
|
||||
export const APPEARANCE_PATENT_CLEAN_ENDPOINT = '/api/admin/appearance-patent-clean-items'
|
||||
/** 主管聚合卡片端点(2026-11-11 客户「获取店铺那边是按店铺做成卡片 我们这边就是按主管划分」)。 */
|
||||
export const APPEARANCE_PATENT_SUPERVISOR_ENDPOINT = `${APPEARANCE_PATENT_CLEAN_ENDPOINT}/supervisors`
|
||||
|
||||
export async function fetchAppearancePatentCleanList(
|
||||
params: AppearancePatentCleanListParams,
|
||||
@@ -37,6 +41,37 @@ export async function fetchAppearancePatentCleanList(
|
||||
return parseAppearancePatentCleanPage(data)
|
||||
}
|
||||
|
||||
export interface AppearancePatentSupervisorListParams {
|
||||
page: number
|
||||
pageSize: number
|
||||
country?: string
|
||||
groupId?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
/** 主管聚合卡片列表(一主管一卡):与明细列表同一过滤面 + 公司 tab,total 是主管数。 */
|
||||
export async function fetchAppearancePatentCleanSupervisors(
|
||||
params: AppearancePatentSupervisorListParams,
|
||||
): Promise<AppearancePatentSupervisorPageResult> {
|
||||
const query = toAppearancePatentCleanListParams(
|
||||
{
|
||||
taskId: '',
|
||||
asin: '',
|
||||
country: params.country ?? '',
|
||||
groupId: params.groupId ?? '',
|
||||
startDate: params.startDate ?? '',
|
||||
endDate: params.endDate ?? '',
|
||||
},
|
||||
params.page,
|
||||
params.pageSize,
|
||||
)
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.get<unknown>(APPEARANCE_PATENT_SUPERVISOR_ENDPOINT, { params: query })
|
||||
return parseAppearancePatentSupervisorPage(data)
|
||||
}
|
||||
|
||||
export interface AppearancePatentCleanExportResult {
|
||||
blob: Blob
|
||||
filename: string
|
||||
@@ -57,19 +92,22 @@ function exportFilenameOf(disposition: unknown): string {
|
||||
return plain?.[1] || '外观专利数据库.xlsx'
|
||||
}
|
||||
|
||||
/** 导出当前过滤面全量明细:与列表共用同一过滤面取值口(含公司 tab),blob 下载交给页面触发保存。 */
|
||||
/** 导出当前过滤面全量明细:与列表共用同一过滤面取值口(含公司 tab),blob 下载交给页面触发保存。
|
||||
* {@code supervisorUserId} 传入=只导出该主管名下明细(卡片上的「下载」,2026-11-11 一主管一卡)。 */
|
||||
export async function exportAppearancePatentCleanList(
|
||||
params: AppearancePatentCleanExportParams,
|
||||
params: AppearancePatentCleanExportParams & { supervisorUserId?: number | null },
|
||||
): Promise<AppearancePatentCleanExportResult> {
|
||||
const query: AppearancePatentCleanExportQuery = toAppearancePatentCleanExportParams({
|
||||
taskId: params.taskId ?? '',
|
||||
asin: params.asin ?? '',
|
||||
country: params.country ?? '',
|
||||
groupId: params.groupId ?? '',
|
||||
startDate: params.startDate ?? '',
|
||||
endDate: params.endDate ?? '',
|
||||
})
|
||||
const query: AppearancePatentCleanExportQuery & { supervisor_user_id?: number } =
|
||||
toAppearancePatentCleanExportParams({
|
||||
taskId: params.taskId ?? '',
|
||||
asin: params.asin ?? '',
|
||||
country: params.country ?? '',
|
||||
groupId: params.groupId ?? '',
|
||||
startDate: params.startDate ?? '',
|
||||
endDate: params.endDate ?? '',
|
||||
})
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
if (params.supervisorUserId != null) query.supervisor_user_id = params.supervisorUserId
|
||||
const response = await http.get<Blob>(`${APPEARANCE_PATENT_CLEAN_ENDPOINT}/export`, {
|
||||
params: query,
|
||||
responseType: 'blob',
|
||||
|
||||
@@ -37,10 +37,82 @@ export interface AppearancePatentCleanPageResult {
|
||||
/** 前端首屏默认容量:与后端 PageDefaults.CLEAN_ITEMS_PAGE_SIZE(蓝图 §3.2 默认 10)同值。 */
|
||||
export const APPEARANCE_PATENT_CLEAN_DEFAULT_SIZE = 10
|
||||
|
||||
/** 主管卡片(2026-11-11 客户「获取店铺那边是按店铺做成卡片 我们这边就是按主管划分」):
|
||||
* 一主管一卡,卡内是该主管名下的汇总——不再按明细铺卡(几千条明细=几千张卡,客户明确不要)。 */
|
||||
export interface AppearancePatentSupervisorCard {
|
||||
/** 主管用户 id;null=读不到主管的那一组(该卡不提供按主管下载)。 */
|
||||
supervisorId: number | null
|
||||
/** 主管名(读不到为空,界面展示 -)。 */
|
||||
supervisorName: string
|
||||
/** 无侵权明细条数。 */
|
||||
itemCount: number
|
||||
/** 涉及任务数。 */
|
||||
taskCount: number
|
||||
/** 最近涉及的任务号。 */
|
||||
lastTaskId: number | null
|
||||
/** 最近同步时间。 */
|
||||
lastSyncedAt?: string
|
||||
/** 涉及国家码集(前端用自己的国家字典翻中文)。 */
|
||||
countryCodes: string[]
|
||||
}
|
||||
|
||||
export interface AppearancePatentSupervisorPageResult {
|
||||
items: AppearancePatentSupervisorCard[]
|
||||
/** 主管数(不是明细条数)。 */
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export function emptyAppearancePatentCleanPage(): AppearancePatentCleanPageResult {
|
||||
return { items: [], total: 0, page: 1, pageSize: APPEARANCE_PATENT_CLEAN_DEFAULT_SIZE }
|
||||
}
|
||||
|
||||
/** 解析主管卡片;缺 supervisorId 的(未知主管组)依然保留(那一卡展示 -),不算无效行。 */
|
||||
export function toAppearancePatentSupervisorCard(raw: unknown): AppearancePatentSupervisorCard | null {
|
||||
if (!raw || typeof raw !== 'object') return null
|
||||
const record = raw as Record<string, unknown>
|
||||
const itemCount = numberOrNull(record.itemCount ?? record.item_count)
|
||||
if (itemCount === null) return null
|
||||
const rawCodes = record.countryCodes ?? record.country_codes
|
||||
const countryCodes = Array.isArray(rawCodes)
|
||||
? rawCodes.map((code) => text(code)).filter((code) => code.length > 0)
|
||||
: []
|
||||
return {
|
||||
supervisorId: numberOrNull(record.supervisorId ?? record.supervisor_id),
|
||||
supervisorName: text(record.supervisorName ?? record.supervisor_name),
|
||||
itemCount,
|
||||
taskCount: numberOrNull(record.taskCount ?? record.task_count) ?? 0,
|
||||
lastTaskId: numberOrNull(record.lastTaskId ?? record.last_task_id),
|
||||
lastSyncedAt: text(record.lastSyncedAt ?? record.last_synced_at) || undefined,
|
||||
countryCodes,
|
||||
}
|
||||
}
|
||||
|
||||
/** 解析主管卡片分页信封({items,total,page,pageSize});total 是主管数。 */
|
||||
export function parseAppearancePatentSupervisorPage(payload: unknown): AppearancePatentSupervisorPageResult {
|
||||
const out: AppearancePatentSupervisorPageResult = {
|
||||
items: [],
|
||||
total: 0,
|
||||
page: 1,
|
||||
pageSize: APPEARANCE_PATENT_CLEAN_DEFAULT_SIZE,
|
||||
}
|
||||
const core = unwrap<unknown>(payload)
|
||||
if (!core || typeof core !== 'object') return out
|
||||
const record = core as Record<string, unknown>
|
||||
if (Array.isArray(record.items)) {
|
||||
out.items = record.items
|
||||
.map((raw) => toAppearancePatentSupervisorCard(raw))
|
||||
.filter((item): item is AppearancePatentSupervisorCard => item !== null)
|
||||
}
|
||||
if (typeof record.total === 'number') out.total = Math.floor(record.total)
|
||||
if (typeof record.page === 'number' && record.page >= 1) out.page = Math.floor(record.page)
|
||||
const rawSize = record.pageSize ?? record.page_size
|
||||
if (typeof rawSize === 'number' && rawSize >= 1) out.pageSize = Math.floor(rawSize)
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
function text(value: unknown): string {
|
||||
return typeof value === 'string' ? value.trim() : ''
|
||||
}
|
||||
|
||||
@@ -130,6 +130,8 @@ const SEND_POINTS: ReadonlyArray<SendPoint> = [
|
||||
// 500 够得着自己、够不到隔壁(对平用例逐处从真文件重算,注释过期即红)。
|
||||
{ menuKey: 'admin_appearance_patent_clean_items', file: 'src/pages/patent/appearance-patent-clean-api.ts', fn: 'fetchAppearancePatentCleanList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 500, title: 'GET /appearance-patent-clean-items 无侵权只读列表' },
|
||||
{ menuKey: 'admin_appearance_patent_clean_items', file: 'src/pages/patent/appearance-patent-clean-api.ts', fn: 'exportAppearancePatentCleanList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 500, title: 'GET /appearance-patent-clean-items/export 导出(2026-11-11 客户需求「数据得导出来」,与列表共用同一过滤面)' },
|
||||
// 2026-11-11 二次改版(一主管一卡):/supervisors 主管聚合卡片的取数口,与列表/导出同一过滤面与正门。
|
||||
{ menuKey: 'admin_appearance_patent_clean_items', file: 'src/pages/patent/appearance-patent-clean-api.ts', fn: 'fetchAppearancePatentCleanSupervisors', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 500, title: 'GET /appearance-patent-clean-items/supervisors 主管聚合卡片(客户「我们这边就是按主管划分」)' },
|
||||
]
|
||||
|
||||
/** 任务看板那 5 处(1b ④ 那条用例按文件筛它们,沿用旧名字不漂;表只有一份,不会漂出两个口径)。 */
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
/**
|
||||
* 外观专利无侵权数据页(v1.3 AC-5)的挂载契约 —— Phase 3 激活。
|
||||
* 外观专利无侵权数据页(v1.3 AC-5)的挂载契约。
|
||||
*
|
||||
* 展示形式(2026-11-11 客户改版,推翻 2026-11-10「参照去重库页自绘 table、不做卡片宫格」的
|
||||
* 旧拍板):参照「店铺数据记录」页(ShopDataTasksPage)——form-box 筛选条件 + panel-box
|
||||
* 工具条[导出] + 卡片宫格 + `OldPagination.vue` 服务端分页。同日三改(客户「要按主管分组
|
||||
* 显示」「价格 asin 无侵权 这些都不需要展示的」「到时候能下载表格看就行」):卡片按所属主管
|
||||
* 连续分组(组头=主管名+本页条数,保持行序、不跨页聚合、不按名重排),每卡一条明细:标题
|
||||
* (卡头)/任务号/国家/品牌/SKU/同步时间;价格、ASIN、结论徽章(无侵权)、所属主管行不再
|
||||
* 上卡——全量明细(含价格/ASIN/结论/主管列)仍走 /export xlsx。筛选面同日二次精简(客户「按账号对应的
|
||||
* 主管吧 不需要店铺」):分组(=主管)/国家/起止时间三样,任务号/ASIN 输入框下架(后端
|
||||
* §3.2 参数契约与过滤模块逐字对撞护栏保留,UI 不再暴露)。取数/导出/公司 tab 契约不变:
|
||||
* `companyScoped: true` 公司 Tab;`page`/`page_size` snake 参数,响应
|
||||
* `{items, total, page, pageSize}`。默认仅 super_admin 可见(菜单不预授权,
|
||||
* 判据在后端 AdminAppearancePatentCleanItemsControllerTest 的菜单迁移支,这里只管前端接线)。
|
||||
* 形态(2026-11-11 客户三连拍板:「要按主管分组显示」→「应该是只显示一个卡片的才对」→
|
||||
* 「获取店铺那边是按店铺做成卡片 我们这边就是按主管划分」):<b>一主管一卡</b>,对齐
|
||||
* 「店铺数据记录」页的一店一卡——卡头=主管名,卡内 条数 / 任务(几个任务·最近任务号)/
|
||||
* 国家 / 最新同步时间 + [下载](导出该主管名下 xlsx)。明细分页卡片(每明细一卡)已下架:
|
||||
* 3488 条明细铺成几千张卡是客户明确不要的形态;明细仍走 /export 表格看。
|
||||
* 数据来自 GET /supervisors(后端按归属表达式聚合,total 是主管数)。筛选面不变
|
||||
* (分组=主管/国家/同步起止,分组选中即查),取数/导出/公司 tab 契约照旧。
|
||||
*
|
||||
* 跑法:`npx vitest run tests/mount/appearance-patent-clean-page.test.ts`
|
||||
*/
|
||||
@@ -32,36 +27,22 @@ const PAGE_PATH = 'src/pages/patent/AppearancePatentCleanItemsPage.vue'
|
||||
const MENU_KEY = 'admin_appearance_patent_clean_items'
|
||||
|
||||
const cleanApi = vi.hoisted(() => ({
|
||||
fetchAppearancePatentCleanList: vi.fn(),
|
||||
fetchAppearancePatentCleanSupervisors: vi.fn(),
|
||||
exportAppearancePatentCleanList: vi.fn(),
|
||||
fetchDedupeTotalGroups: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/pages/patent/appearance-patent-clean-api.ts', () => cleanApi)
|
||||
|
||||
function row(id: number, over: Record<string, unknown> = {}) {
|
||||
function card(supervisorId: number | null, over: Record<string, unknown> = {}) {
|
||||
return {
|
||||
id,
|
||||
resultId: 900 + id,
|
||||
taskId: 33179,
|
||||
userId: 7,
|
||||
supervisorName: `主管${id}`,
|
||||
companyId: 1,
|
||||
rowNo: id,
|
||||
asin: `B0AB8CDEF${id}`,
|
||||
country: 'DE',
|
||||
sku: `SKU-${id}`,
|
||||
brand: 'Anker',
|
||||
price: '29.99',
|
||||
title: `无侵权商品 ${id}`,
|
||||
imageUrl: '',
|
||||
itemUrl: '',
|
||||
conclusion: '无侵权',
|
||||
titleReason: '',
|
||||
appearanceReason: '',
|
||||
patentReason: '',
|
||||
sourceFilename: 'list.xlsx',
|
||||
syncedAt: '2026-11-10T10:30:00',
|
||||
supervisorId,
|
||||
supervisorName: supervisorId == null ? '' : `主管${supervisorId}`,
|
||||
itemCount: 120,
|
||||
taskCount: 3,
|
||||
lastTaskId: 33874,
|
||||
lastSyncedAt: '2026-11-11T11:34:29',
|
||||
countryCodes: ['DE', 'UK'],
|
||||
...over,
|
||||
}
|
||||
}
|
||||
@@ -74,28 +55,26 @@ beforeEach(() => {
|
||||
setActivePinia(pinia)
|
||||
useAdminSessionStore().user = { id: 1, username: 'root', role: 'super_admin' }
|
||||
useCompanyTabStore().setActiveId(1)
|
||||
// 分组(主管)选项默认空集:分组用例各自覆写
|
||||
cleanApi.fetchDedupeTotalGroups.mockResolvedValue([])
|
||||
})
|
||||
|
||||
async function mountWith(payload: unknown): Promise<VueWrapper<Element>> {
|
||||
cleanApi.fetchAppearancePatentCleanList.mockImplementation(() => Promise.resolve(payload))
|
||||
cleanApi.fetchAppearancePatentCleanSupervisors.mockImplementation(() => Promise.resolve(payload))
|
||||
const wrapper = mount(AppearancePatentCleanItemsPage, { global: { plugins: [pinia] } })
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
}
|
||||
|
||||
describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版参照店铺数据记录页)', () => {
|
||||
it('页面组件落位且是店铺数据记录式卡片宫格 + OldPagination 的分页列表', () => {
|
||||
// vitest 的 cwd = admin-frontend-vue 根(Phase 0 预置用 new URL 模板串,被 vite 静态分析成
|
||||
// undefined——skip 期间从未执行所以没暴露,激活时改走 cwd 解析)。
|
||||
describe('外观专利数据库页(一主管一卡,2026-11-11 客户「我们这边就是按主管划分」)', () => {
|
||||
it('页面组件落位:卡片宫格 + 主管聚合端点,不再按明细铺卡', () => {
|
||||
const src = readFileSync(resolve(process.cwd(), PAGE_PATH), 'utf-8')
|
||||
expect(src).toContain('OldPagination')
|
||||
expect(src).toContain('clean-card-grid', '卡片宫格容器必须就位(2026-11-11 客户改版)')
|
||||
expect(src).toContain('clean-card-grid', '卡片宫格容器必须就位')
|
||||
expect(src).toContain('clean-card-head', '卡片本体结构必须就位')
|
||||
expect(src).toContain('clean-group-head', '主管分组头必须就位(2026-11-11 三改「按主管分组显示」)')
|
||||
expect(src).not.toContain('<table', '改版后不再有自绘行列表(推翻 2026-11-10 旧拍板)')
|
||||
expect(src).toContain('fetchAppearancePatentCleanSupervisors', '必须走主管聚合端点(一主管一卡)')
|
||||
expect(src).toContain('supervisorUserId', '单卡下载按主管收窄导出')
|
||||
expect(src).not.toContain('<table', '本页不是自绘行列表')
|
||||
expect(src).not.toContain('el-card')
|
||||
})
|
||||
|
||||
@@ -110,65 +89,81 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
expect(scoped?.pageFiles).toContain(PAGE_PATH)
|
||||
})
|
||||
|
||||
it('挂载后按首屏 snake 分页参数取数并解包 {items,total,page,pageSize}', async () => {
|
||||
const wrapper = await mountWith({ items: [row(1), row(2)], total: 42, page: 1, pageSize: 10 })
|
||||
it('挂载后按首屏分页参数取主管聚合,卡片数=主管数而不是明细条数', async () => {
|
||||
const wrapper = await mountWith({
|
||||
items: [card(9), card(44), card(null, { supervisorName: '' })],
|
||||
total: 3,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
expect(cleanApi.fetchAppearancePatentCleanList).toHaveBeenCalledTimes(1)
|
||||
const firstCall = cleanApi.fetchAppearancePatentCleanList.mock.calls[0][0]
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors).toHaveBeenCalledTimes(1)
|
||||
const firstCall = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls[0][0]
|
||||
expect(firstCall.page).toBe(1)
|
||||
expect(firstCall.pageSize).toBe(10)
|
||||
expect(firstCall.companyId).toBe(1)
|
||||
expect(wrapper.findAll('.clean-card')).toHaveLength(2, '一卡一条明细')
|
||||
expect(wrapper.text()).toContain('共 42 条')
|
||||
// 2026-11-11 三改:ASIN/价格/结论徽章不再上卡(全量明细走导出),卡头换成标题
|
||||
expect(wrapper.text()).not.toContain('B0AB8CDEF1')
|
||||
expect(wrapper.text()).not.toContain('29.99')
|
||||
expect(wrapper.find('.st-pill').exists()).toBe(false, '无侵权结论徽章不再上卡')
|
||||
const heads = wrapper.findAll('.clean-card-head')
|
||||
expect(heads).toHaveLength(2)
|
||||
expect(heads[0].text()).toContain('无侵权商品 1', '卡头=标题(替下原 ASIN 卡头)')
|
||||
expect(wrapper.findAll('.clean-card')).toHaveLength(3, '一主管一卡')
|
||||
expect(wrapper.text()).toContain('共 3 位主管', '汇总按主管计数(不是明细条数)')
|
||||
})
|
||||
|
||||
it('按所属主管分组显示(2026-11-11 三改):组头=主管名+本页条数,卡片不再重复主管行', async () => {
|
||||
const wrapper = await mountWith({
|
||||
items: [row(1, { supervisorName: '主管甲' }), row(2, { supervisorName: '主管甲' }), row(3, { supervisorName: '主管乙' })],
|
||||
total: 3,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
const heads = wrapper.findAll('.clean-group-head')
|
||||
expect(heads).toHaveLength(2, '连续同主管的行切段成组')
|
||||
expect(heads[0].text()).toContain('主管甲')
|
||||
expect(heads[0].text()).toContain('本页 2 条')
|
||||
expect(heads[1].text()).toContain('主管乙')
|
||||
expect(heads[1].text()).toContain('本页 1 条')
|
||||
expect(wrapper.findAll('.clean-card')).toHaveLength(3, '组头不占卡片位,三张明细卡都在')
|
||||
// 主管行已由组头表达,卡片不再重复;价格行同批下卡
|
||||
expect(wrapper.text()).not.toContain('所属主管')
|
||||
expect(wrapper.text()).not.toContain('价格')
|
||||
it('卡片内容=主管名/条数/任务/国家/最新(对齐店铺数据记录的一卡一主体信息面)', async () => {
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
const one = wrapper.find('.clean-card')
|
||||
expect(one.find('.clean-card-supervisor').text()).toBe('主管9', '卡头=主管名')
|
||||
const rowValue = (label: string): string => {
|
||||
const row = one.findAll('.clean-card-row').find((r) => r.find('.clean-card-label').text() === label)
|
||||
expect(row, `卡片必须有「${label}」行`).toBeTruthy()
|
||||
return row!.find('.clean-card-value').text()
|
||||
}
|
||||
expect(rowValue('条数')).toContain('120 条', '明细条数是汇总不是列表')
|
||||
expect(rowValue('任务')).toContain('3 个任务')
|
||||
expect(rowValue('任务')).toContain('33874', '带最近任务号')
|
||||
expect(rowValue('国家')).toContain('德国')
|
||||
expect(rowValue('国家')).toContain('英国')
|
||||
expect(rowValue('最新')).not.toBe('')
|
||||
})
|
||||
|
||||
it('分组只在当前页窗口内连续切段:保持服务端行序、不跨页聚合、不按名重排', async () => {
|
||||
const wrapper = await mountWith({
|
||||
items: [row(1, { supervisorName: '主管甲' }), row(2, { supervisorName: '主管乙' }), row(3, { supervisorName: '主管甲' })],
|
||||
total: 3,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
const names = wrapper.findAll('.clean-group-name').map((n) => n.text())
|
||||
expect(names).toEqual(['主管甲', '主管乙', '主管甲'], '同名主管被隔开时按行序出多个同名组头,忠实反映同步顺序')
|
||||
expect(wrapper.findAll('.clean-card')).toHaveLength(3)
|
||||
it('读不到主管的那一卡展示 -,且不给下载按钮(不猜是哪位主管)', async () => {
|
||||
const wrapper = await mountWith({ items: [card(null)], total: 1, page: 1, pageSize: 10 })
|
||||
const one = wrapper.find('.clean-card')
|
||||
expect(one.find('.clean-card-supervisor').text()).toBe('-', '读不到主管不猜名字')
|
||||
const downloadBtn = one.findAll('button').find((b) => b.text() === '下载')
|
||||
expect(downloadBtn).toBeTruthy()
|
||||
expect((downloadBtn!.element as HTMLButtonElement).disabled).toBe(true, '无主管 id 不可按主管导出')
|
||||
})
|
||||
|
||||
it('读不到主管名的行不猜:组头展示 -(与旧卡片行同口径)', async () => {
|
||||
const wrapper = await mountWith({ items: [row(9, { supervisorName: '' })], total: 1, page: 1, pageSize: 10 })
|
||||
const heads = wrapper.findAll('.clean-group-head')
|
||||
expect(heads).toHaveLength(1)
|
||||
expect(heads[0].text()).toContain('-', '读不到主管展示 -')
|
||||
expect(heads[0].text()).toContain('本页 1 条')
|
||||
it('单卡下载=按该主管导出(带 supervisorUserId 与当前过滤面)', async () => {
|
||||
const createObjectURL = vi.fn(() => 'blob:mock-url')
|
||||
const revokeObjectURL = vi.fn()
|
||||
const urlRecord = URL as unknown as Record<string, unknown>
|
||||
Object.defineProperty(URL, 'createObjectURL', { value: createObjectURL, configurable: true, writable: true })
|
||||
Object.defineProperty(URL, 'revokeObjectURL', { value: revokeObjectURL, configurable: true, writable: true })
|
||||
const clickSpy = vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(() => {})
|
||||
cleanApi.exportAppearancePatentCleanList.mockImplementation(() =>
|
||||
Promise.resolve({ blob: new Blob(['xlsx']), filename: '外观专利数据库-20261111120000.xlsx' }),
|
||||
)
|
||||
|
||||
try {
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
const btn = wrapper.find('.clean-card').findAll('button').find((b) => b.text() === '下载')
|
||||
await btn!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
expect(cleanApi.exportAppearancePatentCleanList).toHaveBeenCalledTimes(1)
|
||||
const call = cleanApi.exportAppearancePatentCleanList.mock.calls[0][0]
|
||||
expect(call).toMatchObject({ supervisorUserId: 9, companyId: 1, country: '', groupId: '' })
|
||||
expect(createObjectURL).toHaveBeenCalledTimes(1)
|
||||
expect(clickSpy).toHaveBeenCalled()
|
||||
expect(document.body.textContent).toContain('已导出', '成功反馈点名落盘文件')
|
||||
} finally {
|
||||
Object.defineProperty(URL, 'createObjectURL', { value: undefined, configurable: true, writable: true })
|
||||
Object.defineProperty(URL, 'revokeObjectURL', { value: undefined, configurable: true, writable: true })
|
||||
clickSpy.mockRestore()
|
||||
}
|
||||
})
|
||||
|
||||
it('导出按钮带当前过滤面与公司 tab 调导出接口,成功触发 blob 落盘', async () => {
|
||||
it('顶部导出带当前过滤面与公司 tab,不带 supervisorUserId(全量)', async () => {
|
||||
const createObjectURL = vi.fn(() => 'blob:mock-url')
|
||||
const revokeObjectURL = vi.fn()
|
||||
const urlRecord = URL as unknown as Record<string, unknown>
|
||||
@@ -178,18 +173,15 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
Object.defineProperty(URL, 'revokeObjectURL', { value: revokeObjectURL, configurable: true, writable: true })
|
||||
const clickSpy = vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(() => {})
|
||||
cleanApi.exportAppearancePatentCleanList.mockImplementation(() =>
|
||||
Promise.resolve({ blob: new Blob(['xlsx'], { type: 'application/vnd.ms-excel' }), filename: '外观专利数据库-20261111103000.xlsx' }),
|
||||
Promise.resolve({ blob: new Blob(['xlsx']), filename: '外观专利数据库-20261111120000.xlsx' }),
|
||||
)
|
||||
|
||||
try {
|
||||
const wrapper = await mountWith({ items: [row(1)], total: 1, page: 1, pageSize: 10 })
|
||||
const exportBtn = wrapper.findAll('button').find((b) => b.text() === '导出')
|
||||
expect(exportBtn).toBeTruthy()
|
||||
await exportBtn!.trigger('click')
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
await wrapper.findAll('button').find((b) => b.text() === '导出')!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
expect(cleanApi.exportAppearancePatentCleanList).toHaveBeenCalledTimes(1)
|
||||
const call = cleanApi.exportAppearancePatentCleanList.mock.calls[0][0]
|
||||
expect(call).toMatchObject({
|
||||
taskId: '',
|
||||
@@ -200,10 +192,9 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
endDate: '',
|
||||
companyId: 1,
|
||||
})
|
||||
expect(call.supervisorUserId).toBeUndefined()
|
||||
expect(createObjectURL).toHaveBeenCalledTimes(1)
|
||||
expect(revokeObjectURL).toHaveBeenCalledWith('blob:mock-url')
|
||||
expect(clickSpy).toHaveBeenCalled()
|
||||
expect(document.body.textContent).toContain('已导出', '成功反馈点名落盘文件')
|
||||
} finally {
|
||||
Object.defineProperty(URL, 'createObjectURL', { value: origCreate, configurable: true })
|
||||
Object.defineProperty(URL, 'revokeObjectURL', { value: origRevoke, configurable: true })
|
||||
@@ -213,42 +204,40 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
|
||||
it('导出失败把服务端业务文案弹出来,不许静默', async () => {
|
||||
cleanApi.exportAppearancePatentCleanList.mockImplementation(() =>
|
||||
Promise.reject(new Error('无侵权数据共 90001 行,超过导出上限 50000 行,请缩小筛选范围后重试')))
|
||||
Promise.reject(new Error('该主管的无侵权数据共 90001 行,超过导出上限 50000 行,请缩小筛选范围后重试')))
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
|
||||
await wrapper.findAll('button').find((b) => b.text() === '导出')!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('超过导出上限', '失败反馈必须是服务端那句可读文案')
|
||||
// 失败后导出锁复位,按钮可再次点击
|
||||
expect(document.body.textContent).toContain('超过导出上限')
|
||||
expect(wrapper.findAll('button').find((b) => b.text() === '导出')!.text()).toBe('导出')
|
||||
})
|
||||
|
||||
it('翻页与改每页条数都重发请求,改条数回第一页', async () => {
|
||||
const wrapper = await mountWith({ items: [row(11)], total: 42, page: 2, pageSize: 10 })
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 42, page: 2, pageSize: 10 })
|
||||
|
||||
await wrapper.findAll('button').find((b) => b.text() === '下一页')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(cleanApi.fetchAppearancePatentCleanList).toHaveBeenCalledTimes(2)
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls[1][0].page).toBe(3)
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors).toHaveBeenCalledTimes(2)
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls[1][0].page).toBe(3)
|
||||
|
||||
const sizeSelect = wrapper.find('.page-size-select')
|
||||
await sizeSelect.setValue('50')
|
||||
await flushPromises()
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
const last = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.at(-1)![0]
|
||||
expect(last.pageSize).toBe(50)
|
||||
expect(last.page).toBe(1, '改每页条数后回第一页')
|
||||
})
|
||||
|
||||
it('分组/国家/起止时间筛选生效(任务号/ASIN 输入框已下架,2026-11-11 客户拍板)', async () => {
|
||||
it('分组/国家/起止时间筛选生效(任务号/ASIN 输入框已下架)', async () => {
|
||||
cleanApi.fetchDedupeTotalGroups.mockResolvedValue([{ id: 7, name: '甲组', leaderUserId: 9 }])
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
|
||||
|
||||
// 筛选面只剩分组/国家/时间,页面上不再有任务号/ASIN 文本框(OldPagination 跳页框除外)
|
||||
const filterTextInputs = wrapper.findAll('.form-row input[type="text"]')
|
||||
expect(filterTextInputs).toHaveLength(0)
|
||||
|
||||
const selects = wrapper.findAll('select')
|
||||
await selects[0].setValue('7') // 分组(主管=组长)排在国家前,对齐获取店铺页字段顺序
|
||||
await selects[0].setValue('7') // 分组(主管=组长)排在国家前
|
||||
await selects[1].setValue('DE')
|
||||
const dateInputs = wrapper.findAll('input[type="date"]')
|
||||
await dateInputs[0].setValue('2026-11-01')
|
||||
@@ -256,10 +245,8 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
await wrapper.findAll('button').find((b) => b.text() === '查询')!.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
const last = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.at(-1)![0]
|
||||
expect(last).toMatchObject({
|
||||
taskId: '',
|
||||
asin: '',
|
||||
country: 'DE',
|
||||
groupId: '7',
|
||||
startDate: '2026-11-01',
|
||||
@@ -268,37 +255,28 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
})
|
||||
})
|
||||
|
||||
it('分组下拉(主管=组长):选项与去重页同源,选中即查(不必点查询)', async () => {
|
||||
it('分组下拉(主管=组长)选中即查', async () => {
|
||||
cleanApi.fetchDedupeTotalGroups.mockResolvedValue([
|
||||
{ id: 7, name: '甲组', leaderUserId: 9 },
|
||||
{ id: 8, name: '乙组', leaderUserId: 10 },
|
||||
])
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
|
||||
|
||||
// 选项取数走的是公司隔离的同一分组集(GET /shop-manages/groups 的适配层)
|
||||
expect(cleanApi.fetchDedupeTotalGroups).toHaveBeenCalledWith(1)
|
||||
|
||||
const groupSelect = wrapper.findAll('select')[0]
|
||||
const optionTexts = groupSelect.findAll('option').map((o) => o.text())
|
||||
expect(optionTexts).toContain('全部分组')
|
||||
expect(optionTexts).toContain('甲组')
|
||||
expect(optionTexts).toContain('乙组')
|
||||
|
||||
// 2026-11-11 四改「选中即查」:选完主管立刻重发请求(回第一页),不等查询按钮
|
||||
const callsBeforeSelect = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
|
||||
const callsBeforeSelect = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.length
|
||||
await groupSelect.setValue('7')
|
||||
await flushPromises()
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.length).toBe(callsBeforeSelect + 1, '选中分组必须立刻重查')
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]).toMatchObject({
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.length).toBe(callsBeforeSelect + 1,
|
||||
'选中分组必须立刻重查')
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.at(-1)![0]).toMatchObject({
|
||||
groupId: '7',
|
||||
page: 1,
|
||||
}, '选中的分组 id 以 groupId 进列表过滤面(服务端解析组长+名下整集),且回第一页')
|
||||
|
||||
// 显式点查询仍然生效(同一过滤面再发一次)
|
||||
await wrapper.findAll('button').find((b) => b.text() === '查询')!.trigger('click')
|
||||
await flushPromises()
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
expect(last.groupId).toBe('7', '查询按钮走同一过滤面(分组选中即查不改变查询按钮语义)')
|
||||
})
|
||||
})
|
||||
|
||||
it('空态与加载失败条(失败给重试,不把整页打死)', async () => {
|
||||
@@ -308,7 +286,7 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
expect(tip.text()).toContain('暂无无侵权数据')
|
||||
empty.unmount()
|
||||
|
||||
cleanApi.fetchAppearancePatentCleanList.mockRejectedValue(new Error('上游 502'))
|
||||
cleanApi.fetchAppearancePatentCleanSupervisors.mockRejectedValue(new Error('上游 502'))
|
||||
const failed = mount(AppearancePatentCleanItemsPage, { global: { plugins: [pinia] } })
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
@@ -318,23 +296,20 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
|
||||
it('切公司 Tab 重取并清掉上一家的筛选(company-tab-wiring 同口径)', async () => {
|
||||
cleanApi.fetchDedupeTotalGroups.mockResolvedValue([{ id: 7, name: '甲组', leaderUserId: 9 }])
|
||||
const wrapper = await mountWith({ items: [row(1)], total: 1, page: 1, pageSize: 10 })
|
||||
// 选上上一家公司的分组:切走后必须连同 groupId 一起清(分组的成员集是公司隔离的)
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
const groupSelect = wrapper.findAll('select')[0]
|
||||
await groupSelect.setValue('7')
|
||||
const callsAfterMount = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
|
||||
const callsBefore = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.length
|
||||
|
||||
useCompanyTabStore().setActiveId(2)
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.length).toBeGreaterThan(callsAfterMount)
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.length).toBeGreaterThan(callsBefore)
|
||||
const last = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.at(-1)![0]
|
||||
expect(last.companyId).toBe(2)
|
||||
expect(last.groupId).toBe('', '切公司必须清掉上一家选的分组')
|
||||
expect(last.taskId).toBe('', 'watch token 仍整把清栏(taskId/asin 字段留在契约里,UI 不再暴露)')
|
||||
expect(last.page).toBe(1)
|
||||
// 分组选项按新公司重取(选项集公司隔离)
|
||||
expect(cleanApi.fetchDedupeTotalGroups).toHaveBeenLastCalledWith(2)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user