Files
crawler-plugin/admin-frontend-vue/src/pages/patent/AppearancePatentCleanItemsPage.vue
T
huangzd1997 83f1ecf952 feat(phase-3): 后管无侵权只读页——私有鉴权闸+readCompanyIdOrOwn 公司隔离+分页钳制;前端自绘表格页与路由/操作提示/五护栏同轮记账
后端:AdminAppearancePatentCleanItemsController(GET /api/admin/appearance-patent-clean-items,requireCleanItemsAccess 照去重页形状)+ AppearancePatentCleanItemQueryService(page≤10000/size≤100 钳制防 (page-1)*page_size 溢出)+两 VO;PageDefaults 第五种 page_size=10 显式登记。前端:AppearancePatentCleanItemsPage(自绘 table+OldPagination,companyScoped)+api/filter/model 拆件;routes/company-scope/operation-guides 收口。护栏:company-tab-wiring 24 处发送口、date-range-order 分母 21 实例/9 对、date-guard EXEMPT、ChunkRow 无侵权白名单四件(LlmClient 仍是唯一结论值来源)、SourceScan 52 支、G2 WIRED_PAGE_KEYS 第七支。判据修正:columnKey→getColumnKey 对齐代码库命名。
2026-11-10 02:27:50 +08:00

335 lines
9.9 KiB
Vue

<script setup lang="ts">
import { formatDateTime, orderedPair } from '@/utils/datetime'
/** 外观专利无侵权数据 · 只读分页列表(v1.3,展示形式参照「去重数据库」页:自绘 table +
* OldPagination,不做卡片宫格)。数据由出表成功点自动同步(后端 SyncService),本页零写操作:
* 无编辑/导入/导出,下载走既有结果直链/任务中心。 */
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { fetchAppearancePatentCleanList } 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)
/** 同步台账是累计数据,日期初值故意留空(默认当天会让首屏只剩今天同步的行);见 date-filter-default-today 护栏的 EXEMPT。 */
const filter = reactive(createAppearancePatentCleanFilterState())
/** 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)))
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,
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
}
}
function apply(): void {
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 = ''; page.value = 1; void load() })
onMounted(() => {
void load()
})
</script>
<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">
<label>任务号</label>
<input v-model="filter.taskId" type="text" placeholder="输入任务号" @keyup.enter="apply" />
</div>
<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">
<label>同步开始日期</label>
<input v-model="filter.startDate" type="date" :max="filter.endDate" @change="clampDatePair" />
</div>
<div class="form-group">
<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>
</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>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 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="9" class="empty-tip">加载中...</td>
</tr>
<tr v-else>
<td colspan="9" class="empty-tip">暂无无侵权数据</td>
</tr>
</tbody>
</table>
</div>
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
</section>
</div>
</template>
<style scoped>
/* 像素复刻参照「去重数据库」页(panel-box + 自绘表格 + 旧式分页),只读无操作列。 */
.clean-items-view {
font-family: inherit;
color: var(--c-text, #24384d);
display: flex;
flex-direction: column;
gap: 18px;
}
.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 16px;
font-size: 15px;
font-weight: 650;
color: #24384d;
letter-spacing: 0.2px;
}
.clean-panel-head h3 {
margin: 0 0 16px;
}
.clean-filter-row {
display: grid;
grid-template-columns: repeat(5, 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;
gap: 10px;
align-items: center;
white-space: nowrap;
}
.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.6;
}
.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;
}
.table-scroll th {
background: #edf4fa;
color: #4e6479;
border-bottom-color: #d5e1eb;
font-size: 12.5px;
font-weight: 600;
letter-spacing: 0.4px;
}
.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 {
padding: 44px 24px;
text-align: center;
color: #8293a5;
font-size: 13.5px;
}
</style>