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,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'))