760 lines
27 KiB
Vue
760 lines
27 KiB
Vue
<script setup lang="ts">
|
||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
||
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
|
||
import {
|
||
activateJdCollectTask,
|
||
createJdCollectTask,
|
||
deleteJdCollectTask,
|
||
fetchJdCollectDashboard,
|
||
fetchJdCollectHistory,
|
||
fetchJdCollectTaskProgressBatch,
|
||
interruptJdCollectTask,
|
||
type JdCollectHistoryItemVo,
|
||
type JdListTab,
|
||
} from '@/shared/api/types/modules/jd-collect'
|
||
import { retryClientTask } from '@/shared/api/task-retry'
|
||
import { getPywebviewApi } from '@/shared/bridges/pywebview'
|
||
import { resolvePageHref } from '@/shared/page-prefix'
|
||
import { userNotice } from '@/shared/utils/user-notice'
|
||
import { formatDateTime } from '@/shared/utils/datetime'
|
||
import { useLiveTaskBoard } from '@/shared/composables/useLiveTaskBoard'
|
||
import NotificationBell from '@/shared/components/NotificationBell.vue'
|
||
import { JD_SHOP_CATEGORY_SNAPSHOT } from './jd-shop-category.ts'
|
||
|
||
/** 京东「获取店铺数据」(v1.5):一键建单 → 推送本机客户端 → 右侧任务面板实时进度。
|
||
*
|
||
* 四个真源与四条边界(照 v1.4 已落地的采集契约与外观专利任务面板骨架,不另造流程):
|
||
* 1. 建单走后端 `/api/jd-collect/tasks`(通道恒 LOCAL,服务端落 PENDING);可选多选采集
|
||
* 分类(京麦「店内分类」快照,`shopCategoryNames`/`shopCategoryIds` 双键)——空=全店
|
||
* 采集,选中值随建单进 request_json、随推送/兜底拉取进客户端,客户端按行
|
||
* shopCategorys/shopCategoryPath/groupId 等值过滤、任一键命中即命中(三处同键契约;
|
||
* 2026-11-16 类目级联按客户口径「类目不需要只要分类」下线,categoryPaths 仅历史行兼容);
|
||
* 2. 建单成功把 `jd-shop-collect-run` 载荷推进本机客户端队列——只建单不推送会让任务
|
||
* 卡在 PENDING 等兜底拉取(v1.4 Phase 6.1 P0-1 的教训);推送失败不回滚建单;
|
||
* 3. 进度只读服务端:任务状态 + 合并写游标里的 itemsReceived/total。`total` 缺失时
|
||
* 卡片只显示已采集行数,不编造百分比;
|
||
* 4. 失败/中断任务「重试/继续」走通用原位复位(铁律 26,保留已收分片与断点游标),
|
||
* 复位后页面重新激活并推队列——同一份输入不再多出好几行结果。
|
||
*
|
||
* 2026-11-16 客户口径「管理员弄了多少店铺分类 普通账户都能看到」落点改为本多选块:
|
||
* 客户的参照系是京麦后台的「店内分类」(getShopCategoryList 快照),不再是后管平台分组
|
||
* (平台分组接口从本页下线,分组数据面归京东数据库与商品上架)。
|
||
*/
|
||
|
||
/** 页面不再让用户填店铺名:店铺名称由客户端从京麦后台读,建单先按此占位记录。 */
|
||
const DEFAULT_SHOP_NAME = '京麦后台'
|
||
const DEFAULT_TABS: JdListTab[] = ['ONSALE', 'OFFSALE']
|
||
|
||
const homeHref = resolvePageHref('/new_web_source/home.html')
|
||
const backHref = resolvePageHref('/new_web_source/jd-console.html')
|
||
|
||
const username = ref('admin')
|
||
const submitting = ref(false)
|
||
const errorMessage = ref('')
|
||
const successMessage = ref('')
|
||
|
||
// ---- 采集分类(可选,下拉多选;空=全店采集)----
|
||
/** 选项集=京麦「店内分类」快照(getShopCategoryList,2026-11-16 真机取证 9 个;
|
||
* 京麦侧改分类后按取证路重抓,见 jd-shop-category.ts 头注释——快照不会自动过期告警)。
|
||
* 2026-11-17 客户口径「不要全展示出来,弄个下拉式多选」:复选列表换 el-select 多选
|
||
* (collapse-tags 折叠成「+N」徽标),选择模型改存分类 id 数组,label/id 双键从快照反查。 */
|
||
const shopCategoryOptions = JD_SHOP_CATEGORY_SNAPSHOT
|
||
const selectedShopCategoryValues = ref<string[]>([])
|
||
|
||
function clearShopCategories() {
|
||
selectedShopCategoryValues.value = []
|
||
}
|
||
|
||
/** 选中项按快照原序反查回对象(下拉里点选的先后不进请求体——双键顺序恒等于快照序)。 */
|
||
const selectedShopCategories = computed(() =>
|
||
shopCategoryOptions.filter((item) => selectedShopCategoryValues.value.includes(item.value)),
|
||
)
|
||
|
||
/** 建单/推送载荷的选中值:label 与 id 双键同发(行级填充形状未取证,任一键命中即命中)。 */
|
||
const selectedShopCategoryNames = computed(() => selectedShopCategories.value.map((item) => item.label))
|
||
const selectedShopCategoryIds = computed(() => selectedShopCategories.value.map((item) => item.value))
|
||
|
||
function uidForStorage() {
|
||
return typeof window !== 'undefined' ? window.localStorage.getItem('uid') || '0' : '0'
|
||
}
|
||
|
||
// ---- 实时任务面板(与外观专利共用 useLiveTaskBoard 骨架;京东无结果文件,无下载层)----
|
||
const board = useLiveTaskBoard<JdCollectHistoryItemVo>({
|
||
scope: 'jd-collect',
|
||
pollingStorageKey: () => `jd-collect:tasks:${uidForStorage()}`,
|
||
fetchHistory: fetchJdCollectHistory,
|
||
fetchProgressBatch: fetchJdCollectTaskProgressBatch,
|
||
fetchDashboard: fetchJdCollectDashboard,
|
||
normalizeTaskStatus,
|
||
// 京东采集没有结果文件:状态到终态即结束,没有「等文件」那一层
|
||
isResultPreparing: () => false,
|
||
addPendingAfterFinalStatus: () => false,
|
||
keepPendingFileTask: () => false,
|
||
// CANCELLED 也是终态:中断的任务出「继续」按钮并停止轮询,不收手会一直烧进度请求
|
||
settleOnTaskStatuses: ['SUCCESS', 'FAILED', 'CANCELLED'],
|
||
deleteTask: {
|
||
shouldDeleteTask: (item) => item.taskId != null,
|
||
deleteTask: (taskId) => deleteJdCollectTask(taskId),
|
||
deleteHistory: async () => undefined,
|
||
onTaskDeleted: (item) => board.removePollingTask(item.taskId as number),
|
||
},
|
||
})
|
||
|
||
const { batchDeleteHistory, deleteTaskRecord } = board
|
||
|
||
const jdCards = computed<TaskStatCard[]>(() => [
|
||
{ label: '运行中任务', value: board.dashboard.value.pendingTaskCount },
|
||
{ label: '已结束任务', value: board.dashboard.value.processedTaskCount },
|
||
{ label: '成功任务', value: board.dashboard.value.successTaskCount },
|
||
{ label: '失败任务', value: board.dashboard.value.failedTaskCount },
|
||
])
|
||
|
||
const currentTaskViews = computed<TaskItemView[]>(() =>
|
||
board.currentItems.value.map(toJdTaskView),
|
||
)
|
||
const historyTaskViews = computed<TaskItemView[]>(() =>
|
||
board.historyOnlyItems.value.map(toJdTaskView),
|
||
)
|
||
|
||
function itemSource(item: TaskItemView) {
|
||
return item.source as JdCollectHistoryItemVo
|
||
}
|
||
|
||
function toJdTaskView(item: JdCollectHistoryItemVo): TaskItemView {
|
||
const showProgress = isActiveTask(item)
|
||
return {
|
||
key: `jd-${item.taskId ?? item.taskNo ?? item.updatedAt ?? ''}`,
|
||
title: item.shopName || '京东店铺采集',
|
||
taskId: item.taskId ?? '-',
|
||
startedAt: formatDateTime(item.createdAt),
|
||
finishedAt: formatDateTime(item.finishedAt),
|
||
statusText: statusText(item),
|
||
statusClass: statusClass(item),
|
||
extraLines: [
|
||
...(item.rowCount != null ? [`已采集 ${item.rowCount} 个商品`] : []),
|
||
...(showProgress && typeof item.page === 'number' && item.page > 0
|
||
? [`断点游标:第 ${item.page} 页 · 已回传 ${item.batches ?? 0} 批`]
|
||
: []),
|
||
...(item.errorMessage ? [`错误:${userNotice(item.errorMessage)}`] : []),
|
||
],
|
||
progress: showProgress ? { percent: progressPercent(item), countLabel: progressCountLabel(item) } : null,
|
||
source: item,
|
||
}
|
||
}
|
||
|
||
// ---- 本模块的状态语义(京东采集:无结果文件,状态即终态)----
|
||
|
||
function normalizeTaskStatus(item: JdCollectHistoryItemVo | null | undefined) {
|
||
return (item?.taskStatus || '').toUpperCase()
|
||
}
|
||
|
||
function isActiveTask(item: JdCollectHistoryItemVo) {
|
||
const status = normalizeTaskStatus(item)
|
||
return status === 'PENDING' || status === 'RUNNING' || status === 'SCHEDULED'
|
||
}
|
||
|
||
function statusText(item: JdCollectHistoryItemVo) {
|
||
const status = normalizeTaskStatus(item)
|
||
if (status === 'RUNNING') return '正在获取店铺数据…'
|
||
if (status === 'PENDING') return '等待本机客户端领取任务…'
|
||
if (status === 'SCHEDULED') return '已排队,等待执行'
|
||
if (status === 'CANCELLED') return '已中断'
|
||
if (status === 'FAILED') return '获取失败'
|
||
if (status === 'SUCCESS' || item.success) return '获取完成'
|
||
return '等待中'
|
||
}
|
||
|
||
function statusClass(item: JdCollectHistoryItemVo) {
|
||
const status = normalizeTaskStatus(item)
|
||
if (status === 'FAILED') return 'failed'
|
||
if (status === 'RUNNING' || status === 'SCHEDULED') return 'running'
|
||
if (status === 'CANCELLED') return 'pending'
|
||
if (status === 'SUCCESS' || item.success) return 'success'
|
||
return 'pending'
|
||
}
|
||
|
||
/** 百分比:有 total 按已落库商品数算(封顶 99 直到服务端落 SUCCESS);没有 total 不编造分母。 */
|
||
function progressPercent(item: JdCollectHistoryItemVo) {
|
||
const status = normalizeTaskStatus(item)
|
||
if (status === 'SUCCESS') return 100
|
||
const total = typeof item.total === 'number' && item.total > 0 ? item.total : null
|
||
if (!total) return 0
|
||
const done = Math.min(item.itemsReceived ?? 0, total)
|
||
return Math.max(0, Math.min(99, Math.round((done * 100) / total)))
|
||
}
|
||
|
||
/** 计数文案:有 total 带分母和百分比「已采集 30/100 个商品(30%)」——TaskItemCard 的
|
||
* countLabel 会顶掉「总进度 X%」那行字,百分比只能随 countLabel 一起出;
|
||
* 没有 total 保持只报行数,不编造分母(与本页 progressPercent 同一口径)。 */
|
||
function progressCountLabel(item: JdCollectHistoryItemVo) {
|
||
const received = item.itemsReceived ?? item.rowCount ?? 0
|
||
const total = typeof item.total === 'number' && item.total > 0 ? item.total : null
|
||
if (!total) return `已采集 ${received} 个商品`
|
||
return `已采集 ${received}/${total} 个商品(${progressPercent(item)}%)`
|
||
}
|
||
|
||
/** 失败/已中断的任务能续跑:在原任务上复位(不新建任务),成功/进行中的任务不该出现这个按钮。 */
|
||
function canRetryTask(item: JdCollectHistoryItemVo | null | undefined): boolean {
|
||
if (!item?.taskId) return false
|
||
const status = normalizeTaskStatus(item)
|
||
return status === 'FAILED' || status === 'CANCELLED'
|
||
}
|
||
|
||
/** 按钮文案:已中断的任务显示「继续」(从断点接着跑),失败任务仍是「重试」。 */
|
||
function retryLabel(item: JdCollectHistoryItemVo | null | undefined): string {
|
||
return normalizeTaskStatus(item) === 'CANCELLED' ? '继续' : '重试'
|
||
}
|
||
|
||
/** 在跑/待跑的任务可中断:PENDING/RUNNING/SCHEDULED 是服务端 CAS 的同一 ACTIVE 集合。 */
|
||
function canInterruptTask(item: JdCollectHistoryItemVo | null | undefined): boolean {
|
||
if (!item?.taskId) return false
|
||
const status = normalizeTaskStatus(item)
|
||
return status === 'PENDING' || status === 'RUNNING' || status === 'SCHEDULED'
|
||
}
|
||
|
||
async function interruptTaskRecord(item: JdCollectHistoryItemVo | null | undefined) {
|
||
const taskId = item?.taskId
|
||
if (!taskId) return
|
||
// 确认框取消走 reject 两臂(与外观专利同口径,不新增 catch 块)
|
||
const confirmed = await ElMessageBox.confirm(
|
||
'中断后:本机客户端会停止采集,已采集的数据保留在京东数据库。确定中断吗?',
|
||
'中断任务',
|
||
{ type: 'warning', confirmButtonText: '中断', cancelButtonText: '先不中断' },
|
||
).then(
|
||
() => true,
|
||
() => false,
|
||
)
|
||
if (!confirmed) return
|
||
try {
|
||
await interruptJdCollectTask(taskId)
|
||
ElMessage.success('已中断:客户端下一跳心跳后收手,之后可点「继续」接着跑')
|
||
await refreshBoard()
|
||
} catch (error) {
|
||
ElMessage.error(error instanceof Error ? error.message : '中断失败')
|
||
}
|
||
}
|
||
|
||
async function retryTaskRecord(item: JdCollectHistoryItemVo | null | undefined) {
|
||
const taskId = item?.taskId
|
||
if (!taskId) return
|
||
const isResume = normalizeTaskStatus(item) === 'CANCELLED'
|
||
try {
|
||
await retryClientTask(taskId)
|
||
ElMessage.success(isResume
|
||
? '已继续:在这条任务上接着跑(断点游标保留,不重复采集)'
|
||
: '已提交重试:在这条任务上继续跑(不新建任务)')
|
||
// 复位是 PENDING:与建单同一条激活+推队列链路,客户端才会立刻领到这一单。
|
||
// 激活/推送失败不回滚复位——任务留在 PENDING 由客户端兜底拉取认领。
|
||
const activateError = await activateTask(taskId)
|
||
if (!activateError) {
|
||
await pushToClientQueue(taskId, item?.shopName || DEFAULT_SHOP_NAME,
|
||
(item?.listTabs?.length ? item.listTabs : DEFAULT_TABS) as JdListTab[],
|
||
item?.shopCategoryNames ?? [], item?.shopCategoryIds ?? [])
|
||
}
|
||
board.addPollingTask(taskId)
|
||
await refreshBoard()
|
||
} catch (error) {
|
||
ElMessage.error(error instanceof Error ? error.message : '重试失败')
|
||
}
|
||
}
|
||
|
||
/** 手动刷新:强拉历史 + 统计 + 当前轮询任务进度(轮询意外中断后的自救出口) */
|
||
async function refreshBoard() {
|
||
await Promise.all([
|
||
board.loadDashboard(),
|
||
board.loadHistory({ force: true }),
|
||
board.refreshTaskProgress(),
|
||
])
|
||
}
|
||
|
||
/** 激活任务(PENDING→RUNNING),返回 null 表示可推队列,返回 string 表示失败原因。
|
||
*
|
||
* 2026-11-14 真机实录:页面建完单直接推客户端,任务还是 PENDING ⇒ 客户端第一个分片被
|
||
* 「任务不在运行中(PENDING)」拒收、心跳回 alive=false 要求客户端收手,采集白跑一轮。
|
||
*/
|
||
async function activateTask(id: number): Promise<string | null> {
|
||
try {
|
||
await activateJdCollectTask(id)
|
||
return null
|
||
} catch (err) {
|
||
const text = err instanceof Error ? err.message : ''
|
||
// 客户端兜底拉取已原子认领(PENDING→RUNNING)时后端回这句:等同激活成功,不当失败展示。
|
||
if (text.includes('已在执行中')) {
|
||
return null
|
||
}
|
||
console.error('[jd-collect] 激活任务失败', err)
|
||
return '任务激活失败,本机客户端领不到这一单,请稍后重试'
|
||
}
|
||
}
|
||
|
||
/** 建单成功后推送本机队列;返回 null 表示环境无队列能力(浏览器预览),返回 string 表示失败原因。
|
||
* shopCategoryNames/Ids 是建单时选的京麦店内分类(重试/继续从历史行同源带回)——推送载荷
|
||
* 与建单请求体、客户端兜底拉取(request_json)三处同键,缺一处客户端就按全店采集跑。 */
|
||
async function pushToClientQueue(
|
||
id: number,
|
||
shop: string,
|
||
tabs: JdListTab[],
|
||
shopCategoryNames: string[] = [],
|
||
shopCategoryIds: string[] = [],
|
||
): Promise<string | null> {
|
||
const api = getPywebviewApi()
|
||
if (!api?.enqueue_json) {
|
||
return '当前环境未启用任务队列能力(浏览器预览环境不会启动),请在本机客户端中打开本页'
|
||
}
|
||
const payload = {
|
||
type: 'jd-shop-collect-run',
|
||
ts: Date.now(),
|
||
data: { taskId: id, shopName: shop, listTabs: tabs, maxProducts: 0, shopCategoryNames, shopCategoryIds },
|
||
}
|
||
const pushResult = await api.enqueue_json(payload)
|
||
if (pushResult?.success) {
|
||
return null
|
||
}
|
||
// 桥返回的 error 原文(系统/英文)不透传进界面:console 留链,界面固定中文动作句
|
||
if (pushResult?.error) {
|
||
console.error('[jd-collect] enqueue_json 被拒', pushResult.error)
|
||
}
|
||
return '推送本机队列失败,任务将由客户端兜底拉取认领'
|
||
}
|
||
|
||
const isRunning = computed(() => Boolean(board.dashboard.value.pendingTaskCount) || submitting.value)
|
||
|
||
async function startCollect() {
|
||
if (submitting.value) return
|
||
errorMessage.value = ''
|
||
successMessage.value = ''
|
||
submitting.value = true
|
||
const shop = DEFAULT_SHOP_NAME
|
||
const tabs = DEFAULT_TABS
|
||
const shopNames = [...selectedShopCategoryNames.value]
|
||
const shopIds = [...selectedShopCategoryIds.value]
|
||
try {
|
||
const vo = await createJdCollectTask(shop, tabs, 0, [], shopNames, shopIds)
|
||
board.addPollingTask(vo.taskId)
|
||
let pushNote = ''
|
||
const activateError = await activateTask(vo.taskId)
|
||
if (activateError) {
|
||
// 没激活成功就不推队列:推了也是白跑一轮(分片全被拒)。任务留在 PENDING,
|
||
// 由服务端兜底拉取认领后照样会跑,所以这里只提示、不回滚建单。
|
||
pushNote = activateError
|
||
} else {
|
||
try {
|
||
const pushError = await pushToClientQueue(vo.taskId, shop, tabs, shopNames, shopIds)
|
||
if (pushError) pushNote = pushError
|
||
} catch (pushErr) {
|
||
// 推送自身异常不回滚建单:任务可由服务端兜底拉取认领。
|
||
pushNote = '推送本机队列失败,任务将由服务端兜底派发给本机客户端执行'
|
||
console.error('[jd-collect] 推送本机队列失败', pushErr)
|
||
}
|
||
}
|
||
if (pushNote) {
|
||
errorMessage.value = pushNote
|
||
} else {
|
||
successMessage.value = shopNames.length
|
||
? `任务已创建(只采 ${shopNames.length} 个分类)并推送给本机客户端,进度显示在右侧任务区`
|
||
: '任务已创建并推送给本机客户端,进度显示在右侧任务区'
|
||
}
|
||
await Promise.all([board.loadDashboard(), board.loadHistory({ force: true })])
|
||
} catch (err) {
|
||
errorMessage.value = err instanceof Error ? err.message : '建单失败,请稍后重试'
|
||
} finally {
|
||
submitting.value = false
|
||
}
|
||
}
|
||
|
||
onMounted(async () => {
|
||
const localName = (window.localStorage.getItem('username') || '').trim()
|
||
if (localName) username.value = localName
|
||
board.loadPollingIds()
|
||
await Promise.all([
|
||
board.loadDashboard().catch(() => undefined),
|
||
board.loadHistory().catch(() => undefined),
|
||
])
|
||
board.seedRunningTasksFromHistory()
|
||
board.seedPendingFileTasksFromHistory()
|
||
board.ensurePollingIfAny()
|
||
})
|
||
|
||
onUnmounted(() => {
|
||
board.dispose()
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<div class="page-shell module-page jd-collect-page">
|
||
<header class="jd-top">
|
||
<router-link class="home-back" :to="homeHref" title="返回首页">← 返回首页</router-link>
|
||
|
||
<div class="brand">
|
||
<span class="brand-logo">富</span>
|
||
<span class="brand-text">
|
||
<span class="brand-name">数富AI</span>
|
||
<span class="brand-sub">京东运营工具台</span>
|
||
</span>
|
||
</div>
|
||
|
||
<div class="top-right">
|
||
<NotificationBell />
|
||
<span class="admin-name">{{ username }}</span>
|
||
</div>
|
||
</header>
|
||
|
||
<div class="tool-head">
|
||
<router-link class="tool-head__back" :to="backHref">← 返回京东工具台</router-link>
|
||
<span class="tool-head__title">获取店铺数据</span>
|
||
<span class="tool-head__desc">
|
||
一键抓取已登录京麦后台的店铺商品(列表 + 详情全部属性 + 图片),导入后台「京东数据库」。
|
||
</span>
|
||
</div>
|
||
|
||
<main class="jd-body">
|
||
<aside class="left-panel">
|
||
<div class="category-block">
|
||
<span class="category-label">采集分类(可选,多选)</span>
|
||
<el-select v-model="selectedShopCategoryValues" multiple collapse-tags collapse-tags-tooltip
|
||
:max-collapse-tags="1" placeholder="全店采集(点击选择分类)" class="shop-cat-select">
|
||
<el-option v-for="category in shopCategoryOptions" :key="category.value"
|
||
:label="category.label" :value="category.value" />
|
||
</el-select>
|
||
<p class="category-hint">
|
||
{{ selectedShopCategoryValues.length
|
||
? `只采选中 ${selectedShopCategoryValues.length} 个分类的商品;`
|
||
: '默认全店采集。' }}
|
||
分类是京麦后台「店内分类」(2026-11-16 快照);商品要先在京麦挂上分类才会被选中。
|
||
<button v-if="selectedShopCategoryValues.length" class="shop-cat-clear" type="button"
|
||
@click="clearShopCategories">清空</button>
|
||
</p>
|
||
</div>
|
||
|
||
<button class="collect-btn" type="button" :disabled="isRunning" @click="startCollect">
|
||
{{ isRunning ? '获取中…' : (selectedShopCategories.length ? `获取选中分类数据` : '一键获取店铺数据') }}
|
||
</button>
|
||
|
||
<p class="collect-hint">
|
||
点击后本机客户端会自动打开已登录的京麦后台采集商品,请保持客户端在线且京麦已登录;
|
||
采集到的数据会实时回传并导入后台「京东数据库」。进度显示在右侧任务区。
|
||
</p>
|
||
|
||
<p v-if="successMessage" class="feedback success">{{ successMessage }}</p>
|
||
<p v-if="errorMessage" class="feedback error">{{ errorMessage }}</p>
|
||
</aside>
|
||
|
||
<section class="right-panel">
|
||
<TaskCenterPanel
|
||
:on-batch-delete="batchDeleteHistory"
|
||
:on-refresh="refreshBoard"
|
||
title="获取店铺数据"
|
||
:cards="jdCards"
|
||
:current-items="currentTaskViews"
|
||
:history-items="historyTaskViews"
|
||
current-title="当前任务"
|
||
current-empty-text="暂无当前任务"
|
||
history-empty-text="暂无历史记录"
|
||
>
|
||
<template #item-actions="{ item }">
|
||
<button v-if="canInterruptTask(itemSource(item))" type="button" class="btn-interrupt"
|
||
@click="interruptTaskRecord(itemSource(item))">中断</button>
|
||
<button v-if="canRetryTask(itemSource(item))" type="button" class="btn-retry"
|
||
@click="retryTaskRecord(itemSource(item))">{{ retryLabel(itemSource(item)) }}</button>
|
||
<button type="button" class="btn-delete" @click="deleteTaskRecord(itemSource(item))">删除</button>
|
||
</template>
|
||
<template #history-item-actions="{ item }">
|
||
<button v-if="canInterruptTask(itemSource(item))" type="button" class="btn-interrupt"
|
||
@click="interruptTaskRecord(itemSource(item))">中断</button>
|
||
<button v-if="canRetryTask(itemSource(item))" type="button" class="btn-retry"
|
||
@click="retryTaskRecord(itemSource(item))">{{ retryLabel(itemSource(item)) }}</button>
|
||
<button v-if="itemSource(item).taskId" type="button" class="btn-delete"
|
||
@click="deleteTaskRecord(itemSource(item))">删除</button>
|
||
</template>
|
||
</TaskCenterPanel>
|
||
</section>
|
||
</main>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.jd-collect-page {
|
||
display: flex;
|
||
flex-direction: column;
|
||
min-height: 100vh;
|
||
background-color: #1a1f2e;
|
||
background-image: radial-gradient(rgba(45, 212, 191, 0.08) 1px, transparent 1px);
|
||
background-size: 48px 48px;
|
||
font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "微软雅黑", sans-serif;
|
||
}
|
||
|
||
.jd-top {
|
||
flex: 0 0 auto;
|
||
min-height: 64px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 20px;
|
||
padding: 0 28px;
|
||
background: #1a1f2e;
|
||
border-bottom: 1px solid #3e4a62;
|
||
}
|
||
|
||
/* 首页返回与工具台返回按钮同款样式,合并声明 */
|
||
.home-back,
|
||
.tool-head__back {
|
||
flex-shrink: 0;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
padding: 6px 14px;
|
||
border: 1px solid #3e4a62;
|
||
border-radius: 6px;
|
||
color: #c8d2e2;
|
||
font-size: 13px;
|
||
text-decoration: none;
|
||
white-space: nowrap;
|
||
transition: all 0.2s;
|
||
}
|
||
|
||
.home-back:hover,
|
||
.tool-head__back:hover {
|
||
background: #2b3447;
|
||
color: #f5f8fc;
|
||
}
|
||
|
||
.brand {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.brand-logo {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 38px;
|
||
height: 38px;
|
||
border-radius: 8px;
|
||
background: #e1251b;
|
||
color: #fff;
|
||
font-size: 20px;
|
||
font-weight: 700;
|
||
box-shadow: 0 2px 8px rgba(225, 37, 27, 0.32);
|
||
}
|
||
|
||
.brand-text {
|
||
display: flex;
|
||
flex-direction: column;
|
||
line-height: 1.35;
|
||
}
|
||
|
||
.brand-name {
|
||
color: #f5f8fc;
|
||
font-size: 17px;
|
||
font-weight: 700;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.brand-sub {
|
||
color: #a0acbe;
|
||
font-size: 10px;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.top-right {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 14px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.admin-name {
|
||
color: #c8d2e2;
|
||
font-size: 13px;
|
||
font-weight: 700;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.tool-head {
|
||
flex: 0 0 auto;
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 20px;
|
||
min-height: 62px;
|
||
padding: 10px 34px;
|
||
background: #1a1f2e;
|
||
}
|
||
|
||
.tool-head__title {
|
||
flex-shrink: 0;
|
||
color: #f5f8fc;
|
||
font-size: 22px;
|
||
font-weight: 700;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.tool-head__desc {
|
||
min-width: 0;
|
||
max-width: 760px;
|
||
color: #a0acbe;
|
||
font-size: 14px;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
/* ===== 左按钮 + 右任务面板(照外观专利 Tab 布局)===== */
|
||
.jd-body {
|
||
flex: 1 1 auto;
|
||
min-height: 0;
|
||
display: flex;
|
||
align-items: stretch;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.left-panel {
|
||
width: 400px;
|
||
flex-shrink: 0;
|
||
padding: 20px;
|
||
overflow-y: auto;
|
||
border-right: 1px solid #3e4a62;
|
||
}
|
||
|
||
.right-panel {
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow-y: auto;
|
||
padding: 20px;
|
||
}
|
||
|
||
.collect-btn {
|
||
width: 100%;
|
||
padding: 13px 0;
|
||
border: none;
|
||
border-radius: 8px;
|
||
background: linear-gradient(135deg, #ff5a4f, #e1251b);
|
||
color: #ffffff;
|
||
font-size: 16px;
|
||
font-weight: 700;
|
||
font-family: inherit;
|
||
cursor: pointer;
|
||
box-shadow: 0 4px 16px rgba(225, 37, 27, 0.32);
|
||
transition: all 0.2s;
|
||
}
|
||
|
||
/* 类目选择块:与按钮同宽,label 用面板小字口径。 */
|
||
.category-block {
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.category-label {
|
||
display: block;
|
||
margin-bottom: 8px;
|
||
color: #c8d2e2;
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.category-hint {
|
||
margin: 8px 0 0;
|
||
color: #7f8ca3;
|
||
font-size: 12px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
/* 采集分类下拉多选(2026-11-17 客户口径「别全展示,弄下拉式多选」):
|
||
* 暗色主题套品牌页 el-select 同款壳(wrapper 底色/描边/文字色),
|
||
* 面板内弹层由 Element Plus 自带样式,不再逐条铺 9 行复选框。 */
|
||
.shop-cat-select {
|
||
width: 100%;
|
||
}
|
||
|
||
.shop-cat-select :deep(.el-select__wrapper) {
|
||
background-color: #232b3d;
|
||
box-shadow: 0 0 0 1px #3e4a62 inset;
|
||
}
|
||
|
||
.shop-cat-select :deep(.el-select__placeholder),
|
||
.shop-cat-select :deep(.el-select__selected-item) {
|
||
color: #c8d2e2;
|
||
}
|
||
|
||
.shop-cat-clear {
|
||
margin-left: 6px;
|
||
padding: 0;
|
||
border: none;
|
||
background: none;
|
||
color: #6ea8ff;
|
||
font-size: 12px;
|
||
cursor: pointer;
|
||
font-family: inherit;
|
||
}
|
||
|
||
.shop-cat-clear:hover {
|
||
text-decoration: underline;
|
||
}
|
||
|
||
.collect-btn:hover:not(:disabled) {
|
||
filter: brightness(1.1);
|
||
transform: translateY(-1px);
|
||
}
|
||
|
||
.collect-btn:disabled {
|
||
opacity: 0.6;
|
||
cursor: not-allowed;
|
||
}
|
||
|
||
.collect-hint {
|
||
margin: 12px 0 0;
|
||
color: #a0acbe;
|
||
font-size: 12px;
|
||
line-height: 1.7;
|
||
}
|
||
|
||
.feedback {
|
||
margin: 16px 0 0;
|
||
padding: 10px 12px;
|
||
border-radius: 8px;
|
||
font-size: 13px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.feedback.success {
|
||
background: rgba(16, 185, 129, 0.12);
|
||
color: #6ee7b7;
|
||
}
|
||
|
||
.feedback.error {
|
||
background: rgba(248, 113, 113, 0.12);
|
||
color: #fca5a5;
|
||
}
|
||
|
||
/* 行内动作按钮:与外观专利 Tab 同色系(中断琥珀/重试绿/删除红),钉死 12px 字号 */
|
||
.btn-delete, .btn-retry, .btn-interrupt { border: none; cursor: pointer; border-radius: 6px; font-size: 12px; }
|
||
.btn-delete { padding: 6px 10px; color: #ff8f8f; background: rgba(231, 76, 60, .12); }
|
||
.btn-retry { padding: 6px 10px; color: #7fd1a0; background: rgba(39, 174, 96, .14); }
|
||
.btn-interrupt { padding: 6px 10px; color: #f0b35e; background: rgba(240, 179, 94, .12); }
|
||
|
||
@media (max-width: 1100px) {
|
||
.tool-head {
|
||
padding: 10px 16px;
|
||
gap: 10px;
|
||
}
|
||
|
||
.jd-body {
|
||
flex-direction: column;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.left-panel {
|
||
width: 100%;
|
||
border-right: none;
|
||
border-bottom: 1px solid #3e4a62;
|
||
}
|
||
|
||
.right-panel {
|
||
padding: 16px;
|
||
}
|
||
}
|
||
</style>
|