Commit 22ae5842 authored by Data Governance Dev's avatar Data Governance Dev

fix(web): 分析完成后按钮区显示'重新分析'而非消失

原 v-if="currentJob" 的'取消任务'按钮:
  - 任务运行中 → 显示
  - 任务完成/失败/取消后 → currentJob 仍 truthy,但用户已无'取消'语义可做,
    按钮消失后再无任何动作按钮,体验断层

改成按状态显示两种按钮:
  - 运行中:'取消任务' (danger, 调用 cancelJob 走 DELETE /api/jobs/{id})
  - 其它状态(已完成/失败/已取消/有旧结果):'重新分析' (warning)
    调用新增的 resetAndStart():
      - clearInterval(pollTimer) + close SSE
      - 重置 currentJob / jobResult / jobStatus / logs 全清零
      - await startJob() 重新启动一次

测试:本地文件 = 服务返回(52958 字节一致),Refresh 图标已确认存在于 icons-vue 包。
parent 3f7cfa5d
......@@ -118,9 +118,12 @@
<el-button type="success" @click="startJob" :disabled="!connected" :loading="submitting">
<el-icon><VideoPlay /></el-icon>开始分析
</el-button>
<el-button v-if="currentJob" @click="cancelJob" type="danger" plain>
<el-button v-if="currentJob && jobStatus.status === 'running'" @click="cancelJob" type="danger" plain>
<el-icon><Close /></el-icon>取消任务
</el-button>
<el-button v-else-if="jobResult || (currentJob && jobStatus.status !== 'running')" @click="resetAndStart" type="warning" plain>
<el-icon><Refresh /></el-icon>重新分析
</el-button>
</el-form-item>
<el-alert v-if="testResult" :title="testResult.msg" :type="testResult.ok ? 'success' : 'error'" :closable="false" show-icon />
</el-form>
......@@ -744,6 +747,21 @@
} catch (e) {}
}
// 重新分析:清空上次结果 + 状态,再启动新任务
async function resetAndStart() {
if (pollTimer) { clearInterval(pollTimer); pollTimer = null; }
if (logEventSource) { logEventSource.close(); logEventSource = null; }
currentJob.value = null;
jobResult.value = null;
jobStatus.value = {
status: 'pending', progress_pct: 0,
steps_planned: [], steps_completed: [], steps_failed: [],
current_step_title: '', error: null,
};
logs.value = [];
await startJob();
}
// ── 下载报告 ──
function downloadReport(fmt) {
if (!jobResult.value || !jobResult.value.reports) return;
......@@ -798,7 +816,7 @@
currentJob, jobStatus, statusTagType,
logs, logExpanded, showStandardsDialog,
jobResult, activeTab, perTableStats, flatEmptyFields,
testConnection, startJob, cancelJob,
testConnection, startJob, cancelJob, resetAndStart,
downloadReport,
loadStandards,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment