8be9892522
两次定案方向相反,所以分开钉:主看板只要 执行中/成功/失败 三态(其他状态不再当筛选项); 变体采集那页反过来——撤掉「在跑=0∪1 合并」口径,直接显示 待执行/处理中/成功/失败, 历史终态也要能看到。 - 后端 statusFilter 做同义词展开:成功 = SUCCESS∪COMPLETED,失败 = FAILED∪ERROR∪CANCELLED (取消=没成功也不在跑,并入失败),展开只住这一处,页面模型不再各自 if。前端筛选项随之 收成 全部/执行中/成功/失败 四项(原 待执行/执行中/已排期/已完成/已取消 那一排撤掉)。 - 变体采集:不传 status = 全部状态,后端原样直查麦象(含历史终态),不再有 0∪1 合并哨兵; 前端选项与 label 同步改。上线顺序仍是先 jar 后前端——新前端发 ACTIVE 打旧 jar 会整页空。 - AppearancePatentTaskService.saveFileBuildProgress 的终态必须带任务真实状态落库:save() 只对 终态豁免 500ms 节流,而收尾三连写(组装/上传/完成)都在同一次调用里,若全按 RUNNING 写 就只有第一条落地,满格「结果文件已生成」必被吞——2026-10-04 生产实测的「已完成 0/130、 57/59」就是这么来的。对齐货源查询侧的 isTerminalFileBuildProgress。 - 节流侧补一条用例钉住"终态不受节流",模块侧补一条钉住"终态写的是任务状态而不是 RUNNING"—— 这两条分别在 service 与 mapper 出口,任一处回退都会红。 验证:后端定向 4 类 53/0(外观终态快照 4、进度节流 9、看板查询 34、变体采集 6;与批次①同一轮 mvn 197 例 0 红);admin-frontend-vue 定向 task-center-board 25/0(含三态选项、默认视图、 汇总卡口径)、全量 1726 例中本批 0 红。
973 lines
30 KiB
Vue
973 lines
30 KiB
Vue
<script setup lang="ts">
|
||
/** 客户端任务管理看板:全局看有哪些客户端任务在跑,再下钻到任务明细(只读,仅超管或被授权管理员)。
|
||
* 页签一「客户端任务」= biz_file_task(12 个客户端模块)∪ brand_crawl_tasks;
|
||
* 页签二「变体采集」= 麦象批量任务(variant-collection),数据口径与列不同故独立页签。
|
||
* 30s 轮询:页面隐藏暂停、回前台立即刷新、卸载清理;另有手动刷新。 */
|
||
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import OldPagination from '@/components/OldPagination.vue'
|
||
import { formatDateTime } from '@/utils/datetime'
|
||
import {
|
||
fetchTaskCenterOverview,
|
||
fetchTaskCenterShopOptions,
|
||
fetchTaskCenterTaskDetail,
|
||
fetchTaskCenterTasks,
|
||
fetchTaskCenterVariantTasks,
|
||
type TaskCenterOverview,
|
||
type TaskCenterTaskDetail,
|
||
type TaskCenterTaskRow,
|
||
type TaskCenterVariantTaskRow,
|
||
} from '@/api/task-center'
|
||
import {
|
||
ACTIVE_TASK_STATUS,
|
||
MODULE_OPTIONS,
|
||
TASK_STATUS_OPTIONS,
|
||
VARIANT_STATUS_OPTIONS,
|
||
buildTaskQuery,
|
||
buildVariantQuery,
|
||
countryLabel,
|
||
createTaskFilter,
|
||
createVariantFilter,
|
||
deviceDisplayName,
|
||
progressPercent,
|
||
progressText,
|
||
shopDisplayName,
|
||
tabCount,
|
||
taskStatusLabel,
|
||
taskStatusType,
|
||
variantAccountText,
|
||
variantStatusLabel,
|
||
variantStatusType,
|
||
type TaskCenterTaskFilter,
|
||
type TaskCenterVariantFilter,
|
||
} from './task-center-model'
|
||
|
||
const POLL_INTERVAL_MS = 30_000
|
||
|
||
type BoardTab = 'tasks' | 'variant'
|
||
const activeTab = ref<BoardTab>('tasks')
|
||
|
||
// ---------------------------------------------------------------- 客户端任务
|
||
|
||
const overview = ref<TaskCenterOverview | null>(null)
|
||
const shopOptions = ref<string[]>([])
|
||
/** 默认视图 = 只看执行中(合并哨兵,后端展开成三个进行中状态),**不锁创建时间**:
|
||
* 卡片「进行中任务」的 SQL 不带时间窗,锁当天必然比卡片少一截(10-04 实测 21 vs 39,
|
||
* 差的 18 个是跨天仍在上报的长任务)。历史状态与时间窗仍在筛选里,用户自己选。 */
|
||
function defaultTaskFilter(): TaskCenterTaskFilter {
|
||
return { ...createTaskFilter(), status: ACTIVE_TASK_STATUS }
|
||
}
|
||
|
||
const filter = reactive<TaskCenterTaskFilter>(defaultTaskFilter())
|
||
const tasks = ref<TaskCenterTaskRow[]>([])
|
||
const taskTotal = ref(0)
|
||
const taskPage = ref(1)
|
||
const taskPageSize = ref(20)
|
||
const tasksLoading = ref(false)
|
||
|
||
// ---------------------------------------------------------------- 变体采集
|
||
|
||
const variantFilter = reactive<TaskCenterVariantFilter>(createVariantFilter())
|
||
const variantRows = ref<TaskCenterVariantTaskRow[]>([])
|
||
/** 没查过就是 null(徽章画「—」):变体列表是外部依赖,停在页签一时不能替它说 0。 */
|
||
const variantTotal = ref<number | null>(null)
|
||
const variantPage = ref(1)
|
||
const variantPageSize = ref(20)
|
||
const variantLoading = ref(false)
|
||
|
||
// ---------------------------------------------------------------- 详情抽屉
|
||
|
||
const detailVisible = ref(false)
|
||
const detailLoading = ref(false)
|
||
const detail = ref<TaskCenterTaskDetail | null>(null)
|
||
|
||
const updatedAt = ref('')
|
||
|
||
const taskTotalPages = computed(() => Math.max(1, Math.ceil(taskTotal.value / taskPageSize.value)))
|
||
const variantTotalPages = computed(() => Math.max(1, Math.ceil((variantTotal.value ?? 0) / variantPageSize.value)))
|
||
|
||
/** 页签一徽章 = 当前在跑任务数,与汇总卡「进行中任务」同源,不允许两处各算各的。
|
||
* 列表 total(历史全量,且每天 00:00 的 7 天保留清理会往下掉)只用于分页,不上徽章。 */
|
||
const runningBadge = computed(() => tabCount(overview.value?.runningTasks))
|
||
|
||
function errorText(error: unknown, fallback: string): string {
|
||
return error instanceof Error && error.message ? error.message : fallback
|
||
}
|
||
|
||
async function loadOverview() {
|
||
try {
|
||
overview.value = await fetchTaskCenterOverview()
|
||
} catch (error) {
|
||
ElMessage.error(errorText(error, '汇总数据加载失败'))
|
||
}
|
||
}
|
||
|
||
/** 店铺库下拉候选。 */
|
||
async function loadShopOptions() {
|
||
try {
|
||
shopOptions.value = (await fetchTaskCenterShopOptions()) || []
|
||
} catch (error) {
|
||
ElMessage.error(errorText(error, '店铺候选加载失败'))
|
||
}
|
||
}
|
||
|
||
async function loadTasks(silent = false) {
|
||
if (!silent) tasksLoading.value = true
|
||
try {
|
||
const result = await fetchTaskCenterTasks(buildTaskQuery(filter, taskPage.value, taskPageSize.value))
|
||
tasks.value = result?.items || []
|
||
taskTotal.value = Number(result?.total || 0)
|
||
} catch (error) {
|
||
ElMessage.error(errorText(error, '任务列表加载失败'))
|
||
} finally {
|
||
if (!silent) tasksLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function loadVariants(silent = false) {
|
||
if (!silent) variantLoading.value = true
|
||
try {
|
||
const result = await fetchTaskCenterVariantTasks(
|
||
buildVariantQuery(variantFilter, variantPage.value, variantPageSize.value),
|
||
)
|
||
variantRows.value = result?.items || []
|
||
variantTotal.value = tabCount(result?.total)
|
||
} catch (error) {
|
||
variantTotal.value = null
|
||
ElMessage.error(errorText(error, '变体采集加载失败'))
|
||
} finally {
|
||
if (!silent) variantLoading.value = false
|
||
}
|
||
}
|
||
|
||
/** 汇总卡与店铺候选只描述客户端任务,两个页签都刷新它们(切页签时看到的就是最新)。
|
||
* 店铺候选是字典数据(后端 SELECT DISTINCT、无缓存),所以它不进 30s 心跳:
|
||
* 心跳每轮都重拉等于把一次全库去重乘以 2880/天。代价是新入库店铺要等
|
||
* 下一次进页/切页签/点「刷新」才会出现在下拉里。 */
|
||
async function refreshAll(silent = false) {
|
||
await Promise.all([
|
||
loadOverview(),
|
||
silent ? Promise.resolve() : loadShopOptions(),
|
||
activeTab.value === 'tasks' ? loadTasks(silent) : loadVariants(silent),
|
||
])
|
||
updatedAt.value = formatDateTime(Date.now())
|
||
}
|
||
|
||
/** 首屏把「另一个页签」也查一遍,徽章才有真数可画。
|
||
* 只补这一次:变体列表代理麦象 console(外部依赖、8s 超时),不进 30s 轮询热路径。 */
|
||
async function loadInactiveTabTotal() {
|
||
if (activeTab.value === 'tasks') await loadVariants(true)
|
||
else await loadTasks(true)
|
||
}
|
||
|
||
function switchTab(tab: BoardTab) {
|
||
if (activeTab.value === tab) return
|
||
activeTab.value = tab
|
||
if (tab === 'tasks' ? tasks.value.length === 0 : variantRows.value.length === 0) {
|
||
void refreshAll()
|
||
}
|
||
}
|
||
|
||
// ---------------------------------------------------------------- 筛选/分页
|
||
|
||
function search() {
|
||
taskPage.value = 1
|
||
void loadTasks()
|
||
}
|
||
|
||
function resetFilter() {
|
||
Object.assign(filter, defaultTaskFilter())
|
||
taskPage.value = 1
|
||
void loadTasks()
|
||
}
|
||
|
||
function changeTaskPage(next: number) {
|
||
if (next < 1 || next > taskTotalPages.value) return
|
||
taskPage.value = next
|
||
void loadTasks()
|
||
}
|
||
|
||
function changeTaskSize(size: number) {
|
||
taskPageSize.value = size
|
||
taskPage.value = 1
|
||
void loadTasks()
|
||
}
|
||
|
||
function searchVariant() {
|
||
variantPage.value = 1
|
||
void loadVariants()
|
||
}
|
||
|
||
function resetVariant() {
|
||
Object.assign(variantFilter, createVariantFilter())
|
||
variantPage.value = 1
|
||
void loadVariants()
|
||
}
|
||
|
||
function changeVariantPage(next: number) {
|
||
if (next < 1 || next > variantTotalPages.value) return
|
||
variantPage.value = next
|
||
void loadVariants()
|
||
}
|
||
|
||
function changeVariantSize(size: number) {
|
||
variantPageSize.value = size
|
||
variantPage.value = 1
|
||
void loadVariants()
|
||
}
|
||
|
||
// ---------------------------------------------------------------- 详情
|
||
|
||
async function openDetail(row: TaskCenterTaskRow) {
|
||
detailVisible.value = true
|
||
detailLoading.value = true
|
||
detail.value = null
|
||
try {
|
||
detail.value = await fetchTaskCenterTaskDetail(row.taskNo)
|
||
if (!detail.value) ElMessage.warning('任务不存在或无权查看')
|
||
} catch (error) {
|
||
ElMessage.error(errorText(error, '任务详情加载失败'))
|
||
detailVisible.value = false
|
||
} finally {
|
||
detailLoading.value = false
|
||
}
|
||
}
|
||
|
||
function accountOf(row: TaskCenterTaskRow): string {
|
||
return row.username || (row.userId != null ? `UID ${row.userId}` : '—')
|
||
}
|
||
|
||
function deviceOf(row: TaskCenterTaskRow): string {
|
||
return deviceDisplayName(row.deviceName, row.deviceId)
|
||
}
|
||
|
||
function currentScopeOf(row: TaskCenterTaskRow): string {
|
||
return (row.currentScope || '').trim() || '—'
|
||
}
|
||
|
||
// ---------------------------------------------------------------- 轮询
|
||
|
||
let pollTimer: ReturnType<typeof setInterval> | null = null
|
||
|
||
function onVisibilityChange() {
|
||
if (typeof document !== 'undefined' && document.visibilityState === 'visible') {
|
||
void refreshAll(true)
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
void refreshAll()
|
||
void loadInactiveTabTotal()
|
||
document.addEventListener('visibilitychange', onVisibilityChange)
|
||
pollTimer = setInterval(() => {
|
||
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') return
|
||
void refreshAll(true)
|
||
}, POLL_INTERVAL_MS)
|
||
})
|
||
|
||
onUnmounted(() => {
|
||
document.removeEventListener('visibilitychange', onVisibilityChange)
|
||
if (pollTimer != null) {
|
||
clearInterval(pollTimer)
|
||
pollTimer = null
|
||
}
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<div class="tc-view">
|
||
<section class="panel-box">
|
||
<div class="tc-head">
|
||
<div class="tabs">
|
||
<button class="tab" :class="{ active: activeTab === 'tasks' }" type="button" @click="switchTab('tasks')">
|
||
客户端任务 <span class="t-count" title="当前在跑任务数,与上方「进行中任务」同源">{{ runningBadge ?? '—' }}</span>
|
||
</button>
|
||
<button class="tab" :class="{ active: activeTab === 'variant' }" type="button" @click="switchTab('variant')">
|
||
变体采集 <span class="t-count" title="麦象变体采集任务条数(全部状态),「—」= 还没查到">{{ variantTotal ?? '—' }}</span>
|
||
</button>
|
||
</div>
|
||
<div class="tc-head-tools">
|
||
<span class="updated-tip">数据更新时间 {{ updatedAt || '—' }}</span>
|
||
<button class="btn btn-ghost" type="button" @click="refreshAll()">刷新</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="activeTab === 'tasks'" class="tc-cards">
|
||
<div class="tc-card">
|
||
<span class="tc-card-label">总店铺</span>
|
||
<span class="tc-card-value">{{ overview?.shopTotal ?? '—' }}</span>
|
||
<span class="tc-card-note">店铺库内可见店铺</span>
|
||
</div>
|
||
<div class="tc-card">
|
||
<span class="tc-card-label">在跑店铺</span>
|
||
<span class="tc-card-value is-ok">{{ overview?.shopRunning ?? '—' }}</span>
|
||
<span class="tc-card-note">有进行中任务的店铺</span>
|
||
</div>
|
||
<div class="tc-card">
|
||
<span class="tc-card-label">进行中任务</span>
|
||
<span class="tc-card-value">{{ overview?.runningTasks ?? '—' }}</span>
|
||
<span class="tc-card-note">含品牌检测</span>
|
||
</div>
|
||
<div class="tc-card">
|
||
<span class="tc-card-label">今日完成</span>
|
||
<span class="tc-card-value">{{ overview?.todayFinishedTasks ?? '—' }}</span>
|
||
<span class="tc-card-note">终态且完成于今日</span>
|
||
</div>
|
||
<div class="tc-card">
|
||
<span class="tc-card-label">疑似卡住</span>
|
||
<span class="tc-card-value" :class="{ 'is-warn': (overview?.stuckTasks || 0) > 0 }">
|
||
{{ overview?.stuckTasks ?? '—' }}
|
||
</span>
|
||
<span class="tc-card-note">超过 10 分钟无上报</span>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<!-- ============ 页签一:客户端任务 ============ -->
|
||
<template v-if="activeTab === 'tasks'">
|
||
<section class="panel-box">
|
||
<div class="box-head">
|
||
<h3>任务筛选</h3>
|
||
<span class="box-note">默认列出执行中的任务(待执行/已排期并入执行中口径),条数与上方「进行中任务」同源;看历史请换状态或选创建时间</span>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group" style="min-width: 160px">
|
||
<label>账号</label>
|
||
<input v-model="filter.username" type="text" placeholder="模糊搜索账号名" @keyup.enter="search" />
|
||
</div>
|
||
<div class="form-group" style="min-width: 150px">
|
||
<label>业务</label>
|
||
<select v-model="filter.moduleType">
|
||
<option v-for="option in MODULE_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group" style="min-width: 130px">
|
||
<label>状态</label>
|
||
<select v-model="filter.status">
|
||
<option v-for="option in TASK_STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group shop-filter">
|
||
<label>店铺</label>
|
||
<el-select
|
||
v-model="filter.shop"
|
||
class="admin-filter"
|
||
filterable
|
||
clearable
|
||
placeholder="全部店铺"
|
||
style="width: 220px"
|
||
@change="search"
|
||
>
|
||
<el-option v-for="shop in shopOptions" :key="shop" :label="shop" :value="shop" />
|
||
</el-select>
|
||
<span class="filter-tip">精确匹配店铺名</span>
|
||
</div>
|
||
<div class="form-group" style="min-width: 190px">
|
||
<label>创建时间(起)</label>
|
||
<input v-model="filter.startTime" type="datetime-local" />
|
||
</div>
|
||
<div class="form-group" style="min-width: 190px">
|
||
<label>创建时间(止)</label>
|
||
<input v-model="filter.endTime" type="datetime-local" />
|
||
</div>
|
||
<div class="form-group">
|
||
<label> </label>
|
||
<div class="filter-actions">
|
||
<button class="btn" type="button" @click="search">查询</button>
|
||
<button class="btn btn-ghost" type="button" @click="resetFilter">重置</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="table-scroll">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th style="width: 120px">账号</th>
|
||
<th style="width: 160px">店铺</th>
|
||
<th style="width: 90px">国家</th>
|
||
<th style="width: 120px">业务</th>
|
||
<th style="width: 120px">状态</th>
|
||
<th style="width: 170px">任务ID</th>
|
||
<th style="width: 165px">开始时间</th>
|
||
<th style="width: 165px">最近上报</th>
|
||
<th style="width: 165px">结束时间</th>
|
||
<th style="width: 190px">进度</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<template v-if="tasks.length">
|
||
<tr v-for="row in tasks" :key="row.taskNo">
|
||
<td>
|
||
<span class="strong">{{ accountOf(row) }}</span>
|
||
</td>
|
||
<td>{{ shopDisplayName(row.shopName, row.shopCount) }}</td>
|
||
<td>{{ countryLabel(row.country) }}</td>
|
||
<td>{{ row.moduleLabel || row.moduleType }}</td>
|
||
<td>
|
||
<span class="st-pill" :class="`is-${taskStatusType(row.status)}`">{{ taskStatusLabel(row.status) }}</span>
|
||
<span v-if="row.stuck" class="badge warn">疑似卡住</span>
|
||
</td>
|
||
<td>
|
||
<button class="cell-link mono" type="button" @click="openDetail(row)">{{ row.id }}</button>
|
||
</td>
|
||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||
<td>
|
||
<span :class="{ 'is-warn-text': row.stuck }">
|
||
{{ row.lastReportAt ? formatDateTime(row.lastReportAt) : '—' }}
|
||
</span>
|
||
</td>
|
||
<td>{{ row.finishedAt ? formatDateTime(row.finishedAt) : '—' }}</td>
|
||
<td>
|
||
<template v-if="taskStatusType(row.status) === 'failed'">
|
||
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
||
<span v-else>—</span>
|
||
</template>
|
||
<template v-else>
|
||
<div class="progress-line">
|
||
<span>{{ progressText(row) }}</span>
|
||
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
||
</div>
|
||
<div class="p-track" v-if="row.progressTotal > 0">
|
||
<div class="p-fill" :style="{ width: progressPercent(row) + '%' }"></div>
|
||
</div>
|
||
</template>
|
||
</td>
|
||
</tr>
|
||
</template>
|
||
<tr v-else-if="tasksLoading">
|
||
<td colspan="10" class="empty-tip">加载中...</td>
|
||
</tr>
|
||
<tr v-else>
|
||
<td colspan="10" class="empty-tip">暂无符合条件的任务</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<OldPagination
|
||
:total="taskTotal"
|
||
:page="taskPage"
|
||
:page-size="taskPageSize"
|
||
@change="changeTaskPage"
|
||
@size-change="changeTaskSize"
|
||
/>
|
||
</section>
|
||
</template>
|
||
|
||
<!-- ============ 页签二:变体采集 ============ -->
|
||
<template v-else>
|
||
<section class="panel-box">
|
||
<div class="box-head">
|
||
<h3>变体采集(麦象批量任务)</h3>
|
||
<span class="box-note">数据来自麦象平台,范围限本组账号,默认全部状态(待执行/处理中/成功/失败)</span>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group" style="min-width: 150px">
|
||
<label>状态</label>
|
||
<select v-model="variantFilter.status">
|
||
<option v-for="option in VARIANT_STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label> </label>
|
||
<div class="filter-actions">
|
||
<button class="btn" type="button" @click="searchVariant">查询</button>
|
||
<button class="btn btn-ghost" type="button" @click="resetVariant">重置</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="table-scroll">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th style="width: 150px">账号</th>
|
||
<th style="width: 200px">任务号</th>
|
||
<th style="width: 110px">状态</th>
|
||
<th style="width: 165px">开始时间</th>
|
||
<th style="width: 165px">更新时间</th>
|
||
<th>结果信息</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<template v-if="variantRows.length">
|
||
<tr v-for="row in variantRows" :key="row.taskId">
|
||
<td>
|
||
<span class="strong">{{ variantAccountText(row) }}</span>
|
||
<span v-if="!row.username && row.uid" class="sub" :title="row.uid">{{ row.uid }}</span>
|
||
</td>
|
||
<td>
|
||
<span class="mono">{{ row.taskId }}</span>
|
||
</td>
|
||
<td>
|
||
<span class="st-pill" :class="`is-${variantStatusType(row.status)}`">
|
||
{{ row.statusLabel || variantStatusLabel(row.status) }}
|
||
</span>
|
||
</td>
|
||
<td>{{ formatDateTime(row.createTime) }}</td>
|
||
<td>{{ formatDateTime(row.updateTime) }}</td>
|
||
<td>
|
||
<span class="res-mes" :title="row.resMes || ''">{{ row.resMes || '—' }}</span>
|
||
</td>
|
||
</tr>
|
||
</template>
|
||
<tr v-else-if="variantLoading">
|
||
<td colspan="6" class="empty-tip">加载中...</td>
|
||
</tr>
|
||
<tr v-else>
|
||
<td colspan="6" class="empty-tip">暂无变体采集任务</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<OldPagination
|
||
:total="variantTotal ?? 0"
|
||
:page="variantPage"
|
||
:page-size="variantPageSize"
|
||
@change="changeVariantPage"
|
||
@size-change="changeVariantSize"
|
||
/>
|
||
</section>
|
||
</template>
|
||
|
||
<el-drawer v-model="detailVisible" title="任务详情" size="760px">
|
||
<div v-loading="detailLoading">
|
||
<template v-if="detail">
|
||
<el-descriptions :column="2" border size="small">
|
||
<el-descriptions-item label="任务号">{{ detail.taskNo }}</el-descriptions-item>
|
||
<el-descriptions-item label="业务">{{ detail.moduleLabel || detail.moduleType }}</el-descriptions-item>
|
||
<el-descriptions-item label="账号">{{ accountOf(detail) }}</el-descriptions-item>
|
||
<el-descriptions-item label="设备">
|
||
{{ deviceOf(detail) }}<span v-if="detail.webDevice" class="badge web">网页</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="店铺">{{ shopDisplayName(detail.shopName, detail.shopCount) }}</el-descriptions-item>
|
||
<el-descriptions-item label="状态">
|
||
<span class="st-pill" :class="`is-${taskStatusType(detail.status)}`">{{ taskStatusLabel(detail.status) }}</span>
|
||
<span v-if="detail.stuck" class="badge warn">疑似卡住</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="开始时间">{{ formatDateTime(detail.createdAt) }}</el-descriptions-item>
|
||
<el-descriptions-item label="最近上报">{{ detail.lastReportAt ? formatDateTime(detail.lastReportAt) : '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="结束时间">{{ detail.finishedAt ? formatDateTime(detail.finishedAt) : '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="进度">
|
||
<template v-if="taskStatusType(detail.status) === 'failed'">
|
||
<span v-if="detail.progressFailed > 0" class="badge danger">失败 {{ detail.progressFailed }}</span>
|
||
<span v-else>—</span>
|
||
</template>
|
||
<template v-else>
|
||
{{ progressText(detail) }}
|
||
<span v-if="detail.progressFailed > 0" class="badge danger">失败 {{ detail.progressFailed }}</span>
|
||
</template>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="当前处理">{{ currentScopeOf(detail) }}</el-descriptions-item>
|
||
<el-descriptions-item label="错误信息" :span="2">{{ detail.errorMessage || detail.message || '—' }}</el-descriptions-item>
|
||
</el-descriptions>
|
||
|
||
<h4 class="detail-title">分组明细({{ (detail.shops || []).length }} 组)</h4>
|
||
<table v-if="(detail.shops || []).length" class="detail-table">
|
||
<thead>
|
||
<tr>
|
||
<th>分组</th>
|
||
<th style="width: 90px">总数</th>
|
||
<th style="width: 90px">成功</th>
|
||
<th style="width: 90px">失败</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr v-for="(item, index) in detail.shops" :key="`${item.scopeKey}-${index}`">
|
||
<td>{{ item.scopeKey || '—' }}</td>
|
||
<td>{{ item.total }}</td>
|
||
<td>{{ item.success }}</td>
|
||
<td>
|
||
<span :class="{ 'is-failed': item.failed > 0 }">{{ item.failed }}</span>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div v-else class="empty-tip">暂无分组明细</div>
|
||
</template>
|
||
<div v-else-if="!detailLoading" class="empty-tip">任务不存在或无权查看</div>
|
||
</div>
|
||
</el-drawer>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
/* 沿用「记录与版本」系列的旧后台面板视觉语言。 */
|
||
.tc-view {
|
||
font-family: inherit;
|
||
color: #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;
|
||
font-size: 15px;
|
||
font-weight: 650;
|
||
color: #24384d;
|
||
letter-spacing: 0.2px;
|
||
}
|
||
.tc-head {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
flex-wrap: wrap;
|
||
}
|
||
.tc-head-tools {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
}
|
||
.updated-tip {
|
||
color: #8598ab;
|
||
font-size: 12.5px;
|
||
}
|
||
.tabs {
|
||
display: inline-flex;
|
||
gap: 4px;
|
||
padding: 4px;
|
||
border: 1px solid #dbe6f0;
|
||
border-radius: 9px;
|
||
background: #f4f8fb;
|
||
}
|
||
.tab {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 7px;
|
||
min-height: 34px;
|
||
padding: 5px 14px;
|
||
border: none;
|
||
border-radius: 7px;
|
||
background: transparent;
|
||
color: #5b6f83;
|
||
font-family: inherit;
|
||
font-size: 13.5px;
|
||
cursor: pointer;
|
||
}
|
||
.tab:hover {
|
||
color: #2f5d8b;
|
||
}
|
||
.tab.active {
|
||
background: #4f78a5;
|
||
color: #ffffff;
|
||
}
|
||
.t-count {
|
||
padding: 0 7px;
|
||
border-radius: 10px;
|
||
background: rgba(0, 0, 0, 0.08);
|
||
font-size: 11px;
|
||
font-weight: 700;
|
||
}
|
||
.tab.active .t-count {
|
||
background: rgba(255, 255, 255, 0.25);
|
||
}
|
||
.tc-cards {
|
||
display: grid;
|
||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||
gap: 12px;
|
||
margin-top: 16px;
|
||
}
|
||
.tc-card {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 6px;
|
||
padding: 14px 16px;
|
||
border: 1px solid #dbe6f0;
|
||
border-radius: 12px;
|
||
background: #ffffff;
|
||
}
|
||
.tc-card-label {
|
||
color: #5b6f83;
|
||
font-size: 12.5px;
|
||
font-weight: 600;
|
||
}
|
||
.tc-card-value {
|
||
font-size: 24px;
|
||
font-weight: 700;
|
||
line-height: 1.1;
|
||
color: #24384d;
|
||
}
|
||
.tc-card-value.is-ok {
|
||
color: #3f7a42;
|
||
}
|
||
.tc-card-value.is-warn {
|
||
color: #b3803a;
|
||
}
|
||
.tc-card-note {
|
||
color: #93a4b5;
|
||
font-size: 11.5px;
|
||
}
|
||
.box-head {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
margin-bottom: 14px;
|
||
}
|
||
.box-note {
|
||
color: #8598ab;
|
||
font-size: 12.5px;
|
||
}
|
||
.is-warn-text {
|
||
color: #b3803a;
|
||
font-weight: 650;
|
||
}
|
||
.shop-filter {
|
||
position: relative;
|
||
}
|
||
/* 提示行必须退出列流:.form-row 是 align-items: flex-end,组内多一行会把「店铺」label 顶得比别的筛选项高。 */
|
||
.filter-tip {
|
||
position: absolute;
|
||
left: 0;
|
||
top: calc(100% + 4px);
|
||
white-space: nowrap;
|
||
color: #93a4b5;
|
||
font-size: 11.5px;
|
||
}
|
||
.form-row {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: flex-end;
|
||
gap: 14px 18px;
|
||
margin-bottom: 22px;
|
||
}
|
||
.form-group {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 7px;
|
||
}
|
||
.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;
|
||
}
|
||
.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);
|
||
}
|
||
.filter-actions {
|
||
display: flex;
|
||
gap: 10px;
|
||
}
|
||
.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);
|
||
}
|
||
.btn:hover:not(:disabled) {
|
||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||
}
|
||
.btn:disabled {
|
||
cursor: not-allowed;
|
||
opacity: 0.55;
|
||
}
|
||
.btn-ghost {
|
||
background: #ffffff;
|
||
border-color: #c7d7e5;
|
||
color: #4f78a5;
|
||
box-shadow: none;
|
||
}
|
||
.btn-ghost:hover:not(:disabled) {
|
||
background: #edf5fb;
|
||
border-color: #95b1cb;
|
||
color: #2f5d8b;
|
||
}
|
||
.table-scroll {
|
||
width: 100%;
|
||
overflow-x: auto;
|
||
}
|
||
table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
font-size: 13px;
|
||
}
|
||
th {
|
||
padding: 10px 12px;
|
||
text-align: left;
|
||
color: #5b6f83;
|
||
font-weight: 650;
|
||
font-size: 12.5px;
|
||
border-bottom: 1px solid #dbe6f0;
|
||
white-space: nowrap;
|
||
}
|
||
td {
|
||
padding: 10px 12px;
|
||
border-bottom: 1px solid #eaf1f7;
|
||
vertical-align: top;
|
||
}
|
||
.strong {
|
||
display: block;
|
||
font-weight: 600;
|
||
word-break: break-all;
|
||
}
|
||
.sub {
|
||
display: block;
|
||
color: #8598ab;
|
||
font-size: 11.5px;
|
||
word-break: break-all;
|
||
}
|
||
.mono {
|
||
font-family: Consolas, 'Courier New', monospace;
|
||
font-size: 12px;
|
||
word-break: break-all;
|
||
}
|
||
/* 任务 ID 单元格:「操作」列删除后,它是详情抽屉唯一的入口。 */
|
||
.cell-link {
|
||
padding: 0;
|
||
border: none;
|
||
background: none;
|
||
color: #2f5d8b;
|
||
cursor: pointer;
|
||
}
|
||
.cell-link:hover {
|
||
text-decoration: underline;
|
||
}
|
||
.res-mes {
|
||
display: block;
|
||
word-break: break-all;
|
||
}
|
||
.st-pill {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 2px 10px;
|
||
border-radius: 999px;
|
||
font-size: 12px;
|
||
line-height: 1.7;
|
||
border: 1px solid transparent;
|
||
white-space: nowrap;
|
||
}
|
||
.st-pill.is-success {
|
||
color: #3d7158;
|
||
background: #e8f2eb;
|
||
border-color: #bdd7c5;
|
||
}
|
||
.st-pill.is-failed {
|
||
color: #91474f;
|
||
background: #f8ebeb;
|
||
border-color: #e4c2c5;
|
||
}
|
||
.st-pill.is-pending {
|
||
color: #8a6d3b;
|
||
background: #fbf4ea;
|
||
border-color: #e7d3ae;
|
||
}
|
||
.st-pill.is-running {
|
||
color: #37618f;
|
||
background: #e8f1fb;
|
||
border-color: #c3d8ef;
|
||
}
|
||
.badge {
|
||
display: inline-block;
|
||
margin-left: 6px;
|
||
padding: 1px 7px;
|
||
border-radius: 999px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
white-space: nowrap;
|
||
}
|
||
.badge.web {
|
||
background: #e8f1fb;
|
||
color: #37618f;
|
||
}
|
||
.badge.warn {
|
||
background: #fbf4ea;
|
||
color: #8a6d3b;
|
||
}
|
||
.badge.danger {
|
||
background: #f8ebeb;
|
||
color: #91474f;
|
||
}
|
||
.progress-line {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
flex-wrap: wrap;
|
||
margin-bottom: 5px;
|
||
}
|
||
.p-track {
|
||
height: 6px;
|
||
border-radius: 999px;
|
||
background: #eaf1f7;
|
||
overflow: hidden;
|
||
}
|
||
.p-fill {
|
||
height: 100%;
|
||
border-radius: 999px;
|
||
background: linear-gradient(90deg, #6f97bd, #4f78a5);
|
||
}
|
||
.empty-tip {
|
||
padding: 30px 24px;
|
||
text-align: center;
|
||
color: #8293a5;
|
||
font-size: 13.5px;
|
||
}
|
||
.detail-title {
|
||
margin: 18px 0 10px;
|
||
font-size: 13.5px;
|
||
font-weight: 650;
|
||
color: #24384d;
|
||
}
|
||
.detail-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
font-size: 13px;
|
||
}
|
||
.detail-table th,
|
||
.detail-table td {
|
||
padding: 8px 10px;
|
||
border-bottom: 1px solid #eaf1f7;
|
||
text-align: left;
|
||
}
|
||
.detail-table .is-failed {
|
||
color: #91474f;
|
||
font-weight: 600;
|
||
}
|
||
@media (max-width: 1280px) {
|
||
.tc-cards {
|
||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||
}
|
||
}
|
||
@media (max-width: 900px) {
|
||
.tc-cards {
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
}
|
||
}
|
||
</style>
|