feat(aihr): support cancelling running local import tasks
新增 POST /api/knowledge/doc/import-tasks/{id}/cancel,后台目录导入任务
运行中可取消;资料处理页任务列表接取消按钮与状态刷新。
This commit is contained in:
@@ -135,3 +135,10 @@ export function listLocalKnowledgeImportTasks(): Promise<ApiResult<LocalImportTa
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
export function cancelLocalKnowledgeImportTask(id: number): Promise<ApiResult<LocalImportTask>> {
|
||||
return request({
|
||||
url: `/api/knowledge/doc/import-tasks/${id}/cancel`,
|
||||
method: 'post'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ export function uploadKnowledgeDoc(data: FormData): Promise<ApiResult<SopUploadR
|
||||
url: '/api/knowledge/doc/upload',
|
||||
method: 'post',
|
||||
data,
|
||||
timeout: 180000,
|
||||
headers: { repeatSubmit: false }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -193,8 +193,9 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="currentFile" label="当前文件" min-width="220" show-overflow-tooltip />
|
||||
<el-table-column prop="updatedAt" label="更新时间" width="138" />
|
||||
<el-table-column label="操作" width="84">
|
||||
<el-table-column label="操作" width="104">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status === '导入中'" link type="danger" @click="cancelImportTask(row)">取消</el-button>
|
||||
<el-button v-if="row.status !== '导入中'" link type="primary" @click="retryImportTask(row)">重试</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -237,6 +238,7 @@ import {
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import {
|
||||
cancelLocalKnowledgeImportTask,
|
||||
getProcessingOverview,
|
||||
listLocalKnowledgeImportTasks,
|
||||
startLocalKnowledgeImportTask,
|
||||
@@ -474,6 +476,26 @@ async function retryImportTask(row: LocalImportTask) {
|
||||
}
|
||||
}
|
||||
|
||||
async function cancelImportTask(row: LocalImportTask) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认取消导入任务「${row.directory}」?`, '取消导入', {
|
||||
confirmButtonText: '取消任务',
|
||||
cancelButtonText: '返回',
|
||||
type: 'warning'
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
importTaskLoading.value = true;
|
||||
try {
|
||||
await cancelLocalKnowledgeImportTask(row.id);
|
||||
ElMessage.success('已取消导入任务');
|
||||
await Promise.all([loadImportTasks(), loadOverview()]);
|
||||
} finally {
|
||||
importTaskLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleImportPoll() {
|
||||
clearImportPoll();
|
||||
if (!runningImport.value) return;
|
||||
@@ -928,6 +950,11 @@ function fileBadgeClass(type: string) {
|
||||
background: #ffe8ea;
|
||||
}
|
||||
|
||||
.pill-info {
|
||||
color: #657184;
|
||||
background: #eef2f7;
|
||||
}
|
||||
|
||||
.table-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
Reference in New Issue
Block a user