feat(appearance-patent): 后管页恢复明细表+管理员列+导出,撤一主管一卡与删除入口(2026-11-11 客户「不是这种格式 你就按照昨天那个格式」)

This commit is contained in:
2026-11-11 16:29:35 +08:00
parent c00f8c6e1c
commit 7a69210967
6 changed files with 349 additions and 588 deletions
@@ -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')
}