@@ -0,0 +1,615 @@
< 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 {
fetchJdCollectGroups ,
type JdCollectGroupVo ,
} from '@/shared/api/types/modules/jd-collect'
import {
activateJdPublishTask ,
createJdPublishTask ,
deleteJdPublishTask ,
fetchJdPublishDashboard ,
fetchJdPublishHistory ,
fetchJdPublishProducts ,
fetchJdPublishTaskProgressBatch ,
interruptJdPublishTask ,
type JdPublishHistoryItemVo ,
type JdPublishProductVo ,
} from '@/shared/api/types/modules/jd-publish'
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'
/** 京东「商品上架」(v1.5 蓝图 §4 Phase 4):选分类 → 勾商品 → 改价规则 → 建单 → 右侧任务面板实时行级进度。
*
* 六条边界(照 v1.4/v1.5 已落地的采集契约与外观专利任务面板骨架,不另造流程):
* 1. 分类选项唯一来源=jdCollect.groups 既有出口(B113-01,AC-9 源码绊线钉死:本页不得自拼
* 分类 URL);分组下的商品列表走 jdPublish.products( AC-9 owner 过滤:服务端只回归属
* 当前登录用户的行),页内翻页、勾选跨页累计;
* 2. 改价规则三档(none/percent/fixed,蓝图 §3 死契约),与勾选集一起进建单体;服务端按
* 同一规则折算 SKU 价(铁律 27a 改价同源);
* 3. 建单成功把服务端下发的 queuePayload( type=jd-product-publish-run,铁律 32 第三件)原样
* 推进本机客户端队列;激活(PENDING→RUNNING)必须在推队列之前(2026-11-14 采集链真机
* 实录同因);推送失败不回滚建单(兜底拉取认领);
* 4. 进度只读服务端:行级四档计数来自发布明细表聚合,total 缺失时只报已发布行数,不编造百分比;
* 5. 失败/中断「重试/继续」走通用原位复位(铁律 26,不克隆),推送载荷从历史行的建单载荷
* (分类 id+改价规则)同源重建——与建单响应 queuePayload 同键同形状;
* 6. 京麦未登录等凭据致命失败(铁律 31):服务端整单判死后 useLiveTaskBoard 经
* reportCredentialFatal 弹一次窗(credential-fatal 同形接入,AC-5 用户端半边;弹窗组件
* 挂 App.vue,本页无需重复挂)。
*/
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 ( '' )
function uidForStorage ( ) {
return typeof window !== 'undefined' ? window . localStorage . getItem ( 'uid' ) || '0' : '0'
}
// ---- 分类选择(AC-9:唯一来源是 jdCollect 组的既有 fetch 函数,不自拼 URL) ----
const jdCollectGroupLoader = fetchJdCollectGroups
const groupOptions = ref < JdCollectGroupVo [ ] > ( [ ] )
const groupsLoading = ref ( false )
const selectedGroupId = ref < number | null > ( null )
async function loadGroups ( ) {
groupsLoading . value = true
try {
const vo = await jdCollectGroupLoader ( )
groupOptions . value = vo ? ? [ ]
// 默认选中第一个分类:分类是建单的展示维度,缺省选中省一次点击;商品列表随之拉取。
if ( ! selectedGroupId . value && groupOptions . value . length ) {
selectedGroupId . value = groupOptions . value [ 0 ] . id
}
} finally {
groupsLoading . value = false
}
}
// ---- 选品分页(owner 过滤在服务端;勾选跨页累计在本地 Map,翻页不清空)----
const PRODUCT _PAGE _SIZE = 12
const products = ref < JdPublishProductVo [ ] > ( [ ] )
const productTotal = ref ( 0 )
const productPage = ref ( 1 )
const productsLoading = ref ( false )
const selectedProducts = ref ( new Map < number , JdPublishProductVo > ( ) )
const selectedProductIds = computed ( ( ) => Array . from ( selectedProducts . value . keys ( ) ) )
function toggleProduct ( row : JdPublishProductVo , checked : boolean ) {
const next = new Map ( selectedProducts . value )
if ( checked ) next . set ( row . id , row )
else next . delete ( row . id )
selectedProducts . value = next
}
function clearSelection ( ) {
selectedProducts . value = new Map ( )
}
async function loadProducts ( ) {
productsLoading . value = true
try {
const vo = await fetchJdPublishProducts ( selectedGroupId . value , productPage . value , PRODUCT _PAGE _SIZE )
products . value = vo . items ? ? [ ]
productTotal . value = vo . total ? ? 0
} catch ( err ) {
errorMessage . value = err instanceof Error ? err . message : '商品列表拉取失败,请稍后重试'
} finally {
productsLoading . value = false
}
}
function changePage ( page : number ) {
productPage . value = page
void loadProducts ( )
}
// ---- 改价规则(蓝图 §3: none/percent/fixed 三档;percent=百分数,fixed=加价金额)----
const PRICE _RULE _MODES = [
{ value : 'none' , label : '按原价上架' } ,
{ value : 'percent' , label : '按比例加价(%) ' } ,
{ value : 'fixed' , label : '固定加价(元)' } ,
] as const
const priceMode = ref < 'none' | 'percent' | 'fixed' > ( 'none' )
const priceValue = ref < number | null > ( null )
const priceValueMissing = computed ( ( ) => priceMode . value !== 'none' && ( priceValue . value == null || priceValue . value < 0 ) )
const submitDisabled = computed ( ( ) =>
submitting . value
|| ! selectedGroupId . value
|| ! selectedProducts . value . size
|| priceValueMissing . value )
// ---- 实时任务面板(照 JdCollectTab 的 useLiveTaskBoard 形状;京东发布无结果文件,无下载层)----
const board = useLiveTaskBoard < JdPublishHistoryItemVo > ( {
scope : 'jd-publish' ,
pollingStorageKey : ( ) => ` jd-publish:tasks: ${ uidForStorage ( ) } ` ,
fetchHistory : fetchJdPublishHistory ,
fetchProgressBatch : fetchJdPublishTaskProgressBatch ,
fetchDashboard : fetchJdPublishDashboard ,
normalizeTaskStatus ,
// 京东发布没有结果文件:状态到终态即结束,没有「等文件」那一层
isResultPreparing : ( ) => false ,
addPendingAfterFinalStatus : ( ) => false ,
keepPendingFileTask : ( ) => false ,
// CANCELLED 也是终态:中断的任务出「继续」按钮并停止轮询
settleOnTaskStatuses : [ 'SUCCESS' , 'FAILED' , 'CANCELLED' ] ,
deleteTask : {
shouldDeleteTask : ( item ) => item . taskId != null ,
deleteTask : ( taskId ) => deleteJdPublishTask ( 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 ( toJdPublishTaskView ) ,
)
const historyTaskViews = computed < TaskItemView [ ] > ( ( ) =>
board . historyOnlyItems . value . map ( toJdPublishTaskView ) ,
)
function itemSource ( item : TaskItemView ) {
return item . source as JdPublishHistoryItemVo
}
function toJdPublishTaskView ( item : JdPublishHistoryItemVo ) : TaskItemView {
const showProgress = isActiveTask ( item )
const total = typeof item . productTotal === 'number' && item . productTotal > 0 ? item . productTotal : null
const published = ( item . successCount ? ? 0 ) + ( item . failedCount ? ? 0 )
return {
key : ` jd-publish- ${ item . taskId ? ? item . taskNo ? ? item . updatedAt ? ? '' } ` ,
title : ` 商品上架 · ${ total ? ? '—' } 个商品 ` ,
taskId : item . taskId ? ? '-' ,
startedAt : formatDateTime ( item . createdAt ) ,
finishedAt : formatDateTime ( item . finishedAt ) ,
statusText : statusText ( item ) ,
statusClass : statusClass ( item ) ,
extraLines : [
` 成功 ${ item . successCount ? ? 0 } / 失败 ${ item . failedCount ? ? 0 } `
+ ( item . publishingCount ? ` / 发布中 ${ item . publishingCount } ` : '' ) ,
... ( showProgress && total ? [ ` 已发布 ${ Math . min ( published , total ) } / ${ total } 个商品 ` ] : [ ] ) ,
... ( item . errorMessage ? [ ` 错误: ${ userNotice ( item . errorMessage ) } ` ] : [ ] ) ,
] ,
progress : showProgress ? { percent : progressPercent ( item ) , countLabel : progressCountLabel ( item ) } : null ,
source : item ,
}
}
// ---- 本模块的状态语义(京东发布:无结果文件,状态即终态)----
function normalizeTaskStatus ( item : JdPublishHistoryItemVo | null | undefined ) {
return ( item ? . taskStatus || '' ) . toUpperCase ( )
}
function isActiveTask ( item : JdPublishHistoryItemVo ) {
const status = normalizeTaskStatus ( item )
return status === 'PENDING' || status === 'RUNNING' || status === 'SCHEDULED'
}
function statusText ( item : JdPublishHistoryItemVo ) {
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 : JdPublishHistoryItemVo ) {
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 : JdPublishHistoryItemVo ) {
const status = normalizeTaskStatus ( item )
if ( status === 'SUCCESS' ) return 100
const total = typeof item . productTotal === 'number' && item . productTotal > 0 ? item . productTotal : null
if ( ! total ) return 0
const done = Math . min ( ( item . successCount ? ? 0 ) + ( item . failedCount ? ? 0 ) , total )
return Math . max ( 0 , Math . min ( 99 , Math . round ( ( done * 100 ) / total ) ) )
}
/** 计数文案:有 total 带分母和百分比;没有 total 只报行数,不编造分母。 */
function progressCountLabel ( item : JdPublishHistoryItemVo ) {
const published = ( item . successCount ? ? 0 ) + ( item . failedCount ? ? 0 )
const total = typeof item . productTotal === 'number' && item . productTotal > 0 ? item . productTotal : null
if ( ! total ) return ` 已发布 ${ published } 个商品 `
return ` 已发布 ${ published } / ${ total } 个商品( ${ progressPercent ( item ) } %) `
}
/** 失败/已中断的任务能续跑:在原任务上复位(不新建任务)。 */
function canRetryTask ( item : JdPublishHistoryItemVo | null | undefined ) : boolean {
if ( ! item ? . taskId ) return false
const status = normalizeTaskStatus ( item )
return status === 'FAILED' || status === 'CANCELLED'
}
/** 按钮文案:已中断的任务显示「继续」(从断点接着跑),失败任务仍是「重试」。 */
function retryLabel ( item : JdPublishHistoryItemVo | null | undefined ) : string {
return normalizeTaskStatus ( item ) === 'CANCELLED' ? '继续' : '重试'
}
/** 在跑/待跑的任务可中断:PENDING/RUNNING/SCHEDULED 是服务端 CAS 的同一 ACTIVE 集合。 */
function canInterruptTask ( item : JdPublishHistoryItemVo | null | undefined ) : boolean {
if ( ! item ? . taskId ) return false
const status = normalizeTaskStatus ( item )
return status === 'PENDING' || status === 'RUNNING' || status === 'SCHEDULED'
}
async function interruptTaskRecord ( item : JdPublishHistoryItemVo | 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 interruptJdPublishTask ( taskId )
ElMessage . success ( '已中断:客户端下一跳心跳后收手,之后可点「继续」接着跑' )
await refreshBoard ( )
} catch ( error ) {
ElMessage . error ( error instanceof Error ? error . message : '中断失败' )
}
}
async function retryTaskRecord ( item : JdPublishHistoryItemVo | null | undefined ) {
const taskId = item ? . taskId
if ( ! taskId ) return
const isResume = normalizeTaskStatus ( item ) === 'CANCELLED'
try {
await retryClientTask ( taskId )
ElMessage . success ( isResume
? '已继续:在这条任务上接着跑(已成功的商品不会重复发布)'
: '已提交重试:在这条任务上继续跑(不新建任务)' )
// 复位是 PENDING:与建单同一条激活+推队列链路,客户端才会立刻领到这一单。
const activateError = await activateTask ( taskId )
if ( ! activateError ) {
const priceRule = item ? . priceRule && item . priceRule . mode ? item . priceRule : { mode : 'none' }
// 推送载荷从历史行的建单载荷同源重建(与建单响应 queuePayload 同键:type/taskId/priceRule)。
await pushToClientQueue ( { type : 'jd-product-publish-run' , data : { taskId , priceRule } } )
}
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 表示失败原因。
* 漏掉这一步,客户端第一个回传会被「任务不在运行中(PENDING)」拒收(采集链真机实录同因)。 */
async function activateTask ( id : number ) : Promise < string | null > {
try {
await activateJdPublishTask ( id )
return null
} catch ( err ) {
const text = err instanceof Error ? err . message : ''
// 客户端兜底拉取已原子认领(PENDING→RUNNING)时后端回这句:等同激活成功,不当失败展示。
if ( text . includes ( '已在执行中' ) ) {
return null
}
console . error ( '[jd-publish] 激活任务失败' , err )
return '任务激活失败,本机客户端领不到这一单,请稍后重试'
}
}
/** 推送本机队列:建单路径传服务端下发的 queuePayload(页面不拼载荷),重试路径按同键形状重建后传入。 */
async function pushToClientQueue ( payload : Record < string , unknown > ) : Promise < string | null > {
const api = getPywebviewApi ( )
if ( ! api ? . enqueue _json ) {
return '当前环境未启用任务队列能力(浏览器预览环境不会启动),请在本机客户端中打开本页'
}
const pushResult = await api . enqueue _json ( payload )
if ( pushResult ? . success ) {
return null
}
// 桥返回的 error 原文(系统/英文)不透传进界面:console 留链,界面固定中文动作句
if ( pushResult ? . error ) {
console . error ( '[jd-publish] enqueue_json 被拒' , pushResult . error )
}
return '推送本机队列失败,任务将由客户端兜底拉取认领'
}
const isRunning = computed ( ( ) => Boolean ( board . dashboard . value . pendingTaskCount ) || submitting . value )
const priceRuleHint = computed ( ( ) => {
if ( priceMode . value === 'none' ) return '按京东数据库里的采集原价上架。'
if ( priceMode . value === 'percent' ) return '按采集价上浮 N%(填 10 表示加价 10%)。'
return '每个商品统一加固定金额(填 5 表示加 5 元)。'
} )
async function startPublish ( ) {
if ( submitDisabled . value ) return
errorMessage . value = ''
successMessage . value = ''
submitting . value = true
try {
const priceRule = priceMode . value === 'none'
? { mode : 'none' as const }
: { mode : priceMode . value , value : priceValue . value as number }
// 勾选集即建单 productIds; selectedGroupId 即建单体 categoryId
// (服务端按 owner 校验,选了他人商品当场拒,AC-9)。
const categoryId = selectedGroupId . value
const productIds = selectedProductIds . value
const vo = await createJdPublishTask ( categoryId , productIds , priceRule )
board . addPollingTask ( vo . taskId )
let pushNote = ''
const activateError = await activateTask ( vo . taskId )
if ( activateError ) {
// 没激活成功就不推队列:推了也是白跑一轮。任务留在 PENDING,
// 由服务端兜底拉取认领后照样会跑,所以这里只提示、不回滚建单。
pushNote = activateError
} else {
try {
// 建单响应自带 queuePayload(服务端组装,铁律 32 第三件),页面原样投递。
const pushError = await pushToClientQueue ( vo . queuePayload
? ? { type : 'jd-product-publish-run' , data : { taskId : vo . taskId , priceRule } } )
if ( pushError ) pushNote = pushError
} catch ( pushErr ) {
pushNote = '推送本机队列失败,任务将由服务端兜底派发给本机客户端执行'
console . error ( '[jd-publish] 推送本机队列失败' , pushErr )
}
}
if ( pushNote ) {
errorMessage . value = pushNote
} else {
successMessage . value = ` 任务已创建( ${ productIds . 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 ( [
loadGroups ( ) . catch ( ( ) => undefined ) ,
board . loadDashboard ( ) . catch ( ( ) => undefined ) ,
board . loadHistory ( ) . catch ( ( ) => undefined ) ,
] )
board . seedRunningTasksFromHistory ( )
board . seedPendingFileTasksFromHistory ( )
board . ensurePollingIfAny ( )
void loadProducts ( )
} )
onUnmounted ( ( ) => {
board . dispose ( )
} )
< / script >
< template >
< div class = "page-shell module-page jd-publish-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 = "selectedGroupId" placeholder="选择分类" class="shop-cat-select"
:loading = "groupsLoading" @change ="() => { productPage = 1; clearSelection(); void loadProducts() }" >
< el -option v-for = "group in groupOptions" :key="group.id"
: label = "`${group.name}( ${group.productCount ?? 0} 个商品)`" :value = "group.id" / >
< / el-select >
< p class = "category-hint" > 分类由管理员在后台 「 京东数据库 」 维护 ; 列表只显示归属你账号的商品 。 < / p >
< / div >
< div class = "product-block" v-loading = "productsLoading" >
< div class = "product-head" >
< span class = "category-label" > 选择商品 ( 已选 { { selectedProducts . size } } 个 , 跨页累计 ) < / span >
< button v-if = "selectedProducts.size" class="shop-cat-clear" type="button"
@click ="clearSelection" > 清空勾选 < / button >
< / div >
< div v-if = "!products.length && !productsLoading" class="product-empty" >
{{ selectedGroupId ? ' 该分类下暂无归属你账号的商品 ' : ' 请先选择分类 ' }}
< / div >
< label v-for = "product in products" :key="product.id" class="product-row" >
< input type = "checkbox" class = "product-check"
:checked = "selectedProducts.has(product.id)"
@change ="toggleProduct(product, ($event.target as HTMLInputElement).checked)" / >
< img v-if = "product.mainImageUrl" class="product-thumb" :src="product.mainImageUrl" alt="" loading="lazy" / >
< span v-else class = "product-thumb product-thumb--empty" > 无图 < / span >
< span class = "product-info" >
< span class = "product-title" > { { product . title } } < / span >
< span class = "product-meta" >
¥ { { product . priceMin ? ? '-' } } < template v-if = "product.priceMax && product.priceMax !== product.priceMin" > ~ {{ product.priceMax }} < / template >
· 库存 {{ product.stockTotal ? ? ' - ' }} < template v-if = "product.skuCount" > · {{ product.skuCount }} 个SKU < / template >
< / span >
< / span >
< / label >
< el -pagination v-if = "productTotal > PRODUCT_PAGE_SIZE" class="product-pager" layout="prev, pager, next"
:total = "productTotal" :page-size = "PRODUCT_PAGE_SIZE" :current-page = "productPage"
@ current -change = " changePage " / >
< / div >
< div class = "category-block" >
< span class = "category-label" > 改价规则 ( 可选 ) < / span >
< el-select v-model = "priceMode" class="shop-cat-select" >
< el -option v-for = "mode in PRICE_RULE_MODES" :key="mode.value" :label="mode.label" :value="mode.value" / >
< / el-select >
< el-input-number v-if = "priceMode !== 'none'" v-model="priceValue" :min="0" :precision="2"
: step = "priceMode === 'percent' ? 1 : 0.5" class = "price-input" controls -position = " right "
: placeholder = "priceMode === 'percent' ? '加价百分比' : '加价金额'" / >
< p class = "category-hint" > { { priceRuleHint } } < / p >
< / div >
< button class = "collect-btn" type = "button" :disabled = "submitDisabled" @click ="startPublish" >
{{ submitting ? ' 创建中 … ' : ` 上架已选 $ { selectedProducts.size } 个商品 ` }}
< / 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 >
< ! - - 样式与采集页同族暗色主题 ( header / brand / 工具头为两页共通形状 , 各自 scoped 不共享 ) ;
逐规则单行压缩只为过可读棘轮 800 行线 , 不改任何选择器与声明 。 - - >
< style scoped >
. jd - publish - page { display : flex ; flex - direction : column ; min - height : 100 vh ; background - color : # 1 a1f2e ; background - image : radial - gradient ( rgba ( 45 , 212 , 191 , 0.08 ) 1 px , transparent 1 px ) ; background - size : 48 px 48 px ; font - family : "PingFang SC" , "Microsoft YaHei UI" , "Microsoft YaHei" , "微软雅黑" , sans - serif ; }
. jd - top { flex : 0 0 auto ; min - height : 64 px ; display : flex ; align - items : center ; justify - content : space - between ; gap : 20 px ; padding : 0 28 px ; background : # 1 a1f2e ; border - bottom : 1 px solid # 3 e4a62 ; }
. home - back , . tool - head _ _back { flex - shrink : 0 ; display : inline - flex ; align - items : center ; gap : 6 px ; padding : 6 px 14 px ; border : 1 px solid # 3 e4a62 ; border - radius : 6 px ; color : # c8d2e2 ; font - size : 13 px ; text - decoration : none ; white - space : nowrap ; transition : all 0.2 s ; }
. home - back : hover , . tool - head _ _back : hover { background : # 2 b3447 ; color : # f5f8fc ; }
. brand { display : flex ; align - items : center ; gap : 12 px ; flex - shrink : 0 ; }
. brand - logo { display : flex ; align - items : center ; justify - content : center ; width : 38 px ; height : 38 px ; border - radius : 8 px ; background : # e1251b ; color : # fff ; font - size : 20 px ; font - weight : 700 ; box - shadow : 0 2 px 8 px rgba ( 225 , 37 , 27 , 0.32 ) ; }
. brand - text { display : flex ; flex - direction : column ; line - height : 1.35 ; }
. brand - name { color : # f5f8fc ; font - size : 17 px ; font - weight : 700 ; white - space : nowrap ; }
. brand - sub { color : # a0acbe ; font - size : 10 px ; white - space : nowrap ; }
. top - right { display : flex ; align - items : center ; gap : 14 px ; flex - shrink : 0 ; }
. admin - name { color : # c8d2e2 ; font - size : 13 px ; font - weight : 700 ; white - space : nowrap ; }
. tool - head { flex : 0 0 auto ; display : flex ; align - items : center ; flex - wrap : wrap ; gap : 20 px ; min - height : 62 px ; padding : 10 px 34 px ; background : # 1 a1f2e ; }
. tool - head _ _title { flex - shrink : 0 ; color : # f5f8fc ; font - size : 22 px ; font - weight : 700 ; white - space : nowrap ; }
. tool - head _ _desc { min - width : 0 ; max - width : 760 px ; color : # a0acbe ; font - size : 14 px ; line - height : 1.5 ; }
. jd - body { flex : 1 1 auto ; min - height : 0 ; display : flex ; align - items : stretch ; overflow : hidden ; }
. left - panel { width : 440 px ; flex - shrink : 0 ; padding : 20 px ; overflow - y : auto ; border - right : 1 px solid # 3 e4a62 ; }
. right - panel { flex : 1 ; min - width : 0 ; display : flex ; flex - direction : column ; overflow - y : auto ; padding : 20 px ; }
. category - block { margin - bottom : 16 px ; }
. category - label { display : block ; margin - bottom : 8 px ; color : # c8d2e2 ; font - size : 13 px ; font - weight : 600 ; }
. category - hint { margin : 8 px 0 0 ; color : # 7 f8ca3 ; font - size : 12 px ; line - height : 1.6 ; }
. shop - cat - select { width : 100 % ; }
. shop - cat - select : deep ( . el - select _ _wrapper ) { background - color : # 232 b3d ; box - shadow : 0 0 0 1 px # 3 e4a62 inset ; }
. shop - cat - select : deep ( . el - select _ _placeholder ) , . shop - cat - select : deep ( . el - select _ _selected - item ) { color : # c8d2e2 ; }
. shop - cat - clear { margin - left : 6 px ; padding : 0 ; border : none ; background : none ; color : # 6 ea8ff ; font - size : 12 px ; cursor : pointer ; font - family : inherit ; }
. shop - cat - clear : hover { text - decoration : underline ; }
. product - block { margin - bottom : 16 px ; }
. product - head { display : flex ; align - items : center ; justify - content : space - between ; }
. product - head . category - label { margin - bottom : 8 px ; }
. product - row { display : flex ; align - items : center ; gap : 10 px ; padding : 8 px 10 px ; margin - bottom : 6 px ; border : 1 px solid # 2 c3547 ; border - radius : 8 px ; background : # 20283 a ; cursor : pointer ; }
. product - row : hover { border - color : # 3 e4a62 ; }
. product - check { flex - shrink : 0 ; width : 15 px ; height : 15 px ; accent - color : # e1251b ; cursor : pointer ; }
. product - thumb { flex - shrink : 0 ; width : 44 px ; height : 44 px ; border - radius : 6 px ; object - fit : cover ; background : # 232 b3d ; }
. product - thumb -- empty { display : inline - flex ; align - items : center ; justify - content : center ; color : # 5 f6c85 ; font - size : 11 px ; }
. product - info { min - width : 0 ; display : flex ; flex - direction : column ; gap : 3 px ; }
. product - title { color : # d9e1ef ; font - size : 12 px ; line - height : 1.4 ; display : - webkit - box ; - webkit - line - clamp : 2 ; - webkit - box - orient : vertical ; overflow : hidden ; }
. product - meta { color : # 8 a97ad ; font - size : 11 px ; white - space : nowrap ; overflow : hidden ; text - overflow : ellipsis ; }
. product - empty { padding : 18 px 0 ; color : # 5 f6c85 ; font - size : 12 px ; text - align : center ; }
. product - pager { margin - top : 8 px ; justify - content : center ; }
. product - pager : deep ( . el - pager li ) , . product - pager : deep ( . btn - prev ) , . product - pager : deep ( . btn - next ) { background : transparent ; color : # c8d2e2 ; }
. product - pager : deep ( . el - pager li . is - active ) { color : # 6 ea8ff ; }
. price - input { width : 100 % ; margin - top : 8 px ; }
. price - input : deep ( . el - input _ _wrapper ) { background - color : # 232 b3d ; box - shadow : 0 0 0 1 px # 3 e4a62 inset ; }
. price - input : deep ( . el - input _ _inner ) { color : # c8d2e2 ; }
. collect - btn { width : 100 % ; padding : 13 px 0 ; border : none ; border - radius : 8 px ; background : linear - gradient ( 135 deg , # ff5a4f , # e1251b ) ; color : # ffffff ; font - size : 16 px ; font - weight : 700 ; font - family : inherit ; cursor : pointer ; box - shadow : 0 4 px 16 px rgba ( 225 , 37 , 27 , 0.32 ) ; transition : all 0.2 s ; }
. collect - btn : hover : not ( : disabled ) { filter : brightness ( 1.1 ) ; transform : translateY ( - 1 px ) ; }
. collect - btn : disabled { opacity : 0.6 ; cursor : not - allowed ; }
. collect - hint { margin : 12 px 0 0 ; color : # a0acbe ; font - size : 12 px ; line - height : 1.7 ; }
. feedback { margin : 16 px 0 0 ; padding : 10 px 12 px ; border - radius : 8 px ; font - size : 13 px ; line - height : 1.6 ; }
. feedback . success { background : rgba ( 16 , 185 , 129 , 0.12 ) ; color : # 6 ee7b7 ; }
. feedback . error { background : rgba ( 248 , 113 , 113 , 0.12 ) ; color : # fca5a5 ; }
. btn - delete , . btn - retry , . btn - interrupt { border : none ; cursor : pointer ; border - radius : 6 px ; font - size : 12 px ; }
. btn - delete { padding : 6 px 10 px ; color : # ff8f8f ; background : rgba ( 231 , 76 , 60 , .12 ) ; }
. btn - retry { padding : 6 px 10 px ; color : # 7 fd1a0 ; background : rgba ( 39 , 174 , 96 , .14 ) ; }
. btn - interrupt { padding : 6 px 10 px ; color : # f0b35e ; background : rgba ( 240 , 179 , 94 , .12 ) ; }
@ media ( max - width : 1100 px ) {
. tool - head { padding : 10 px 16 px ; gap : 10 px ; }
. jd - body { flex - direction : column ; overflow - y : auto ; }
. left - panel { width : 100 % ; border - right : none ; border - bottom : 1 px solid # 3 e4a62 ; }
. right - panel { padding : 16 px ; }
}
< / style >