refactor(phase-6): 拆分交付工作区与任务中心,五支队列 Tab 收敛到共享匹配表
- DeliveryVideoWorkspace 2690→2176 行,弹窗与结果面板下沉为 4 个子组件,类型抽到共享模块 - TaskCenterBoardPage 1017→834 行,任务表/变体表下沉,失败条与轮询入口留在页面 - 巡店删除/取款/查 ASIN/跟价/商品风险五支 Tab 共用 BrandShopMatchTable,纯逻辑收敛到 brand-shop-match-shared - admin manualChunks 增加 element-plus 分组(915KB 独立 chunk) - 源码钉按新落点更新:分页与表格断言读子组件,页面接线断言保留
This commit is contained in:
@@ -164,71 +164,16 @@
|
||||
>
|
||||
<template #cards-extra>
|
||||
<div class="subsection-title">匹配结果</div>
|
||||
<div v-if="!matchedItems.length" class="match-empty">
|
||||
完成“匹配店铺”后,这里会展示匹配结果。
|
||||
</div>
|
||||
<el-table
|
||||
v-else
|
||||
:data="pagedMatchedItems"
|
||||
:row-key="rowKeyForMatch"
|
||||
:highlight-current-row="false"
|
||||
class="result-table match-table"
|
||||
>
|
||||
<el-table-column prop="shopName" label="店铺名" min-width="120" />
|
||||
<el-table-column label="匹配" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="row.matched ? 'ok' : 'fail'">
|
||||
{{ row.matched ? "是" : "否" }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="shopId"
|
||||
label="店铺 ID"
|
||||
min-width="120"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="platform"
|
||||
label="平台"
|
||||
width="88"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="companyName"
|
||||
label="公司"
|
||||
min-width="120"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="状态" width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatMatchStatus(row.matchStatus) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatMatchRemark(row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<button
|
||||
type="button"
|
||||
class="link-danger"
|
||||
@click="removeMatchedRow(row)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="matchedTotal > matchedPageSize"
|
||||
class="matched-pagination"
|
||||
layout="total, prev, pager, next"
|
||||
<BrandShopMatchTable
|
||||
v-model:page="matchedPage"
|
||||
:items="pagedMatchedItems"
|
||||
:total="matchedTotal"
|
||||
:page-size="matchedPageSize"
|
||||
v-model:current-page="matchedPage"
|
||||
:row-key="rowKeyForMatch"
|
||||
:status-text="formatMatchStatus"
|
||||
:remark-text="formatMatchRemark"
|
||||
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
|
||||
@remove="removeMatchedRow"
|
||||
/>
|
||||
</template>
|
||||
<template #item-actions="{ item }">
|
||||
@@ -252,6 +197,15 @@ import { userNotice } from '@/shared/utils/user-notice'
|
||||
import { ElMessage } from "element-plus";
|
||||
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
||||
import TaskCenterPanel from "@/shared/components/tasks/TaskCenterPanel.vue";
|
||||
import BrandShopMatchTable from './BrandShopMatchTable.vue'
|
||||
import {
|
||||
formatMatchRemark,
|
||||
formatMatchStatus,
|
||||
historyItemKey,
|
||||
isTransientBackendError,
|
||||
rowKeyForMatch,
|
||||
uidForStorage,
|
||||
} from './brand-shop-match-shared'
|
||||
import type { TaskItemView, TaskStatCard } from "@/shared/components/tasks/types";
|
||||
import {
|
||||
addPatrolDeleteCandidate,
|
||||
@@ -405,11 +359,6 @@ const hasQueueWork = computed(
|
||||
!!activeTaskId.value,
|
||||
);
|
||||
|
||||
function uidForStorage() {
|
||||
return typeof window !== "undefined"
|
||||
? window.localStorage.getItem("uid") || "0"
|
||||
: "0";
|
||||
}
|
||||
|
||||
function matchedStorageKey() {
|
||||
return `patrol-delete:matched:${uidForStorage()}`;
|
||||
@@ -423,13 +372,7 @@ function countryCodesStorageKey() {
|
||||
return `patrol-delete:country-codes:${uidForStorage()}`;
|
||||
}
|
||||
|
||||
function rowKeyForMatch(row: PatrolDeleteShopQueueItem) {
|
||||
return `${(row.shopName || "").trim()}::${row.shopId || ""}`;
|
||||
}
|
||||
|
||||
function historyItemKey(item: PatrolDeleteHistoryItem) {
|
||||
return `${item.taskId ?? 0}:${item.resultId ?? 0}`;
|
||||
}
|
||||
|
||||
function taskGroupKey(item: PatrolDeleteHistoryItem) {
|
||||
return `task:${item.taskId ?? item.resultId ?? 0}`;
|
||||
@@ -453,20 +396,6 @@ function clearSleepTimers() {
|
||||
timers.clearCategory("queue-wait");
|
||||
}
|
||||
|
||||
function isTransientBackendError(error: unknown) {
|
||||
const message =
|
||||
error instanceof Error ? error.message.toLowerCase() : String(error || "").toLowerCase();
|
||||
return (
|
||||
message.includes("network error") ||
|
||||
message.includes("failed to fetch") ||
|
||||
message.includes("timeout") ||
|
||||
message.includes("503") ||
|
||||
message.includes("502") ||
|
||||
message.includes("504") ||
|
||||
message.includes("500") ||
|
||||
message.includes("load failed")
|
||||
);
|
||||
}
|
||||
|
||||
async function withTransientRetry<T>(
|
||||
action: () => Promise<T>,
|
||||
@@ -493,34 +422,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
|
||||
return `patrol-delete:${taskId}:${shopName || "shop"}:${Date.now()}`;
|
||||
}
|
||||
|
||||
function formatMatchStatus(status?: string) {
|
||||
const value = (status || "").trim();
|
||||
const map: Record<string, string> = {
|
||||
MATCHED: "已匹配",
|
||||
PENDING: "待匹配",
|
||||
CONFLICT: "需人工确认",
|
||||
INDEX_STALE: "匹配已过期",
|
||||
};
|
||||
return map[value] || value || "-";
|
||||
}
|
||||
|
||||
function formatMatchRemark(row: PatrolDeleteShopQueueItem) {
|
||||
const message = (row.matchMessage || "").trim();
|
||||
if (message) return message;
|
||||
if (row.matched && row.matchStatus === "MATCHED") {
|
||||
return "已匹配成功,可启动任务";
|
||||
}
|
||||
if (row.matched) {
|
||||
return "已匹配成功,请查看状态确认";
|
||||
}
|
||||
if (row.matchStatus === "CONFLICT") {
|
||||
return "存在多个同名店铺,请人工确认";
|
||||
}
|
||||
if (row.matchStatus === "PENDING") {
|
||||
return "店铺尚未匹配完成,请稍后查看";
|
||||
}
|
||||
return "未匹配成功,请检查店铺名";
|
||||
}
|
||||
|
||||
function buildTemplateCountrySections(): PatrolDeleteCountrySection[] {
|
||||
return selectedCountryNames.value.map((country) => ({
|
||||
|
||||
@@ -180,37 +180,21 @@
|
||||
>
|
||||
<template #cards-extra>
|
||||
<div class="subsection-title">匹配结果</div>
|
||||
<div v-if="!matchedItems.length" class="match-empty">完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。</div>
|
||||
<el-table v-else :data="pagedMatchedItems" :row-key="rowKeyForMatch" :highlight-current-row="false"
|
||||
class="result-table match-table">
|
||||
<el-table-column prop="shopName" label="店铺名" min-width="100" />
|
||||
<el-table-column label="匹配" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="row.matched ? 'ok' : 'fail'">{{ row.matched ? '是' : '否' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="shopId" label="店铺ID" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="platform" label="平台" width="88" show-overflow-tooltip />
|
||||
<el-table-column prop="companyName" label="公司" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="状态" width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatMatchStatus(row.matchStatus) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatMatchRemark(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<button type="button" class="link-danger" @click="removeMatchedRow(row)">删除</button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="matchedTotal > matchedPageSize"
|
||||
class="matched-pagination"
|
||||
layout="total, prev, pager, next"
|
||||
<BrandShopMatchTable
|
||||
v-model:page="matchedPage"
|
||||
:items="pagedMatchedItems"
|
||||
:total="matchedTotal"
|
||||
:page-size="matchedPageSize"
|
||||
v-model:current-page="matchedPage"
|
||||
:row-key="rowKeyForMatch"
|
||||
:status-text="formatMatchStatus"
|
||||
:remark-text="formatMatchRemark"
|
||||
empty-text="完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。"
|
||||
:shop-name-min-width="100"
|
||||
shop-id-label="店铺ID"
|
||||
:company-min-width="100"
|
||||
:status-width="100"
|
||||
:remark-min-width="140"
|
||||
@remove="removeMatchedRow"
|
||||
/>
|
||||
</template>
|
||||
<template #item-actions="{ item }">
|
||||
@@ -245,6 +229,7 @@ import {
|
||||
import ModuleTemplateDownload from '@/shared/components/ModuleTemplateDownload.vue'
|
||||
import FileUploadZone from '@/shared/components/FileUploadZone.vue'
|
||||
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
||||
import BrandShopMatchTable from './BrandShopMatchTable.vue'
|
||||
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
|
||||
import { getPywebviewApi, type PywebviewApi } from '@/shared/bridges/pywebview'
|
||||
import { useExcelFileUpload } from '@/shared/composables/useExcelFileUpload'
|
||||
@@ -940,7 +925,7 @@ async function runMatch() {
|
||||
}
|
||||
}
|
||||
|
||||
function formatMatchStatus(status: string | undefined) {
|
||||
function formatMatchStatus(status?: string | null) {
|
||||
const s = (status || '').trim()
|
||||
const map: Record<string, string> = { MATCHED: '已匹配', PENDING: '待匹配', CONFLICT: '需人工确认', INDEX_STALE: '匹配已过期' }
|
||||
return map[s] || (s ? s : '—')
|
||||
|
||||
@@ -99,37 +99,21 @@
|
||||
>
|
||||
<template #cards-extra>
|
||||
<div class="subsection-title">匹配结果</div>
|
||||
<div v-if="!matchedItems.length" class="match-empty">完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。</div>
|
||||
<el-table v-else :data="pagedMatchedItems" :row-key="rowKeyForMatch" :highlight-current-row="false"
|
||||
class="result-table match-table">
|
||||
<el-table-column prop="shopName" label="店铺名" min-width="100" />
|
||||
<el-table-column label="匹配" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="row.matched ? 'ok' : 'fail'">{{ row.matched ? '是' : '否' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="shopId" label="店铺ID" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="platform" label="平台" width="88" show-overflow-tooltip />
|
||||
<el-table-column prop="companyName" label="公司" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="状态" width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatMatchStatus(row.matchStatus) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatMatchRemark(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<button type="button" class="link-danger" @click="removeMatchedRow(row)">删除</button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="matchedTotal > matchedPageSize"
|
||||
class="matched-pagination"
|
||||
layout="total, prev, pager, next"
|
||||
<BrandShopMatchTable
|
||||
v-model:page="matchedPage"
|
||||
:items="pagedMatchedItems"
|
||||
:total="matchedTotal"
|
||||
:page-size="matchedPageSize"
|
||||
v-model:current-page="matchedPage"
|
||||
:row-key="rowKeyForMatch"
|
||||
:status-text="formatMatchStatus"
|
||||
:remark-text="formatMatchRemark"
|
||||
empty-text="完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。"
|
||||
:shop-name-min-width="100"
|
||||
shop-id-label="店铺ID"
|
||||
:company-min-width="100"
|
||||
:status-width="100"
|
||||
:remark-min-width="140"
|
||||
@remove="removeMatchedRow"
|
||||
/>
|
||||
</template>
|
||||
<template #item-actions="{ item }">
|
||||
@@ -155,6 +139,7 @@ import { userNotice } from '@/shared/utils/user-notice'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
||||
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
||||
import BrandShopMatchTable from './BrandShopMatchTable.vue'
|
||||
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
|
||||
import { LISTING_FILTER_OPTIONS, RISK_LISTING_FILTER_KEY, productRiskFilterIssues, type ListingFilterValue } from '@/pages/brand/components/listingFilters'
|
||||
import {
|
||||
@@ -1073,7 +1058,7 @@ async function downloadResult(item: ProductRiskHistoryItem) {
|
||||
}
|
||||
}
|
||||
|
||||
function formatMatchStatus(status: string | undefined) {
|
||||
function formatMatchStatus(status?: string | null) {
|
||||
const s = (status || '').trim()
|
||||
const map: Record<string, string> = {
|
||||
MATCHED: '已匹配',
|
||||
|
||||
@@ -116,71 +116,16 @@
|
||||
>
|
||||
<template #cards-extra>
|
||||
<div class="subsection-title">匹配结果</div>
|
||||
<div v-if="!matchedItems.length" class="match-empty">
|
||||
完成“匹配店铺”后,这里会展示匹配结果。
|
||||
</div>
|
||||
<el-table
|
||||
v-else
|
||||
:data="pagedMatchedItems"
|
||||
:row-key="rowKeyForMatch"
|
||||
:highlight-current-row="false"
|
||||
class="result-table match-table"
|
||||
>
|
||||
<el-table-column prop="shopName" label="店铺名" min-width="120" />
|
||||
<el-table-column label="匹配" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="row.matched ? 'ok' : 'fail'">
|
||||
{{ row.matched ? "是" : "否" }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="shopId"
|
||||
label="店铺 ID"
|
||||
min-width="120"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="platform"
|
||||
label="平台"
|
||||
width="88"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="companyName"
|
||||
label="公司"
|
||||
min-width="120"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="状态" width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatMatchStatus(row.matchStatus) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatMatchRemark(row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<button
|
||||
type="button"
|
||||
class="link-danger"
|
||||
@click="removeMatchedRow(row)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="matchedTotal > matchedPageSize"
|
||||
class="matched-pagination"
|
||||
layout="total, prev, pager, next"
|
||||
<BrandShopMatchTable
|
||||
v-model:page="matchedPage"
|
||||
:items="pagedMatchedItems"
|
||||
:total="matchedTotal"
|
||||
:page-size="matchedPageSize"
|
||||
v-model:current-page="matchedPage"
|
||||
:row-key="rowKeyForMatch"
|
||||
:status-text="formatMatchStatus"
|
||||
:remark-text="formatMatchRemark"
|
||||
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
|
||||
@remove="removeMatchedRow"
|
||||
/>
|
||||
</template>
|
||||
<template #item-actions="{ item }">
|
||||
@@ -205,6 +150,15 @@ import { ElMessage } from "element-plus";
|
||||
import type { TableInstance } from "element-plus";
|
||||
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
||||
import TaskCenterPanel from "@/shared/components/tasks/TaskCenterPanel.vue";
|
||||
import BrandShopMatchTable from './BrandShopMatchTable.vue'
|
||||
import {
|
||||
formatMatchRemark,
|
||||
formatMatchStatus,
|
||||
historyItemKey,
|
||||
isTransientBackendError,
|
||||
rowKeyForMatch,
|
||||
uidForStorage,
|
||||
} from './brand-shop-match-shared'
|
||||
import type { TaskItemView, TaskStatCard } from "@/shared/components/tasks/types";
|
||||
import {
|
||||
addQueryAsinCandidate,
|
||||
@@ -356,11 +310,6 @@ const hasQueuedTaskWork = computed(
|
||||
const hasQueueWork = computed(() => queueWorkerRunning.value || hasQueuedTaskWork.value);
|
||||
const isQueueBusy = computed(() => queueWorkerRunning.value && hasQueuedTaskWork.value);
|
||||
|
||||
function uidForStorage() {
|
||||
return typeof window !== "undefined"
|
||||
? window.localStorage.getItem("uid") || "0"
|
||||
: "0";
|
||||
}
|
||||
|
||||
function matchedStorageKey() {
|
||||
return `query-asin:matched:${uidForStorage()}`;
|
||||
@@ -374,13 +323,7 @@ function taskStartTimeStorageKey() {
|
||||
return `query-asin:start-times:${uidForStorage()}`;
|
||||
}
|
||||
|
||||
function rowKeyForMatch(row: QueryAsinShopQueueItem) {
|
||||
return `${(row.shopName || "").trim()}::${row.shopId || ""}`;
|
||||
}
|
||||
|
||||
function historyItemKey(item: QueryAsinHistoryItem) {
|
||||
return `${item.taskId ?? 0}:${item.resultId ?? 0}`;
|
||||
}
|
||||
|
||||
let disposed = false;
|
||||
|
||||
@@ -400,20 +343,6 @@ function clearSleepTimers() {
|
||||
timers.clearCategory("queue-wait");
|
||||
}
|
||||
|
||||
function isTransientBackendError(error: unknown) {
|
||||
const message =
|
||||
error instanceof Error ? error.message.toLowerCase() : String(error || "").toLowerCase();
|
||||
return (
|
||||
message.includes("network error") ||
|
||||
message.includes("failed to fetch") ||
|
||||
message.includes("timeout") ||
|
||||
message.includes("503") ||
|
||||
message.includes("502") ||
|
||||
message.includes("504") ||
|
||||
message.includes("500") ||
|
||||
message.includes("load failed")
|
||||
);
|
||||
}
|
||||
|
||||
async function withTransientRetry<T>(
|
||||
action: () => Promise<T>,
|
||||
@@ -440,34 +369,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
|
||||
return `query-asin:${taskId}:${shopName || "shop"}:${Date.now()}`;
|
||||
}
|
||||
|
||||
function formatMatchStatus(status?: string) {
|
||||
const value = (status || "").trim();
|
||||
const map: Record<string, string> = {
|
||||
MATCHED: "已匹配",
|
||||
PENDING: "待匹配",
|
||||
CONFLICT: "需人工确认",
|
||||
INDEX_STALE: "匹配已过期",
|
||||
};
|
||||
return map[value] || value || "-";
|
||||
}
|
||||
|
||||
function formatMatchRemark(row: QueryAsinShopQueueItem) {
|
||||
const message = (row.matchMessage || "").trim();
|
||||
if (message) return message;
|
||||
if (row.matched && row.matchStatus === "MATCHED") {
|
||||
return "已匹配成功,可启动任务";
|
||||
}
|
||||
if (row.matched) {
|
||||
return "已匹配成功,请查看状态确认";
|
||||
}
|
||||
if (row.matchStatus === "CONFLICT") {
|
||||
return "存在多个同名店铺,请人工确认";
|
||||
}
|
||||
if (row.matchStatus === "PENDING") {
|
||||
return "店铺尚未匹配完成,请稍后查看";
|
||||
}
|
||||
return "未匹配成功,请检查店铺名";
|
||||
}
|
||||
|
||||
function flattenQueryAsinRows(record: Pick<QueryAsinHistoryItem, "shopName" | "queryAsins">) {
|
||||
const sections = readQueryAsins(record);
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<script setup lang="ts" generic="T extends BrandShopMatchRow">
|
||||
import type { BrandShopMatchRow } from './brand-shop-match-shared'
|
||||
|
||||
const page = defineModel<number>('page', { required: true })
|
||||
|
||||
defineProps<{
|
||||
items: T[]
|
||||
total: number
|
||||
pageSize: number
|
||||
rowKey: (row: T) => string
|
||||
statusText: (status?: string | null) => string
|
||||
remarkText: (row: T) => string
|
||||
emptyText: string
|
||||
shopNameMinWidth?: number
|
||||
shopIdLabel?: string
|
||||
companyMinWidth?: number
|
||||
statusWidth?: number
|
||||
remarkMinWidth?: number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
remove: [T]
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="!items.length" class="match-empty">{{ emptyText }}</div>
|
||||
<template v-else>
|
||||
<el-table
|
||||
:data="items"
|
||||
:row-key="rowKey"
|
||||
:highlight-current-row="false"
|
||||
class="result-table match-table"
|
||||
>
|
||||
<el-table-column prop="shopName" label="店铺名" :min-width="shopNameMinWidth ?? 120" />
|
||||
<el-table-column label="匹配" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="row.matched ? 'ok' : 'fail'">
|
||||
{{ row.matched ? '是' : '否' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="shopId" :label="shopIdLabel ?? '店铺 ID'" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="platform" label="平台" width="88" show-overflow-tooltip />
|
||||
<el-table-column prop="companyName" label="公司" :min-width="companyMinWidth ?? 120" show-overflow-tooltip />
|
||||
<el-table-column label="状态" :width="statusWidth ?? 110" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ statusText(row.matchStatus) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" :min-width="remarkMinWidth ?? 180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ remarkText(row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<button type="button" class="link-danger" @click="emit('remove', row)">删除</button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="total > pageSize"
|
||||
class="matched-pagination"
|
||||
layout="total, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
v-model:current-page="page"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.match-empty {
|
||||
color: #5e6878;
|
||||
font-size: 13px;
|
||||
padding: 12px 8px;
|
||||
margin-bottom: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
.match-table {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.match-table :deep(.el-table__body tr:hover > td.el-table__cell),
|
||||
.match-table :deep(.el-table__body tr.hover-row > td.el-table__cell),
|
||||
.match-table :deep(.el-table__body tr.current-row > td.el-table__cell) {
|
||||
background-color: var(--el-table-tr-bg-color, #242424) !important;
|
||||
}
|
||||
.result-table {
|
||||
--el-table-bg-color: #242424;
|
||||
--el-table-tr-bg-color: #242424;
|
||||
--el-table-header-bg-color: #2e3a52;
|
||||
--el-table-text-color: #c8d2e2;
|
||||
--el-table-border-color: #333;
|
||||
}
|
||||
.ok {
|
||||
color: #27ae60;
|
||||
}
|
||||
.fail {
|
||||
color: #e67e22;
|
||||
}
|
||||
.link-danger {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #e74c3c;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
padding: 0;
|
||||
}
|
||||
.link-danger:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@@ -121,67 +121,16 @@
|
||||
完成“匹配店铺”后,这里会展示匹配结果。
|
||||
</div>
|
||||
<div v-else class="match-zone-scroll">
|
||||
<el-table
|
||||
:data="pagedMatchedItems"
|
||||
:row-key="rowKeyForMatch"
|
||||
:highlight-current-row="false"
|
||||
class="result-table match-table"
|
||||
>
|
||||
<el-table-column prop="shopName" label="店铺名" min-width="120" />
|
||||
<el-table-column label="匹配" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="row.matched ? 'ok' : 'fail'">
|
||||
{{ row.matched ? "是" : "否" }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="shopId"
|
||||
label="店铺 ID"
|
||||
min-width="120"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="platform"
|
||||
label="平台"
|
||||
width="88"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="companyName"
|
||||
label="公司"
|
||||
min-width="120"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="状态" width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatMatchStatus(row.matchStatus) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatMatchRemark(row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="72" align="center">
|
||||
<template #default="{ row }">
|
||||
<button
|
||||
type="button"
|
||||
class="link-danger"
|
||||
@click="removeMatchedRow(row)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="matchedTotal > matchedPageSize"
|
||||
class="matched-pagination"
|
||||
layout="total, prev, pager, next"
|
||||
<BrandShopMatchTable
|
||||
v-model:page="matchedPage"
|
||||
:items="pagedMatchedItems"
|
||||
:total="matchedTotal"
|
||||
:page-size="matchedPageSize"
|
||||
v-model:current-page="matchedPage"
|
||||
:row-key="rowKeyForMatch"
|
||||
:status-text="formatMatchStatus"
|
||||
:remark-text="formatMatchRemark"
|
||||
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
|
||||
@remove="removeMatchedRow"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -273,6 +222,15 @@ import { formatDateTime } from '@/shared/utils/datetime'
|
||||
import { RUNNING_UNTIL_DONE_STATUS_OPTIONS, taskStatusClass, taskStatusText } from '@/shared/utils/task-status-text'
|
||||
import { useHistoryPolling } from '@/shared/composables/useHistoryPolling'
|
||||
import { runBatchDelete } from '@/shared/utils/batch-delete'
|
||||
import BrandShopMatchTable from './BrandShopMatchTable.vue'
|
||||
import {
|
||||
formatMatchRemark,
|
||||
formatMatchStatus,
|
||||
historyItemKey,
|
||||
isTransientBackendError,
|
||||
rowKeyForMatch,
|
||||
uidForStorage,
|
||||
} from './brand-shop-match-shared'
|
||||
import { isRecordMissingError, parseTaskStartTimes, removeTaskStartTime, upsertTaskStartTime } from '@/shared/utils/task-queue-state.ts'
|
||||
import { useTablePaging } from '@/shared/composables/useTablePaging.ts'
|
||||
import { getModuleProgressLight } from '@/shared/api/progress-light.ts'
|
||||
@@ -389,11 +347,6 @@ function toWithdrawTaskView(item: WithdrawTaskGroupItem): TaskItemView {
|
||||
};
|
||||
}
|
||||
|
||||
function uidForStorage() {
|
||||
return typeof window !== "undefined"
|
||||
? window.localStorage.getItem("uid") || "0"
|
||||
: "0";
|
||||
}
|
||||
|
||||
function matchedStorageKey() {
|
||||
return `withdraw:matched:${uidForStorage()}`;
|
||||
@@ -407,13 +360,7 @@ function taskStartTimeStorageKey() {
|
||||
return `withdraw:start-times:${uidForStorage()}`;
|
||||
}
|
||||
|
||||
function rowKeyForMatch(row: WithdrawShopQueueItem) {
|
||||
return `${(row.shopName || "").trim()}::${row.shopId || ""}`;
|
||||
}
|
||||
|
||||
function historyItemKey(item: WithdrawHistoryItem) {
|
||||
return `${item.taskId ?? 0}:${item.resultId ?? 0}`;
|
||||
}
|
||||
|
||||
function batchKeyForItems(items: WithdrawShopQueueItem[]) {
|
||||
return items.map((item) => rowKeyForMatch(item)).join("||");
|
||||
@@ -513,20 +460,6 @@ function clearSleepTimers() {
|
||||
timers.clearCategory("queue-wait");
|
||||
}
|
||||
|
||||
function isTransientBackendError(error: unknown) {
|
||||
const message =
|
||||
error instanceof Error ? error.message.toLowerCase() : String(error || "").toLowerCase();
|
||||
return (
|
||||
message.includes("network error") ||
|
||||
message.includes("failed to fetch") ||
|
||||
message.includes("timeout") ||
|
||||
message.includes("503") ||
|
||||
message.includes("502") ||
|
||||
message.includes("504") ||
|
||||
message.includes("500") ||
|
||||
message.includes("load failed")
|
||||
);
|
||||
}
|
||||
|
||||
async function withTransientRetry<T>(
|
||||
action: () => Promise<T>,
|
||||
@@ -553,34 +486,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
|
||||
return `withdraw:${taskId}:${shopName || "shop"}:${Date.now()}`;
|
||||
}
|
||||
|
||||
function formatMatchStatus(status?: string) {
|
||||
const value = (status || "").trim();
|
||||
const map: Record<string, string> = {
|
||||
MATCHED: "已匹配",
|
||||
PENDING: "待匹配",
|
||||
CONFLICT: "需人工确认",
|
||||
INDEX_STALE: "匹配已过期",
|
||||
};
|
||||
return map[value] || value || "-";
|
||||
}
|
||||
|
||||
function formatMatchRemark(row: WithdrawShopQueueItem) {
|
||||
const message = (row.matchMessage || "").trim();
|
||||
if (message) return message;
|
||||
if (row.matched && row.matchStatus === "MATCHED") {
|
||||
return "已匹配成功,可启动任务";
|
||||
}
|
||||
if (row.matched) {
|
||||
return "已匹配成功,请查看状态确认";
|
||||
}
|
||||
if (row.matchStatus === "CONFLICT") {
|
||||
return "存在多个同名店铺,请人工确认";
|
||||
}
|
||||
if (row.matchStatus === "PENDING") {
|
||||
return "店铺尚未匹配完成,请稍后查看";
|
||||
}
|
||||
return "未匹配成功,请检查店铺名";
|
||||
}
|
||||
|
||||
function withWithdrawFallback<T extends WithdrawHistoryItem | WithdrawShopQueueItem>(
|
||||
item: T,
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/** 品牌队列类 Tab(巡店删除/取款/查 ASIN)共用的纯逻辑与存储口径。
|
||||
* 这三个页面历史上各抄一份,改一处漏两处;这里只收**逐字同形**的部分。 */
|
||||
|
||||
export type BrandShopMatchRow = {
|
||||
shopName?: string | null
|
||||
shopId?: number | string | null
|
||||
platform?: string | null
|
||||
companyName?: string | null
|
||||
matchStatus?: string | null
|
||||
matchMessage?: string | null
|
||||
matched?: boolean
|
||||
}
|
||||
|
||||
const TRANSIENT_BACKEND_ERROR_PATTERNS = [
|
||||
'network error',
|
||||
'failed to fetch',
|
||||
'timeout',
|
||||
'503',
|
||||
'502',
|
||||
'504',
|
||||
'500',
|
||||
'load failed',
|
||||
]
|
||||
|
||||
export function uidForStorage(): string {
|
||||
return typeof window !== 'undefined' ? window.localStorage.getItem('uid') || '0' : '0'
|
||||
}
|
||||
|
||||
export function isTransientBackendError(error: unknown): boolean {
|
||||
const message = (error instanceof Error ? error.message : String(error || '')).toLowerCase()
|
||||
return TRANSIENT_BACKEND_ERROR_PATTERNS.some((pattern) => message.includes(pattern))
|
||||
}
|
||||
|
||||
export function formatMatchStatus(status?: string | null): string {
|
||||
const value = (status || '').trim()
|
||||
const map: Record<string, string> = {
|
||||
MATCHED: '已匹配',
|
||||
PENDING: '待匹配',
|
||||
CONFLICT: '需人工确认',
|
||||
INDEX_STALE: '匹配已过期',
|
||||
}
|
||||
return map[value] || value || '-'
|
||||
}
|
||||
|
||||
export function formatMatchRemark(row: BrandShopMatchRow): string {
|
||||
const message = (row.matchMessage || '').trim()
|
||||
if (message) return message
|
||||
if (row.matched && row.matchStatus === 'MATCHED') return '已匹配成功,可启动任务'
|
||||
if (row.matched) return '已匹配成功,请查看状态确认'
|
||||
if (row.matchStatus === 'CONFLICT') return '存在多个同名店铺,请人工确认'
|
||||
if (row.matchStatus === 'PENDING') return '店铺尚未匹配完成,请稍后查看'
|
||||
return '未匹配成功,请检查店铺名'
|
||||
}
|
||||
|
||||
export function rowKeyForMatch(row: { shopName?: string | null; shopId?: number | string | null }): string {
|
||||
return `${(row.shopName || '').trim()}::${row.shopId || ''}`
|
||||
}
|
||||
|
||||
export function historyItemKey(item: { taskId?: number | null; resultId?: number | null }): string {
|
||||
return `${item.taskId ?? 0}:${item.resultId ?? 0}`
|
||||
}
|
||||
Reference in New Issue
Block a user