feat(pwl):新增AI云文档目录表、AI云文件表
This commit is contained in:
147
src/api/ai/aiCloudDoc/index.ts
Normal file
147
src/api/ai/aiCloudDoc/index.ts
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import type { ApiResult, PageResult } from '@/api';
|
||||||
|
import type { AiCloudDoc, AiCloudDocParam } from './model';
|
||||||
|
import { MODULES_API_URL } from '@/config/setting';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function pageAiCloudDoc(params: AiCloudDocParam) {
|
||||||
|
const res = await request.get<ApiResult<PageResult<AiCloudDoc>>>(
|
||||||
|
MODULES_API_URL + '/ai/doc/page',
|
||||||
|
{
|
||||||
|
params
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询AI云文档目录表列表
|
||||||
|
*/
|
||||||
|
export async function listAiCloudDoc(params?: AiCloudDocParam) {
|
||||||
|
const res = await request.get<ApiResult<AiCloudDoc[]>>(
|
||||||
|
MODULES_API_URL + '/ai/doc',
|
||||||
|
{
|
||||||
|
params
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function addAiCloudDoc(data: AiCloudDoc) {
|
||||||
|
const res = await request.post<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/doc',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function updateAiCloudDoc(data: AiCloudDoc) {
|
||||||
|
const res = await request.put<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/doc',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function removeAiCloudDoc(id?: number) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/doc/' + id
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function removeBatchAiCloudDoc(data: (number | undefined)[]) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/doc/batch',
|
||||||
|
{
|
||||||
|
data
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function getAiCloudDoc(id: number) {
|
||||||
|
const res = await request.get<ApiResult<AiCloudDoc>>(
|
||||||
|
MODULES_API_URL + '/ai/doc/' + id
|
||||||
|
);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ids查询AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function getAiCloudDocByIds(ids: string) {
|
||||||
|
const res = await request.get<ApiResult<AiCloudDoc[]>>(
|
||||||
|
MODULES_API_URL + '/ai/doc/byIds/' + ids
|
||||||
|
);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function addBatchAiCloudDoc(data: AiCloudDoc[]) {
|
||||||
|
const res = await request.post<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/doc/batch',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改AI云文档目录表
|
||||||
|
*/
|
||||||
|
export async function updateBatchAiCloudDoc(data: AiCloudDoc[]) {
|
||||||
|
const res = await request.put<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/doc/batch',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
39
src/api/ai/aiCloudDoc/model/index.ts
Normal file
39
src/api/ai/aiCloudDoc/model/index.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import type { PageParam } from '@/api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI云文档目录表
|
||||||
|
*/
|
||||||
|
export interface AiCloudDoc {
|
||||||
|
// ID
|
||||||
|
id?: number;
|
||||||
|
// 云目录ID
|
||||||
|
categoryId?: string;
|
||||||
|
// 单位ID
|
||||||
|
companyId?: number;
|
||||||
|
// 上级目录ID
|
||||||
|
parentId?: number;
|
||||||
|
// 目录名称
|
||||||
|
name?: string;
|
||||||
|
// 排序(数字越小越靠前)
|
||||||
|
sortNumber?: number;
|
||||||
|
// 状态, 0正常, 1冻结
|
||||||
|
status?: number;
|
||||||
|
// 是否删除, 0否, 1是
|
||||||
|
deleted?: number;
|
||||||
|
// 创建用户ID
|
||||||
|
userId?: number;
|
||||||
|
// 租户id
|
||||||
|
tenantId?: number;
|
||||||
|
// 创建时间
|
||||||
|
createTime?: string;
|
||||||
|
// 修改时间
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI云文档目录表搜索条件
|
||||||
|
*/
|
||||||
|
export interface AiCloudDocParam extends PageParam {
|
||||||
|
id?: number;
|
||||||
|
keywords?: string;
|
||||||
|
}
|
||||||
84
src/api/ai/aiCloudFile/index.ts
Normal file
84
src/api/ai/aiCloudFile/index.ts
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import type { ApiResult, PageResult } from '@/api';
|
||||||
|
import type { AiCloudFile, AiCloudFileParam } from './model';
|
||||||
|
import { MODULES_API_URL } from '@/config/setting';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询AI云文件表
|
||||||
|
*/
|
||||||
|
export async function pageAiCloudFile(params: AiCloudFileParam) {
|
||||||
|
const res = await request.get<ApiResult<PageResult<AiCloudFile>>>(
|
||||||
|
MODULES_API_URL + '/ai/file/page',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询AI云文件表列表
|
||||||
|
*/
|
||||||
|
export async function listAiCloudFile(params?: AiCloudFileParam) {
|
||||||
|
const res = await request.get<ApiResult<AiCloudFile[]>>(
|
||||||
|
MODULES_API_URL + '/ai/file',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件到云中心
|
||||||
|
*/
|
||||||
|
export async function uploadFiles(docId: number, categoryId: string, files: File[]) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('docId', docId);
|
||||||
|
formData.append('categoryId', categoryId);
|
||||||
|
files.forEach(file => {
|
||||||
|
formData.append('files', file);
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await request.post<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/file/uploadFiles',
|
||||||
|
formData,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除AI云文件表
|
||||||
|
*/
|
||||||
|
export async function removeAiCloudFile(id?: number) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/file/' + id
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询AI云文件表
|
||||||
|
*/
|
||||||
|
export async function getAiCloudFile(id: number) {
|
||||||
|
const res = await request.get<ApiResult<AiCloudFile>>(
|
||||||
|
MODULES_API_URL + '/ai/file/' + id
|
||||||
|
);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
52
src/api/ai/aiCloudFile/model/index.ts
Normal file
52
src/api/ai/aiCloudFile/model/index.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import type { PageParam } from '@/api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI云文件表
|
||||||
|
*/
|
||||||
|
export interface AiCloudFile {
|
||||||
|
// ID
|
||||||
|
id?: number;
|
||||||
|
// 文档目录ID
|
||||||
|
docId?: number;
|
||||||
|
// 文件名
|
||||||
|
fileName?: string;
|
||||||
|
// 文件大小(字节)
|
||||||
|
fileSize?: number;
|
||||||
|
// 文件类型
|
||||||
|
fileType?: string;
|
||||||
|
// 工作空间ID
|
||||||
|
workspaceId?: string;
|
||||||
|
// 云文件ID
|
||||||
|
fileId?: string;
|
||||||
|
// 文件地址URL
|
||||||
|
fileUrl?: string;
|
||||||
|
// 文件扩展名
|
||||||
|
fileExt?: string;
|
||||||
|
// 上传时间
|
||||||
|
uploadTime?: string;
|
||||||
|
// 排序(数字越小越靠前)
|
||||||
|
sortNumber?: number;
|
||||||
|
// 状态, 0正常, 1冻结
|
||||||
|
status?: number;
|
||||||
|
// 是否删除, 0否, 1是
|
||||||
|
deleted?: number;
|
||||||
|
// 上传用户ID
|
||||||
|
userId?: number;
|
||||||
|
// 租户id
|
||||||
|
tenantId?: number;
|
||||||
|
// 创建时间
|
||||||
|
createTime?: string;
|
||||||
|
// 修改时间
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI云文件表搜索条件
|
||||||
|
*/
|
||||||
|
export interface AiCloudFileParam extends PageParam {
|
||||||
|
id?: number;
|
||||||
|
keywords?: string;
|
||||||
|
docId?: number;
|
||||||
|
workspaceId?: number;
|
||||||
|
fileType?: string;
|
||||||
|
}
|
||||||
114
src/views/oa/oaCompany/components/Import2.vue
Normal file
114
src/views/oa/oaCompany/components/Import2.vue
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<!-- 文档导入弹窗 -->
|
||||||
|
<template>
|
||||||
|
<ele-modal
|
||||||
|
:width="520"
|
||||||
|
:footer="null"
|
||||||
|
:title="`批量导入文档`"
|
||||||
|
:visible="visible"
|
||||||
|
@update:visible="updateVisible"
|
||||||
|
>
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<a-upload-dragger
|
||||||
|
accept=".pdf,.doc,.docx,.txt,.md,.xls,.xlsx"
|
||||||
|
:show-upload-list="false"
|
||||||
|
:customRequest="doUpload"
|
||||||
|
:multiple="true"
|
||||||
|
style="padding: 24px 0; margin-bottom: 16px"
|
||||||
|
>
|
||||||
|
<p class="ant-upload-drag-icon">
|
||||||
|
<cloud-upload-outlined />
|
||||||
|
</p>
|
||||||
|
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||||
|
<p class="ant-upload-hint" style="font-size: 12px; color: #999;">
|
||||||
|
支持格式:PDF、Word、Excel、TXT、MD 等文档格式
|
||||||
|
</p>
|
||||||
|
</a-upload-dragger>
|
||||||
|
</a-spin>
|
||||||
|
</ele-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { message } from 'ant-design-vue/es';
|
||||||
|
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||||
|
import { debounce } from 'lodash-es';
|
||||||
|
import { uploadFiles } from '@/api/ai/aiCloudFile';
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'done'): void;
|
||||||
|
(e: 'update:visible', visible: boolean): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
// 在顶层定义 props - 修改为接收 doc 对象
|
||||||
|
const props = defineProps<{
|
||||||
|
visible: boolean;
|
||||||
|
doc: { // 改为接收完整的 doc 对象
|
||||||
|
id: number;
|
||||||
|
categoryId: string;
|
||||||
|
};
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
// 新增批量上传方法 - 修改调用参数
|
||||||
|
const handleBatchUpload = debounce(async () => {
|
||||||
|
if (uploadQueue.length === 0) return;
|
||||||
|
|
||||||
|
const files = [...uploadQueue];
|
||||||
|
uploadQueue.length = 0; // 清空队列
|
||||||
|
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
// 修改:传入 doc.id 和 doc.categoryId
|
||||||
|
const msg = await uploadFiles(props.doc.id, props.doc.categoryId, files);
|
||||||
|
message.success(msg || '上传成功');
|
||||||
|
updateVisible(false);
|
||||||
|
emit('done');
|
||||||
|
} catch (e: any) {
|
||||||
|
message.error(e.message || '上传失败');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
// 修改后的上传方法
|
||||||
|
const doUpload = ({ file }: { file: File }) => {
|
||||||
|
// 检查文件类型
|
||||||
|
const allowedTypes = [
|
||||||
|
'application/pdf',
|
||||||
|
'application/msword',
|
||||||
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
'text/plain',
|
||||||
|
'text/markdown',
|
||||||
|
'application/vnd.ms-excel',
|
||||||
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||||
|
];
|
||||||
|
|
||||||
|
const allowedExtensions = ['.pdf', '.doc', '.docx', '.txt', '.md', '.xls', '.xlsx'];
|
||||||
|
const fileExtension = '.' + file.name.split('.').pop()?.toLowerCase();
|
||||||
|
|
||||||
|
if (!allowedTypes.includes(file.type) && !allowedExtensions.includes(fileExtension)) {
|
||||||
|
message.error('只能上传文档文件(PDF、Word、Excel、TXT、MD)');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.size / 1024 / 1024 > 100) {
|
||||||
|
message.error('文件大小不能超过 100MB');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将文件加入队列并触发防抖上传
|
||||||
|
uploadQueue.push(file);
|
||||||
|
handleBatchUpload();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 新增文件队列
|
||||||
|
const uploadQueue: File[] = [];
|
||||||
|
|
||||||
|
/* 更新 visible */
|
||||||
|
const updateVisible = (value: boolean) => {
|
||||||
|
emit('update:visible', value);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user