feat(appearance-patent): 后管页恢复明细表+管理员列+导出,撤一主管一卡与删除入口(2026-11-11 客户「不是这种格式 你就按照昨天那个格式」)
This commit is contained in:
@@ -1,33 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
||||
/** 外观专利数据库 · 按主管划分的卡片列表(v1.3 后续,2026-11-11 客户三连拍板:
|
||||
* 「要按主管分组显示」→「应该是只显示一个卡片的才对」→「获取店铺那边是按店铺做成卡片
|
||||
* 我们这边就是按主管划分」)。
|
||||
*
|
||||
* 形态:一主管一卡(对齐「店铺数据记录」页的一店一卡),卡内是该主管名下的汇总——
|
||||
* 条数 / 任务(几个任务、最近任务号)/ 国家 / 最新同步时间 + [下载](导出该主管名下全量 xlsx)
|
||||
* + [删除](删该主管名下明细,2026-11-11 客户「也要加个删除按钮」)。
|
||||
* 明细分页卡片(每明细一卡)已下架:3488 条明细会铺成几千张卡,客户明确不要。
|
||||
* 数据来自 GET /supervisors(后端按「主管本人取自己、普通账户取创建人」的归属表达式聚合,
|
||||
* total 是主管数),与明细导出走同一过滤面(分组/国家/同步起止 + 公司 tab)。
|
||||
* 页签零出表:明细本身仍走 xlsx 看(客户「到时候能下载表格看就行」);
|
||||
* 顶部不再给「全量导出」——每张卡自带下载与删除,客户口径「这个可以不要 有下载就行了」。
|
||||
* 分组(主管)下拉选中即查(同日四改):客户选了主管就该只看到这一位/这一组的主管卡片。 */
|
||||
/** 外观专利数据库 · 明细分页表(2026-11-11 晚间按客户口径恢复「昨天那个格式」:
|
||||
* 「不是这种格式 你就按照昨天那个格式」——撤掉一主管一卡视图,恢复只读明细表;
|
||||
* 「添加个管理员 跟导出数据就可以」——表上加「管理员」列(后端读侧现算:主管/公司超管=自己,
|
||||
* 普通账户=创建人,读不到为空展示 -,不猜名),筛选行加「导出」(与「去重数据库」页同款:
|
||||
* 当前过滤面+公司 tab 全量出 xlsx,不传 supervisor_user_id——传了会走按主管分支并忽略任务号/ASIN);
|
||||
* 「任务号/ASIN 两个筛选框恢复」(后端能力一直在,之前产品决定下过架,客户要「一目了然」选数据);
|
||||
* 分组(主管)下拉保留「选中即查」。数据按 ASIN 累计:同 ASIN 只保留一条(V192 唯一键,
|
||||
* 重复检测更新那条),不同 ASIN 同品牌全保留——页面只管展示,累计语义在后端同步链。
|
||||
* 主管卡片视图与卡片级删除按钮从页面下架(客户下午反馈数据疑似被误删,删除入口先撤;
|
||||
* 后端 /supervisors 两接口保留不动)。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import {
|
||||
deleteAppearancePatentCleanSupervisor,
|
||||
exportAppearancePatentCleanList,
|
||||
fetchAppearancePatentCleanSupervisors,
|
||||
fetchAppearancePatentCleanList,
|
||||
fetchDedupeTotalGroups,
|
||||
type DedupeGroupOption,
|
||||
} from './appearance-patent-clean-api.ts'
|
||||
import type { AppearancePatentSupervisorCard } from './appearance-patent-clean-model.ts'
|
||||
import type { AppearancePatentCleanItem } from './appearance-patent-clean-model.ts'
|
||||
import { cleanItemReasonTooltip } 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'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
@@ -35,15 +31,12 @@ const companyTab = useCompanyTabStore()
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const cards = ref<AppearancePatentSupervisorCard[]>([])
|
||||
/** 主管数(不是明细条数)。 */
|
||||
const rows = ref<AppearancePatentCleanItem[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
/** 单卡下载在途标记(存 supervisorId,避免连点同一张卡)。 */
|
||||
const downloadingId = ref<number | null>(null)
|
||||
/** 单卡删除在途标记(存 supervisorId;删除是破坏性动作,确认后才置位)。 */
|
||||
const deletingId = ref<number | null>(null)
|
||||
/** 导出在途锁:避免连点导出把同一份过滤面重复请求两遍。 */
|
||||
const exporting = ref(false)
|
||||
/** 同步台账是累计数据,日期初值故意留空(默认当天会让首屏只剩今天同步的行);见 date-filter-default-today 护栏的 EXEMPT。 */
|
||||
const filter = reactive(createAppearancePatentCleanFilterState())
|
||||
/** 分组(主管)下拉选项:公司 tab 切换时重取;选项失败不拦列表,只回空下拉(可见「全部分组」)。 */
|
||||
@@ -58,7 +51,7 @@ function clampDatePair(): void {
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
|
||||
/** 分组选项与去重页/店铺管理同源(GET /shop-manages/groups);失败静默回空——分组只是筛选项,
|
||||
* 不该让它把首屏卡片一起拖死(列表失败有自己的 LoadFailureBar)。 */
|
||||
* 不该让它把首屏行集一起拖死(列表失败有自己的 LoadFailureBar)。 */
|
||||
async function loadGroupOptions(): Promise<void> {
|
||||
try {
|
||||
groupOptions.value = await fetchDedupeTotalGroups(companyTab.requestCompanyId)
|
||||
@@ -71,16 +64,18 @@ async function load(): Promise<void> {
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchAppearancePatentCleanSupervisors({
|
||||
const result = await fetchAppearancePatentCleanList({
|
||||
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,
|
||||
})
|
||||
cards.value = result.items
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
if (result.page >= 1) page.value = result.page
|
||||
} catch (error) {
|
||||
@@ -91,75 +86,38 @@ async function load(): 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
|
||||
/** 导出与页签同一过滤面(含公司 tab 与分组),服务端全量出 xlsx;成功后浏览器落盘,失败弹可读文案。
|
||||
* 不传 supervisor_user_id:按主管分支会忽略任务号/ASIN 参数,「按当前筛选导出」必须走明细分支。 */
|
||||
async function exportAll(): Promise<void> {
|
||||
if (exporting.value) return
|
||||
exporting.value = true
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/** 单卡删除:删该主管名下明细(谓词与「下载」同一过滤面+同一归属表达式)。
|
||||
* 破坏性动作:先弹确认(点名主管与条数、写明不可恢复),确认后真删,再按剩余卡片回退页码——
|
||||
* 删掉本页最后一张卡时不能停在空页上。读不到主管的那组没有 id,不给按钮。 */
|
||||
async function removeSupervisor(card: AppearancePatentSupervisorCard): Promise<void> {
|
||||
if (card.supervisorId == null || deletingId.value !== null) return
|
||||
const label = card.supervisorName || '该主管'
|
||||
// 危险确认:danger 形态与调用写在同一行(confirm-exit-ledger 的判据就锚这一行,
|
||||
// 拆行会让「删除/清空必须 danger」那条守卫认不出)。
|
||||
const confirmText = `确认删除「${label}」名下的 ${card.itemCount} 条外观专利数据库记录?此操作不可恢复(任务记录与结果文件不受影响)。`
|
||||
const confirmed = await openAdminConfirm({ message: confirmText, danger: true })
|
||||
if (!confirmed) return
|
||||
deletingId.value = card.supervisorId
|
||||
try {
|
||||
const deleted = await deleteAppearancePatentCleanSupervisor({
|
||||
supervisorUserId: card.supervisorId,
|
||||
taskId: filter.taskId,
|
||||
asin: filter.asin,
|
||||
country: filter.country,
|
||||
groupId: filter.groupId,
|
||||
startDate: filter.startDate,
|
||||
endDate: filter.endDate,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
showAdminFeedback(`已删除「${label}」的 ${deleted} 条记录`, 'success')
|
||||
if (cards.value.length === 1 && page.value > 1) page.value -= 1
|
||||
await load()
|
||||
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)
|
||||
showAdminFeedback(`已导出 ${result.filename}`, 'success')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error && error.message ? error.message : `删除「${label}」的记录失败`
|
||||
const message = error instanceof Error && error.message ? error.message : '导出失败,请稍后重试'
|
||||
showAdminFeedback(message, 'error')
|
||||
} finally {
|
||||
deletingId.value = null
|
||||
exporting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -196,98 +154,95 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<div class="clean-items-view">
|
||||
<section class="form-box">
|
||||
<h3>外观专利数据库</h3>
|
||||
<h4 class="clean-filter-title">筛选条件</h4>
|
||||
<div class="form-row">
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<label>分组</label>
|
||||
<!-- 分组(主管)选中即查(2026-11-11 客户反馈「选了主管应该只显示这一个主管的才对」):
|
||||
选完立刻按该主管过滤刷新(回第一页),不必再点查询;国家/时间仍走查询按钮。 -->
|
||||
<select v-model="filter.groupId" @change="apply">
|
||||
<option value="">全部分组</option>
|
||||
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">{{ group.name }}</option>
|
||||
</select>
|
||||
<section class="panel-box">
|
||||
<div class="clean-panel-head">
|
||||
<h3>外观专利数据库</h3>
|
||||
</div>
|
||||
|
||||
<div class="clean-filter-row">
|
||||
<div class="form-group">
|
||||
<label>任务号</label>
|
||||
<input v-model="filter.taskId" type="text" placeholder="输入任务号" @keyup.enter="apply" />
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 130px">
|
||||
<div class="form-group">
|
||||
<label>ASIN</label>
|
||||
<input v-model="filter.asin" type="text" placeholder="输入 ASIN" @keyup.enter="apply" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in ASIN_COUNTRY_CODES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<!-- 分组(主管)选中即查:选完立刻按该主管过滤刷新(回第一页),不必再点查询。 -->
|
||||
<select v-model="filter.groupId" @change="apply">
|
||||
<option value="">全部分组</option>
|
||||
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">{{ group.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>同步开始日期</label>
|
||||
<input v-model="filter.startDate" type="date" :max="filter.endDate" @change="clampDatePair" />
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<div class="form-group">
|
||||
<label>同步结束日期</label>
|
||||
<input v-model="filter.endDate" type="date" :min="filter.startDate" @change="clampDatePair" />
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<button class="btn btn-secondary" type="button" @click="reset">重置</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel-box">
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="clean-toolbar">
|
||||
<div class="clean-toolbar-side">
|
||||
<span class="clean-summary">共 {{ total }} 位主管 · 本页 {{ cards.length }} 位</span>
|
||||
<div class="clean-filter-actions">
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<button class="btn btn-export" type="button" :disabled="exporting" @click="exportAll">
|
||||
{{ exporting ? '导出中...' : '导出' }}
|
||||
</button>
|
||||
<button class="btn btn-secondary" type="button" @click="reset">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clean-card-grid">
|
||||
<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>
|
||||
<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 || deletingId !== null"
|
||||
:title="card.supervisorId == null ? '读不到主管账号,无法按主管导出' : undefined"
|
||||
@click="downloadSupervisor(card)"
|
||||
>
|
||||
{{ downloadingId === card.supervisorId && card.supervisorId != null ? '下载中...' : '下载' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
type="button"
|
||||
:disabled="card.supervisorId == null || deletingId !== null || downloadingId !== null"
|
||||
:title="card.supervisorId == null ? '读不到主管账号,无法按主管删除' : undefined"
|
||||
@click="removeSupervisor(card)"
|
||||
>
|
||||
{{ deletingId === 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>
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="clean-toolbar">
|
||||
<span class="clean-summary">共 {{ total }} 条无侵权数据</span>
|
||||
</div>
|
||||
<div class="table-scroll clean-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 90px">任务号</th>
|
||||
<th style="width: 110px">管理员</th>
|
||||
<th>ASIN</th>
|
||||
<th style="width: 64px">国家</th>
|
||||
<th>SKU</th>
|
||||
<th>品牌</th>
|
||||
<th style="width: 90px">价格</th>
|
||||
<th>标题</th>
|
||||
<th style="width: 130px">结论</th>
|
||||
<th style="width: 150px">同步时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="rows.length">
|
||||
<tr v-for="row in rows" :key="row.id">
|
||||
<td>{{ row.taskId ?? '-' }}</td>
|
||||
<td :title="row.supervisorName || ''">{{ row.supervisorName || '-' }}</td>
|
||||
<td class="mono-cell">{{ row.asin || '-' }}</td>
|
||||
<td>{{ asinCountryLabel(row.country || '') }}</td>
|
||||
<td class="mono-cell">{{ row.sku || '-' }}</td>
|
||||
<td>{{ row.brand || '-' }}</td>
|
||||
<td>{{ row.price || '-' }}</td>
|
||||
<td class="title-cell" :title="row.title">{{ row.title || '-' }}</td>
|
||||
<td class="conclusion-cell" :title="cleanItemReasonTooltip(row)">{{ row.conclusion || '-' }}</td>
|
||||
<td>{{ formatDateTime(row.syncedAt || '') }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="10" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="10" class="empty-tip">暂无无侵权数据</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
||||
@@ -296,17 +251,15 @@ onMounted(() => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 形态参照「店铺数据记录」页(ShopDataTasksPage):form-box 筛选 + panel-box 工具条 +
|
||||
卡片宫格 + 旧式分页,蓝白末层。2026-11-11 客户三连拍板后本页是<b>一主管一卡</b>:
|
||||
卡头=主管名,卡内条数/任务/国家/最新 + [下载];明细不再铺卡(几千条明细=几千张卡)。 */
|
||||
/* 像素复刻参照「去重数据库」页(panel-box + 自绘表格 + 旧式分页),只读无操作列。
|
||||
2026-11-11 晚间恢复明细表形态(客户「按照昨天那个格式」),表头第二列=管理员。 */
|
||||
.clean-items-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
color: var(--c-text, #24384d);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18px;
|
||||
}
|
||||
.form-box,
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
@@ -317,23 +270,30 @@ onMounted(() => {
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0 0 14px;
|
||||
margin: 0 0 16px;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.clean-filter-title {
|
||||
margin: 0 0 14px;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
color: #40586e;
|
||||
.clean-panel-head h3 {
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
.form-row {
|
||||
.clean-filter-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(150px, 1fr)) auto;
|
||||
gap: 12px;
|
||||
align-items: end;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.clean-filter-row .form-group {
|
||||
min-width: 0;
|
||||
}
|
||||
.clean-filter-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 18px;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
@@ -397,7 +357,7 @@ h3 {
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
@@ -409,112 +369,72 @@ h3 {
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 14px;
|
||||
}
|
||||
.clean-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
/* 工具条只剩右侧汇总(顶部「导出」已按客户口径摘掉),用 margin-left:auto 顶到右边保持原位。 */
|
||||
.clean-toolbar-side {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
margin-left: auto;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.clean-summary {
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.clean-card-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 14px;
|
||||
}
|
||||
.clean-card {
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 12px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
overflow: hidden;
|
||||
}
|
||||
.clean-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #e6edf4;
|
||||
}
|
||||
.clean-card-supervisor {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: #24384d;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.clean-card-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: 6px 16px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.clean-card-label {
|
||||
flex: none;
|
||||
width: 46px;
|
||||
color: #8293a5;
|
||||
}
|
||||
.clean-card-value {
|
||||
color: #40586e;
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.clean-table-scroll > table {
|
||||
min-width: 1040px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.clean-card-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
padding: 8px 16px 14px;
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.country-chip {
|
||||
padding: 1px 8px;
|
||||
margin-right: 4px;
|
||||
border-radius: 999px;
|
||||
background: #eef4fa;
|
||||
color: #40586e;
|
||||
font-size: 12px;
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.mono-cell {
|
||||
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.title-cell {
|
||||
max-width: 260px;
|
||||
}
|
||||
.conclusion-cell {
|
||||
max-width: 130px;
|
||||
}
|
||||
.empty-tip {
|
||||
grid-column: 1 / -1;
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
@media (max-width: 1400px) {
|
||||
.clean-card-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.clean-card-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.clean-card-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/** 外观专利无侵权数据列表查询适配(v1.3 AC-5):GET /api/admin/appearance-patent-clean-items。
|
||||
* 只读页+导出(2026-11-11 客户需求「数据得导出来」):公司 tab 的值由本发送口从原始入参自己下传
|
||||
* (白名单构造不认识 company_id),取值口形状由 company-tab-wiring 护栏钉住。 */
|
||||
* (白名单构造不认识 company_id),取值口形状由 company-tab-wiring 护栏钉住。
|
||||
* 2026-11-11 晚间恢复明细表:主管聚合(/supervisors)与按主管删除的前端发送口随卡片视图一并
|
||||
* 下架(客户「不是这种格式 按照昨天那个格式」+删除入口先撤);后端两接口保留,要恢复时
|
||||
* 从 git 历史(e1767faf)找回。 */
|
||||
import { http } from '@/api/http'
|
||||
import { errorTextOf, unwrap } from '../../api/envelope.ts'
|
||||
import {
|
||||
@@ -12,14 +15,10 @@ 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,
|
||||
@@ -41,37 +40,6 @@ 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
|
||||
@@ -92,22 +60,19 @@ function exportFilenameOf(disposition: unknown): string {
|
||||
return plain?.[1] || '外观专利数据库.xlsx'
|
||||
}
|
||||
|
||||
/** 导出当前过滤面全量明细:与列表共用同一过滤面取值口(含公司 tab),blob 下载交给页面触发保存。
|
||||
* {@code supervisorUserId} 传入=只导出该主管名下明细(卡片上的「下载」,2026-11-11 一主管一卡)。 */
|
||||
/** 导出当前过滤面全量明细:与列表共用同一过滤面取值口(含公司 tab),blob 下载交给页面触发保存。 */
|
||||
export async function exportAppearancePatentCleanList(
|
||||
params: AppearancePatentCleanExportParams & { supervisorUserId?: number | null },
|
||||
params: AppearancePatentCleanExportParams,
|
||||
): Promise<AppearancePatentCleanExportResult> {
|
||||
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 ?? '',
|
||||
})
|
||||
const query: AppearancePatentCleanExportQuery = 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',
|
||||
@@ -131,37 +96,6 @@ export async function exportAppearancePatentCleanList(
|
||||
return { blob: response.data, filename: exportFilenameOf(disposition) }
|
||||
}
|
||||
|
||||
export interface AppearancePatentSupervisorDeleteParams {
|
||||
supervisorUserId: number
|
||||
country?: string
|
||||
groupId?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
/** 删除某位主管名下明细(卡片上的「删除」,2026-11-11 客户「也要加个删除按钮」):
|
||||
* 谓词与卡片「下载」逐字同源(同一过滤面 + 同一主管归属表达式),返回实际删除行数。
|
||||
* supervisorUserId 必填——后端缺值按业务错误拒绝(不按主管收窄的删除等于删整个过滤面)。 */
|
||||
export async function deleteAppearancePatentCleanSupervisor(
|
||||
params: AppearancePatentSupervisorDeleteParams,
|
||||
): Promise<number> {
|
||||
const query = toAppearancePatentCleanExportParams({
|
||||
taskId: '',
|
||||
asin: '',
|
||||
country: params.country ?? '',
|
||||
groupId: params.groupId ?? '',
|
||||
startDate: params.startDate ?? '',
|
||||
endDate: params.endDate ?? '',
|
||||
})
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.delete<unknown>(APPEARANCE_PATENT_SUPERVISOR_ENDPOINT, {
|
||||
params: { ...query, supervisor_user_id: params.supervisorUserId },
|
||||
})
|
||||
const deleted = unwrap<number>(data)
|
||||
return typeof deleted === 'number' ? deleted : Number(deleted) || 0
|
||||
}
|
||||
|
||||
/** 分组(主管)下拉选项:复用既有 GET /shop-manages/groups(与去重页/店铺管理共用同一分组集,
|
||||
* 不下新端点)。2026-11-11 客户口径「主管就是组长,可以筛选组长来导出,就是分组」——
|
||||
* 选项是分组管理里那一行(DedupeGroupOption {id, name, leaderUserId}),选中后以 group_id
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* 原始入参自己下传——取值口由 company-tab-wiring 护栏的发送行钉看守。
|
||||
* 分组语义(2026-11-11 客户口径「主管就是组长,可以筛选组长来导出,就是分组」):下拉选项是
|
||||
* 分组管理里那一行(biz_shop_manage_group),group_id 下发后服务端解析「组长本人+名下子账户」
|
||||
* 整集 SQL 下推;行上「所属主管」列与它同源(组长行=自己,子账户行=创建人)。 */
|
||||
* 整集 SQL 下推;表上「管理员」列与它同源(组长行=自己,子账户行=创建人)。 */
|
||||
import { validIsoDateOrUndefined } from '../asin/asin-filter.ts'
|
||||
|
||||
/** 每页条数默认 10(蓝图 §3.2),上限 100。 */
|
||||
|
||||
@@ -7,7 +7,7 @@ export interface AppearancePatentCleanItem {
|
||||
resultId: number | null
|
||||
taskId: number | null
|
||||
userId: number | null
|
||||
/** 所属主管(后端读侧现算列:主管/公司超管=自己,普通账户=创建人;读不到为空 → 界面展示 -)。 */
|
||||
/** 管理员列(表头「管理员」,客户 2026-11-11 口径;后端读侧现算:主管/公司超管=自己,普通账户=创建人,读不到为空 → 界面展示 -)。 */
|
||||
supervisorName: string
|
||||
companyId: number | null
|
||||
rowNo: number | null
|
||||
@@ -37,79 +37,17 @@ 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
|
||||
/** 结论列悬停提示=三因原文拼装(2026-11-11 随明细表恢复回归;3cfca462 曾随结论徽章一起退役)。 */
|
||||
export function cleanItemReasonTooltip(item: AppearancePatentCleanItem): string {
|
||||
const parts: string[] = []
|
||||
if (item.titleReason) parts.push(`标题:${item.titleReason}`)
|
||||
if (item.appearanceReason) parts.push(`外观:${item.appearanceReason}`)
|
||||
if (item.patentReason) parts.push(`专利:${item.patentReason}`)
|
||||
return parts.join('\n')
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -125,17 +125,13 @@ const SEND_POINTS: ReadonlyArray<SendPoint> = [
|
||||
{ menuKey: 'admin_users', file: 'src/pages/account/user-menu-auth-api.ts', fn: 'fetchGrantableMenus', line: TASK_CENTER_SEND_LINE, window: 300, title: 'GET /permission-menus?grantableOnly 授权树:一家一套树后取错公司=已授权勾不上、提交必判无效' },
|
||||
// ↓ 批次 7(2026-11-10 v1.3 外观专利无侵权数据):出表成功自动同步的只读明细,归属物化在行
|
||||
// company_id 列(V189,同店铺密钥形状)⇒ 后端正门 readCompanyIdOrOwn;2026-11-11 客户需求
|
||||
// 「数据得导出来」补导出发送口(与列表共用同一过滤面与正门);同日再补主管聚合与按主管删除,
|
||||
// 这一页共四个发送口(四条都用同一行塞键 ⇒ (文件, 整行) 仍聚成同一组)。
|
||||
// 窗口 500:两处 own 实测 416/395(groupId 行加入后),同文件两条塞键行的间距 1585 ⇒
|
||||
// 「数据得导出来」补导出发送口(与列表共用同一过滤面与正门)。这一页共两个发送口
|
||||
// (同日曾加的 /supervisors 取数与按主管删除两口,随当晚「恢复昨天那个明细表格式」一并
|
||||
// 下架——后端接口保留,前端发送口撤,重上时从 e1767faf 历史找回再登记)。
|
||||
// 窗口 500:own 实测 416(groupId 行加入后),同文件两条塞键行的间距 1585 ⇒
|
||||
// 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 主管聚合卡片(客户「我们这边就是按主管划分」)' },
|
||||
// 2026-11-11 三次改版(客户「也要加个删除按钮」):DELETE /supervisors 按主管收窄删除,
|
||||
// 与卡片下载同一过滤面与同一公司正门(非超管只能删本公司行)。
|
||||
{ menuKey: 'admin_appearance_patent_clean_items', file: 'src/pages/patent/appearance-patent-clean-api.ts', fn: 'deleteAppearancePatentCleanSupervisor', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 500, title: 'DELETE /appearance-patent-clean-items/supervisors 按主管删除(客户「也要加个删除按钮」)' },
|
||||
]
|
||||
|
||||
/** 任务看板那 5 处(1b ④ 那条用例按文件筛它们,沿用旧名字不漂;表只有一份,不会漂出两个口径)。 */
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
/**
|
||||
* 外观专利无侵权数据页(v1.3 AC-5)的挂载契约。
|
||||
* 外观专利数据库页(v1.3 AC-5,2026-11-11 晚间恢复明细表)的挂载契约。
|
||||
*
|
||||
* 形态(2026-11-11 客户三连拍板:「要按主管分组显示」→「应该是只显示一个卡片的才对」→
|
||||
* 「获取店铺那边是按店铺做成卡片 我们这边就是按主管划分」,随后两改:「这个可以不要 有下载就行了」
|
||||
* 摘掉顶部全量导出、「也要加个删除按钮」给每卡加删除):<b>一主管一卡</b>,对齐
|
||||
* 「店铺数据记录」页的一店一卡——卡头=主管名,卡内 条数 / 任务(几个任务·最近任务号)/
|
||||
* 国家 / 最新同步时间 + [下载](导出该主管名下 xlsx)+ [删除](删该主管名下明细,先确认)。
|
||||
* 明细分页卡片(每明细一卡)已下架:3488 条明细铺成几千张卡是客户明确不要的形态;
|
||||
* 明细仍走 xlsx 看。数据来自 GET /supervisors(后端按归属表达式聚合,total 是主管数)。
|
||||
* 筛选面不变(分组=主管/国家/同步起止,分组选中即查),取数/导出/删除/公司 tab 契约照旧。
|
||||
* 形态(客户当日口径「不是这种格式 你就按照昨天那个格式」):撤掉一主管一卡视图,
|
||||
* 恢复只读明细表(自绘 table + OldPagination,参照「去重数据库」页);表头第二列=「管理员」
|
||||
* (后端读侧现算 supervisorName,读不到展示 -);「添加个管理员 跟导出数据就可以」——
|
||||
* 筛选行有「导出」(当前过滤面+公司 tab 全量出 xlsx,与去重页同款);「任务号/ASIN 两个
|
||||
* 筛选框恢复」(客户要「一目了然」选数据);分组(主管)下拉保留选中即查。
|
||||
* 卡片级下载/删除入口随卡片视图一并下架(删除入口先撤,防误删;后端 /supervisors 接口保留)。
|
||||
* 数据按 ASIN 累计(同 ASIN 只保留一条,V192 唯一键),页面零写操作。
|
||||
*
|
||||
* 跑法:`npx vitest run tests/mount/appearance-patent-clean-page.test.ts`
|
||||
*/
|
||||
@@ -28,26 +27,36 @@ const PAGE_PATH = 'src/pages/patent/AppearancePatentCleanItemsPage.vue'
|
||||
const MENU_KEY = 'admin_appearance_patent_clean_items'
|
||||
|
||||
const cleanApi = vi.hoisted(() => ({
|
||||
fetchAppearancePatentCleanSupervisors: vi.fn(),
|
||||
fetchAppearancePatentCleanList: vi.fn(),
|
||||
exportAppearancePatentCleanList: vi.fn(),
|
||||
deleteAppearancePatentCleanSupervisor: vi.fn(),
|
||||
fetchDedupeTotalGroups: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/pages/patent/appearance-patent-clean-api.ts', () => cleanApi)
|
||||
|
||||
const confirmMock = vi.hoisted(() => vi.fn())
|
||||
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmMock }))
|
||||
|
||||
function card(supervisorId: number | null, over: Record<string, unknown> = {}) {
|
||||
function item(id: number, over: Record<string, unknown> = {}) {
|
||||
return {
|
||||
supervisorId,
|
||||
supervisorName: supervisorId == null ? '' : `主管${supervisorId}`,
|
||||
itemCount: 120,
|
||||
taskCount: 3,
|
||||
lastTaskId: 33874,
|
||||
lastSyncedAt: '2026-11-11T11:34:29',
|
||||
countryCodes: ['DE', 'UK'],
|
||||
id,
|
||||
resultId: 36800 + id,
|
||||
taskId: 33874,
|
||||
userId: 9,
|
||||
supervisorName: '主管9',
|
||||
companyId: 1,
|
||||
rowNo: id,
|
||||
asin: `B0CLEAN00${id}`,
|
||||
country: 'DE',
|
||||
sku: `SKU-00${id}`,
|
||||
brand: 'Nike',
|
||||
price: '12.99',
|
||||
title: 'Women Floral Dress Summer Casual',
|
||||
imageUrl: '',
|
||||
itemUrl: '',
|
||||
conclusion: '无侵权',
|
||||
titleReason: '',
|
||||
appearanceReason: '',
|
||||
patentReason: '',
|
||||
sourceFilename: 'appearance_patent_33874.xlsx',
|
||||
syncedAt: '2026-11-11T11:34:29',
|
||||
...over,
|
||||
}
|
||||
}
|
||||
@@ -64,25 +73,29 @@ beforeEach(() => {
|
||||
})
|
||||
|
||||
async function mountWith(payload: unknown): Promise<VueWrapper<Element>> {
|
||||
cleanApi.fetchAppearancePatentCleanSupervisors.mockImplementation(() => Promise.resolve(payload))
|
||||
cleanApi.fetchAppearancePatentCleanList.mockImplementation(() => Promise.resolve(payload))
|
||||
const wrapper = mount(AppearancePatentCleanItemsPage, { global: { plugins: [pinia] } })
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
}
|
||||
|
||||
describe('外观专利数据库页(一主管一卡,2026-11-11 客户「我们这边就是按主管划分」)', () => {
|
||||
it('页面组件落位:卡片宫格 + 主管聚合端点,不再按明细铺卡', () => {
|
||||
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', '卡片宫格容器必须就位')
|
||||
expect(src).toContain('clean-card-head', '卡片本体结构必须就位')
|
||||
expect(src).toContain('fetchAppearancePatentCleanSupervisors', '必须走主管聚合端点(一主管一卡)')
|
||||
expect(src).toContain('supervisorUserId', '单卡下载按主管收窄导出')
|
||||
expect(src).toContain('deleteAppearancePatentCleanSupervisor', '单卡删除按主管收窄')
|
||||
expect(src).toContain('openAdminConfirm', '破坏性删除必须先确认')
|
||||
expect(src).not.toContain('exportAll', '顶部全量导出已按客户口径摘掉(「这个可以不要 有下载就行了」)')
|
||||
expect(src).not.toContain('<table', '本页不是自绘行列表')
|
||||
expect(src).toContain('<table', '恢复自绘明细表(客户「按照昨天那个格式」)')
|
||||
expect(src).toContain('管理员', '表头必须有「管理员」列(客户「添加个管理员」)')
|
||||
expect(src).toContain('fetchAppearancePatentCleanList', '必须走明细分页端点')
|
||||
expect(src).toContain('exportAll', '筛选行要有「导出」(客户「跟数据去重一样 能导出来就可以」)')
|
||||
expect(src).toContain('cleanItemReasonTooltip', '结论列带三因原因提示')
|
||||
expect(src).toContain('filter.taskId', '任务号筛选框恢复')
|
||||
expect(src).toContain('filter.asin', 'ASIN 筛选框恢复')
|
||||
// 卡片视图与删除入口下架:这些符号只该在后端/历史里,不该再出现在本页
|
||||
expect(src).not.toContain('clean-card-grid', '一主管一卡视图已撤')
|
||||
expect(src).not.toContain('fetchAppearancePatentCleanSupervisors', '主管聚合取数口已撤')
|
||||
expect(src).not.toContain('deleteAppearancePatentCleanSupervisor', '按主管删除的页面入口已撤')
|
||||
expect(src).not.toContain('openAdminConfirm', '本页零写操作,不该再有任何确认弹窗')
|
||||
expect(src).not.toContain('el-card')
|
||||
})
|
||||
|
||||
@@ -97,53 +110,48 @@ describe('外观专利数据库页(一主管一卡,2026-11-11 客户「我
|
||||
expect(scoped?.pageFiles).toContain(PAGE_PATH)
|
||||
})
|
||||
|
||||
it('挂载后按首屏分页参数取主管聚合,卡片数=主管数而不是明细条数', async () => {
|
||||
it('挂载后按首屏分页参数取明细列表,行数=本页明细条数', async () => {
|
||||
const wrapper = await mountWith({
|
||||
items: [card(9), card(44), card(null, { supervisorName: '' })],
|
||||
total: 3,
|
||||
items: [item(1), item(2), item(3)],
|
||||
total: 42,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors).toHaveBeenCalledTimes(1)
|
||||
const firstCall = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls[0][0]
|
||||
expect(cleanApi.fetchAppearancePatentCleanList).toHaveBeenCalledTimes(1)
|
||||
const firstCall = cleanApi.fetchAppearancePatentCleanList.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(3, '一主管一卡')
|
||||
expect(wrapper.text()).toContain('共 3 位主管', '汇总按主管计数(不是明细条数)')
|
||||
expect(wrapper.findAll('tbody tr')).toHaveLength(3)
|
||||
expect(wrapper.find('.clean-summary').text()).toContain('共 42 条', '汇总按明细条数(不是主管数)')
|
||||
})
|
||||
|
||||
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('行内容=任务号/管理员/ASIN/国家/SKU/品牌/价格/标题/结论/同步时间', async () => {
|
||||
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 10 })
|
||||
const cells = wrapper.findAll('tbody tr')[0].findAll('td')
|
||||
expect(cells).toHaveLength(10)
|
||||
expect(cells[0].text()).toBe('33874', '任务号')
|
||||
expect(cells[1].text()).toBe('主管9', '管理员(supervisorName 读侧现算列)')
|
||||
expect(cells[2].text()).toBe('B0CLEAN001')
|
||||
expect(cells[3].text()).toBe('德国', '国家码翻中文')
|
||||
expect(cells[4].text()).toBe('SKU-001')
|
||||
expect(cells[5].text()).toBe('Nike')
|
||||
expect(cells[6].text()).toBe('12.99')
|
||||
expect(cells[7].text()).toContain('Women Floral Dress')
|
||||
expect(cells[8].text()).toBe('无侵权')
|
||||
expect(cells[9].text()).not.toBe('-', '同步时间格式化展示')
|
||||
const headers = wrapper.findAll('thead th').map((th) => th.text())
|
||||
expect(headers).toContain('管理员')
|
||||
expect(headers).not.toContain('所属主管', '列名按客户口径叫「管理员」')
|
||||
})
|
||||
|
||||
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 不可按主管导出')
|
||||
const deleteBtn = one.findAll('button').find((b) => b.text() === '删除')
|
||||
expect(deleteBtn).toBeTruthy()
|
||||
expect((deleteBtn!.element as HTMLButtonElement).disabled).toBe(true, '无主管 id 不可按主管删除')
|
||||
it('读不到主管的那一行管理员列展示 -(不猜名字)', async () => {
|
||||
const wrapper = await mountWith({ items: [item(1, { supervisorName: '' })], total: 1, page: 1, pageSize: 10 })
|
||||
expect(wrapper.findAll('tbody tr')[0].findAll('td')[1].text()).toBe('-')
|
||||
})
|
||||
|
||||
it('单卡下载=按该主管导出(带 supervisorUserId 与当前过滤面)', async () => {
|
||||
it('导出=当前过滤面全量(含任务号/ASIN 与公司 tab),不传按主管参数', async () => {
|
||||
const createObjectURL = vi.fn(() => 'blob:mock-url')
|
||||
const revokeObjectURL = vi.fn()
|
||||
const urlRecord = URL as unknown as Record<string, unknown>
|
||||
@@ -151,19 +159,21 @@ describe('外观专利数据库页(一主管一卡,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']), filename: '外观专利数据库-20261111120000.xlsx' }),
|
||||
Promise.resolve({ blob: new Blob(['xlsx']), filename: '外观专利数据库-20261111235900.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() === '下载')
|
||||
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 10 })
|
||||
const btn = wrapper.findAll('button').find((b) => b.text() === '导出')
|
||||
expect(btn, '筛选行必须有「导出」按钮').toBeTruthy()
|
||||
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(call).toMatchObject({ taskId: '', asin: '', country: '', groupId: '', companyId: 1 })
|
||||
expect(call.supervisorUserId).toBeUndefined()
|
||||
expect(createObjectURL).toHaveBeenCalledTimes(1)
|
||||
expect(clickSpy).toHaveBeenCalled()
|
||||
expect(document.body.textContent).toContain('已导出', '成功反馈点名落盘文件')
|
||||
@@ -174,114 +184,41 @@ describe('外观专利数据库页(一主管一卡,2026-11-11 客户「我
|
||||
}
|
||||
})
|
||||
|
||||
it('工具栏不再有「导出」按钮(客户「这个可以不要 有下载就行了」),下载只在卡上', async () => {
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
const labels = wrapper.findAll('button').map((b) => b.text())
|
||||
expect(labels).not.toContain('导出')
|
||||
expect(labels).toContain('下载')
|
||||
expect(wrapper.find('.clean-summary').text()).toContain('共 1 位主管')
|
||||
})
|
||||
|
||||
it('导出失败把服务端业务文案弹出来,不许静默', async () => {
|
||||
it('导出失败把服务端业务文案弹出来,不许静默;在途标记复位', async () => {
|
||||
cleanApi.exportAppearancePatentCleanList.mockImplementation(() =>
|
||||
Promise.reject(new Error('该主管的无侵权数据共 90001 行,超过导出上限 50000 行,请缩小筛选范围后重试')))
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
await wrapper.find('.clean-card').findAll('button').find((b) => b.text() === '下载')!.trigger('click')
|
||||
Promise.reject(new Error('无侵权数据共 90001 行,超过导出上限 50000 行,请缩小筛选范围后重试')))
|
||||
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 10 })
|
||||
await wrapper.findAll('button').find((b) => b.text() === '导出')!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('超过导出上限')
|
||||
const downloadBtn = wrapper.find('.clean-card').findAll('button').find((b) => b.text() === '下载')
|
||||
expect(downloadBtn!.text()).toBe('下载', '失败后在途标记必须复位')
|
||||
const btn = wrapper.findAll('button').find((b) => b.text() === '导出')
|
||||
expect(btn!.text()).toBe('导出', '失败后在途标记必须复位')
|
||||
expect((btn!.element as HTMLButtonElement).disabled).toBe(false)
|
||||
})
|
||||
|
||||
it('删除:确认后按主管收窄真删,反馈删了多少条并重取列表', async () => {
|
||||
confirmMock.mockResolvedValue(true)
|
||||
cleanApi.deleteAppearancePatentCleanSupervisor.mockResolvedValue(120)
|
||||
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() === '删除')
|
||||
expect(btn, '每张卡都要有删除').toBeTruthy()
|
||||
await btn!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
expect(confirmMock).toHaveBeenCalledTimes(1)
|
||||
const confirmArgs = confirmMock.mock.calls[0][0] as { message: string; danger?: boolean }
|
||||
expect(confirmArgs.message).toContain('主管9', '确认文案点名是哪位主管')
|
||||
expect(confirmArgs.message).toContain('120', '确认文案给出将删条数')
|
||||
expect(confirmArgs.danger).toBe(true)
|
||||
|
||||
expect(cleanApi.deleteAppearancePatentCleanSupervisor).toHaveBeenCalledTimes(1)
|
||||
expect(cleanApi.deleteAppearancePatentCleanSupervisor.mock.calls[0][0]).toMatchObject({
|
||||
supervisorUserId: 9,
|
||||
companyId: 1,
|
||||
country: '',
|
||||
groupId: '',
|
||||
})
|
||||
expect(document.body.textContent).toContain('已删除', '成功反馈必须给出删除结果')
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors).toHaveBeenCalledTimes(2, '删完要重取')
|
||||
})
|
||||
|
||||
it('删除:确认弹窗被取消时一个字节都不发', async () => {
|
||||
confirmMock.mockResolvedValue(false)
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
|
||||
await wrapper.find('.clean-card').findAll('button').find((b) => b.text() === '删除')!.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(cleanApi.deleteAppearancePatentCleanSupervisor).not.toHaveBeenCalled()
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('删除失败把服务端业务文案弹出来,不许静默', async () => {
|
||||
confirmMock.mockResolvedValue(true)
|
||||
cleanApi.deleteAppearancePatentCleanSupervisor.mockImplementation(() =>
|
||||
Promise.reject(new Error('缺少主管,无法按主管删除')))
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
|
||||
await wrapper.find('.clean-card').findAll('button').find((b) => b.text() === '删除')!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
expect(document.body.textContent).toContain('无法按主管删除')
|
||||
const btn = wrapper.find('.clean-card').findAll('button').find((b) => b.text() === '删除')
|
||||
expect(btn!.text()).toBe('删除', '失败后在途标记必须复位,不能永久禁用')
|
||||
})
|
||||
|
||||
it('翻页与改每页条数都重发请求,改条数回第一页', async () => {
|
||||
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.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.fetchAppearancePatentCleanSupervisors.mock.calls.at(-1)![0]
|
||||
expect(last.pageSize).toBe(50)
|
||||
expect(last.page).toBe(1, '改每页条数后回第一页')
|
||||
})
|
||||
|
||||
it('分组/国家/起止时间筛选生效(任务号/ASIN 输入框已下架)', async () => {
|
||||
it('任务号/ASIN/国家/分组/起止时间筛选生效', async () => {
|
||||
cleanApi.fetchDedupeTotalGroups.mockResolvedValue([{ id: 7, name: '甲组', leaderUserId: 9 }])
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
|
||||
|
||||
const filterTextInputs = wrapper.findAll('.form-row input[type="text"]')
|
||||
expect(filterTextInputs).toHaveLength(0)
|
||||
const textInputs = wrapper.findAll('.form-group input[type="text"]')
|
||||
expect(textInputs).toHaveLength(2, '任务号+ASIN 两个筛选框恢复(客户要一目了然)')
|
||||
await textInputs[0].setValue('33874')
|
||||
await textInputs[1].setValue('B0CLEAN')
|
||||
|
||||
const selects = wrapper.findAll('select')
|
||||
await selects[0].setValue('7') // 分组(主管=组长)排在国家前
|
||||
await selects[1].setValue('DE')
|
||||
await selects[0].setValue('DE') // 国家排在前(模板顺序:任务号/ASIN/国家/分组)
|
||||
await selects[1].setValue('7') // 分组(主管=组长)
|
||||
const dateInputs = wrapper.findAll('input[type="date"]')
|
||||
await dateInputs[0].setValue('2026-11-01')
|
||||
await dateInputs[1].setValue('2026-11-09')
|
||||
await wrapper.findAll('button').find((b) => b.text() === '查询')!.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
const last = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.at(-1)![0]
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
expect(last).toMatchObject({
|
||||
taskId: '33874',
|
||||
asin: 'B0CLEAN',
|
||||
country: 'DE',
|
||||
groupId: '7',
|
||||
startDate: '2026-11-01',
|
||||
@@ -298,22 +235,53 @@ describe('外观专利数据库页(一主管一卡,2026-11-11 客户「我
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
|
||||
expect(cleanApi.fetchDedupeTotalGroups).toHaveBeenCalledWith(1)
|
||||
|
||||
const groupSelect = wrapper.findAll('select')[0]
|
||||
const groupSelect = wrapper.findAll('select')[1] // 模板顺序:国家在前、分组在后
|
||||
const optionTexts = groupSelect.findAll('option').map((o) => o.text())
|
||||
expect(optionTexts).toContain('全部分组')
|
||||
expect(optionTexts).toContain('甲组')
|
||||
|
||||
const callsBeforeSelect = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.length
|
||||
const callsBeforeSelect = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
|
||||
await groupSelect.setValue('7')
|
||||
await flushPromises()
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.length).toBe(callsBeforeSelect + 1,
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.length).toBe(callsBeforeSelect + 1,
|
||||
'选中分组必须立刻重查')
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.at(-1)![0]).toMatchObject({
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]).toMatchObject({
|
||||
groupId: '7',
|
||||
page: 1,
|
||||
})
|
||||
})
|
||||
|
||||
it('重置把筛选面回空并回第一页重取', async () => {
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
|
||||
const textInputs = wrapper.findAll('.form-group input[type="text"]')
|
||||
await textInputs[0].setValue('33874')
|
||||
await textInputs[1].setValue('B0CLEAN')
|
||||
const callsBefore = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
|
||||
|
||||
await wrapper.findAll('button').find((b) => b.text() === '重置')!.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.length).toBeGreaterThan(callsBefore)
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
expect(last).toMatchObject({ taskId: '', asin: '', page: 1 }, '重置后筛选全空、回第一页')
|
||||
})
|
||||
|
||||
it('翻页与改每页条数都重发请求,改条数回第一页', async () => {
|
||||
const wrapper = await mountWith({ items: [item(1)], 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)
|
||||
|
||||
const sizeSelect = wrapper.find('.page-size-select')
|
||||
await sizeSelect.setValue('50')
|
||||
await flushPromises()
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
expect(last.pageSize).toBe(50)
|
||||
expect(last.page).toBe(1, '改每页条数后回第一页')
|
||||
})
|
||||
|
||||
it('空态与加载失败条(失败给重试,不把整页打死)', async () => {
|
||||
const empty = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
|
||||
const tip = empty.find('.empty-tip')
|
||||
@@ -321,7 +289,7 @@ describe('外观专利数据库页(一主管一卡,2026-11-11 客户「我
|
||||
expect(tip.text()).toContain('暂无无侵权数据')
|
||||
empty.unmount()
|
||||
|
||||
cleanApi.fetchAppearancePatentCleanSupervisors.mockRejectedValue(new Error('上游 502'))
|
||||
cleanApi.fetchAppearancePatentCleanList.mockRejectedValue(new Error('上游 502'))
|
||||
const failed = mount(AppearancePatentCleanItemsPage, { global: { plugins: [pinia] } })
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
@@ -331,18 +299,23 @@ describe('外观专利数据库页(一主管一卡,2026-11-11 客户「我
|
||||
|
||||
it('切公司 Tab 重取并清掉上一家的筛选(company-tab-wiring 同口径)', async () => {
|
||||
cleanApi.fetchDedupeTotalGroups.mockResolvedValue([{ id: 7, name: '甲组', leaderUserId: 9 }])
|
||||
const wrapper = await mountWith({ items: [card(9)], total: 1, page: 1, pageSize: 10 })
|
||||
const groupSelect = wrapper.findAll('select')[0]
|
||||
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 10 })
|
||||
const textInputs = wrapper.findAll('.form-group input[type="text"]')
|
||||
await textInputs[0].setValue('33874')
|
||||
await textInputs[1].setValue('B0CLEAN')
|
||||
const groupSelect = wrapper.findAll('select')[1]
|
||||
await groupSelect.setValue('7')
|
||||
const callsBefore = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.length
|
||||
const callsBefore = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
|
||||
|
||||
useCompanyTabStore().setActiveId(2)
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
expect(cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.length).toBeGreaterThan(callsBefore)
|
||||
const last = cleanApi.fetchAppearancePatentCleanSupervisors.mock.calls.at(-1)![0]
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.length).toBeGreaterThan(callsBefore)
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
expect(last.companyId).toBe(2)
|
||||
expect(last.taskId).toBe('', '切公司必须清掉上一家的任务号')
|
||||
expect(last.asin).toBe('', '切公司必须清掉上一家的 ASIN')
|
||||
expect(last.groupId).toBe('', '切公司必须清掉上一家选的分组')
|
||||
expect(last.page).toBe(1)
|
||||
expect(cleanApi.fetchDedupeTotalGroups).toHaveBeenLastCalledWith(2)
|
||||
|
||||
Reference in New Issue
Block a user