diff --git a/ui/src/api/document.ts b/ui/src/api/document.ts index 06580d269..4a76439d8 100644 --- a/ui/src/api/document.ts +++ b/ui/src/api/document.ts @@ -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> = ( - dataset_id, - document_id -) => { - return del(`${prefix}/${dataset_id}/document/${document_id}`) +const delDocument: ( + dataset_id: string, + document_id: string, + loading?: Ref +) => Promise> = (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 +) => Promise> = (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> = ( -// dataset_id, -// document_id -// ) => { -// return del(`${prefix}/${dataset_id}/document/${document_id}`) -// } /** * 文档详情 * @param 参数 dataset_id @@ -152,6 +154,37 @@ const putDocumentRefresh: ( ) } +/** + * 批量同步文档 + * @param 参数 dataset_id, + */ +const delMulSyncDocument: ( + dataset_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, data, loading) => { + return put(`${prefix}/${dataset_id}/document/_bach`, { id_list: data }, undefined, loading) +} + +/** + * 创建Web站点文档 + * @param 参数 + * { + "source_url_list": [ + "string" + ], + "selector": "string" + } +} + */ +const postWebDocument: ( + dataset_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, data, loading) => { + return post(`${prefix}/${dataset_id}/document/web`, data, undefined, loading) +} + export default { postSplitDocument, getDocument, @@ -159,7 +192,10 @@ export default { postDocument, putDocument, delDocument, + delMulDocument, getDocumentDetail, listSplitPattern, - putDocumentRefresh + putDocumentRefresh, + delMulSyncDocument, + postWebDocument } diff --git a/ui/src/assets/icon_web.svg.svg b/ui/src/assets/icon_web.svg.svg new file mode 100644 index 000000000..f958baf61 --- /dev/null +++ b/ui/src/assets/icon_web.svg.svg @@ -0,0 +1,4 @@ + + + + diff --git a/ui/src/components/ai-chat/ParagraphSourceDialog.vue b/ui/src/components/ai-chat/ParagraphSourceDialog.vue index 34eb44ef3..12e687721 100644 --- a/ui/src/components/ai-chat/ParagraphSourceDialog.vue +++ b/ui/src/components/ai-chat/ParagraphSourceDialog.vue @@ -17,7 +17,6 @@ class="paragraph-source-card cursor mb-8" :class="item.is_active ? '' : 'disabled'" :showIcon="false" - @click="editParagraph(item)" > + diff --git a/ui/src/views/document/index.vue b/ui/src/views/document/index.vue index d8a8f01a5..83ef2d495 100644 --- a/ui/src/views/document/index.vue +++ b/ui/src/views/document/index.vue @@ -10,9 +10,18 @@ @click="router.push({ path: '/dataset/upload', query: { id: id } })" >上传文档 - 导入文档 - - 批量删除 + 导入文档 + 批量同步 + 批量删除 - + - + @@ -145,6 +157,7 @@ import { ref, onMounted, reactive, onBeforeUnmount } from 'vue' import { useRouter, useRoute } from 'vue-router' import { ElTable } from 'element-plus' import documentApi from '@/api/document' +import ImportDocumentDialog from './component/ImportDocumentDialog.vue' import { numberFormat } from '@/utils/utils' import { datetimeFormat } from '@/utils/time' import { MsgSuccess, MsgConfirm } from '@/utils/message' @@ -169,8 +182,19 @@ const paginationConfig = reactive({ total: 0 }) +const ImportDocumentDialogRef = ref() const multipleTableRef = ref>() const multipleSelection = ref([]) +const title = ref('') + +function importDoc() { + title.value = '导入文档' + ImportDocumentDialogRef.value.open() +} +function settingDoc(row: any) { + title.value = '设置' + ImportDocumentDialogRef.value.open(row) +} const handleSelectionChange = (val: any[]) => { multipleSelection.value = val @@ -199,9 +223,22 @@ const closeInterval = () => { } } function refreshDocument(row: any) { - documentApi.putDocumentRefresh(row.dataset_id, row.id).then((res) => { - getList() - }) + if (row.type === '1') { + MsgConfirm(`确认同步文档?`, `同步将删除已有数据重新获取新数据,请谨慎操作。`, { + confirmButtonText: '同步', + confirmButtonClass: 'danger' + }) + .then(() => { + documentApi.putDocumentRefresh(row.dataset_id, row.id).then((res) => { + getList() + }) + }) + .catch(() => {}) + } else { + documentApi.putDocumentRefresh(row.dataset_id, row.id).then((res) => { + getList() + }) + } } function rowClickHandle(row: any) { @@ -225,6 +262,32 @@ function creatQuickHandle(val: string) { }) } +function syncMulDocument() { + const arr: string[] = [] + multipleSelection.value.map((v) => { + if (v) { + arr.push(v.id) + } + }) + documentApi.delMulSyncDocument(id, arr, loading).then(() => { + MsgSuccess('批量同步成功') + getList() + }) +} + +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 +298,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(() => {}) } @@ -314,6 +371,11 @@ function getDetail() { }) } +function refresh() { + paginationConfig.current_page = 1 + getList() +} + onMounted(() => { getDetail() getList()