mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:02:46 +00:00
feat: document
This commit is contained in:
parent
56dc0c89de
commit
f0bbe1c2f8
|
|
@ -1,21 +1,17 @@
|
|||
import {Result} from '@/request/Result'
|
||||
import {get, post, del, put, exportExcel, exportFile} from '@/request/index'
|
||||
import type {Ref} from 'vue'
|
||||
import type {KeyValue} from '@/api/type/common'
|
||||
import type {pageRequest} from '@/api/type/common'
|
||||
import { Result } from '@/request/Result'
|
||||
import { get, post, del, put, exportExcel, exportFile } from '@/request/index'
|
||||
import type { Ref } from 'vue'
|
||||
import type { KeyValue } from '@/api/type/common'
|
||||
import type { pageRequest } from '@/api/type/common'
|
||||
|
||||
const prefix = '/workspace/' + localStorage.getItem('workspace_id') + '/knowledge'
|
||||
|
||||
/**
|
||||
* 文档分页列表
|
||||
* @param 参数 knowledge_id,
|
||||
* page {
|
||||
"current_page": "string",
|
||||
"page_size": "string",
|
||||
}
|
||||
* param {
|
||||
"name": "string",
|
||||
}
|
||||
" name": "string",
|
||||
}
|
||||
*/
|
||||
|
||||
const getDocument: (
|
||||
|
|
@ -31,6 +27,342 @@ const getDocument: (
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档详情
|
||||
* @param 参数 knowledge_id
|
||||
*/
|
||||
const getDocumentDetail: (knowledge_id: string, document_id: string) => Promise<Result<any>> = (
|
||||
knowledge_id,
|
||||
document_id,
|
||||
) => {
|
||||
return get(`${prefix}/${knowledge_id}/document/${document_id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文档
|
||||
* @param 参数
|
||||
* knowledge_id, document_id,
|
||||
* {
|
||||
"name": "string",
|
||||
"is_active": true,
|
||||
"meta": {}
|
||||
}
|
||||
*/
|
||||
const putDocument: (
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, document_id, data: any, loading) => {
|
||||
return put(`${prefix}/${knowledge_id}/document/${document_id}`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文档
|
||||
* @param 参数 knowledge_id, document_id,
|
||||
*/
|
||||
const delDocument: (
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, document_id, loading) => {
|
||||
return del(`${prefix}/${knowledge_id}/document/${document_id}`, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消文档任务
|
||||
* @param 参数 knowledge_id, document_id,
|
||||
*{
|
||||
"id_list": [
|
||||
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
|
||||
],
|
||||
"type": 0
|
||||
}
|
||||
*/
|
||||
|
||||
const putBatchCancelTask: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, data, loading) => {
|
||||
return put(`${prefix}/${knowledge_id}/document/cancel_task/_batch`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消文档任务
|
||||
* @param 参数 knowledge_id, document_id,
|
||||
*/
|
||||
const putCancelTask: (
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, document_id, data, loading) => {
|
||||
return put(
|
||||
`${prefix}/${knowledge_id}/document/${document_id}/cancel_task`,
|
||||
data,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载原文档
|
||||
* @param 参数 knowledge_id
|
||||
*/
|
||||
const getDownloadSourceFile: (knowledge_id: string, document_id: string) => Promise<Result<any>> = (
|
||||
knowledge_id,
|
||||
document_id,
|
||||
) => {
|
||||
return get(`${prefix}/${knowledge_id}/document/${document_id}/download_source_file`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出文档
|
||||
* @param document_name 文档名称
|
||||
* @param knowledge_id 数据集id
|
||||
* @param document_id 文档id
|
||||
* @param loading 加载器
|
||||
* @returns
|
||||
*/
|
||||
const exportDocument: (
|
||||
document_name: string,
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<any> = (document_name, knowledge_id, document_id, loading) => {
|
||||
return exportExcel(
|
||||
document_name + '.xlsx',
|
||||
`${prefix}/${knowledge_id}/document/${document_id}/export`,
|
||||
{},
|
||||
loading,
|
||||
)
|
||||
}
|
||||
/**
|
||||
* 导出文档
|
||||
* @param document_name 文档名称
|
||||
* @param knowledge_id 数据集id
|
||||
* @param document_id 文档id
|
||||
* @param loading 加载器
|
||||
* @returns
|
||||
*/
|
||||
const exportDocumentZip: (
|
||||
document_name: string,
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<any> = (document_name, knowledge_id, document_id, loading) => {
|
||||
return exportFile(
|
||||
document_name + '.zip',
|
||||
`${prefix}/${knowledge_id}/document/${document_id}/export_zip`,
|
||||
{},
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新文档向量库
|
||||
* @param 参数
|
||||
* knowledge_id, document_id,
|
||||
* {
|
||||
"state_list": [
|
||||
"string"
|
||||
]
|
||||
}
|
||||
*/
|
||||
const putDocumentRefresh: (
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
state_list: Array<string>,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, document_id, state_list, loading) => {
|
||||
return put(
|
||||
`${prefix}/${knowledge_id}/document/${document_id}/refresh`,
|
||||
{ state_list },
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步web站点类型
|
||||
* @param 参数
|
||||
* knowledge_id, document_id,
|
||||
*/
|
||||
const putDocumentSync: (
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, document_id, loading) => {
|
||||
return put(
|
||||
`${prefix}/${knowledge_id}/document/${document_id}/sync`,
|
||||
undefined,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建批量文档
|
||||
* @param 参数
|
||||
{
|
||||
"name": "string",
|
||||
"paragraphs": [
|
||||
{
|
||||
"content": "string",
|
||||
"title": "string",
|
||||
"problem_list": [
|
||||
{
|
||||
"id": "string",
|
||||
"content": "string"
|
||||
}
|
||||
],
|
||||
"is_active": true
|
||||
}
|
||||
],
|
||||
"source_file_id": string
|
||||
}
|
||||
*/
|
||||
const postMulDocument: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, data, loading) => {
|
||||
return post(`${prefix}/${knowledge_id}/document/bach_create`, data, {}, loading, 1000 * 60 * 5)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文档
|
||||
* @param 参数 knowledge_id,
|
||||
* {
|
||||
"id_list": [String]
|
||||
}
|
||||
*/
|
||||
const delMulDocument: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, data, loading) => {
|
||||
return del(
|
||||
`${prefix}/${knowledge_id}/document/bach_delete`,
|
||||
undefined,
|
||||
{ id_list: data },
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量关联
|
||||
* @param 参数 knowledge_id,
|
||||
{
|
||||
"document_id_list": [
|
||||
"string"
|
||||
],
|
||||
"model_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"prompt": "string",
|
||||
"state_list": [
|
||||
"string"
|
||||
]
|
||||
}
|
||||
*/
|
||||
const putBatchGenerateRelated: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, data, loading) => {
|
||||
return put(`${prefix}/${knowledge_id}/document/batch_generate_related`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改命中方式
|
||||
* @param knowledge_id 知识库id
|
||||
* @param data
|
||||
* {id_list:[],hit_handling_method:'directly_return|optimization',directly_return_similarity}
|
||||
* @param loading
|
||||
* @returns
|
||||
*/
|
||||
const putBatchEditHitHandling: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, data, loading) => {
|
||||
return put(`${prefix}/${knowledge_id}/document/batch_hit_handling`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量刷新文档向量库
|
||||
* @param knowledge_id 知识库id
|
||||
* @param data
|
||||
{
|
||||
"id_list": [
|
||||
"string"
|
||||
],
|
||||
"state_list": [
|
||||
"string"
|
||||
]
|
||||
}
|
||||
* @param loading
|
||||
* @returns
|
||||
*/
|
||||
const putBatchRefresh: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
stateList: Array<string>,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, data, stateList, loading) => {
|
||||
return put(
|
||||
`${prefix}/${knowledge_id}/document/batch_refresh`,
|
||||
{ id_list: data, state_list: stateList },
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量同步文档
|
||||
* @param 参数 knowledge_id,
|
||||
*/
|
||||
const putMulSyncDocument: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, data, loading) => {
|
||||
return put(`${prefix}/${knowledge_id}/document/batch_sync`, { id_list: data }, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量迁移文档
|
||||
* @param 参数 knowledge_id,target_knowledge_id,
|
||||
|
||||
*/
|
||||
const putMigrateMulDocument: (
|
||||
knowledge_id: string,
|
||||
target_knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (knowledge_id, target_knowledge_id, data, loading) => {
|
||||
return put(
|
||||
`${prefix}/${knowledge_id}/document/migrate/${target_knowledge_id}`,
|
||||
data,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入QA文档
|
||||
* @param 参数
|
||||
* file
|
||||
}
|
||||
*/
|
||||
const postQADocument: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, data, loading) => {
|
||||
return post(`${prefix}/${knowledge_id}/document/qa`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 分段预览(上传文档)
|
||||
* @param 参数 file:file,limit:number,patterns:array,with_filter:boolean
|
||||
|
|
@ -50,167 +382,41 @@ const listSplitPattern: (
|
|||
return get(`${prefix}/document/split_pattern`, {}, loading)
|
||||
}
|
||||
|
||||
const getAllDocument: (dataset_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
dataset_id,
|
||||
/**
|
||||
* 导入表格
|
||||
* @param 参数
|
||||
* file
|
||||
*/
|
||||
const postTableDocument: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, data, loading) => {
|
||||
return post(`${prefix}/${knowledge_id}/document/table`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得QA模版
|
||||
* @param 参数 fileName,type,
|
||||
*/
|
||||
const exportQATemplate: (fileName: string, type: string, loading?: Ref<boolean>) => void = (
|
||||
fileName,
|
||||
type,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}/${dataset_id}/document`, undefined, loading)
|
||||
return exportExcel(fileName, `${prefix}/document/template/export`, { type }, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建批量文档
|
||||
* @param 参数
|
||||
* {
|
||||
"name": "string",
|
||||
"paragraphs": [
|
||||
{
|
||||
"content": "string",
|
||||
"title": "string",
|
||||
"problem_list": [
|
||||
{
|
||||
"id": "string",
|
||||
"content": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
* 获得table模版
|
||||
* @param 参数 fileName,type,
|
||||
*/
|
||||
const postDocument: (
|
||||
dataset_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (dataset_id, data, loading) => {
|
||||
return post(`${prefix}/${dataset_id}/document/_bach`, data, {}, loading, 1000 * 60 * 5)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文档
|
||||
* @param 参数
|
||||
* dataset_id, document_id,
|
||||
* {
|
||||
"name": "string",
|
||||
"is_active": true,
|
||||
"meta": {}
|
||||
}
|
||||
*/
|
||||
const putDocument: (
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (dataset_id, document_id, data: any, loading) => {
|
||||
return put(`${prefix}/${dataset_id}/document/${document_id}`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文档
|
||||
* @param 参数 dataset_id, 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)
|
||||
}
|
||||
|
||||
const batchRefresh: (
|
||||
dataset_id: string,
|
||||
data: any,
|
||||
stateList: Array<string>,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (dataset_id, data, stateList, loading) => {
|
||||
return put(
|
||||
`${prefix}/${dataset_id}/document/batch_refresh`,
|
||||
{id_list: data, state_list: stateList},
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
/**
|
||||
* 文档详情
|
||||
* @param 参数 dataset_id
|
||||
*/
|
||||
const getDocumentDetail: (dataset_id: string, document_id: string) => Promise<Result<any>> = (
|
||||
dataset_id,
|
||||
document_id,
|
||||
const exportTableTemplate: (fileName: string, type: string, loading?: Ref<boolean>) => void = (
|
||||
fileName,
|
||||
type,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}/${dataset_id}/document/${document_id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新文档向量库
|
||||
* @param 参数
|
||||
* dataset_id, document_id,
|
||||
*/
|
||||
const putDocumentRefresh: (
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
state_list: Array<string>,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (dataset_id, document_id, state_list, loading) => {
|
||||
return put(
|
||||
`${prefix}/${dataset_id}/document/${document_id}/refresh`,
|
||||
{state_list},
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步web站点类型
|
||||
* @param 参数
|
||||
* dataset_id, document_id,
|
||||
*/
|
||||
const putDocumentSync: (
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (dataset_id, document_id, loading) => {
|
||||
return put(`${prefix}/${dataset_id}/document/${document_id}/sync`, undefined, undefined, loading)
|
||||
}
|
||||
const putLarkDocumentSync: (
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (dataset_id, document_id, loading) => {
|
||||
return put(
|
||||
`${prefix}/lark/${dataset_id}/document/${document_id}/sync`,
|
||||
undefined,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量同步文档
|
||||
* @param 参数 dataset_id,
|
||||
*/
|
||||
const delMulSyncDocument: (
|
||||
dataset_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (dataset_id, data, loading) => {
|
||||
return put(`${prefix}/${dataset_id}/document/_bach`, {id_list: data}, undefined, loading)
|
||||
}
|
||||
const delMulLarkSyncDocument: (
|
||||
dataset_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (dataset_id, data, loading) => {
|
||||
return put(`${prefix}/lark/${dataset_id}/_batch`, {id_list: data}, undefined, loading)
|
||||
return exportExcel(fileName, `${prefix}/document/table_template/export`, { type }, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -225,195 +431,69 @@ const delMulLarkSyncDocument: (
|
|||
}
|
||||
*/
|
||||
const postWebDocument: (
|
||||
dataset_id: string,
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (dataset_id, data, loading) => {
|
||||
return post(`${prefix}/${dataset_id}/document/web`, data, undefined, loading)
|
||||
) => Promise<Result<any>> = (knowledge_id, data, loading) => {
|
||||
return post(`${prefix}/${knowledge_id}/document/web`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入QA文档
|
||||
* @param 参数
|
||||
* file
|
||||
}
|
||||
*/
|
||||
const postQADocument: (
|
||||
dataset_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (dataset_id, data, loading) => {
|
||||
return post(`${prefix}/${dataset_id}/document/qa`, data, undefined, loading)
|
||||
const getAllDocument: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
knowledge_id,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}/${knowledge_id}/document`, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入表格
|
||||
* @param 参数
|
||||
* file
|
||||
*/
|
||||
const postTableDocument: (
|
||||
dataset_id: string,
|
||||
data: any,
|
||||
const putLarkDocumentSync: (
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (dataset_id, data, loading) => {
|
||||
return post(`${prefix}/${dataset_id}/document/table`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量迁移文档
|
||||
* @param 参数 dataset_id,target_dataset_id,
|
||||
*/
|
||||
const putMigrateMulDocument: (
|
||||
dataset_id: string,
|
||||
target_dataset_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (dataset_id, target_dataset_id, data, loading) => {
|
||||
) => Promise<Result<any>> = (knowledge_id, document_id, loading) => {
|
||||
return put(
|
||||
`${prefix}/${dataset_id}/document/migrate/${target_dataset_id}`,
|
||||
data,
|
||||
`${prefix}/lark/${knowledge_id}/document/${document_id}/sync`,
|
||||
undefined,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改命中方式
|
||||
* @param dataset_id 知识库id
|
||||
* @param data {id_list:[],hit_handling_method:'directly_return|optimization'}
|
||||
* @param loading
|
||||
* @returns
|
||||
*/
|
||||
const batchEditHitHandling: (
|
||||
dataset_id: string,
|
||||
const delMulLarkSyncDocument: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (dataset_id, data, loading) => {
|
||||
return put(`${prefix}/${dataset_id}/document/batch_hit_handling`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得QA模版
|
||||
* @param 参数 fileName,type,
|
||||
*/
|
||||
const exportQATemplate: (fileName: string, type: string, loading?: Ref<boolean>) => void = (
|
||||
fileName,
|
||||
type,
|
||||
loading,
|
||||
) => {
|
||||
return exportExcel(fileName, `${prefix}/document/template/export`, {type}, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得table模版
|
||||
* @param 参数 fileName,type,
|
||||
*/
|
||||
const exportTableTemplate: (fileName: string, type: string, loading?: Ref<boolean>) => void = (
|
||||
fileName,
|
||||
type,
|
||||
loading,
|
||||
) => {
|
||||
return exportExcel(fileName, `${prefix}/document/table_template/export`, {type}, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出文档
|
||||
* @param document_name 文档名称
|
||||
* @param dataset_id 数据集id
|
||||
* @param document_id 文档id
|
||||
* @param loading 加载器
|
||||
* @returns
|
||||
*/
|
||||
const exportDocument: (
|
||||
document_name: string,
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<any> = (document_name, dataset_id, document_id, loading) => {
|
||||
return exportExcel(
|
||||
document_name + '.xlsx',
|
||||
`${prefix}/${dataset_id}/document/${document_id}/export`,
|
||||
{},
|
||||
loading,
|
||||
)
|
||||
}
|
||||
/**
|
||||
* 导出文档
|
||||
* @param document_name 文档名称
|
||||
* @param dataset_id 数据集id
|
||||
* @param document_id 文档id
|
||||
* @param loading 加载器
|
||||
* @returns
|
||||
*/
|
||||
const exportDocumentZip: (
|
||||
document_name: string,
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<any> = (document_name, dataset_id, document_id, loading) => {
|
||||
return exportFile(
|
||||
document_name + '.zip',
|
||||
`${prefix}/${dataset_id}/document/${document_id}/export_zip`,
|
||||
{},
|
||||
loading,
|
||||
)
|
||||
}
|
||||
const batchGenerateRelated: (
|
||||
dataset_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (dataset_id, data, loading) => {
|
||||
return put(`${prefix}/${dataset_id}/document/batch_generate_related`, data, undefined, loading)
|
||||
}
|
||||
|
||||
const cancelTask: (
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (dataset_id, document_id, data, loading) => {
|
||||
return put(
|
||||
`${prefix}/${dataset_id}/document/${document_id}/cancel_task`,
|
||||
data,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
const batchCancelTask: (
|
||||
dataset_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (dataset_id, data, loading) => {
|
||||
return put(`${prefix}/${dataset_id}/document/cancel_task/_batch`, data, undefined, loading)
|
||||
) => Promise<Result<boolean>> = (knowledge_id, data, loading) => {
|
||||
return put(`${prefix}/lark/${knowledge_id}/_batch`, { id_list: data }, undefined, loading)
|
||||
}
|
||||
|
||||
export default {
|
||||
postSplitDocument,
|
||||
getDocument,
|
||||
getAllDocument,
|
||||
postDocument,
|
||||
getDocumentDetail,
|
||||
putDocument,
|
||||
delDocument,
|
||||
delMulDocument,
|
||||
getDocumentDetail,
|
||||
listSplitPattern,
|
||||
putBatchCancelTask,
|
||||
putCancelTask,
|
||||
getDownloadSourceFile,
|
||||
exportDocument,
|
||||
exportDocumentZip,
|
||||
putDocumentRefresh,
|
||||
putDocumentSync,
|
||||
delMulSyncDocument,
|
||||
postWebDocument,
|
||||
postMulDocument,
|
||||
delMulDocument,
|
||||
putBatchGenerateRelated,
|
||||
putBatchEditHitHandling,
|
||||
putBatchRefresh,
|
||||
putMulSyncDocument,
|
||||
putMigrateMulDocument,
|
||||
batchEditHitHandling,
|
||||
postQADocument,
|
||||
postSplitDocument,
|
||||
listSplitPattern,
|
||||
postTableDocument,
|
||||
exportQATemplate,
|
||||
exportTableTemplate,
|
||||
postQADocument,
|
||||
postTableDocument,
|
||||
exportDocument,
|
||||
batchRefresh,
|
||||
batchGenerateRelated,
|
||||
cancelTask,
|
||||
exportDocumentZip,
|
||||
batchCancelTask,
|
||||
postWebDocument,
|
||||
|
||||
getAllDocument,
|
||||
putLarkDocumentSync,
|
||||
delMulLarkSyncDocument,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M33.0404 11.3738C33.2279 11.5614 33.3333 11.8157 33.3333 12.0809V34.8149C33.3333 35.8376 32.5374 36.6667 31.5555 36.6667H8.4444C7.46256 36.6667 6.66663 35.8376 6.66663 34.8149V5.18523C6.66663 4.16248 7.46256 3.33337 8.4444 3.33337H24.5857C24.851 3.33337 25.1053 3.43873 25.2929 3.62627L33.0404 11.3738Z" fill="#3370FF"/>
|
||||
<path d="M20.6509 15.8135C20.3173 15.3965 19.683 15.3965 19.3494 15.8135L14.4166 21.9795C13.9801 22.5251 14.3686 23.3334 15.0673 23.3334H18.3335V26.6667H21.6668V23.3334H24.9329C25.6317 23.3334 26.0202 22.5251 25.5837 21.9795L20.6509 15.8135Z" fill="white"/>
|
||||
<path d="M18.3335 30.0001V28.3334H21.6668V30.0001H18.3335Z" fill="white"/>
|
||||
<path d="M25 3.33337L33.3333 11.6667H26.6667C25.7462 11.6667 25 10.9205 25 10V3.33337Z" fill="#2B5FD9"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 871 B |
|
|
@ -166,7 +166,7 @@ const submitHandle = async (formEl: FormInstance) => {
|
|||
document_id_list: idList.value,
|
||||
state_list: stateMap[state.value]
|
||||
}
|
||||
documentApi.batchGenerateRelated(id, data, loading).then(() => {
|
||||
documentApi.putBatchGenerateRelated(id, data, loading).then(() => {
|
||||
MsgSuccess(t('views.document.generateQuestion.successMessage'))
|
||||
emit('refresh')
|
||||
dialogVisible.value = false
|
||||
|
|
|
|||
|
|
@ -11,6 +11,15 @@ const ModelRouter = {
|
|||
meta: { title: '知识库主页', activeMenu: '/knowledge' },
|
||||
component: () => import('@/views/knowledge/index.vue'),
|
||||
},
|
||||
|
||||
// 上传文档
|
||||
{
|
||||
path: '/knowledge/document/upload',
|
||||
name: 'UploadDocument',
|
||||
meta: { activeMenu: '/knowledge' },
|
||||
component: () => import('@/views/document/UploadDocument.vue'),
|
||||
hidden: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const useDocumentStore = defineStore('document', {
|
|||
async asyncPostDocument(knowledgeId: string, data: any, loading?: Ref<boolean>) {
|
||||
return new Promise((resolve, reject) => {
|
||||
documentApi
|
||||
.postDocument(knowledgeId, data, loading)
|
||||
.postMulDocument(knowledgeId, data, loading)
|
||||
.then((data) => {
|
||||
resolve(data)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,27 +1,30 @@
|
|||
<template>
|
||||
<LayoutContainer :header="$t('views.document.uploadDocument')" class="create-dataset">
|
||||
<template #backButton>
|
||||
<back-button @click="back"></back-button>
|
||||
</template>
|
||||
<div class="create-dataset__main flex" v-loading="loading">
|
||||
<div class="create-dataset__component main-calc-height">
|
||||
<el-scrollbar>
|
||||
<template v-if="active === 0">
|
||||
<div class="upload-document p-24">
|
||||
<!-- 上传文档 -->
|
||||
<UploadComponent ref="UploadComponentRef" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="active === 1">
|
||||
<SetRules ref="SetRulesRef" />
|
||||
</template>
|
||||
<template v-else-if="active === 2">
|
||||
<ResultSuccess :data="successInfo" />
|
||||
</template>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
<div class="upload-document p-12-24">
|
||||
<div class="flex align-center mb-16">
|
||||
<back-button to="-1" style="margin-left: -4px"></back-button>
|
||||
<h3 style="display: inline-block">{{ $t('views.document.uploadDocument') }}</h3>
|
||||
</div>
|
||||
<div class="create-dataset__footer text-right border-t" v-if="active !== 2">
|
||||
<el-card style="--el-card-padding: 0">
|
||||
<div class="upload-document__main flex" v-loading="loading">
|
||||
<div class="upload-document__component main-calc-height">
|
||||
<el-scrollbar>
|
||||
<template v-if="active === 0">
|
||||
<div class="upload-component p-24">
|
||||
<!-- 上传文档 -->
|
||||
<UploadComponent ref="UploadComponentRef" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="active === 1">
|
||||
<SetRules ref="SetRulesRef" />
|
||||
</template>
|
||||
<template v-else-if="active === 2">
|
||||
<ResultSuccess :data="successInfo" />
|
||||
</template>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<div class="upload-document__footer text-right border-t" v-if="active !== 2">
|
||||
<el-button @click="router.go(-1)" :disabled="SetRulesRef?.loading || loading">{{
|
||||
$t('common.cancel')
|
||||
}}</el-button>
|
||||
|
|
@ -49,15 +52,15 @@
|
|||
{{ $t('views.document.buttons.import') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</LayoutContainer>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onUnmounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import SetRules from './component/SetRules.vue'
|
||||
import ResultSuccess from './component/ResultSuccess.vue'
|
||||
import UploadComponent from './component/UploadComponent.vue'
|
||||
import documentApi from '@/api/document'
|
||||
import SetRules from './upload/SetRules.vue'
|
||||
import ResultSuccess from './upload/ResultSuccess.vue'
|
||||
import UploadComponent from './upload/UploadComponent.vue'
|
||||
import documentApi from '@/api/knowledge/document'
|
||||
import { MsgConfirm, MsgSuccess } from '@/utils/message'
|
||||
import { t } from '@/locales'
|
||||
import useStore from '@/stores'
|
||||
|
|
@ -68,7 +71,7 @@ const documentsType = computed(() => knowledge.documentsType)
|
|||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const {
|
||||
query: { id } // id为knowledgeID,有id的是上传文档
|
||||
query: { id }, // id为knowledgeID,有id的是上传文档
|
||||
} = route
|
||||
|
||||
const SetRulesRef = ref()
|
||||
|
|
@ -137,7 +140,7 @@ function submit() {
|
|||
}
|
||||
documents.push({
|
||||
name: item.name,
|
||||
paragraphs: item.content
|
||||
paragraphs: item.content,
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -159,7 +162,7 @@ function back() {
|
|||
if (documentsFiles.value?.length > 0) {
|
||||
MsgConfirm(t('common.tip'), t('views.document.tip.saveMessage'), {
|
||||
confirmButtonText: t('common.confirm'),
|
||||
type: 'warning'
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
router.go(-1)
|
||||
|
|
@ -175,7 +178,7 @@ onUnmounted(() => {
|
|||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.create-dataset {
|
||||
.upload-document {
|
||||
&__steps {
|
||||
min-width: 450px;
|
||||
max-width: 800px;
|
||||
|
|
@ -203,7 +206,7 @@ onUnmounted(() => {
|
|||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.upload-document {
|
||||
.upload-component {
|
||||
width: 70%;
|
||||
margin: 0 auto;
|
||||
margin-bottom: 20px;
|
||||
|
|
@ -217,7 +217,7 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
directly_return_similarity: form.value.directly_return_similarity,
|
||||
id_list: documentList.value
|
||||
}
|
||||
documentApi.batchEditHitHandling(id, obj, loading).then(() => {
|
||||
documentApi.putBatchEditHitHandling(id, obj, loading).then(() => {
|
||||
MsgSuccess(t('common.settingSuccess'))
|
||||
emit('refresh')
|
||||
dialogVisible.value = false
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<el-button
|
||||
v-if="datasetDetail.type === 0"
|
||||
type="primary"
|
||||
@click="router.push({ path: '/knowledge/upload', query: { id: id } })"
|
||||
@click="router.push({ path: '/knowledge/document/upload', query: { id: id } })"
|
||||
>{{ $t('views.document.uploadDocument') }}
|
||||
</el-button>
|
||||
<el-button v-if="datasetDetail.type === 1" type="primary" @click="importDoc"
|
||||
|
|
@ -625,7 +625,7 @@ function cancelTaskHandle(val: any) {
|
|||
id_list: arr,
|
||||
type: val,
|
||||
}
|
||||
documentApi.batchCancelTask(id, obj, loading).then(() => {
|
||||
documentApi.putBatchCancelTask(id, obj, loading).then(() => {
|
||||
MsgSuccess(t('views.document.tip.cancelSuccess'))
|
||||
multipleTableRef.value?.clearSelection()
|
||||
})
|
||||
|
|
@ -668,7 +668,7 @@ function beforeCommand(attr: string, val: any, task_type?: number) {
|
|||
}
|
||||
|
||||
const cancelTask = (row: any, task_type: number) => {
|
||||
documentApi.cancelTask(row.dataset_id, row.id, { type: task_type }).then(() => {
|
||||
documentApi.putCancelTask(row.dataset_id, row.id, { type: task_type }).then(() => {
|
||||
MsgSuccess(t('views.document.tip.sendMessage'))
|
||||
})
|
||||
}
|
||||
|
|
@ -796,7 +796,7 @@ function syncMulDocument() {
|
|||
arr.push(v.id)
|
||||
}
|
||||
})
|
||||
documentApi.delMulSyncDocument(id, arr, loading).then(() => {
|
||||
documentApi.putMulSyncDocument(id, arr, loading).then(() => {
|
||||
MsgSuccess(t('views.document.sync.successMessage'))
|
||||
getList()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@
|
|||
import { ref, computed, onMounted, reactive, watch } from 'vue'
|
||||
import ParagraphPreview from '@/views/knowledge/component/ParagraphPreview.vue'
|
||||
import { cutFilename } from '@/utils/utils'
|
||||
import documentApi from '@/api/document'
|
||||
import documentApi from '@/api/knowledge/document'
|
||||
import useStore from '@/stores'
|
||||
import type { KeyValue } from '@/api/type/common'
|
||||
const { knowledge } = useStore()
|
||||
|
|
@ -199,7 +199,7 @@ import { ref, reactive, onUnmounted, onMounted, computed, watch, nextTick } from
|
|||
import type { UploadFiles } from 'element-plus'
|
||||
import { filesize, getImgUrl, isRightType } from '@/utils/utils'
|
||||
import { MsgError } from '@/utils/message'
|
||||
import documentApi from '@/api/document'
|
||||
import documentApi from '@/api/knowledge/document'
|
||||
import useStore from '@/stores'
|
||||
import { t } from '@/locales'
|
||||
const { knowledge } = useStore()
|
||||
Loading…
Reference in New Issue