| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267 |
- <template>
- <div :class="prefixCls" class="case-clean-progress">
- <!-- 清洗流程公共顶栏:品牌 / 案件 / 模板库 / 下载管理 / 窗口控制 -->
- <CaseFlowTopBar />
- <div class="page-body">
- <div class="page-header">
- <div class="page-header__main">
- <span class="page-title-icon">
- <Icon icon="i-ant-design:database-outlined" :size="19" />
- </span>
- <div class="page-title-wrap">
- <div class="page-title">{{ isComplete ? '数据清洗结果' : '数据清洗进行中' }}</div>
- <div class="page-subtitle">{{ pageSubtitle }}</div>
- </div>
- </div>
- <div v-if="!isComplete" class="page-header__actions">
- <Button class="stop-clean-btn" danger :loading="stopping" @click="handleStopClean">
- {{ stopping ? '正在停止…' : '停止清洗' }}
- </Button>
- <span class="sse-pill" :class="{ 'is-on': sseConnected }">
- <span class="sse-dot"></span>
- {{ sseConnected ? '实时推送已连接' : '实时推送未连接' }}
- </span>
- </div>
- </div>
- <div class="progress-layout" :class="{ 'is-fused': isFused }">
- <div class="progress-card">
- <template v-if="!isComplete">
- <div class="run-layout">
- <aside class="run-side">
- <div class="run-head">
- <span class="run-live"></span>
- <div class="run-head__text">
- <div class="run-title">任务执行中</div>
- <div class="run-subtitle">{{ progressStatusText }}</div>
- </div>
- </div>
- <div class="run-summary">
- <div class="run-ring">
- <div class="progress-ring">
- <svg viewBox="0 0 120 120">
- <circle cx="60" cy="60" r="50" class="ring-bg" />
- <circle
- cx="60"
- cy="60"
- r="50"
- class="ring-value"
- :style="{
- strokeDasharray: `${RING_CIRCUMFERENCE}`,
- strokeDashoffset: `${RING_CIRCUMFERENCE - progressDash}`,
- }"
- />
- </svg>
- <div class="progress-value">
- <strong>{{ overallProgress }}<small>%</small></strong>
- <span>{{ currentStepLabel }}</span>
- </div>
- </div>
- </div>
- <div class="run-summary__stats">
- <div class="run-stat-line">
- <span class="run-stat-line__label">导入成功</span>
- <strong class="run-stat-line__value is-success">{{ displaySuccessCount }}</strong>
- </div>
- <div class="run-stat-line">
- <span class="run-stat-line__label">导入失败</span>
- <strong class="run-stat-line__value is-fail">{{ displayFailCount }}</strong>
- </div>
- </div>
- </div>
- <div class="run-steps">
- <div
- v-for="(step, index) in runSteps"
- :key="step.title"
- class="run-step"
- :class="{
- 'is-done': activeStep > index,
- 'is-active': activeStep === index,
- 'is-pending': activeStep < index,
- }"
- >
- <div class="run-step__rail">
- <span class="run-step__dot">{{ activeStep > index ? '✓' : index + 1 }}</span>
- <span v-if="index < runSteps.length - 1" class="run-step__line"></span>
- <span v-else-if="activeStep === index" class="run-step__line run-step__line--tail"></span>
- <span v-if="activeStep === index" class="run-step__flow" aria-hidden="true"></span>
- </div>
- <div class="run-step__body">
- <div class="run-step__head">
- <span class="run-step__title">{{ step.title }}</span>
- <span class="run-step__status">
- <i v-if="activeStep === index" class="run-step__status-dot"></i>
- {{ activeStep > index ? '已完成' : activeStep === index ? '进行中' : '待执行' }}
- </span>
- </div>
- <div class="run-step__desc">{{ step.desc }}</div>
- </div>
- </div>
- </div>
- </aside>
- <section class="run-log" :class="{ 'is-govern': shouldRunGovernAfterClean && activeStep >= 2 }">
- <TaskLogList
- :logs="taskLog"
- title="处理日志"
- live
- console-style
- fill
- empty-text="等待任务推送,处理记录将实时写入这里"
- />
- </section>
- </div>
- <!-- 融合模式的出口:SSE 推送中断(后端重启/网络断开),进度无法继续更新 -->
- <div v-if="aiStageTimeout && !isComplete" class="ai-timeout-banner">
- <span class="ai-timeout-text">
- AI
- 清洗进度推送已中断(连接断开或后端已重启)。稍后可在「数据治理」查看已入库结果,或改用手动清洗处理这批文件。
- </span>
- <Button type="link" size="small" @click="goManualClean">改为手动清洗</Button>
- </div>
- </template>
- <template v-else>
- <div class="progress-complete-layout">
- <div class="complete-summary" :class="{ 'is-failed': governFailed }">
- <div class="complete-icon" :class="{ 'is-failed': governFailed }">
- {{ governFailed ? '!' : '✓' }}
- </div>
- <div class="complete-main">
- <div class="complete-title" :class="{ 'is-failed': governFailed }">{{ completeTitle }}</div>
- <div class="complete-desc">{{ completeDesc }}</div>
- <div class="complete-meta">
- <span v-if="currentCleanBatchId" class="complete-meta__item">批次 {{ currentCleanBatchId }}</span>
- <span class="complete-meta__item">共 {{ taskLog.length }} 条日志</span>
- <span class="complete-meta__item">任务耗时 {{ taskDurationText }}</span>
- </div>
- </div>
- <div class="complete-stats">
- <div class="complete-stat">
- <span class="complete-stat__value is-success">{{ displaySuccessCount }}</span>
- <span class="complete-stat__label">导入成功(条)</span>
- </div>
- <span class="complete-stat__divider"></span>
- <div class="complete-stat">
- <!-- 失败数固定用红色(与成功数的绿色对应),0 也保持红色,避免完成态一眼看不出哪一项是失败口径 -->
- <span class="complete-stat__value is-fail">{{ displayFailCount }}</span>
- <span class="complete-stat__label">导入失败(条)</span>
- </div>
- <!-- AI 无法清洗的表:同属失败语义,单独明示 -->
- <template v-if="unableCount > 0">
- <span class="complete-stat__divider"></span>
- <div class="complete-stat">
- <span class="complete-stat__value is-warn">{{ unableCount }}</span>
- <span class="complete-stat__label">未清洗(表)</span>
- </div>
- </template>
- <span class="complete-stat__divider"></span>
- <div class="complete-stat">
- <span class="complete-stat__value is-rate">{{ successRate }}</span>
- <span class="complete-stat__label">成功率</span>
- </div>
- </div>
- <div class="complete-actions">
- <Button class="complete-log" @click="handleViewLog">查看清洗日志</Button>
- <Button type="primary" class="complete-result" @click="handleViewResult">查看结果</Button>
- </div>
- </div>
- <div class="progress-log progress-log--complete">
- <TaskLogList :logs="taskLog" title="任务日志" console-style fill empty-text="本次任务暂无日志" />
- </div>
- </div>
- </template>
- </div>
- </div>
- </div>
- <CleanLogModal v-model:open="logModalOpen" :file-infos="currentCleanFiles" :batch-id="currentCleanBatchId" />
- </div>
- </template>
- <script lang="ts" setup name="ViewsDataCleanProgress">
- import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
- import { useRoute } from 'vue-router';
- import { Button, Modal } from 'ant-design-vue';
- import { Icon } from '@/core/components/Icon';
- import { useGo } from '@/core/hooks/web/usePage';
- import { PageEnum } from '@/core/enums/pageEnum';
- import { useDesign } from '@/core/hooks/web/useDesign';
- import { useMessage } from '@/core/hooks/web/useMessage';
- import { useEmitter, useUserStore } from '@/core/store/modules/case';
- import { getToken } from '@/core/utils/auth';
- import { markAnalysisDataChanged } from '@/core/logics/analysisRefreshPrompt';
- import {
- calcTask,
- doClean,
- getGovernConfList,
- getGovernTaskSseUrl,
- smartCleanStatus,
- stopClean,
- stopSmartClean,
- testSse,
- } from '@/case/api/govern/governApi';
- import CleanLogModal from './components/CleanLogModal.vue';
- import CaseFlowTopBar from './components/CaseFlowTopBar.vue';
- import TaskLogList from './components/TaskLogList.vue';
- import type { SmartCleanReviewItem, SmartCleanStatusVO } from '@/case/api/govern/types/dto';
- import type { FileInfo } from '@/types/api';
- import {
- clearImportProgress,
- clearLegacyTaskLogStorage,
- getActiveImportProgress,
- getImportProgressEventSource,
- resetImportProgressRuntimeState,
- saveImportProgress,
- setImportProgressEventSource,
- useImportProgressRuntimeState,
- type TaskLogItem,
- } from './importProgressSession';
- const { prefixCls } = useDesign('case-clean-progress');
- const go = useGo();
- const emitter = useEmitter();
- const userStore = useUserStore();
- const { createMessage } = useMessage();
- const CASE_DATA_REFRESH_EVENT = 'case-data:refresh';
- const CASE_IMPORT_FILE_REFRESH_EVENT = 'case-import-file:refresh';
- const FILE_INFO_STORAGE_KEY = 'case_clean_file_infos';
- const IMPORT_FILE_INFO_STORAGE_KEY = 'case_clean_import_file_infos';
- const RECLEAN_CONTEXT_STORAGE_KEY = 'case_clean_reclean_context';
- /** 清洗完成跳转统计页时的一次性上下文:目标页签 + 清洗来源(自主/智能) */
- const CLEAN_RESULT_CONTEXT_KEY = 'case_clean_result_context';
- const GOVERN_START_TASK_PROCESS = 1;
- const {
- progress,
- activeStep,
- currentFileName,
- currentCleanFiles,
- currentCleanBatchId,
- sseConnected,
- sseError,
- cleanTaskStarted,
- calcTaskTriggered,
- cleanTaskFinished,
- governTaskStarted,
- governTaskFinished,
- shouldRunGovernAfterClean,
- governCompleteNotified,
- successCount,
- failCount,
- cleanStatsSnapshot,
- } = useImportProgressRuntimeState();
- const sseMessages = ref<string[]>([]);
- /**
- * 处理日志:清洗 + 治理统一成一条时间线,只存在本页内存里。
- * 页面退出即清空;不落 localStorage,也不在导入文件页提供历史日志入口。
- */
- const taskLog = ref<TaskLogItem[]>([]);
- const taskLogBatchId = ref('');
- const governFailed = ref(false);
- let taskLogSeq = 0;
- const logModalOpen = ref(false);
- /**
- * 执行中左侧的步骤说明:activeStep 0/1(开启治理时含 2)与之一一对应。
- * 「数据治理」只在治理设置开启自动治理时展示;未开启时流程只有「读取数据 → 清洗入库」两步。
- */
- const runSteps = computed(() => {
- const steps = [
- { title: '读取数据', desc: '解析上传文件与工作表' },
- { title: '清洗入库', desc: '按模板清洗并写入案件库' },
- ];
- if (shouldRunGovernAfterClean.value) {
- steps.push({ title: '数据治理', desc: '去重、关系识别与分类树统计' });
- }
- return steps;
- });
- let eventSource = getImportProgressEventSource();
- /**
- * 清洗 100% 后等待数据治理收尾的兜底:
- * 治理未启动 / 启动失败 / 进度不再推送 / SSE 断流 / AI 终态消息丢失时,页面不能永远停在「执行中」
- * —— 超过静默期就按清洗完成处理,用户仍能进结果页(治理可在数据页手动补跑)。
- */
- const COMPLETION_FALLBACK_GRACE_MS = 15_000;
- /** 治理压根没启动时用更短的静默期(终端消息里 101→103→102 基本同刻到达,等 3s 足够) */
- const COMPLETION_FALLBACK_QUICK_MS = 3_000;
- const completionFallback = ref(false);
- let completionFallbackTimer: ReturnType<typeof setTimeout> | undefined;
- /** 最近一次收到任务事件(cmd 101/102/103)的时间戳:区分「任务在跑只是慢」与「任务没动静」 */
- let lastTaskActivityAt = 0;
- let completionFallbackNotified = false;
- const closeSse = () => {
- const activeEventSource = eventSource || getImportProgressEventSource();
- activeEventSource?.close();
- if (getImportProgressEventSource() === activeEventSource) {
- setImportProgressEventSource(null);
- }
- eventSource = null;
- sseConnected.value = false;
- };
- /**
- * 进度环几何:r=50 → 周长 2πr≈314.159。
- * dasharray 必须固定为「整圈」,只滚动 dashoffset 才能得到与百分比一致的弧长;
- * 旧写法 `dasharray: `${dash} 314`` + `offset: 314 - dash` 会让弧长与进度错位
- * (50% 时弧长为 0 → 圆环上的进度颜色整段空白)。
- */
- const RING_CIRCUMFERENCE = 2 * Math.PI * 50;
- const progressDash = computed(() => (overallProgress.value / 100) * RING_CIRCUMFERENCE);
- const currentStepLabel = computed(() => {
- if (shouldRunGovernAfterClean.value && activeStep.value >= 2) return '数据治理';
- if (activeStep.value >= 1) return '清洗入库';
- return '读取数据';
- });
- const progressStatusText = computed(() => {
- if (governFailed.value) return '数据治理失败';
- if (stopping.value) return '正在停止:等待当前文件处理完成';
- if (isComplete.value) return governTaskFinished.value ? '数据治理完成' : '清洗入库流程已完成';
- return `当前正在执行${currentStepLabel.value}`;
- });
- const completeTitle = computed(() => {
- if (governFailed.value) return '数据治理未完成';
- return stoppedClean.value ? '已停止清洗' : '清洗导入完成';
- });
- const completeDesc = computed(() => {
- if (governFailed.value) {
- return '清洗与入库已完成,但治理阶段失败。可查看任务日志定位原因,或到数据页重新执行治理。';
- }
- if (stoppedClean.value) {
- return '已完成的数据已保留,正在清洗的文件已跑完,其余文件未清洗(也不会自动进入数据治理)。可查看任务日志,稍后重新发起清洗。';
- }
- return governTaskFinished.value ? '数据治理已完成,治理结果已写入案件数据。' : '清洗与入库流程已执行完毕。';
- });
- const displaySuccessCount = computed(() => cleanStatsSnapshot.value.success ?? successCount.value);
- const displayFailCount = computed(() => cleanStatsSnapshot.value.fail ?? failCount.value);
- /** 完成概览里的成功率:成功 /(成功 + 失败),没有数据时显示横杠 */
- const successRate = computed(() => {
- const total = displaySuccessCount.value + displayFailCount.value;
- if (total <= 0) return '—';
- return `${Math.round((displaySuccessCount.value / total) * 100)}%`;
- });
- /** 任务耗时:用日志首尾时间估算(日志按时间倒序,第一条最新、最后一条最早) */
- const taskDurationText = computed(() => {
- if (taskLog.value.length < 2) return '—';
- const toSeconds = (value: string) => {
- const [hour, minute, second] = String(value || '')
- .split(':')
- .map((item) => Number(item));
- if (![hour, minute, second].every(Number.isFinite)) return Number.NaN;
- return hour * 3600 + minute * 60 + second;
- };
- const newest = toSeconds(taskLog.value[0]?.time || '');
- const oldest = toSeconds(taskLog.value[taskLog.value.length - 1]?.time || '');
- if (!Number.isFinite(newest) || !Number.isFinite(oldest)) return '—';
- let diff = newest - oldest;
- // 跨零点时时间是回绕的,补一天
- if (diff < 0) diff += 24 * 3600;
- if (diff < 60) return `${Math.max(1, diff)} 秒`;
- if (diff < 3600) return `${Math.floor(diff / 60)} 分 ${diff % 60} 秒`;
- return `${Math.floor(diff / 3600)} 小时 ${Math.floor((diff % 3600) / 60)} 分`;
- });
- const getCurrentCaseId = () => userStore.getCaseInfo?.id;
- const persistImportProgress = () => {
- if (isComplete.value) {
- clearImportProgress(getCurrentCaseId());
- return;
- }
- if (!cleanTaskStarted.value) return;
- saveImportProgress({
- active: true,
- caseId: getCurrentCaseId(),
- progress: progress.value,
- activeStep: activeStep.value,
- currentFileName: currentFileName.value,
- currentCleanFiles: currentCleanFiles.value,
- currentCleanBatchId: currentCleanBatchId.value,
- successCount: successCount.value,
- failCount: failCount.value,
- cleanStatsSnapshot: cleanStatsSnapshot.value,
- cleanTaskStarted: cleanTaskStarted.value,
- cleanTaskFinished: cleanTaskFinished.value,
- calcTaskTriggered: calcTaskTriggered.value,
- governTaskStarted: governTaskStarted.value,
- governTaskFinished: governTaskFinished.value,
- shouldRunGovernAfterClean: shouldRunGovernAfterClean.value,
- updatedAt: Date.now(),
- });
- };
- const restoreImportProgress = () => {
- const snapshot = getActiveImportProgress(getCurrentCaseId());
- if (!snapshot) return false;
- progress.value = snapshot.progress;
- activeStep.value = snapshot.activeStep;
- currentFileName.value = snapshot.currentFileName;
- currentCleanFiles.value = snapshot.currentCleanFiles || [];
- currentCleanBatchId.value = snapshot.currentCleanBatchId;
- successCount.value = snapshot.successCount;
- failCount.value = snapshot.failCount;
- cleanStatsSnapshot.value = snapshot.cleanStatsSnapshot || {};
- cleanTaskStarted.value = snapshot.cleanTaskStarted;
- cleanTaskFinished.value = snapshot.cleanTaskFinished;
- calcTaskTriggered.value = snapshot.calcTaskTriggered;
- governTaskStarted.value = snapshot.governTaskStarted;
- governTaskFinished.value = snapshot.governTaskFinished;
- shouldRunGovernAfterClean.value = snapshot.shouldRunGovernAfterClean;
- // 恢复快照即视为「此刻还活着」:卡 100% 的兜底看门狗从页面打开时刻重新计时
- lastTaskActivityAt = Date.now();
- return true;
- };
- watch(
- [
- progress,
- activeStep,
- currentFileName,
- currentCleanFiles,
- currentCleanBatchId,
- successCount,
- failCount,
- cleanStatsSnapshot,
- cleanTaskStarted,
- cleanTaskFinished,
- calcTaskTriggered,
- governTaskStarted,
- governTaskFinished,
- shouldRunGovernAfterClean,
- ],
- persistImportProgress,
- { deep: true },
- );
- const normalizeText = (value: unknown) => String(value ?? '').trim();
- const normalizeBatchId = (value: unknown) => normalizeText(value);
- /**
- * 后端 SSE 消息 → 日志文本。
- *
- * <p>直接保留原文(含 {@code [数据清洗]} / {@code [数据治理]} 前缀),不判断级别、不归类。
- */
- const resolveTaskLogText = (payload: SseDTO): string => {
- const raw = normalizeText(payload.message);
- if (!raw || raw === '心跳' || raw === '连接成功') return '';
- return raw;
- };
- /**
- * 写一条处理日志:后端说什么就记什么,最新在上;新批次的第一条日志会清空上一批次的缓存。
- */
- const addTaskLog = (text: string) => {
- const normalized = normalizeText(text);
- if (!normalized) return;
- const batchId = currentCleanBatchId.value || refreshCurrentCleanBatchId();
- if (taskLogBatchId.value && batchId && batchId !== taskLogBatchId.value) {
- taskLog.value = [];
- governFailed.value = false;
- }
- taskLogBatchId.value = batchId || taskLogBatchId.value;
- taskLogSeq += 1;
- taskLog.value.unshift({
- id: `${Date.now()}-${taskLogSeq}`,
- time: new Date().toLocaleTimeString('zh-CN', { hour12: false }),
- text: normalized,
- });
- if (taskLog.value.length > 200) {
- taskLog.value.length = 200;
- }
- };
- const findBatchId = (items?: FileInfo[] | null): string => {
- if (!Array.isArray(items) || !items.length) return '';
- for (const item of items) {
- const batchId = normalizeBatchId(item?.batchId);
- if (batchId) return batchId;
- const childBatchId = findBatchId(Array.isArray(item?.children) ? item.children : []);
- if (childBatchId) return childBatchId;
- }
- return '';
- };
- const refreshCurrentCleanBatchId = () => {
- const preFileRaw = sessionStorage.getItem(FILE_INFO_STORAGE_KEY);
- if (preFileRaw) {
- try {
- const preFileInfos = JSON.parse(preFileRaw) as FileInfo[];
- const preFileBatchId = findBatchId(preFileInfos);
- if (preFileBatchId) {
- currentCleanBatchId.value = preFileBatchId;
- return currentCleanBatchId.value;
- }
- } catch (error) {
- // Ignore invalid preFile cache and fallback to current task files.
- }
- }
- currentCleanBatchId.value = findBatchId(currentCleanFiles.value);
- return currentCleanBatchId.value;
- };
- const handleViewLog = () => {
- refreshCurrentCleanBatchId();
- logModalOpen.value = true;
- };
- /** 完成出口「查看结果」:跳清洗结果统计页(导入文件列表带数据量/成功失败条数) */
- const handleViewResult = async () => {
- if (!shouldRunGovernAfterClean.value) {
- createMessage.warning('数据治理已关闭,本次导入未自动治理,可在数据页手动执行');
- }
- await navigateToImportResult();
- };
- const navigateToImportResult = async () => {
- sessionStorage.removeItem(IMPORT_FILE_INFO_STORAGE_KEY);
- sessionStorage.removeItem(RECLEAN_CONTEXT_STORAGE_KEY);
- markAnalysisDataChanged();
- // 落到「导入文件」页签:列表带每个文件的数据量与成功/失败条数,即清洗结果统计。
- // 页签与完成出口标记经 sessionStorage 一次性传递——目标页被 keep-alive 缓存,
- // 激活时机由 onActivated 消费该上下文决定。
- // 跳转**不带任何 URL 参数**:「案件数据」是固定页签,带 query 会让 URL 变脏、也容易把页签身份搞乱。
- sessionStorage.setItem(CLEAN_RESULT_CONTEXT_KEY, JSON.stringify({ tab: 'files', mode: 'manual' }));
- await go({ path: PageEnum.BASE_HOME }, true);
- await nextTick();
- emitter.emit(CASE_DATA_REFRESH_EVENT);
- };
- type SseDTO = {
- cmd: number;
- code: number;
- process: number;
- message: string;
- caseId?: number | string;
- seeData?: Recordable;
- data?: Recordable;
- result?: Recordable;
- successCount?: number;
- failCount?: number;
- successNum?: number;
- failNum?: number;
- };
- const readNumber = (source: Recordable | null | undefined, keys: string[]) => {
- if (!source) return undefined;
- for (const key of keys) {
- const value = source[key];
- if (value !== undefined && value !== null && value !== '') {
- const numberValue = Number(value);
- if (Number.isFinite(numberValue)) return numberValue;
- }
- }
- return undefined;
- };
- const normalizeCleanResult = (result: Recordable | null | undefined) => {
- const nested =
- result?.data && typeof result.data === 'object'
- ? (result.data as Recordable)
- : result?.seeData && typeof result.seeData === 'object'
- ? (result.seeData as Recordable)
- : result?.result && typeof result.result === 'object'
- ? (result.result as Recordable)
- : result;
- const data = nested || {};
- const completedCount = readNumber(data, ['completedCount', 'successCount', 'successNum', 'success']);
- const failCount = readNumber(data, ['failCount', 'failNum', 'failedCount', 'fail']);
- return {
- success: completedCount,
- fail: failCount,
- process: readNumber(data, ['process', 'progress', 'taskProcess']),
- };
- };
- const normalizeSseProcess = (value: unknown) => {
- const numberValue = Number(value);
- if (!Number.isFinite(numberValue)) return progress.value;
- return Math.min(100, Math.max(0, Math.round(numberValue)));
- };
- const applyCleanResult = (result: Recordable | null | undefined, applyProcess = true) => {
- const normalized = normalizeCleanResult(result);
- if (normalized.success !== undefined) {
- successCount.value = normalized.success;
- cleanStatsSnapshot.value = { ...cleanStatsSnapshot.value, success: normalized.success };
- }
- if (normalized.fail !== undefined) {
- failCount.value = normalized.fail;
- cleanStatsSnapshot.value = { ...cleanStatsSnapshot.value, fail: normalized.fail };
- }
- if (applyProcess && normalized.process !== undefined) {
- progress.value = Math.min(100, Math.max(0, normalized.process));
- }
- };
- // const isCleanFinishedResult = (result: Recordable | null | undefined) => {
- // const normalized = normalizeCleanResult(result);
- // if (normalized.process !== undefined && normalized.process >= 100) return true;
- // const cmd = Number(result?.cmd ?? result?.data?.cmd ?? result?.seeData?.cmd ?? result?.result?.cmd);
- // if (cmd === 102) return false;
- // const data = (result?.data || result?.seeData || result?.result || result || {}) as Recordable;
- // const message = String(data?.message || data?.msg || result?.message || result?.msg || '').trim();
- // return (
- // message.includes('清洗导入完成') ||
- // message.includes('清洗完成') ||
- // message.includes('清洗结束') ||
- // message.includes('入库完成') ||
- // message.includes('全部清洗完成') ||
- // message.includes('全部入库完成')
- // );
- // };
- const startGovernAfterClean = async () => {
- // if (!shouldRunGovernAfterClean.value) {
- // await triggerCalcTask();
- // return;
- // }
- activeStep.value = 2;
- await triggerCalcTask();
- };
- const safeEmitImportRefresh = () => {
- try {
- emitter.emit(CASE_IMPORT_FILE_REFRESH_EVENT);
- } catch (error) {
- console.error('[clean-progress] import refresh emit failed', error);
- }
- };
- // const handleCleanFinished = async () => {
- // if (calcTaskTriggered.value || governTaskStarted.value || governTaskFinished.value) return;
- // if (!cleanTaskFinished.value) {
- // cleanTaskFinished.value = true;
- // }
- // await startGovernAfterClean();
- // safeEmitImportRefresh();
- // };
- const normalizeGovernConfFlag = (value?: unknown) =>
- String(value ?? '')
- .trim()
- .toUpperCase();
- const getRequestErrorMessage = (error: any, fallback = '操作失败') =>
- error?.response?.data?.message || error?.message || fallback;
- /** 是否在清洗完成后自动治理:按「同时治理」配置执行 */
- const loadGovernSwitch = async () => {
- try {
- const list = await getGovernConfList();
- const hasGovernConf = (Array.isArray(list) ? list : []).find(
- (item) =>
- String(item?.confType ?? '')
- .trim()
- .toLowerCase() === 'hasgovern',
- );
- // `hasGovern` 的实际语义以接口返回为准:N 表示导入不立即治理,Y 表示立即治理。
- shouldRunGovernAfterClean.value = normalizeGovernConfFlag(hasGovernConf?.confStr) === 'Y';
- } catch (error) {
- shouldRunGovernAfterClean.value = true;
- createMessage.warning('治理配置读取失败,将按默认流程继续执行数据治理');
- }
- };
- const isGovernCompleteText = (text: string) =>
- ['数据治理完成', '治理完成', '治理结束', '治理任务完成'].some((keyword) => text.includes(keyword));
- const isGovernCompletePayload = (payload: SseDTO, raw = '') => {
- const value = Number(payload.process ?? 0);
- const message = `${payload.message || ''}${raw}`;
- if (isGovernCompleteText(message)) return true;
- if (payload.cmd === 101) return false;
- return (governTaskStarted.value || calcTaskTriggered.value || activeStep.value >= 2) && value >= 100;
- };
- const markGovernComplete = () => {
- if (governTaskFinished.value) return;
- activeStep.value = 2;
- governTaskFinished.value = true;
- closeSse();
- clearImportProgress(getCurrentCaseId());
- safeEmitImportRefresh();
- if (!governCompleteNotified.value) {
- governCompleteNotified.value = true;
- createMessage.success('数据治理完成');
- }
- };
- const triggerCalcTask = async () => {
- if (!shouldRunGovernAfterClean.value) {
- activeStep.value = 1;
- progress.value = 100;
- closeSse();
- persistImportProgress();
- return;
- }
- if (calcTaskTriggered.value) return;
- calcTaskTriggered.value = true;
- persistImportProgress();
- try {
- if (!eventSource) {
- connectSse();
- }
- await calcTask({
- // 治理启动接口固定传起始进度值,不能复用清洗完成时返回的 100。
- taskProcess: progress.value,
- });
- governTaskStarted.value = true;
- lastTaskActivityAt = Date.now();
- persistImportProgress();
- if (!eventSource || !sseConnected.value) {
- connectSse();
- }
- createMessage.success('治理任务已启动');
- } catch (error: any) {
- const message = getRequestErrorMessage(error, '治理任务启动失败');
- calcTaskTriggered.value = false;
- governTaskStarted.value = false;
- governFailed.value = true;
- progress.value = 100;
- addTaskLog(`[数据治理]${message}`);
- closeSse();
- createMessage.error(message);
- }
- };
- const updateProgressFromMessage = (rawMessage: string) => {
- const normalized = rawMessage.trim();
- if (!normalized) return;
- let payload: SseDTO | null = null;
- try {
- payload = JSON.parse(normalized) as SseDTO;
- } catch (error) {
- payload = null;
- }
- if (payload) {
- // 案件切换后,上一个案件可能还有后台任务在推进度;只处理当前案件(心跳无 caseId,照常放行)
- const currentCaseId = getCurrentCaseId();
- if (
- payload.caseId !== undefined &&
- payload.caseId !== null &&
- String(payload.caseId) !== String(currentCaseId ?? '')
- ) {
- return;
- }
- // 任何任务事件(清洗 101 / 治理 102 / AI 状态 103 / 清洗日志 104)都算「任务在推进」:
- // 兜底看门狗据此续期;999 心跳不算,避免 SSE 还连着但任务早已停摆时被无限续期
- if (payload.cmd === 101 || payload.cmd === 102 || payload.cmd === 103 || payload.cmd === 104) {
- lastTaskActivityAt = Date.now();
- }
- const value = normalizeSseProcess(payload.process);
- // 清洗 / 治理 / 清洗日志(104)原样进任务日志;AI 状态(103)由 AI 卡片单独展示,不重复刷日志。
- // 104 只追加日志,不参与进度与终态判定(后端逐 sheet 推「识别/入库」流水账)。
- if (payload.cmd === 101 || payload.cmd === 102 || payload.cmd === 104) {
- const logText = resolveTaskLogText(payload);
- if (logText) addTaskLog(logText);
- }
- if (payload.cmd === 101) {
- const shouldApplyCleanProgress = !calcTaskTriggered.value && activeStep.value < 2;
- // 停止收口消息:完成页文案按「已停止」展示
- if (String(payload.message || '').includes('[清洗] 已停止')) {
- stoppedByUser.value = true;
- }
- const fileName = String(payload.message || '').trim();
- if (fileName) currentFileName.value = fileName;
- applyCleanResult(payload as unknown as Recordable, shouldApplyCleanProgress);
- if (shouldApplyCleanProgress) {
- activeStep.value = 1;
- progress.value = value;
- }
- // if (isCleanFinishedResult(payload as unknown as Recordable)) {
- // void handleCleanFinished();
- // }
- if (value >= 100) {
- // 终态文案由后端统一推送(「[清洗] 全部完成:成功 N 行,失败 M 行」),
- // 这里不再补一条重复的「清洗入库完成」
- cleanTaskFinished.value = true;
- }
- } else if (payload.cmd === 102) {
- activeStep.value = 2;
- governTaskStarted.value = true;
- const message = String(payload.message || '').trim();
- if (/治理失败|治理异常/.test(message)) {
- governFailed.value = true;
- progress.value = 100;
- closeSse();
- createMessage.error(message || '数据治理失败,请查看任务日志');
- return;
- }
- progress.value = value;
- // shouldRunGovernAfterClean.value = true;
- startGovernAfterClean();
- // 「开始治理」本身不是完成信号:智能链路会带 process=100 推这条启动消息,
- // 不能据此关掉 SSE,否则治理阶段的日志全部收不到。
- const isGovernStartLog = /开始数据治理|治理任务已启动|正在准备执行/.test(message);
- if (value >= 100 && !isGovernStartLog) {
- markGovernComplete();
- }
- } else if (payload.cmd === 103) {
- // AI 清洗批次状态快照(后端 SSE 推送,非轮询):
- // 进度环、无法清洗明细、完成判定都由它驱动;终态快照即「清洗入库完成」
- const vo = (payload.seeData as Recordable | undefined)?.payload as SmartCleanStatusVO | undefined;
- if (vo && vo.stage) {
- applyAiStage(vo);
- if (aiStageFinished.value && !cleanTaskFinished.value) {
- // 终态文案由后端 cmd 101 统一推送,这里只落状态,不重复写日志
- cleanTaskFinished.value = true;
- }
- }
- } else {
- // activeStep.value = 0;
- // progress.value = value;
- }
- if (payload.message) {
- sseMessages.value.unshift(payload.message);
- sseMessages.value = sseMessages.value.slice(0, 20);
- }
- persistImportProgress();
- return;
- }
- // if (isGovernCompleteText(normalized)) {
- // sseMessages.value.unshift(normalized);
- // sseMessages.value = sseMessages.value.slice(0, 20);
- // markGovernComplete();
- // return;
- // }
- // const percentMatch = normalized.match(/(\d{1,3})%/);
- // if (percentMatch) {
- // const value = Math.min(100, Math.max(0, Number(percentMatch[1])));
- // progress.value = value;
- // if (value >= 90) {
- // activeStep.value = 2;
- // } else if (value >= 50) {
- // activeStep.value = 1;
- // } else {
- // activeStep.value = 0;
- // }
- // return;
- // }
- // if (normalized.includes('读取')) {
- // activeStep.value = 0;
- // } else if (normalized.includes('清洗')) {
- // activeStep.value = 1;
- // } else if (normalized.includes('治理')) {
- // activeStep.value = 2;
- // }
- };
- /**
- * 建立治理进度 SSE 连接。
- *
- * ★ 不能用原生 EventSource:它无法自定义请求头,而本项目登录凭据走 `x-token` 头
- * (后端 sa-token 配置为「仅 Header」模式),EventSource 必然 401。
- * 这里改用 fetch + ReadableStream 手动按 `\n\n` 分帧。
- */
- const connectSse = () => {
- const activeEventSource = getImportProgressEventSource();
- if (activeEventSource) {
- eventSource = activeEventSource;
- return;
- }
- sseConnected.value = false;
- sseError.value = null;
- const controller = new AbortController();
- // 占位句柄:让共享的「已有连接」判断成立,并支持既有的 .close() 调用
- const handle = { close: () => controller.abort() } as unknown as EventSource;
- eventSource = handle;
- setImportProgressEventSource(handle);
- void (async () => {
- try {
- const token = getToken();
- const res = await fetch(getGovernTaskSseUrl(), {
- headers: {
- Accept: 'text/event-stream',
- ...(token ? { 'x-token': token as string } : {}),
- },
- credentials: 'include',
- signal: controller.signal,
- });
- const contentType = res.headers.get('content-type') || '';
- if (!res.ok || !contentType.includes('text/event-stream')) {
- // 未登录等场景后端返回的是普通 Result JSON
- let msg = 'SSE 连接失败';
- try {
- const json = await res.json();
- msg = json?.message || msg;
- } catch {
- /* ignore */
- }
- sseConnected.value = false;
- sseError.value = msg;
- if (isFused.value && !aiStageFinished.value) {
- // 进度全靠 SSE 推送:连接起不来就没有后续事件,给出超时出口而不是傻等
- aiStageTimeout.value = true;
- }
- return;
- }
- sseConnected.value = true;
- sseError.value = null;
- const reader = res.body?.getReader();
- if (!reader) {
- sseError.value = 'SSE 连接中断';
- return;
- }
- const decoder = new TextDecoder();
- let buffer = '';
- for (;;) {
- const { value, done } = await reader.read();
- if (done) break;
- buffer += decoder.decode(value, { stream: true });
- let idx = buffer.indexOf('\n\n');
- while (idx >= 0) {
- const frame = buffer.slice(0, idx);
- buffer = buffer.slice(idx + 2);
- const payload = frame
- .split('\n')
- .filter((line) => line.startsWith('data:'))
- .map((line) => line.slice(5).trimStart())
- .join('\n');
- if (payload) {
- updateProgressFromMessage(payload);
- }
- idx = buffer.indexOf('\n\n');
- }
- }
- } catch (error: any) {
- if (error?.name !== 'AbortError') {
- sseConnected.value = false;
- if (!governTaskFinished.value) {
- sseError.value = 'SSE 连接中断';
- }
- if (isFused.value && !aiStageFinished.value) {
- // 流断了就收不到后续的 AI 进度推送:给「改为手动清洗」出口
- aiStageTimeout.value = true;
- }
- }
- } finally {
- sseConnected.value = false;
- if (getImportProgressEventSource() === eventSource) {
- setImportProgressEventSource(null);
- }
- eventSource = null;
- }
- })();
- };
- const loadCleanFiles = () => {
- const storageKeys = [IMPORT_FILE_INFO_STORAGE_KEY, FILE_INFO_STORAGE_KEY];
- for (const key of storageKeys) {
- const raw = sessionStorage.getItem(key);
- if (!raw) continue;
- try {
- const parsed = JSON.parse(raw) as FileInfo[];
- if (Array.isArray(parsed) && parsed.length) {
- return parsed;
- }
- } catch (error) {
- // Ignore invalid session payload and continue reading fallback storage.
- }
- }
- return [];
- };
- const loadReCleanContext = (): { reClean?: 0 | 1; fileId?: string } | null => {
- const raw = sessionStorage.getItem(RECLEAN_CONTEXT_STORAGE_KEY);
- if (!raw) return null;
- try {
- const parsed = JSON.parse(raw) as { reClean?: number; fileId?: string | number };
- const reClean = Number(parsed?.reClean) === 1 ? 1 : 0;
- const fileId = normalizeText(parsed?.fileId);
- if (reClean !== 1 || !fileId) return null;
- return { reClean: 1, fileId };
- } catch {
- return null;
- }
- };
- const pickFirstFileName = (files: FileInfo[]) => {
- const first = files[0];
- if (!first) return '暂无文件';
- return first.fileName || first.sheetName || first.filePath || '暂无文件';
- };
- const startClean = async () => {
- if (cleanTaskStarted.value) return;
- stopping.value = false;
- stoppedByUser.value = false;
- const fileInfos = loadCleanFiles();
- if (!fileInfos.length || !fileInfos.some((item) => (item.children || []).length > 0)) {
- createMessage.warning('未找到可清洗文件,请先上传并匹配文件');
- closeSse();
- go(PageEnum.BASE_UPLOAD, true);
- return;
- }
- currentCleanFiles.value = fileInfos;
- currentCleanBatchId.value = findBatchId(fileInfos);
- currentFileName.value = pickFirstFileName(fileInfos);
- addTaskLog(`[数据清洗]开始处理:${currentFileName.value}`);
- cleanTaskStarted.value = true;
- persistImportProgress();
- try {
- const reCleanContext = loadReCleanContext();
- await doClean(
- reCleanContext
- ? {
- fileInfos,
- reClean: 1,
- fileId: reCleanContext.fileId,
- }
- : { fileInfos },
- );
- // 清洗任务已发起:文件列表已读入 currentCleanFiles、进度快照由 persistImportProgress 维护,
- // 因此立即清空「已上传文件缓存」与清洗流程中间缓存,避免后续进入流程时复用上一批文件。
- // 放在 doClean 成功之后再清,保证发起失败时缓存仍在、可重新发起。
- sessionStorage.removeItem(FILE_INFO_STORAGE_KEY);
- sessionStorage.removeItem(IMPORT_FILE_INFO_STORAGE_KEY);
- sessionStorage.removeItem(RECLEAN_CONTEXT_STORAGE_KEY);
- // applyCleanResult(result);
- // if (isCleanFinishedResult(result)) {
- // await handleCleanFinished();
- // }
- createMessage.success('清洗任务已启动');
- addTaskLog('[数据清洗]清洗任务已启动');
- } catch (error) {
- cleanTaskStarted.value = false;
- clearImportProgress(getCurrentCaseId());
- createMessage.error('清洗任务启动失败');
- }
- };
- // ==================== 融合模式:上传页「智能」= 既有清洗 + AI 清洗 ====================
- const route = useRoute();
- const AI_STAGE_DONE = ['DONE', 'PARTIAL', 'FAILED', 'STOPPED'];
- /** fused=1 且带 batchId 才认融合模式;没有批次号就没法关联进度,宁可退回原行为 */
- const isFused = computed(() => normalizeText(route.query?.fused) === '1' && !!normalizeText(route.query?.batchId));
- const fusedBatchId = computed(() => normalizeText(route.query?.batchId));
- const aiStage = ref<SmartCleanStatusVO | null>(null);
- const aiStageTimeout = ref(false);
- /** 用户已点「停止清洗」:后端收口前按钮转 loading */
- const stopping = ref(false);
- /** 本轮被用户停止(决定完成页文案) */
- const stoppedByUser = ref(false);
- const stoppedClean = computed(() => stoppedByUser.value || aiStage.value?.stage === 'STOPPED');
- /** 交给 AI 判定的表数 = 全部 sheet - 原本就匹配上模板的 sheet */
- const aiSheetTotal = computed(() =>
- Math.max(0, (aiStage.value?.sheetTotal ?? 0) - (aiStage.value?.matchedCount ?? 0)),
- );
- const aiJudgedCount = computed(() => aiStage.value?.aiJudgedCount ?? 0);
- const aiStageFinished = computed(() => AI_STAGE_DONE.includes(aiStage.value?.stage ?? ''));
- /** 清洗结果页的「无法清洗」统计与明细(仅融合模式有 AI 链路) */
- const unableCount = computed(() => (isFused.value ? (aiStage.value?.needReviewCount ?? 0) : 0));
- /**
- * 统一进度:系统清洗(SSE)与 AI 识别两条链路按各自处理的 sheet 数加权合成一个百分比。
- * AI 识别进度 = 已判定数 / 待判定数(判定完的入库/并入清洗随 SSE 推进)。
- * 非融合模式(纯既有清洗)直接用 SSE 进度。
- */
- const overallProgress = computed(() => {
- if (!isFused.value || !aiStage.value) return progress.value;
- // 批次已到终态 = 1/2/3 级全部收尾,进度定格 100%(与 isComplete 的判定保持一致)
- if (aiStageFinished.value) return 100;
- const matched = aiStage.value.matchedCount ?? 0;
- const total = Math.max(1, aiSheetTotal.value + matched);
- const aiWeight = aiSheetTotal.value / total;
- const aiPct = Math.round((aiJudgedCount.value / Math.max(1, aiSheetTotal.value)) * 100);
- return Math.min(100, Math.round(progress.value * (1 - aiWeight) + aiPct * aiWeight));
- });
- /**
- * 清洗阶段完成判定:非融合模式看 SSE 进度;融合模式看 AI 批次终态 —— 后端在
- * 1/2/3 级全部结束后推终态消息(cmd 103,stage=DONE/PARTIAL/FAILED)。纯 AI/4级
- * 批次没有 doClean,SSE 进度不会走到 100%,不能拿 progress 当完成依据。
- */
- const cleanPhaseDone = computed(() => (isFused.value ? aiStageFinished.value : progress.value >= 100));
- /**
- * 「正常完成」判定(不含兜底):
- * 1) 清洗完成 + (治理关闭或治理已完成);
- * 2) 治理已完成且进度环已 100% —— 即便 AI 阶段终态消息(cmd 103)丢了也算完成。
- */
- const baseComplete = computed(
- () =>
- (cleanPhaseDone.value && (!shouldRunGovernAfterClean.value || governTaskFinished.value)) ||
- (governTaskFinished.value && overallProgress.value >= 100),
- );
- /**
- * 最终完成态:兜底成立时不再要求 cleanPhaseDone —— 融合模式的 AI 阶段终态消息(cmd 103)
- * 丢失时,进度环可能已经 100%(cmd 101),但 aiStageFinished 永远为 false,会永久卡住。
- */
- const isComplete = computed(() => governFailed.value || completionFallback.value || baseComplete.value);
- /** 页面说明文案:治理未开启时不出现「治理」,与左侧步骤条保持一致 */
- const pageSubtitle = computed(() => {
- const scope = shouldRunGovernAfterClean.value ? '清洗、入库与治理' : '清洗与入库';
- return isComplete.value
- ? `查看本次${scope}的执行结果,以及完整任务日志。`
- : `实时展示文件${scope}的执行进度,便于快速确认任务运行状态。`;
- });
- /**
- * 完成时提示「另有 N 个表 AI 无法清洗」——只在完成那一刻提醒一次。
- * 完成后<b>不自动跳转</b>(2026-10-11 需求):跳转由完成面板上的「查看结果」按钮触发。
- */
- watch(isComplete, (done) => {
- if (!done) return;
- const unable = isFused.value ? (aiStage.value?.needReviewCount ?? 0) : 0;
- if (unable > 0) {
- createMessage.warning(`另有 ${unable} 个表 AI 无法清洗,详情见处理日志;可用「手动清洗」处理。`);
- }
- });
- /**
- * 融合模式批次终态收口:既有清洗完成时由 SSE 的 100% 触发治理/关会话,但纯 AI/4级
- * 批次没有 doClean、SSE 不推完成消息 —— 批次到终态(cmd 103 推送)时在这里补上与
- * 既有清洗完成相同的出口(治理开关开启则启动治理,否则定格完成并触发自动跳转)。
- * calcTaskTriggered 幂等:混合批次里治理已被触发过时不会重复启动。
- */
- watch(aiStageFinished, (finished) => {
- if (!isFused.value || !finished) return;
- void triggerCalcTask();
- });
- const clearCompletionFallbackTimer = () => {
- if (completionFallbackTimer !== undefined) {
- clearTimeout(completionFallbackTimer);
- completionFallbackTimer = undefined;
- }
- };
- const resetCompletionFallback = () => {
- clearCompletionFallbackTimer();
- completionFallback.value = false;
- lastTaskActivityAt = 0;
- completionFallbackNotified = false;
- };
- /** 进度环已 100%、但「正常完成」条件还不成立 = 卡在收尾阶段,需要看门狗兜底 */
- const completionStalled = computed(() => overallProgress.value >= 100 && !baseComplete.value);
- /**
- * 卡 100% 的兜底看门狗:静默期内只要还有任务事件(cmd 101/102/103)就继续等,
- * 彻底没动静后按完成处理 —— 覆盖治理未启动/启动失败、SSE 断流、AI 终态消息丢失等异常。
- */
- const scheduleCompletionFallback = () => {
- clearCompletionFallbackTimer();
- if (!completionStalled.value) return;
- const waitMs = governTaskStarted.value ? COMPLETION_FALLBACK_GRACE_MS : COMPLETION_FALLBACK_QUICK_MS;
- completionFallbackTimer = setTimeout(() => {
- completionFallbackTimer = undefined;
- if (!completionStalled.value) return;
- // 还在静默期内(可能有事件晚到)或治理刚开始、需要给更长的观察期
- const quietFor = Date.now() - lastTaskActivityAt;
- if (
- quietFor < COMPLETION_FALLBACK_QUICK_MS ||
- (governTaskStarted.value && quietFor < COMPLETION_FALLBACK_GRACE_MS)
- ) {
- scheduleCompletionFallback();
- return;
- }
- completionFallback.value = true;
- addTaskLog('[数据清洗]超过静默期未收到后续进度,已按完成处理(数据治理可能未执行)');
- if (!completionFallbackNotified) {
- completionFallbackNotified = true;
- createMessage.warning('长时间未收到数据治理完成通知,已按清洗完成处理;如需治理可在数据页手动执行');
- }
- }, waitMs);
- };
- watch(
- completionStalled,
- (stalled) => {
- if (!stalled) {
- resetCompletionFallback();
- return;
- }
- scheduleCompletionFallback();
- },
- { immediate: true },
- );
- // 新一轮任务(清洗未启动)时清掉上一轮留下的兜底状态,避免沿用旧的「已完成」判定
- watch(cleanTaskStarted, (started) => {
- if (!started) resetCompletionFallback();
- });
- /** 记录上一次看到的 AI 状态,用于把变化差量写进处理日志(SSE 推送与启动同步共用) */
- const lastAiLogged = ref({ stage: '', judged: -1, reviewKeys: '' });
- /**
- * AI 链路事件并入处理日志:阶段迁移记里程碑,无法清洗的表逐条记文件级日志。
- * 系统清洗与 AI 只是处理方式不同,日志/进度统一在同一张卡里呈现。
- */
- const logAiStageEvents = (res: SmartCleanStatusVO) => {
- const prev = lastAiLogged.value;
- if (res.stage !== prev.stage) {
- if (res.stage === 'CLEANING_EXISTING') {
- addTaskLog('[数据清洗]AI 识别完成,命中模板的表已并入系统清洗');
- } else if (res.stage === 'LOADING_AI') {
- addTaskLog('[数据清洗]AI 新建表入库中');
- } else if (res.stage === 'DONE') {
- addTaskLog(
- `[数据清洗]AI 识别阶段完成:无法清洗 ${res.needReviewCount ?? 0} 个,失败 ${res.failedCount ?? 0} 个`,
- );
- } else if (res.stage === 'PARTIAL') {
- addTaskLog(
- `[数据清洗]AI 识别阶段部分完成:无法清洗 ${res.needReviewCount ?? 0} 个,失败 ${res.failedCount ?? 0} 个`,
- );
- } else if (res.stage === 'FAILED') {
- addTaskLog('[数据清洗]AI 识别阶段异常结束(已匹配模板的文件仍按系统流程清洗)');
- } else if (res.stage === 'STOPPED') {
- addTaskLog('[数据清洗]已停止:已完成的部分保留,其余文件未清洗');
- stoppedByUser.value = true;
- }
- }
- const keys = (res.needReview || [])
- .map((row) => String(row.sheetId))
- .sort()
- .join('|');
- if (keys !== prev.reviewKeys) {
- const prevSet = new Set(prev.reviewKeys ? prev.reviewKeys.split('|') : []);
- for (const row of res.needReview || []) {
- if (!prevSet.has(String(row.sheetId))) {
- addTaskLog(
- `[数据清洗]AI 无法清洗:${row.sheetName || row.fileName || '-'}(${row.reason || '原因见后端日志'})`,
- );
- }
- }
- }
- lastAiLogged.value = { stage: res.stage, judged: res.aiJudgedCount ?? 0, reviewKeys: keys };
- };
- /** 应用一份 AI 批次状态:进度环、处理日志、步骤条统一在这里收口 */
- const applyAiStage = (res: SmartCleanStatusVO) => {
- aiStage.value = res;
- aiStageTimeout.value = false;
- lastTaskActivityAt = Date.now();
- logAiStageEvents(res);
- // AI 判定/入库属于「清洗入库」阶段:有在跑的 AI 任务就把步骤条推进到第 2 步
- if (!aiStageFinished.value && activeStep.value < 1) {
- activeStep.value = 1;
- }
- };
- const logAiStageWarn = (msg: string, error?: any) => {
- console.warn(`[smartClean] ${msg}: ${error?.message ?? error}`);
- };
- /**
- * 打开页面(含刷新恢复)时的一次性状态同步:只调一次状态接口对齐初始值,
- * 后续进度全部由后端 SSE 推送(cmd 103)驱动 —— 不做周期轮询(需求 2026-10-11)。
- */
- const syncAiStageOnce = async () => {
- if (!isFused.value) return;
- try {
- const res = await smartCleanStatus(fusedBatchId.value);
- if (!res) {
- // 后端重启过或批次被清掉:给出出口而不是傻等
- aiStageTimeout.value = true;
- return;
- }
- applyAiStage(res);
- } catch (error: any) {
- logAiStageWarn('AI 阶段状态同步失败', error);
- }
- };
- /**
- * 停止清洗(协作式):
- * 已清洗的数据不回滚;正在清洗的文件跑完;未开始的文件不再清洗;不自动进入数据治理。
- */
- const handleStopClean = () => {
- if (stopping.value) return;
- Modal.confirm({
- title: '停止清洗?',
- content: '已完成的数据保留;正在清洗的文件会继续跑完;其余文件不再清洗,也不会自动进入数据治理。',
- okText: '停止清洗',
- okType: 'danger',
- cancelText: '继续清洗',
- onOk: async () => {
- stopping.value = true;
- try {
- if (isFused.value && fusedBatchId.value) {
- await stopSmartClean(fusedBatchId.value);
- } else {
- await stopClean();
- }
- stoppedByUser.value = true;
- addTaskLog('[清洗] 已请求停止:正在清洗的文件会跑完,其余文件将不再清洗');
- createMessage.success('已请求停止清洗,等待当前文件处理完成');
- } catch (error: any) {
- stopping.value = false;
- createMessage.error(error?.message || '停止清洗失败');
- }
- },
- });
- };
- // 收口后按钮不再 loading(后端推完终态、页面切到完成态)
- watch(isComplete, (done) => {
- if (done) stopping.value = false;
- });
- /** 融合模式下后端已经发过那一次 doClean,这里只把文件与批次读进来供本页展示 */
- const prepareFusedFiles = () => {
- const fileInfos = loadCleanFiles();
- currentCleanFiles.value = fileInfos;
- currentCleanBatchId.value = findBatchId(fileInfos);
- currentFileName.value = pickFirstFileName(fileInfos);
- addTaskLog(`[数据清洗]开始处理:${currentFileName.value}`);
- cleanTaskStarted.value = true;
- persistImportProgress();
- // 与 startClean 成功后一致:这批文件已进入清洗流程,不能再被下次进入时复用
- sessionStorage.removeItem(FILE_INFO_STORAGE_KEY);
- sessionStorage.removeItem(IMPORT_FILE_INFO_STORAGE_KEY);
- sessionStorage.removeItem(RECLEAN_CONTEXT_STORAGE_KEY);
- addTaskLog('[数据清洗]融合清洗已启动(既有清洗 + AI 识别并行)');
- };
- /** 超时出口「改为手动清洗」:不带 focusKey,清洗页按 batchId 从后端重建本批次文件树 */
- const goManualClean = () => {
- const query: Recordable = {};
- if (fusedBatchId.value) {
- query.batchId = fusedBatchId.value;
- query.redirect = encodeURIComponent(route.fullPath);
- }
- go({ path: PageEnum.BASE_CLEANING, query });
- };
- const initializeProgress = async () => {
- // 任务日志只存在本页内存:进入时清空,并清掉旧版本遗留的 localStorage 快照
- taskLog.value = [];
- taskLogBatchId.value = '';
- governFailed.value = false;
- stopping.value = false;
- stoppedByUser.value = false;
- clearLegacyTaskLogStorage();
- if (restoreImportProgress()) {
- eventSource = getImportProgressEventSource();
- if (!eventSource) {
- connectSse();
- await testSse();
- }
- // 刷新恢复:一次性对齐 AI 批次状态,之后全靠 SSE 推送
- void syncAiStageOnce();
- return;
- }
- resetImportProgressRuntimeState();
- await loadGovernSwitch();
- connectSse();
- await testSse();
- if (isFused.value) {
- prepareFusedFiles();
- // 打开页即对齐一次 AI 批次状态(此后全部由 SSE 推送驱动,无轮询)
- void syncAiStageOnce();
- return;
- }
- await startClean();
- };
- onMounted(() => {
- void initializeProgress();
- });
- onBeforeUnmount(() => {
- clearCompletionFallbackTimer();
- // 清洗/治理日志不跨页面保留:退出即清空内存,并清掉旧版本遗留的 localStorage
- taskLog.value = [];
- taskLogBatchId.value = '';
- clearLegacyTaskLogStorage();
- if (isComplete.value) {
- closeSse();
- } else {
- persistImportProgress();
- }
- });
- </script>
- <style lang="less">
- @prefix-cls: ~'jeesite-case-clean-progress';
- .@{prefix-cls}.case-clean-progress {
- // 独立全屏路由(不套 LAYOUT):父级不再是有确定高度的布局内容容器,
- // height: 100% 会退化成 auto(页面塌成内容高度),必须用 100vh 撑满视口。
- min-height: 100vh;
- height: 100vh;
- background: #f0f2f5;
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- overflow: hidden;
- // 公共顶栏由 AppTopBar 自带高度,内容区在剩余高度里滚动
- .page-body {
- flex: 1 1 auto;
- min-height: 0;
- padding: 16px 24px 20px;
- display: flex;
- flex-direction: column;
- gap: 14px;
- box-sizing: border-box;
- overflow: auto;
- }
- // 页头:与下方进度卡一致的白色卡片
- .page-header {
- flex: 0 0 auto;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 16px;
- padding: 12px 16px;
- border: 1px solid #e2e8f0;
- border-radius: 14px;
- background: #fff;
- box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
- box-sizing: border-box;
- }
- /* 顶栏右侧:停止清洗按钮 + SSE 连接状态 */
- .page-header__actions {
- display: flex;
- flex: 0 0 auto;
- align-items: center;
- gap: 10px;
- }
- .page-header__main {
- display: flex;
- align-items: center;
- gap: 12px;
- min-width: 0;
- }
- .page-title-icon {
- display: flex;
- align-items: center;
- justify-content: center;
- flex: none;
- width: 38px;
- height: 38px;
- border-radius: 11px;
- background: #eff6ff;
- color: #2563eb;
- }
- .page-title-wrap {
- min-width: 0;
- overflow: hidden;
- }
- .page-title {
- font-size: 16px;
- line-height: 1.4;
- font-weight: 600;
- color: #0f172a;
- }
- .page-subtitle {
- margin-top: 2px;
- overflow: hidden;
- font-size: 12px;
- line-height: 1.6;
- color: #64748b;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- // 页头右侧的实时推送状态胶囊(完成态隐藏)
- .sse-pill {
- display: inline-flex;
- align-items: center;
- gap: 8px;
- flex: none;
- height: 32px;
- padding: 0 14px;
- border-radius: 999px;
- background: #fff;
- border: 1px solid #e2e8f0;
- font-size: 12px;
- color: #64748b;
- .sse-dot {
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background: #cbd5e1;
- }
- &.is-on {
- color: #15803d;
- border-color: #bbf7d0;
- background: #f0fdf4;
- .sse-dot {
- background: #22c55e;
- box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
- }
- }
- }
- .progress-layout {
- flex: 1 1 auto;
- min-height: 0;
- display: flex;
- }
- .progress-card {
- display: flex;
- flex-direction: column;
- gap: 8px;
- padding: 20px 24px;
- border: 1px solid #e5e7eb;
- border-radius: 16px;
- background: #fff;
- box-shadow:
- 0 1px 2px rgba(15, 23, 42, 0.04),
- 0 8px 24px rgba(15, 23, 42, 0.05);
- min-height: 0;
- width: 100%;
- }
- // 执行中:左侧任务状态 + 右侧整块日志
- .run-layout {
- flex: 1 1 auto;
- min-height: 0;
- display: grid;
- grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
- align-items: stretch;
- gap: 16px;
- }
- .run-side {
- display: flex;
- flex-direction: column;
- gap: 18px;
- min-height: 0;
- padding: 18px;
- border: 1px solid #e8eef6;
- border-radius: 14px;
- background: #f8fbff;
- box-sizing: border-box;
- }
- .run-head {
- display: flex;
- align-items: flex-start;
- gap: 10px;
- min-width: 0;
- }
- // 执行中的呼吸圆点
- .run-live {
- position: relative;
- flex: none;
- width: 10px;
- height: 10px;
- margin-top: 6px;
- border-radius: 50%;
- background: #2563eb;
- &::after {
- content: '';
- position: absolute;
- inset: -4px;
- border-radius: 50%;
- border: 2px solid rgba(37, 99, 235, 0.28);
- animation: clean-progress-live-pulse 1.6s ease-out infinite;
- }
- }
- .run-head__text {
- min-width: 0;
- }
- .run-title {
- font-size: 15px;
- font-weight: 600;
- line-height: 1.4;
- color: #0f172a;
- }
- .run-subtitle {
- margin-top: 2px;
- font-size: 12px;
- line-height: 1.6;
- color: #64748b;
- }
- .run-summary {
- display: flex;
- align-items: center;
- gap: 18px;
- }
- .run-ring {
- flex: none;
- .progress-ring,
- .progress-ring svg {
- width: 140px;
- height: 140px;
- }
- .progress-value {
- inset: 18px;
- gap: 3px;
- strong {
- font-size: 30px;
- small {
- font-size: 15px;
- }
- }
- span {
- font-size: 11.5px;
- }
- }
- }
- .run-summary__stats {
- flex: 1 1 auto;
- min-width: 0;
- display: flex;
- flex-direction: column;
- }
- .run-stat-line {
- display: flex;
- align-items: baseline;
- justify-content: space-between;
- gap: 10px;
- padding: 9px 0;
- border-bottom: 1px solid #eef2f7;
- &:last-child {
- border-bottom: 0;
- }
- }
- .run-stat-line__label {
- font-size: 11.5px;
- color: #94a3b8;
- white-space: nowrap;
- }
- .run-stat-line__value {
- font-size: 22px;
- line-height: 1.1;
- font-weight: 700;
- color: #0f172a;
- font-variant-numeric: tabular-nums;
- &.is-success {
- color: #16a34a;
- }
- &.is-fail {
- color: #dc2626;
- }
- }
- .run-steps {
- flex: 1 1 auto;
- min-height: 0;
- display: flex;
- flex-direction: column;
- }
- .run-step {
- flex: 1 1 0;
- min-height: 0;
- display: flex;
- gap: 12px;
- }
- .run-step__rail {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: center;
- flex: none;
- width: 24px;
- }
- .run-step__dot {
- display: flex;
- align-items: center;
- justify-content: center;
- flex: none;
- width: 24px;
- height: 24px;
- border: 1.5px solid #dbe3ee;
- border-radius: 50%;
- background: #fff;
- color: #94a3b8;
- font-size: 12px;
- font-weight: 600;
- box-sizing: border-box;
- transition:
- color 0.2s ease,
- background-color 0.2s ease,
- border-color 0.2s ease;
- }
- .run-step__line {
- flex: 1;
- width: 2px;
- margin: 4px 0;
- border-radius: 1px;
- background: #e2e8f0;
- }
- .run-step__body {
- position: relative;
- flex: 1 1 auto;
- min-width: 0;
- padding-bottom: 8px;
- > * {
- position: relative;
- z-index: 1;
- }
- }
- .run-step__head {
- display: flex;
- align-items: center;
- gap: 8px;
- min-width: 0;
- }
- .run-step__title {
- font-size: 13.5px;
- font-weight: 600;
- line-height: 24px;
- color: #64748b;
- }
- .run-step__status {
- display: inline-flex;
- align-items: center;
- flex: none;
- height: 18px;
- margin-left: auto;
- padding: 0 7px;
- border-radius: 999px;
- background: #f1f5f9;
- color: #94a3b8;
- font-size: 10.5px;
- font-weight: 600;
- line-height: 18px;
- white-space: nowrap;
- }
- .run-step__status-dot {
- display: inline-block;
- width: 5px;
- height: 5px;
- margin-right: 5px;
- border-radius: 50%;
- background: currentColor;
- animation: run-status-blink 1.2s ease-in-out infinite;
- }
- .run-step__desc {
- margin-top: 1px;
- font-size: 11.5px;
- line-height: 1.5;
- color: #94a3b8;
- }
- .run-step.is-done {
- .run-step__dot {
- border-color: #86efac;
- background: #f0fdf4;
- color: #16a34a;
- }
- .run-step__line {
- background: #86efac;
- }
- .run-step__title {
- color: #334155;
- }
- .run-step__status {
- color: #15803d;
- background: #ecfdf5;
- }
- }
- .run-step.is-active {
- .run-step__body::before {
- content: '';
- position: absolute;
- inset: -8px -10px -8px -6px;
- border-radius: 12px;
- background: rgba(37, 99, 235, 0.06);
- pointer-events: none;
- }
- .run-step__dot {
- border-color: #2563eb;
- background: #2563eb;
- color: #fff;
- animation: run-dot-pulse 1.8s ease-out infinite;
- }
- .run-step__line {
- background: #bfdbfe;
- }
- .run-step__title {
- color: #0f172a;
- }
- .run-step__desc {
- color: #64748b;
- }
- .run-step__status {
- color: #1d4ed8;
- background: #eff6ff;
- box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
- }
- }
- // 沿时间线向下移动的小圆点:实色,不使用渐变
- .run-step__flow {
- position: absolute;
- left: 50%;
- top: 28px;
- width: 6px;
- height: 6px;
- margin-left: -3px;
- border-radius: 50%;
- background: #2563eb;
- box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
- pointer-events: none;
- animation: run-flow-down 1.8s linear infinite;
- }
- .run-log {
- display: flex;
- flex-direction: column;
- flex: 1 1 auto;
- align-self: stretch;
- min-height: 0;
- padding: 14px 16px;
- border: 1px solid #e8eef6;
- border-radius: 14px;
- background: #fbfdff;
- overflow: hidden;
- box-sizing: border-box;
- }
- .run-log.is-govern {
- border-color: #dbeafe;
- background: #f7fbff;
- }
- .progress-ring {
- position: relative;
- flex: none;
- width: 200px;
- height: 200px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .progress-ring svg {
- width: 200px;
- height: 200px;
- transform: rotate(-90deg);
- }
- .ring-bg {
- fill: none;
- // 轨道色不能太接近卡片白底(旧值 #eef2f7 在 0% 时几乎看不见「圆环」存在)
- stroke: #e2e8f0;
- stroke-width: 10;
- }
- .ring-value {
- fill: none;
- stroke: #2563eb;
- stroke-width: 10;
- stroke-linecap: round;
- transition:
- stroke-dasharray 0.4s ease,
- stroke-dashoffset 0.4s ease;
- filter: drop-shadow(0 10px 18px rgba(37, 99, 235, 0.18));
- }
- .progress-value {
- position: absolute;
- inset: 26px;
- border-radius: 50%;
- background: #fff;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: 6px;
- strong {
- font-size: 36px;
- line-height: 1;
- font-weight: 700;
- color: #0f172a;
- font-variant-numeric: tabular-nums;
- small {
- margin-left: 1px;
- font-size: 18px;
- font-weight: 600;
- color: #64748b;
- }
- }
- span {
- font-size: 13px;
- color: #64748b;
- }
- }
- // 完成态日志容器(执行中的日志改用 .run-log)
- .progress-log {
- display: flex;
- flex-direction: column;
- gap: 8px;
- width: min(560px, 100%);
- padding: 18px 20px;
- border-radius: 14px;
- background: #f8fafc;
- border: 1px solid #eef2f7;
- }
- // 完成态:顶部一条概览(结论 / 统计 / 操作),下方任务日志占满剩余高度
- .progress-complete-layout {
- flex: 1 1 auto;
- min-height: 0;
- display: flex;
- flex-direction: column;
- gap: 16px;
- }
- .complete-summary {
- flex: 0 0 auto;
- display: flex;
- align-items: center;
- gap: 20px;
- padding: 16px 20px;
- border: 1px solid #d9f0e3;
- border-radius: 14px;
- background: #f6fcf9;
- &.is-failed {
- border-color: #fecaca;
- background: #fff6f6;
- }
- }
- .complete-icon {
- display: flex;
- align-items: center;
- justify-content: center;
- flex: none;
- width: 58px;
- height: 58px;
- border-radius: 16px;
- background: #16a34a;
- color: #fff;
- font-size: 28px;
- font-weight: 700;
- box-shadow: 0 10px 22px rgba(22, 163, 74, 0.22);
- &.is-failed {
- background: #dc2626;
- box-shadow: 0 10px 22px rgba(220, 38, 38, 0.22);
- }
- }
- .complete-main {
- flex: 1 1 auto;
- min-width: 0;
- }
- .complete-title {
- font-size: 20px;
- font-weight: 600;
- line-height: 1.35;
- color: #0f172a;
- &.is-failed {
- color: #b91c1c;
- }
- }
- .complete-desc {
- margin-top: 3px;
- font-size: 12.5px;
- line-height: 1.6;
- color: #64748b;
- }
- .complete-meta {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 8px;
- margin-top: 6px;
- font-size: 11.5px;
- color: #94a3b8;
- }
- .complete-meta__item {
- display: inline-flex;
- align-items: center;
- & + & {
- &::before {
- content: '·';
- margin-right: 8px;
- color: #cbd5e1;
- }
- }
- }
- .complete-stats {
- display: flex;
- align-items: center;
- gap: 20px;
- flex: 0 0 auto;
- padding: 0 4px;
- }
- .complete-stat {
- display: flex;
- flex-direction: column;
- gap: 3px;
- min-width: 66px;
- }
- .complete-stat__value {
- font-size: 24px;
- line-height: 1.1;
- font-weight: 700;
- color: #0f172a;
- font-variant-numeric: tabular-nums;
- &.is-success {
- color: #16a34a;
- }
- &.is-fail {
- color: #dc2626;
- }
- &.is-warn {
- color: #d97706;
- }
- &.is-rate {
- color: #2563eb;
- font-size: 20px;
- }
- }
- .complete-stat__label {
- font-size: 11.5px;
- color: #64748b;
- white-space: nowrap;
- }
- .complete-stat__divider {
- width: 1px;
- height: 30px;
- background: #e2e8f0;
- }
- .complete-actions {
- display: flex;
- align-items: center;
- gap: 10px;
- flex: 0 0 auto;
- }
- .complete-log,
- .complete-result {
- min-width: 108px;
- height: 34px;
- border-radius: 8px;
- }
- // 完成态日志:占满概览以下的全部高度,内部滚动
- .progress-log--complete {
- flex: 1 1 auto;
- width: 100%;
- min-height: 0;
- padding: 14px 16px;
- border-radius: 14px;
- background: #fbfdff;
- border: 1px solid #e8eef6;
- overflow: hidden;
- }
- // 融合模式出口横幅:AI 识别超时时的提示与「改为手动清洗」(在主卡内展示)
- .ai-timeout-banner {
- display: flex;
- align-items: center;
- gap: 12px;
- margin: 0 0 4px;
- padding: 10px 14px;
- border: 1px solid #fde68a;
- border-radius: 10px;
- background: #fffbeb;
- font-size: 13px;
- color: #92400e;
- }
- @keyframes clean-progress-live-pulse {
- 0% {
- transform: scale(0.6);
- opacity: 1;
- }
- 100% {
- transform: scale(1.5);
- opacity: 0;
- }
- }
- @keyframes run-dot-pulse {
- 0% {
- box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.35);
- }
- 70% {
- box-shadow: 0 0 0 9px rgba(37, 99, 235, 0);
- }
- 100% {
- box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
- }
- }
- @keyframes run-status-blink {
- 0%,
- 100% {
- opacity: 1;
- }
- 50% {
- opacity: 0.25;
- }
- }
- @keyframes run-flow-down {
- 0% {
- top: 28px;
- opacity: 0;
- }
- 10% {
- opacity: 1;
- }
- 85% {
- opacity: 1;
- }
- 100% {
- top: calc(100% - 6px);
- opacity: 0;
- }
- }
- @media (max-width: 1100px) {
- .run-layout {
- grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
- }
- .complete-summary {
- flex-wrap: wrap;
- }
- .complete-main {
- flex: 1 1 calc(100% - 78px);
- }
- .complete-stats {
- order: 3;
- flex: 1 1 100%;
- padding-top: 4px;
- }
- .complete-actions {
- order: 4;
- flex: 1 1 100%;
- justify-content: flex-end;
- }
- }
- @media (max-width: 900px) {
- .run-layout {
- grid-template-columns: minmax(0, 1fr);
- }
- .run-log {
- min-height: 420px;
- }
- }
- @media (max-width: 768px) {
- .page-header {
- flex-direction: column;
- align-items: flex-start;
- }
- .complete-actions {
- width: 100%;
- flex-direction: column;
- }
- .complete-log,
- .complete-result {
- width: 100%;
- }
- }
- }
- </style>
|