feat: 批量删除

This commit is contained in:
wangdan-fit2cloud 2024-01-19 14:59:51 +08:00
parent f74bafd59a
commit 6103e64de8
2 changed files with 40 additions and 28 deletions

View File

@ -103,22 +103,24 @@ const putDocument: (dataset_id: string, document_id: string, data: any) => Promi
*
* @param dataset_id, document_id,
*/
const delDocument: (dataset_id: string, document_id: string) => Promise<Result<boolean>> = (
dataset_id,
document_id
) => {
return del(`${prefix}/${dataset_id}/document/${document_id}`)
const delDocument: (
dataset_id: string,
document_id: string,
loading?: Ref<boolean>
) => Promise<Result<boolean>> = (dataset_id, document_id, loading) => {
return del(`${prefix}/${dataset_id}/document/${document_id}`, loading)
}
/**
*
* @param dataset_id,
*/
const delMulDocument: (
dataset_id: string,
data: any,
loading?: Ref<boolean>
) => Promise<Result<boolean>> = (dataset_id, data, loading) => {
return del(`${prefix}/${dataset_id}/document/_bach`, undefined, { id_list: data }, loading)
}
// /**
// * 批量删除文档
// * @param 参数 dataset_id, document_id,
// */
// const delDocument: (dataset_id: string, document_id: string) => Promise<Result<boolean>> = (
// dataset_id,
// document_id
// ) => {
// return del(`${prefix}/${dataset_id}/document/${document_id}`)
// }
/**
*
* @param dataset_id
@ -159,6 +161,7 @@ export default {
postDocument,
putDocument,
delDocument,
delMulDocument,
getDocumentDetail,
listSplitPattern,
putDocumentRefresh

View File

@ -12,7 +12,9 @@
>
<el-button v-if="datasetDetail.type === '1'" type="primary">导入文档</el-button>
<!-- <el-button v-if="datasetDetail.type === '1'">批量同步</el-button> -->
<el-button :disabled="multipleSelection.length === 0">批量删除</el-button>
<el-button :disabled="multipleSelection.length === 0" @click="deleteMulDocument"
>批量删除</el-button
>
</div>
<el-input
@ -119,9 +121,9 @@
</el-tooltip>
<span @click.stop>
<el-dropdown trigger="click">
<span class="el-dropdown-link cursor">
<el-button text>
<el-icon><MoreFilled /></el-icon>
</span>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item icon="Setting">设置</el-dropdown-item>
@ -225,6 +227,19 @@ function creatQuickHandle(val: string) {
})
}
function deleteMulDocument() {
const arr: string[] = []
multipleSelection.value.map((v) => {
if (v) {
arr.push(v.id)
}
})
documentApi.delMulDocument(id, arr, loading).then(() => {
MsgSuccess('删除成功')
getList()
})
}
function deleteDocument(row: any) {
MsgConfirm(
`是否删除文档:${row.name} ?`,
@ -235,16 +250,10 @@ function deleteDocument(row: any) {
}
)
.then(() => {
loading.value = true
documentApi
.delDocument(id, row.id)
.then(() => {
MsgSuccess('删除成功')
getList()
})
.catch(() => {
loading.value = false
})
documentApi.delDocument(id, row.id, loading).then(() => {
MsgSuccess('删除成功')
getList()
})
})
.catch(() => {})
}