527 lines
17 KiB
Vue
527 lines
17 KiB
Vue
<script setup lang="ts">
|
||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
||
/** 外观专利无侵权数据 · 只读分页列表(v1.3)。展示形式 2026-11-11 客户改版:参照「店铺数据记录」页
|
||
* (ShopDataTasksPage)——form-box 筛选条件 + panel-box 工具条[导出] + 卡片宫格(4/3/2/1 响应式)
|
||
* + OldPagination 服务端分页,推翻 2026-11-10「参照去重库页自绘 table」的旧拍板。
|
||
* 筛选面同日二次精简(客户「筛选条件只要…和获取店铺一样」「按账号对应的主管吧 不需要店铺」):
|
||
* 只留 分组(下拉,主管=组长,选中按「组长本人+名下子账户」整集 SQL 下推过滤)/国家/同步起止
|
||
* 时间,字段顺序对齐获取店铺页(分组→国家→时间);任务号/ASIN 输入框下架——后端 §3.2 参数契约
|
||
* (task_id/asin)与前端过滤模块逐字对撞护栏原样保留,只是 UI 不再暴露。数据由出表成功点
|
||
* 自动同步(后端 SyncService),本页零写操作:无编辑/导入;单条明细没有可下载文件,下载/导出
|
||
* 统一走既有 /export 全量出 xlsx(带当前过滤面 + 公司 tab,含所属主管列)。分组下拉选项与去重页
|
||
* 共用 GET /shop-manages/groups,选中后以 group_id 走同一过滤面(列表与导出同源)。 */
|
||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||
import {
|
||
exportAppearancePatentCleanList,
|
||
fetchAppearancePatentCleanList,
|
||
fetchDedupeTotalGroups,
|
||
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'
|
||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||
|
||
const companyTab = useCompanyTabStore()
|
||
|
||
const loading = ref(false)
|
||
const loadFailure = ref('')
|
||
const rows = ref<AppearancePatentCleanItem[]>([])
|
||
const total = ref(0)
|
||
const page = ref(1)
|
||
const pageSize = ref(10)
|
||
/** 导出在途锁:避免连点导出把同一份过滤面重复请求两遍。 */
|
||
const exporting = ref(false)
|
||
/** 同步台账是累计数据,日期初值故意留空(默认当天会让首屏只剩今天同步的行);见 date-filter-default-today 护栏的 EXEMPT。 */
|
||
const filter = reactive(createAppearancePatentCleanFilterState())
|
||
/** 分组(主管)下拉选项:公司 tab 切换时重取;选项失败不拦列表,只回空下拉(可见「全部分组」)。 */
|
||
const groupOptions = ref<DedupeGroupOption[]>([])
|
||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
||
function clampDatePair(): void {
|
||
const [s, e] = orderedPair(filter.startDate, filter.endDate)
|
||
filter.startDate = s
|
||
filter.endDate = e
|
||
}
|
||
|
||
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> {
|
||
try {
|
||
groupOptions.value = await fetchDedupeTotalGroups(companyTab.requestCompanyId)
|
||
} catch {
|
||
groupOptions.value = []
|
||
}
|
||
}
|
||
|
||
async function load(): Promise<void> {
|
||
loading.value = true
|
||
loadFailure.value = ''
|
||
try {
|
||
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,
|
||
})
|
||
rows.value = result.items
|
||
total.value = result.total
|
||
if (result.page >= 1) page.value = result.page
|
||
} catch (error) {
|
||
loadFailure.value = loadFailureMessage(error, '无侵权数据加载失败')
|
||
showAdminFeedback(loadFailure.value, 'error')
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
/** 导出与页签同一过滤面(含公司 tab 与分组),服务端全量出 xlsx;成功后浏览器落盘,失败弹可读文案。 */
|
||
async function exportAll(): Promise<void> {
|
||
if (exporting.value) return
|
||
exporting.value = true
|
||
try {
|
||
const result = await exportAppearancePatentCleanList({
|
||
taskId: filter.taskId,
|
||
asin: filter.asin,
|
||
country: filter.country,
|
||
groupId: filter.groupId,
|
||
startDate: filter.startDate,
|
||
endDate: filter.endDate,
|
||
companyId: companyTab.requestCompanyId,
|
||
})
|
||
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 : '导出失败,请稍后重试'
|
||
showAdminFeedback(message, 'error')
|
||
} finally {
|
||
exporting.value = false
|
||
}
|
||
}
|
||
|
||
function apply(): void {
|
||
page.value = 1
|
||
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
|
||
void load()
|
||
}
|
||
|
||
function changeSize(size: number) {
|
||
pageSize.value = size
|
||
page.value = 1
|
||
void load()
|
||
}
|
||
|
||
// 切公司 = 重新取数:任务号/ASIN/分组是上一家选中的值,在新一家的行集里筛不出东西,必须一起清,
|
||
// 分组选项也按新公司重取(选项集是公司隔离的)。
|
||
watch(() => companyTab.activeId, () => { filter.taskId = ''; filter.asin = ''; filter.groupId = ''; page.value = 1; void loadGroupOptions(); void load() })
|
||
|
||
onMounted(() => {
|
||
void loadGroupOptions()
|
||
void load()
|
||
})
|
||
</script>
|
||
|
||
<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>
|
||
<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" 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" style="min-width: 150px">
|
||
<label>同步开始日期</label>
|
||
<input v-model="filter.startDate" type="date" :max="filter.endDate" @change="clampDatePair" />
|
||
</div>
|
||
<div class="form-group" style="min-width: 150px">
|
||
<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-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>
|
||
|
||
<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" />
|
||
</section>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
/* 像素复刻参照「店铺数据记录」页(ShopDataTasksPage):form-box 筛选 + panel-box 工具条 +
|
||
卡片宫格 + 旧式分页,蓝白末层;只读卡片无勾选/无单卡操作(本页零写操作)。 */
|
||
.clean-items-view {
|
||
font-family: inherit;
|
||
color: #24384d;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 18px;
|
||
}
|
||
.form-box,
|
||
.panel-box {
|
||
width: 100%;
|
||
min-width: 0;
|
||
padding: 20px 22px 24px;
|
||
border: 1px solid #d8e3ee;
|
||
border-radius: 14px;
|
||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||
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;
|
||
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;
|
||
}
|
||
.form-row {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: flex-end;
|
||
gap: 14px 18px;
|
||
}
|
||
.form-group {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 7px;
|
||
margin-bottom: 0;
|
||
}
|
||
.form-group label {
|
||
color: #5b6f83;
|
||
font-size: 12.5px;
|
||
font-weight: 600;
|
||
}
|
||
.form-group input,
|
||
.form-group select {
|
||
min-width: 0;
|
||
min-height: 42px;
|
||
padding: 8px 12px;
|
||
border: 1px solid #cbd9e6;
|
||
border-radius: 9px;
|
||
background: #f8fbfd;
|
||
color: #24384d;
|
||
font-size: 13.5px;
|
||
font-family: inherit;
|
||
color-scheme: light;
|
||
outline: none;
|
||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||
}
|
||
.form-group input:hover,
|
||
.form-group select:hover {
|
||
border-color: #9fb7cd;
|
||
}
|
||
.form-group input:focus,
|
||
.form-group select:focus {
|
||
background: #ffffff;
|
||
border-color: #5f85ad;
|
||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||
}
|
||
.form-group input[type="date"] {
|
||
color-scheme: light;
|
||
}
|
||
.btn {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 8px;
|
||
min-height: 42px;
|
||
padding: 9px 18px;
|
||
border: 1px solid #4f78a5;
|
||
border-radius: 9px;
|
||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||
color: #ffffff;
|
||
font-family: inherit;
|
||
font-size: 13.5px;
|
||
cursor: pointer;
|
||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||
}
|
||
.btn:hover:not(:disabled) {
|
||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||
}
|
||
.btn:disabled {
|
||
cursor: not-allowed;
|
||
opacity: 0.55;
|
||
}
|
||
.btn-secondary {
|
||
background: #ffffff;
|
||
color: #5b6f83;
|
||
border-color: #c7d7e5;
|
||
}
|
||
.btn-secondary:hover:not(:disabled) {
|
||
color: #2f5d8b;
|
||
border-color: #95b1cb;
|
||
background: #edf5fb;
|
||
}
|
||
.clean-toolbar {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
flex-wrap: wrap;
|
||
margin-bottom: 14px;
|
||
}
|
||
.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;
|
||
}
|
||
.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;
|
||
gap: 10px;
|
||
padding: 6px 16px;
|
||
font-size: 13px;
|
||
}
|
||
.clean-card-label {
|
||
flex: none;
|
||
width: 60px;
|
||
color: #8293a5;
|
||
}
|
||
.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;
|
||
}
|
||
.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;
|
||
}
|
||
.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>
|