feat(appearance-patent): 外观专利数据库卡片按所属主管分组显示+字段精简(2026-11-11 客户拍板「要按主管分组显示」「价格 asin 无侵权 这些都不需要展示的」「到时候能下载表格看就行」)——卡片按主管连续切段,组头=主管名+本页条数(保持服务端 synced_at DESC 行序、不跨页聚合、不按名重排;同名主管被隔开按行序出多个同名组头,只看单人走既有分组下拉);卡片字段精简为 标题(卡头替下 ASIN)/任务/国家/品牌/SKU/同步,价格、ASIN、结论徽章(无侵权)、所属主管行全部下卡(主管由组头表达,全量明细含价格/ASIN/结论/主管列仍走 /export xlsx);退役 cleanItemReasonTooltip(唯一消费者=结论徽章悬停);取数/过滤面/导出/公司tab契约一字未动(company-tab-wiring watch token 与 date-filter 豁免照旧);挂载测试 11→13 例适配(分组切段+组头计数/连续切段不重排/空主管 - 三用例新钉,ASIN/价格/徽章反断言),vue-tsc rc=0、vitest 13 绿、扫本文件三支 node --test 21 绿
This commit is contained in:
@@ -9,7 +9,13 @@ import { formatDateTime, orderedPair } from '@/utils/datetime'
|
||||
* (task_id/asin)与前端过滤模块逐字对撞护栏原样保留,只是 UI 不再暴露。数据由出表成功点
|
||||
* 自动同步(后端 SyncService),本页零写操作:无编辑/导入;单条明细没有可下载文件,下载/导出
|
||||
* 统一走既有 /export 全量出 xlsx(带当前过滤面 + 公司 tab,含所属主管列)。分组下拉选项与去重页
|
||||
* 共用 GET /shop-manages/groups,选中后以 group_id 走同一过滤面(列表与导出同源)。 */
|
||||
* 共用 GET /shop-manages/groups,选中后以 group_id 走同一过滤面(列表与导出同源)。
|
||||
* 同日三改(客户「要按主管分组显示」「价格 asin 无侵权 这些都不需要展示的」「到时候能下载
|
||||
* 表格看就行」):卡片按所属主管连续分组——组头=主管名+本页条数(grid 全宽一行),组内行序
|
||||
* 保持服务端 synced_at DESC 原样,不跨页聚合、不按名重排(跨主管交错时按行序出多个同名组头,
|
||||
* 忠实反映同步顺序;要只看一个主管用分组下拉过滤)。卡片字段同批精简:只留 标题(卡头,替下
|
||||
* 原 ASIN 卡头)/任务/国家/品牌/SKU/同步;价格、ASIN、结论徽章(无侵权)、所属主管行不再
|
||||
* 上卡——全量明细(含价格/ASIN/结论/主管列)仍走 /export xlsx。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import {
|
||||
exportAppearancePatentCleanList,
|
||||
@@ -18,7 +24,6 @@ import {
|
||||
type DedupeGroupOption,
|
||||
} from './appearance-patent-clean-api.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'
|
||||
@@ -50,15 +55,19 @@ 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'
|
||||
}
|
||||
/** 主管分组视图(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)。 */
|
||||
@@ -208,48 +217,40 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
</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>
|
||||
<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>
|
||||
</template>
|
||||
<div v-else-if="loading" class="empty-tip">加载中...</div>
|
||||
<div v-else class="empty-tip">暂无无侵权数据</div>
|
||||
@@ -262,7 +263,9 @@ onMounted(() => {
|
||||
|
||||
<style scoped>
|
||||
/* 像素复刻参照「店铺数据记录」页(ShopDataTasksPage):form-box 筛选 + panel-box 工具条 +
|
||||
卡片宫格 + 旧式分页,蓝白末层;只读卡片无勾选/无单卡操作(本页零写操作)。 */
|
||||
卡片宫格 + 旧式分页,蓝白末层;只读卡片无勾选/无单卡操作(本页零写操作)。
|
||||
2026-11-11 三改:卡片宫格按所属主管分段(.clean-group-head 全宽组头),卡头=标题;
|
||||
ASIN/结论徽章(st-pill)/价格/主管行的样式随下卡一并退役。 */
|
||||
.clean-items-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
@@ -418,31 +421,14 @@ h3 {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #e6edf4;
|
||||
}
|
||||
.clean-card-asin {
|
||||
.clean-card-title {
|
||||
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;
|
||||
}
|
||||
.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;
|
||||
font-size: 12px;
|
||||
color: #24384d;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.clean-card-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
@@ -466,32 +452,29 @@ h3 {
|
||||
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.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;
|
||||
.clean-group-head {
|
||||
grid-column: 1 / -1;
|
||||
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;
|
||||
cursor: default;
|
||||
}
|
||||
.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;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.country-chip {
|
||||
padding: 1px 8px;
|
||||
|
||||
@@ -97,12 +97,3 @@ export function parseAppearancePatentCleanPage(payload: unknown): AppearancePate
|
||||
if (typeof rawSize === 'number' && rawSize >= 1) out.pageSize = Math.floor(rawSize)
|
||||
return out
|
||||
}
|
||||
|
||||
/** 结论单元格的悬停全文:三因齐给,空因不下发(读侧不加工的展示面出口)。 */
|
||||
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')
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
*
|
||||
* 展示形式(2026-11-11 客户改版,推翻 2026-11-10「参照去重库页自绘 table、不做卡片宫格」的
|
||||
* 旧拍板):参照「店铺数据记录」页(ShopDataTasksPage)——form-box 筛选条件 + panel-box
|
||||
* 工具条[导出] + 卡片宫格(每卡一条明细:ASIN/任务号/结论徽章/所属主管/国家/品牌/SKU/价格/
|
||||
* 标题/同步时间)+ `OldPagination.vue` 服务端分页。筛选面同日二次精简(客户「按账号对应的
|
||||
* 工具条[导出] + 卡片宫格 + `OldPagination.vue` 服务端分页。同日三改(客户「要按主管分组
|
||||
* 显示」「价格 asin 无侵权 这些都不需要展示的」「到时候能下载表格看就行」):卡片按所属主管
|
||||
* 连续分组(组头=主管名+本页条数,保持行序、不跨页聚合、不按名重排),每卡一条明细:标题
|
||||
* (卡头)/任务号/国家/品牌/SKU/同步时间;价格、ASIN、结论徽章(无侵权)、所属主管行不再
|
||||
* 上卡——全量明细(含价格/ASIN/结论/主管列)仍走 /export xlsx。筛选面同日二次精简(客户「按账号对应的
|
||||
* 主管吧 不需要店铺」):分组(=主管)/国家/起止时间三样,任务号/ASIN 输入框下架(后端
|
||||
* §3.2 参数契约与过滤模块逐字对撞护栏保留,UI 不再暴露)。取数/导出/公司 tab 契约不变:
|
||||
* `companyScoped: true` 公司 Tab;`page`/`page_size` snake 参数,响应
|
||||
@@ -16,7 +19,7 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { flushPromises, mount, type DOMWrapper, type VueWrapper } from '@vue/test-utils'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { createPinia, setActivePinia, type Pinia } from 'pinia'
|
||||
|
||||
import AppearancePatentCleanItemsPage from '@/pages/patent/AppearancePatentCleanItemsPage.vue'
|
||||
@@ -91,6 +94,7 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
expect(src).toContain('OldPagination')
|
||||
expect(src).toContain('clean-card-grid', '卡片宫格容器必须就位(2026-11-11 客户改版)')
|
||||
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).not.toContain('el-card')
|
||||
})
|
||||
@@ -116,26 +120,52 @@ describe('AC-5 外观专利无侵权数据页(卡片宫格,2026-11-11 改版
|
||||
expect(firstCall.companyId).toBe(1)
|
||||
expect(wrapper.findAll('.clean-card')).toHaveLength(2, '一卡一条明细')
|
||||
expect(wrapper.text()).toContain('共 42 条')
|
||||
expect(wrapper.text()).toContain('B0AB8CDEF1')
|
||||
expect(wrapper.text()).toContain('无侵权')
|
||||
// 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 卡头)')
|
||||
})
|
||||
|
||||
it('所属主管行(2026-11-11 客户需求):卡片行就位,行值展示 supervisorName,读不到展示 -', async () => {
|
||||
it('按所属主管分组显示(2026-11-11 三改):组头=主管名+本页条数,卡片不再重复主管行', async () => {
|
||||
const wrapper = await mountWith({
|
||||
items: [row(1, { supervisorName: '主管甲' }), row(2, { supervisorName: '' })],
|
||||
total: 2,
|
||||
items: [row(1, { supervisorName: '主管甲' }), row(2, { supervisorName: '主管甲' }), row(3, { supervisorName: '主管乙' })],
|
||||
total: 3,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
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('-', '读不到主管不猜名字,展示 -')
|
||||
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: [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: [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('导出按钮带当前过滤面与公司 tab 调导出接口,成功触发 blob 落盘', async () => {
|
||||
|
||||
Reference in New Issue
Block a user