feat(appearance-patent): 后管外观专利数据库改卡片宫格样式(2026-11-11 客户需求:像店铺数据记录那样卡片展示+下载导出)——参照 ShopDataTasksPage 像素复刻:form-box 筛选条件(任务号/ASIN/国家/分组/同步起止+查询/重置)+ panel-box 工具条[导出(带当前过滤面与公司tab)+共N条汇总] + 每明细一卡(ASIN头/任务号/结论徽章含三因悬停/所属主管/国家chip/品牌/SKU/价格/标题/同步时间,4-3-2-1响应式)+ OldPagination 服务端分页;推翻 2026-11-10「自绘 table 不做卡片宫格」旧拍板并同步挂载测试契约(先红后绿 3 用例改卡片断言),取数/过滤面/导出/公司tab契约一字未动(company-tab-wiring watch token 与 date-filter 豁免照旧),本页仍零写操作、单卡无下载按钮(明细无文件,下载统一走 /export)

This commit is contained in:
2026-11-11 09:30:59 +08:00
parent 6f85f17c58
commit a5bd4011e2
2 changed files with 272 additions and 137 deletions
@@ -1,10 +1,12 @@
<script setup lang="ts">
import { formatDateTime, orderedPair } from '@/utils/datetime'
/** 外观专利无侵权数据 · 只读分页列表(v1.3,展示形式参照「去重数据库」页:自绘 table +
* OldPagination,不做卡片宫格)。数据由出表成功点自动同步(后端 SyncService),本页零写操作:
* 无编辑/导入,下载走既有结果直链/任务中心;导出(2026-11-11 客户需求)带当前过滤面 +
* 公司 tab 走后端 /export 全量出 xlsx(含所属主管列)。分组下拉(主管=组长)选项与去重页
* 共用 GET /shop-manages/groups,选中后以 group_id 走同一过滤面(列表与导出同源)。 */
/** 外观专利无侵权数据 · 只读分页列表(v1.3)。展示形式 2026-11-11 客户改版:参照「店铺数据记录」页
* (ShopDataTasksPage)——form-box 筛选条件 + panel-box 工具条[导出] + 卡片宫格(4/3/2/1 响应式)
* + OldPagination 服务端分页,推翻 2026-11-10「参照去重库页自绘 table」的旧拍板;取数/过滤面/
* 导出/公司 tab 契约一字未动(company-tab-wiring 与 date-filter 护栏照旧)。数据由出表成功点
* 自动同步(后端 SyncService),本页零写操作:无编辑/导入;单条明细没有可下载文件,下载/导出
* 统一走既有 /export 全量出 xlsx(带当前过滤面 + 公司 tab,含所属主管列)。分组下拉(主管=组长)
* 选项与去重页共用 GET /shop-manages/groups,选中后以 group_id 走同一过滤面(列表与导出同源)。 */
import { computed, onMounted, reactive, ref, watch } from 'vue'
import {
exportAppearancePatentCleanList,
@@ -45,6 +47,16 @@ function clampDatePair(): void {
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
/** 结论徽章档位:先判「无侵权」再判「侵权」(『无侵权』串里也含『侵权』二字),其余中性灰。
* 本页同步面只进「结论=无侵权」的行,绿色是常态;兜住服务端将来放宽同步口径的展示。 */
function conclusionBand(conclusion: string): 'success' | 'failed' | 'cancelled' {
const text = (conclusion || '').trim()
if (!text) return 'cancelled'
if (text.includes('无侵权')) return 'success'
if (text.includes('侵权') || text.includes('风险') || text.includes('存疑')) return 'failed'
return 'cancelled'
}
/** 分组选项与去重页/店铺管理同源(GET /shop-manages/groups);失败静默回空——分组只是筛选项,
* 不该让它把首屏行集一起拖死(列表失败有自己的 LoadFailureBar)。 */
async function loadGroupOptions(): Promise<void> {
@@ -117,6 +129,13 @@ function apply(): void {
void load()
}
/** 重置(对齐店铺数据记录页样式):筛选面回出厂空态,回第一页重取。 */
function reset(): void {
Object.assign(filter, createAppearancePatentCleanFilterState())
page.value = 1
void load()
}
function changePage(next: number): void {
if (next < 1 || next > totalPages.value) return
page.value = next
@@ -141,90 +160,104 @@ onMounted(() => {
<template>
<div class="clean-items-view">
<section class="panel-box">
<div class="clean-panel-head">
<h3>外观专利数据库</h3>
</div>
<div class="clean-filter-row">
<div class="form-group">
<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>
<input v-model="filter.taskId" type="text" placeholder="输入任务号" @keyup.enter="apply" />
</div>
<div class="form-group">
<div class="form-group" style="min-width: 150px">
<label>ASIN</label>
<input v-model="filter.asin" type="text" placeholder="输入 ASIN" @keyup.enter="apply" />
</div>
<div class="form-group">
<div class="form-group" style="min-width: 130px">
<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">
<div class="form-group" style="min-width: 130px">
<label>分组</label>
<select v-model="filter.groupId">
<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">
<div class="form-group" style="min-width: 150px">
<label>同步开始日期</label>
<input v-model="filter.startDate" type="date" :max="filter.endDate" @change="clampDatePair" />
</div>
<div class="form-group">
<div class="form-group" style="min-width: 150px">
<label>同步结束日期</label>
<input v-model="filter.endDate" type="date" :min="filter.startDate" @change="clampDatePair" />
</div>
<div class="clean-filter-actions">
<button class="btn" type="button" @click="apply">查询</button>
<button class="btn btn-export" type="button" :disabled="exporting" @click="exportAll">
<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-main">
<button class="btn" type="button" :disabled="exporting" @click="exportAll">
{{ exporting ? '导出中...' : '导出' }}
</button>
</div>
<div class="clean-toolbar-side">
<span class="clean-summary">共 {{ total }} 条记录 · 本页 {{ rows.length }} 条</span>
</div>
</div>
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
<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 class="clean-card-grid">
<template v-if="rows.length">
<article v-for="row in rows" :key="row.id" class="clean-card">
<header class="clean-card-head">
<span class="clean-card-asin" :title="row.asin || '-'">{{ row.asin || '-' }}</span>
</header>
<div class="clean-card-select-row">
<span class="clean-card-task" :title="`任务 ${row.taskId ?? '-'}`">任务 {{ row.taskId ?? '-' }}</span>
<span class="st-pill" :class="`is-${conclusionBand(row.conclusion)}`" :title="cleanItemReasonTooltip(row)">
{{ row.conclusion || '-' }}
</span>
</div>
<div class="clean-card-row">
<span class="clean-card-label">所属主管</span>
<span class="clean-card-value">{{ row.supervisorName || '-' }}</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">{{ row.price || '-' }}</span>
</div>
<div class="clean-card-row">
<span class="clean-card-label">标题</span>
<span class="clean-card-value clean-card-title" :title="row.title">{{ row.title || '-' }}</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 v-else-if="loading" class="empty-tip">加载中...</div>
<div v-else class="empty-tip">暂无无侵权数据</div>
</div>
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
@@ -233,14 +266,16 @@ onMounted(() => {
</template>
<style scoped>
/* 像素复刻参照「去重数据库」页(panel-box + 自绘表格 + 旧式分页),只读无操作列。 */
/* 像素复刻参照「店铺数据记录」页(ShopDataTasksPage):form-box 筛选 + panel-box 工具条 +
卡片宫格 + 旧式分页,蓝白末层;只读卡片无勾选/无单卡操作(本页零写操作)。 */
.clean-items-view {
font-family: inherit;
color: var(--c-text, #24384d);
color: #24384d;
display: flex;
flex-direction: column;
gap: 18px;
}
.form-box,
.panel-box {
width: 100%;
min-width: 0;
@@ -251,30 +286,23 @@ 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 16px;
margin: 0 0 14px;
font-size: 15px;
font-weight: 650;
color: #24384d;
letter-spacing: 0.2px;
}
.clean-panel-head h3 {
margin: 0 0 16px;
.clean-filter-title {
margin: 0 0 14px;
font-size: 13.5px;
font-weight: 600;
color: #40586e;
}
.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 {
.form-row {
display: flex;
gap: 10px;
align-items: center;
white-space: nowrap;
flex-wrap: wrap;
align-items: flex-end;
gap: 14px 18px;
}
.form-group {
display: flex;
@@ -338,64 +366,166 @@ h3 {
}
.btn:disabled {
cursor: not-allowed;
opacity: 0.6;
opacity: 0.55;
}
.table-scroll {
width: 100%;
min-width: 0;
overflow-x: auto;
border: 1px solid #dbe5ee;
border-radius: 10px;
.btn-secondary {
background: #ffffff;
color: #5b6f83;
border-color: #c7d7e5;
}
.table-scroll table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
.btn-secondary:hover:not(:disabled) {
color: #2f5d8b;
border-color: #95b1cb;
background: #edf5fb;
}
.clean-table-scroll > table {
min-width: 1040px;
.clean-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
margin-bottom: 14px;
}
.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;
.clean-toolbar-main {
display: inline-flex;
align-items: center;
gap: 14px;
flex-wrap: wrap;
}
.clean-toolbar-side {
display: inline-flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
justify-content: flex-end;
}
.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-asin {
font-weight: 600;
color: #24384d;
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
font-size: 13px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.table-scroll th {
background: #edf4fa;
color: #4e6479;
border-bottom-color: #d5e1eb;
font-size: 12.5px;
.clean-card-select-row {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 16px 0;
}
.clean-card-task {
flex: 1 1 auto;
min-width: 0;
font-weight: 600;
letter-spacing: 0.4px;
font-size: 12px;
color: #24384d;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.table-scroll tbody tr:hover td {
background: #f1f7fb;
.clean-card-row {
display: flex;
align-items: flex-start;
gap: 10px;
padding: 6px 16px;
font-size: 13px;
}
.table-scroll tbody tr:last-child td {
border-bottom: 0;
.clean-card-label {
flex: none;
width: 60px;
color: #8293a5;
}
.mono-cell {
.clean-card-value {
color: #40586e;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.mono {
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
font-size: 12.5px;
}
.title-cell {
max-width: 260px;
.st-pill {
display: inline-flex;
align-items: center;
padding: 2px 10px;
border-radius: 999px;
font-size: 12px;
line-height: 1.7;
border: 1px solid transparent;
white-space: nowrap;
flex: none;
cursor: default;
}
.conclusion-cell {
max-width: 130px;
.st-pill.is-success {
color: #3d7158;
background: #e8f2eb;
border-color: #bdd7c5;
}
.st-pill.is-failed {
color: #91474f;
background: #f8ebeb;
border-color: #e4c2c5;
}
.st-pill.is-cancelled {
color: #5b6f83;
background: #f1f6fa;
border-color: #d6e2ec;
}
.country-chip {
padding: 1px 8px;
margin-right: 4px;
border-radius: 999px;
background: #eef4fa;
color: #40586e;
font-size: 12px;
}
.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,18 +1,20 @@
/**
* 外观专利无侵权数据页(v1.3 AC-5)的挂载契约 —— Phase 3 激活。
*
* 用户拍板(2026-11-10):展示形式参照「去重数据库」页(DedupeRegistryPage 形态:自绘
* `<table>` 行列表 + `OldPagination.vue` 分页,**不做卡片宫格**);`companyScoped: true`
* 公司 Tab;任务号/ASIN/国家/起止时间筛选;`page`/`page_size` snake 参数,响应
* `{items, total, page, pageSize}`。默认仅 super_admin 可见(菜单不预授权,判据在后端
* AdminAppearancePatentCleanItemsControllerTest 的菜单迁移支,这里只管前端接线)。
* 展示形式(2026-11-11 客户改版,推翻 2026-11-10「参照去重库页自绘 table、不做卡片宫格」的
* 旧拍板):参照「店铺数据记录」页(ShopDataTasksPage)——form-box 筛选条件 + panel-box
* 工具条[导出] + 卡片宫格(每卡一条明细:ASIN/任务号/结论徽章/所属主管/国家/品牌/SKU/价格/
* 标题/同步时间)+ `OldPagination.vue` 服务端分页。取数/过滤面/导出/公司 tab 契约不变:
* `companyScoped: true` 公司 Tab;任务号/ASIN/国家/分组/起止时间筛选;`page`/`page_size`
* snake 参数,响应 `{items, total, page, pageSize}`。默认仅 super_admin 可见(菜单不预授权,
* 判据在后端 AdminAppearancePatentCleanItemsControllerTest 的菜单迁移支,这里只管前端接线)。
*
* 跑法:`npx vitest run tests/mount/appearance-patent-clean-page.test.ts`
*/
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { flushPromises, mount, type DOMWrapper, type VueWrapper } from '@vue/test-utils'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import AppearancePatentCleanItemsPage from '@/pages/patent/AppearancePatentCleanItemsPage.vue'
@@ -79,13 +81,15 @@ async function mountWith(payload: unknown): Promise<VueWrapper<Element>> {
return wrapper
}
describe('AC-5 外观专利无侵权数据页(分页列表,参照去重数据库页)', () => {
it('页面组件落位且是自绘 table + OldPagination 的分页列表', () => {
describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版参照店铺数据记录页)', () => {
it('页面组件落位且是店铺数据记录式卡片宫格 + OldPagination 的分页列表', () => {
// vitest 的 cwd = admin-frontend-vue 根(Phase 0 预置用 new URL 模板串,被 vite 静态分析成
// undefined——skip 期间从未执行所以没暴露,激活时改走 cwd 解析)。
const src = readFileSync(resolve(process.cwd(), PAGE_PATH), 'utf-8')
expect(src).toContain('OldPagination')
expect(src).toContain('<table')
expect(src).toContain('clean-card-grid', '卡片宫格容器必须就位(2026-11-11 客户改版)')
expect(src).toContain('clean-card-head', '卡片本体结构必须就位')
expect(src).not.toContain('<table', '改版后不再有自绘行列表(推翻 2026-11-10 旧拍板)')
expect(src).not.toContain('el-card')
})
@@ -108,26 +112,28 @@ describe('AC-5 外观专利无侵权数据页(分页列表,参照去重数
expect(firstCall.page).toBe(1)
expect(firstCall.pageSize).toBe(10)
expect(firstCall.companyId).toBe(1)
expect(wrapper.findAll('tbody tr')).toHaveLength(2)
expect(wrapper.findAll('.clean-card')).toHaveLength(2, '一卡一条明细')
expect(wrapper.text()).toContain('共 42 条')
expect(wrapper.text()).toContain('B0AB8CDEF1')
expect(wrapper.text()).toContain('无侵权')
})
it('主管列(2026-11-11 客户需求):表头就位,行值展示 supervisorName,读不到展示 -', async () => {
it('所属主管行(2026-11-11 客户需求):卡片行就位,行值展示 supervisorName,读不到展示 -', async () => {
const wrapper = await mountWith({
items: [row(1, { supervisorName: '主管甲' }), row(2, { supervisorName: '' })],
total: 2,
page: 1,
pageSize: 10,
})
const headers = wrapper.findAll('thead th').map((th) => th.text())
expect(headers).toContain('所属主管')
expect(headers.indexOf('所属主管')).toBe(headers.indexOf('任务号') + 1, '主管列紧跟任务号之后')
const firstRowCells = wrapper.findAll('tbody tr')[0].findAll('td')
expect(firstRowCells[headers.indexOf('所属主管')].text()).toBe('主管甲')
const secondRowCells = wrapper.findAll('tbody tr')[1].findAll('td')
expect(secondRowCells[headers.indexOf('所属主管')].text()).toBe('-', '读不到主管不猜名字,展示 -')
const cards = wrapper.findAll('.clean-card')
expect(cards).toHaveLength(2)
const supervisorValue = (card: DOMWrapper<Element>): string => {
const rowEl = card.findAll('.clean-card-row').find((r) => r.find('.clean-card-label').text() === '所属主管')
expect(rowEl, '每张卡必须有「所属主管」行').toBeTruthy()
return rowEl!.find('.clean-card-value').text()
}
expect(supervisorValue(cards[0])).toBe('主管甲')
expect(supervisorValue(cards[1])).toBe('-', '读不到主管不猜名字,展示 -')
})
it('导出按钮带当前过滤面与公司 tab 调导出接口,成功触发 blob 落盘', async () => {
@@ -253,10 +259,9 @@ describe('AC-5 外观专利无侵权数据页(分页列表,参照去重数
it('空态与加载失败条(失败给重试,不把整页打死)', async () => {
const empty = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
const thCount = empty.findAll('thead th').length
const emptyRow = empty.find('tbody tr')
expect(emptyRow.text()).toContain('暂无无侵权数据')
expect(Number(emptyRow.find('td').attributes('colspan'))).toBe(thCount, '空态 colspan 跟着列数走')
const tip = empty.find('.empty-tip')
expect(tip.exists()).toBe(true)
expect(tip.text()).toContain('暂无无侵权数据')
empty.unmount()
cleanApi.fetchAppearancePatentCleanList.mockRejectedValue(new Error('上游 502'))