3a8f6968ff
- 路由 task-center/board(menuKey admin_task_center)+ guides 文案,both 由既有门禁守 - api 层 5 个只读接口;详情接口把后端 data:null 归一为 null(unwrap 对 null data 回传信封) - 页签一:5 项汇总卡 + 设备卡条(点击按设备筛选/再点取消)+ 10 列任务表(stuck/网页/失败角标、进度条)+ 详情抽屉(分组明细) - 页签二:变体采集专列(不显示设备与店铺),展示麦象 res_mes 与任务参数 - 30s 轮询:页面隐藏跳过、回前台立即刷新、卸载清理;另有手动刷新 - 顺带补 admin_device_logs 缺失的 guide(a7f244f9 登记路由时漏补,align-operation-guide 一直红) Tests run: 1634, Failures: 0(node --test 全量)+ vue-tsc 无错误 + vite build 通过, 浏览器真跑:页签切换、设备卡筛选、详情抽屉均正常,控制台无报错
1016 lines
30 KiB
Vue
1016 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 {
|
||
fetchTaskCenterDevices,
|
||
fetchTaskCenterOverview,
|
||
fetchTaskCenterTaskDetail,
|
||
fetchTaskCenterTasks,
|
||
fetchTaskCenterVariantTasks,
|
||
type TaskCenterDevice,
|
||
type TaskCenterOverview,
|
||
type TaskCenterTaskDetail,
|
||
type TaskCenterTaskRow,
|
||
type TaskCenterVariantTaskRow,
|
||
} from '@/api/task-center'
|
||
import {
|
||
MODULE_OPTIONS,
|
||
TASK_STATUS_OPTIONS,
|
||
VARIANT_STATUS_OPTIONS,
|
||
buildTaskQuery,
|
||
buildVariantQuery,
|
||
createTaskFilter,
|
||
createVariantFilter,
|
||
deviceDisplayName,
|
||
progressPercent,
|
||
progressText,
|
||
shopDisplayName,
|
||
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 devices = ref<TaskCenterDevice[]>([])
|
||
const filter = reactive<TaskCenterTaskFilter>(createTaskFilter())
|
||
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[]>([])
|
||
const variantTotal = ref(0)
|
||
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 / variantPageSize.value)))
|
||
|
||
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 loadDevices() {
|
||
try {
|
||
devices.value = (await fetchTaskCenterDevices()) || []
|
||
} 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 = Number(result?.total || 0)
|
||
} catch (error) {
|
||
ElMessage.error(errorText(error, '变体采集加载失败'))
|
||
} finally {
|
||
if (!silent) variantLoading.value = false
|
||
}
|
||
}
|
||
|
||
/** 汇总卡与设备条只描述客户端任务,两个页签都刷新它们(切页签时看到的就是最新)。 */
|
||
async function refreshAll(silent = false) {
|
||
await Promise.all([
|
||
loadOverview(),
|
||
loadDevices(),
|
||
activeTab.value === 'tasks' ? loadTasks(silent) : loadVariants(silent),
|
||
])
|
||
updatedAt.value = formatDateTime(Date.now())
|
||
}
|
||
|
||
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, createTaskFilter())
|
||
taskPage.value = 1
|
||
void loadTasks()
|
||
}
|
||
|
||
/** 点设备卡:按该设备筛选任务(再点一次取消)。 */
|
||
function selectDevice(deviceId: string) {
|
||
filter.deviceId = filter.deviceId === deviceId ? '' : deviceId
|
||
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()
|
||
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">{{ taskTotal }}</span>
|
||
</button>
|
||
<button class="tab" :class="{ active: activeTab === 'variant' }" type="button" @click="switchTab('variant')">
|
||
变体采集 <span class="t-count">{{ 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?.deviceTotal ?? '—' }}</span>
|
||
<span class="tc-card-note">近 30 天任务 ∪ 近 7 天日志</span>
|
||
</div>
|
||
<div class="tc-card">
|
||
<span class="tc-card-label">在线设备</span>
|
||
<span class="tc-card-value is-ok">{{ overview?.deviceOnline ?? '—' }}</span>
|
||
<span class="tc-card-note">5 分钟内有上报</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 v-if="devices.length" class="device-strip">
|
||
<button
|
||
v-for="device in devices"
|
||
:key="device.deviceId"
|
||
class="device-card"
|
||
:class="{ active: filter.deviceId === device.deviceId, online: device.online }"
|
||
type="button"
|
||
:title="device.deviceId"
|
||
@click="selectDevice(device.deviceId)"
|
||
>
|
||
<span class="device-line">
|
||
<span class="dot" :class="device.online ? 'is-online' : 'is-offline'"></span>
|
||
<span class="device-name">{{ deviceDisplayName(device.deviceName, device.deviceId) }}</span>
|
||
<span v-if="device.webDevice" class="badge web">网页</span>
|
||
</span>
|
||
<span class="device-meta">
|
||
{{ device.runningTasks > 0 ? `跑任务 ${device.runningTasks}` : '空闲' }} ·
|
||
{{ device.lastActiveAt ? formatDateTime(device.lastActiveAt) : '窗口内无活动' }}
|
||
</span>
|
||
</button>
|
||
</div>
|
||
<div v-else class="empty-tip">暂无设备记录</div>
|
||
</section>
|
||
|
||
<section class="panel-box">
|
||
<div class="box-head">
|
||
<h3>任务筛选</h3>
|
||
</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" style="min-width: 190px">
|
||
<label>设备</label>
|
||
<select v-model="filter.deviceId">
|
||
<option value="">全部设备</option>
|
||
<option v-for="device in devices" :key="device.deviceId" :value="device.deviceId">
|
||
{{ deviceDisplayName(device.deviceName, device.deviceId) }}
|
||
</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group" style="min-width: 160px">
|
||
<label>店铺</label>
|
||
<input v-model="filter.shop" type="text" placeholder="模糊搜索店铺名" @keyup.enter="search" />
|
||
</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: 170px">设备</th>
|
||
<th style="width: 160px">店铺</th>
|
||
<th style="width: 120px">业务</th>
|
||
<th style="width: 120px">状态</th>
|
||
<th style="width: 170px">当前处理</th>
|
||
<th style="width: 165px">开始时间</th>
|
||
<th style="width: 165px">结束时间</th>
|
||
<th style="width: 190px">进度</th>
|
||
<th style="width: 90px">操作</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>
|
||
<span class="sub">{{ row.taskNo }}</span>
|
||
</td>
|
||
<td>
|
||
<span class="strong">{{ deviceOf(row) }}</span>
|
||
<span v-if="row.webDevice" class="badge web">网页</span>
|
||
<span v-if="row.deviceId && row.deviceName" class="sub" :title="row.deviceId">{{ row.deviceId }}</span>
|
||
</td>
|
||
<td>{{ shopDisplayName(row.shopName, row.shopCount) }}</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>
|
||
<span class="scope" :title="currentScopeOf(row)">{{ currentScopeOf(row) }}</span>
|
||
</td>
|
||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||
<td>{{ row.finishedAt ? formatDateTime(row.finishedAt) : '—' }}</td>
|
||
<td>
|
||
<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"><div class="p-fill" :style="{ width: progressPercent(row) + '%' }"></div></div>
|
||
</td>
|
||
<td>
|
||
<button class="btn btn-ghost btn-sm" type="button" @click="openDetail(row)">查看</button>
|
||
</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>
|
||
<span v-if="row.taskData" class="sub mono" :title="row.taskData">{{ row.taskData }}</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"
|
||
: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.finishedAt ? formatDateTime(detail.finishedAt) : '—' }}</el-descriptions-item>
|
||
<el-descriptions-item label="进度">
|
||
{{ progressText(detail) }}
|
||
<span v-if="detail.progressFailed > 0" class="badge danger">失败 {{ detail.progressFailed }}</span>
|
||
</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;
|
||
}
|
||
.device-strip {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 10px;
|
||
}
|
||
.device-card {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 6px;
|
||
min-width: 190px;
|
||
max-width: 260px;
|
||
padding: 10px 14px;
|
||
border: 1px solid #dbe6f0;
|
||
border-radius: 11px;
|
||
background: #ffffff;
|
||
color: #24384d;
|
||
font-family: inherit;
|
||
font-size: 13px;
|
||
text-align: left;
|
||
cursor: pointer;
|
||
}
|
||
.device-card:hover {
|
||
border-color: #95b1cb;
|
||
background: #f2f8fd;
|
||
}
|
||
.device-card.active {
|
||
border-color: #4f78a5;
|
||
box-shadow: 0 0 0 2px rgba(79, 120, 165, 0.18);
|
||
}
|
||
.device-line {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 7px;
|
||
min-width: 0;
|
||
}
|
||
.device-name {
|
||
font-weight: 600;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
.device-meta {
|
||
color: #8598ab;
|
||
font-size: 11.5px;
|
||
}
|
||
.dot {
|
||
flex: none;
|
||
width: 8px;
|
||
height: 8px;
|
||
border-radius: 50%;
|
||
}
|
||
.dot.is-online {
|
||
background: #4f9a58;
|
||
}
|
||
.dot.is-offline {
|
||
background: #c2cdd8;
|
||
}
|
||
.form-row {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: flex-end;
|
||
gap: 14px 18px;
|
||
margin-bottom: 16px;
|
||
}
|
||
.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;
|
||
}
|
||
.btn-sm {
|
||
min-height: 32px;
|
||
padding: 4px 12px;
|
||
font-size: 12.5px;
|
||
border-radius: 7px;
|
||
}
|
||
.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;
|
||
}
|
||
.scope {
|
||
display: inline-block;
|
||
max-width: 160px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
.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-cancelled {
|
||
color: #5b6f83;
|
||
background: #f1f6fa;
|
||
border-color: #d6e2ec;
|
||
}
|
||
.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>
|