feat(rohs-check): 新增 RoHS 检核工具进度查询功能及相关接口

This commit is contained in:
hugo committed 2026-06-11 10:05:29 +08:00
1 parent fee33f69d9
commit a18a07ef1a
19 files changed
+654 -58

No files matched your search

@@ -0,0 +1,105 @@
<script setup lang="ts">
import { AlertCircle, CheckCircle2, Clock3, Download, Loader2 } from 'lucide-vue-next';
import type { ToolRunProgress } from '@/api/toolRunProgress';
const props = defineProps<{
run: ToolRunProgress | null;
loading?: boolean;
error?: string;
fallbackTitle?: string;
}>();
const statusLabel = (status?: string) => {
const map: Record<string, string> = {
running: '执行中',
success: '已完成',
partial_failed: '部分失败',
failed: '失败',
cancelled: '已取消',
canceled: '已取消',
};
return map[String(status || '')] || status || '等待中';
};
const formatTime = (value?: string | null) => {
if (!value) return '-';
return String(value).replace('T', ' ').slice(0, 19);
};
const percent = () => Math.max(0, Math.min(Number(props.run?.progress_percent || 0), 100));
</script>
<template>
<section
v-if="run || loading || error"
class="mx-auto mb-4 w-full max-w-4xl overflow-hidden rounded-2xl border border-sky-100 bg-gradient-to-br from-sky-50 via-white to-emerald-50 shadow-sm"
>
<div class="flex items-start justify-between gap-3 border-b border-sky-100/80 px-4 py-3">
<div>
<div class="flex items-center gap-2 text-sm font-semibold text-slate-800">
<Loader2 v-if="run?.status === 'running'" class="h-4 w-4 animate-spin text-sky-600" />
<CheckCircle2 v-else-if="run?.status === 'success'" class="h-4 w-4 text-emerald-600" />
<AlertCircle v-else-if="run?.status === 'failed' || run?.status === 'partial_failed'" class="h-4 w-4 text-amber-600" />
<Clock3 v-else class="h-4 w-4 text-sky-600" />
{{ run?.title || fallbackTitle || '任务进度' }}
</div>
<p class="mt-1 text-xs text-slate-500">
<template v-if="run">批次:{{ run.run_no }} · 状态:{{ statusLabel(run.status) }}</template>
<template v-else-if="loading">正在查询任务进度...</template>
<template v-else>{{ error }}</template>
</p>
</div>
<a
v-if="run?.excel?.download_url"
:href="run.excel.download_url"
target="_blank"
class="inline-flex items-center gap-1 rounded-full bg-sky-600 px-3 py-1.5 text-xs font-medium text-white transition hover:bg-sky-700"
>
<Download class="h-3.5 w-3.5" />
下载 Excel
</a>
</div>
<div v-if="run" class="space-y-3 px-4 py-4">
<div class="h-2.5 overflow-hidden rounded-full bg-slate-200">
<div
class="h-full rounded-full bg-gradient-to-r from-sky-500 to-emerald-500 transition-all duration-500"
:style="{ width: `${percent()}%` }"
></div>
</div>
<div class="flex flex-wrap items-center justify-between gap-2 text-xs text-slate-500">
<span>进度 {{ percent() }}%</span>
<span>开始:{{ formatTime(run.started_at) }} · 完成:{{ formatTime(run.finished_at) }}</span>
</div>
<div class="grid grid-cols-2 gap-2 md:grid-cols-5">
<div class="rounded-xl bg-white/80 px-3 py-2">
<div class="text-xs text-slate-500">总数</div>
<div class="text-lg font-bold text-slate-800">{{ run.total_count }}</div>
</div>
<div class="rounded-xl bg-white/80 px-3 py-2">
<div class="text-xs text-slate-500">已处理</div>
<div class="text-lg font-bold text-sky-700">{{ run.processed_count }}</div>
</div>
<div class="rounded-xl bg-white/80 px-3 py-2">
<div class="text-xs text-slate-500">成功</div>
<div class="text-lg font-bold text-emerald-700">{{ run.success_count }}</div>
</div>
<div class="rounded-xl bg-white/80 px-3 py-2">
<div class="text-xs text-slate-500">失败</div>
<div class="text-lg font-bold text-rose-700">{{ run.failed_count }}</div>
</div>
<div class="rounded-xl bg-white/80 px-3 py-2">
<div class="text-xs text-slate-500">跳过</div>
<div class="text-lg font-bold text-amber-700">{{ run.skipped_count }}</div>
</div>
</div>
<div v-if="run.knowledge_base?.sync_status || run.error_message" class="rounded-xl bg-white/70 px-3 py-2 text-xs text-slate-600">
<div v-if="run.knowledge_base?.sync_status">知识库同步:{{ run.knowledge_base.sync_status }}</div>
<div v-if="run.knowledge_base?.error_message" class="text-amber-700">同步错误:{{ run.knowledge_base.error_message }}</div>
<div v-if="run.error_message" class="text-rose-700">错误信息:{{ run.error_message }}</div>
</div>
</div>
</section>
</template>