Skip to content

Commit 6446b70

Browse files
committed
feat: Batch cancel tasks
1 parent a1d872a commit 6446b70

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

ui/src/api/document.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ const cancelTask: (
359359
)
360360
}
361361

362+
const batchCancelTask: (
363+
dataset_id: string,
364+
data: any,
365+
loading?: Ref<boolean>
366+
) => Promise<Result<boolean>> = (dataset_id, data, loading) => {
367+
return put(`${prefix}/${dataset_id}/document/cancel_task/_batch`, data, undefined, loading)
368+
}
369+
362370
export default {
363371
postSplitDocument,
364372
getDocument,
@@ -383,5 +391,6 @@ export default {
383391
batchRefresh,
384392
batchGenerateRelated,
385393
cancelTask,
386-
exportDocumentZip
394+
exportDocumentZip,
395+
batchCancelTask
387396
}

ui/src/styles/element-plus.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
--el-text-color-regular: #1f2329;
77
--el-color-info: #8f959e !important;
88
--el-disabled-bg-color: #eff0f1;
9-
--el-disabled-border-color: #bbbfc4;
109
--el-text-color-primary: #1f2329;
1110
}
1211

ui/src/views/document/index.vue

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<LayoutContainer header="文档">
2+
<LayoutContainer header="文档" class="document-main">
33
<div class="main-calc-height">
44
<div class="p-24">
55
<div class="flex-between">
@@ -403,12 +403,25 @@
403403
</el-table-column>
404404
</app-table>
405405
</div>
406+
406407
<ImportDocumentDialog ref="ImportDocumentDialogRef" :title="title" @refresh="refresh" />
407408
<SyncWebDialog ref="SyncWebDialogRef" @refresh="refresh" />
408409
<!-- 选择知识库 -->
409410
<SelectDatasetDialog ref="SelectDatasetDialogRef" @refresh="refreshMigrate" />
410411
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" />
411412
</div>
413+
<div class="mul-operation w-full flex" v-if="multipleSelection.length !== 0">
414+
<el-button :disabled="multipleSelection.length === 0" @click="cancelTaskHandle(1)">
415+
取消向量化
416+
</el-button>
417+
<el-button :disabled="multipleSelection.length === 0" @click="cancelTaskHandle(2)">
418+
取消生成
419+
</el-button>
420+
<el-text type="info" class="secondary ml-24">
421+
已选 {{ multipleSelection.length }} 项
422+
</el-text>
423+
<el-button class="ml-16" type="primary" link @click="clearSelection"> 清空 </el-button>
424+
</div>
412425
</LayoutContainer>
413426
</template>
414427
<script setup lang="ts">
@@ -478,6 +491,7 @@ const multipleSelection = ref<any[]>([])
478491
const title = ref('')
479492
480493
const SelectDatasetDialogRef = ref()
494+
481495
const exportDocument = (document: any) => {
482496
documentApi.exportDocument(document.name, document.dataset_id, document.id, loading).then(() => {
483497
MsgSuccess('导出成功')
@@ -490,6 +504,28 @@ const exportDocumentZip = (document: any) => {
490504
MsgSuccess('导出成功')
491505
})
492506
}
507+
508+
function cancelTaskHandle(val: any) {
509+
const arr: string[] = []
510+
multipleSelection.value.map((v) => {
511+
if (v) {
512+
arr.push(v.id)
513+
}
514+
})
515+
const obj = {
516+
id_list: arr,
517+
type: val
518+
}
519+
documentApi.batchCancelTask(id, obj, loading).then(() => {
520+
MsgSuccess('批量取消成功')
521+
multipleTableRef.value?.clearSelection()
522+
})
523+
}
524+
525+
function clearSelection() {
526+
multipleTableRef.value?.clearSelection()
527+
}
528+
493529
function openDatasetDialog(row?: any) {
494530
const arr: string[] = []
495531
if (row) {
@@ -813,4 +849,20 @@ onBeforeUnmount(() => {
813849
closeInterval()
814850
})
815851
</script>
816-
<style lang="scss" scoped></style>
852+
<style lang="scss" scoped>
853+
.document-main {
854+
box-sizing: border-box;
855+
.mul-operation {
856+
position: fixed;
857+
margin-left: var(--sidebar-width);
858+
bottom: 0;
859+
right: 24px;
860+
width: calc(100% - var(--sidebar-width) - 48px);
861+
padding: 16px 24px;
862+
box-sizing: border-box;
863+
background: #ffffff;
864+
z-index: 22;
865+
box-shadow: 0px -2px 4px 0px rgba(31, 35, 41, 0.08);
866+
}
867+
}
868+
</style>

0 commit comments

Comments
 (0)