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>
|
||||
@@ -70,46 +70,60 @@
|
||||
<a-modal
|
||||
v-model:visible="showDocManage"
|
||||
:title="`文档管理 - ${currentKbName}`"
|
||||
width="800px"
|
||||
width="1200px"
|
||||
:footer="null"
|
||||
wrap-class-name="doc-manage-modal"
|
||||
>
|
||||
<div style="margin-bottom: 16px">
|
||||
<p class="text-red-500 mb-1" style="padding-left: calc(88px + 0.5rem)">请选择分类上传资料</p>
|
||||
<div class="flex justify-start items-start">
|
||||
<a-button type="primary" @click="openImport">新增文档</a-button>
|
||||
<div class="ml-2">
|
||||
<div class="flex justify-start items-center flex-wrap">
|
||||
<span
|
||||
@click="activeTag = item.id"
|
||||
:class="[activeTag === item.id ? 'tag-active' : '']"
|
||||
class="tag"
|
||||
v-for="(item, index) in tagList"
|
||||
:key="index"
|
||||
:title="item.description"
|
||||
>{{ item.title }}</span
|
||||
<div class="doc-manage-container">
|
||||
<div class="doc-layout">
|
||||
<!-- 左侧目录树 -->
|
||||
<div class="dir-tree-panel">
|
||||
<div class="dir-header">
|
||||
<span>文档目录</span>
|
||||
<a-button type="link" size="small" @click="openAddDir" title="新增目录">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
</a-button>
|
||||
</div>
|
||||
<div class="tree-container">
|
||||
<a-tree
|
||||
v-if="treeData.length > 0"
|
||||
:tree-data="treeData"
|
||||
:expanded-keys="expandedKeys"
|
||||
:selected-keys="selectedKeys"
|
||||
:load-data="onLoadData"
|
||||
@expand="onExpand"
|
||||
@select="onSelect"
|
||||
:field-names="{ title: 'name', key: 'id', children: 'children' }"
|
||||
>
|
||||
<template #title="{ name, id }">
|
||||
<span :class="{ 'active-dir': selectedKeys[0] === id }">{{ name }}</span>
|
||||
</template>
|
||||
</a-tree>
|
||||
<a-empty v-else :image="simpleImage" description="暂无目录" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧文档列表 -->
|
||||
<div class="doc-list-panel">
|
||||
<div class="doc-header">
|
||||
<div class="doc-actions">
|
||||
<a-button type="primary" @click="openImport">
|
||||
<template #icon><UploadOutlined /></template>
|
||||
上传文档
|
||||
</a-button>
|
||||
<span class="doc-tips">请选择分类上传资料</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="doc-content">
|
||||
<a-table
|
||||
:dataSource="docList"
|
||||
:columns="docColumns"
|
||||
:loading="docLoading"
|
||||
rowKey="id"
|
||||
:pagination="{
|
||||
current: currentPage,
|
||||
pageSize: 10,
|
||||
total: total,
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => `共 ${total} 条`
|
||||
}"
|
||||
@change="
|
||||
(pag) => {
|
||||
currentPage = pag.current;
|
||||
loadDocuments();
|
||||
}
|
||||
"
|
||||
:scroll="{ y: 500 }"
|
||||
:pagination="pagination"
|
||||
@change="handleTableChange"
|
||||
size="middle"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
@@ -124,21 +138,40 @@
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-modal>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<Import
|
||||
<Import2
|
||||
v-model:visible="showImport"
|
||||
@done="loadDocuments"
|
||||
:kbId="currentKbId"
|
||||
@done="loadCloudFiles"
|
||||
:doc="selectedDoc"
|
||||
/>
|
||||
|
||||
<!-- 新增目录弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="showAddDir"
|
||||
:title="`新增目录 - ${selectedDirName ? '在『' + selectedDirName + '』下' : '在根目录下'}`"
|
||||
width="400px"
|
||||
@ok="handleAddDir"
|
||||
@cancel="showAddDir = false"
|
||||
>
|
||||
<a-form :model="dirForm" layout="vertical">
|
||||
<a-form-item label="目录名称">
|
||||
<a-input v-model:value="dirForm.name" placeholder="请输入目录名称" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { createVNode, ref, computed } from 'vue';
|
||||
import { message, Modal, Empty } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
@@ -147,8 +180,8 @@
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import OaCompanyEdit from './components/oaCompanyEdit.vue';
|
||||
// 导入Import组件和API
|
||||
import Import from './components/Import.vue';
|
||||
// 导入Import2组件和API
|
||||
import Import2 from './components/Import2.vue';
|
||||
import {
|
||||
pageOaCompany,
|
||||
removeOaCompany,
|
||||
@@ -156,11 +189,12 @@
|
||||
} from '@/api/oa/oaCompany';
|
||||
import type { OaCompany, OaCompanyParam } from '@/api/oa/oaCompany/model';
|
||||
import { getPageTitle, isImage } from '@/utils/common';
|
||||
// 导入知识库API
|
||||
import {
|
||||
getKnowledgeBaseDocuments,
|
||||
deleteKnowledgeBaseDocument
|
||||
} from '@/api/ai/knowledgeBase'; // 请修改为正确的API路径
|
||||
// 导入AiCloudDoc API
|
||||
import { listAiCloudDoc, addAiCloudDoc } from '@/api/ai/aiCloudDoc';
|
||||
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
||||
// 导入AiCloudFile API
|
||||
import { listAiCloudFile, removeAiCloudFile } from '@/api/ai/aiCloudFile';
|
||||
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
@@ -176,39 +210,119 @@
|
||||
// 文档管理相关响应式变量
|
||||
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
||||
const showImport = ref(false); // 是否显示导入弹窗
|
||||
const showAddDir = ref(false); // 是否显示新增目录弹窗
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 新增分页状态变量
|
||||
const currentPage = ref(1);
|
||||
const total = ref(0);
|
||||
|
||||
// 文档管理相关变量
|
||||
const currentKbId = ref(''); // 当前知识库ID
|
||||
const currentKbName = ref(''); // 当前知识库名称
|
||||
const docList = ref<any[]>([]); // 文档列表数据
|
||||
const currentCompanyId = ref<number>(); // 当前单位ID
|
||||
const docList = ref<AiCloudFile[]>([]); // 文档列表数据改为使用AiCloudFile类型
|
||||
const docLoading = ref(false); // 文档加载状态
|
||||
// 文档表格列配置
|
||||
const allDirs = ref<AiCloudDoc[]>([]); // 所有目录列表
|
||||
|
||||
// 树形结构相关
|
||||
const expandedKeys = ref<(string | number)[]>([]);
|
||||
const selectedKeys = ref<(string | number)[]>([]);
|
||||
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;
|
||||
|
||||
// 新增目录表单
|
||||
const dirForm = ref({
|
||||
name: ''
|
||||
});
|
||||
|
||||
// 分页配置
|
||||
const pagination = ref({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
showSizeChanger: false,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`,
|
||||
pageSizeOptions: ['10', '20', '50', '100']
|
||||
});
|
||||
|
||||
// 计算树形数据
|
||||
const treeData = computed(() => {
|
||||
const buildTree = (parentId: number = 0): any[] => {
|
||||
return allDirs.value
|
||||
.filter(item => item.parentId === parentId)
|
||||
.map(item => ({
|
||||
...item,
|
||||
key: item.id,
|
||||
title: item.name,
|
||||
children: buildTree(item.id),
|
||||
isLeaf: allDirs.value.filter(child => child.parentId === item.id).length === 0
|
||||
}));
|
||||
};
|
||||
return buildTree(0);
|
||||
});
|
||||
|
||||
// 选中的目录名称
|
||||
const selectedDirName = computed(() => {
|
||||
if (selectedKeys.value.length === 0) return '';
|
||||
const selectedId = selectedKeys.value[0];
|
||||
const dir = allDirs.value.find(item => item.id === selectedId);
|
||||
return dir?.name || '';
|
||||
});
|
||||
|
||||
// 计算选中的目录ID(用于文件上传)
|
||||
const selectedCategoryId = computed(() => {
|
||||
if (selectedKeys.value.length === 0) return '';
|
||||
return selectedKeys.value[0].toString();
|
||||
});
|
||||
|
||||
// 计算选中的文档对象
|
||||
const selectedDoc = computed(() => {
|
||||
if (selectedKeys.value.length === 0) return null;
|
||||
const selectedId = selectedKeys.value[0];
|
||||
const doc = allDirs.value.find(item => item.id === selectedId);
|
||||
return doc ? {
|
||||
id: doc.id!,
|
||||
categoryId: doc.categoryId || '' // 假设 AiCloudDoc 有 categoryId 字段
|
||||
} : null;
|
||||
});
|
||||
|
||||
// 文档表格列配置 - 去掉固定宽度,使用自适应
|
||||
const docColumns = ref([
|
||||
{
|
||||
title: '文件名',
|
||||
dataIndex: 'name', // 改为接口返回的name字段
|
||||
key: 'fileName'
|
||||
dataIndex: 'fileName',
|
||||
key: 'fileName',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '文件大小',
|
||||
dataIndex: 'size', // 改为接口返回的size字段
|
||||
key: 'fileSize'
|
||||
dataIndex: 'fileSize',
|
||||
key: 'fileSize',
|
||||
width: 120,
|
||||
customRender: ({ text }: { text: string }) => {
|
||||
if (!text) return '-';
|
||||
const size = Number(text);
|
||||
if (size < 1024) return size + ' B';
|
||||
if (size < 1024 * 1024) return (size / 1024).toFixed(1) + ' KB';
|
||||
return (size / (1024 * 1024)).toFixed(1) + ' MB';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '文件类型',
|
||||
dataIndex: 'fileType',
|
||||
key: 'fileType',
|
||||
width: 120,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '上传时间',
|
||||
dataIndex: 'gmtModified', // 改为接口返回的gmtModified字段
|
||||
key: 'createTime',
|
||||
customRender: ({ text }) => toDateString(text) // 添加时间格式化
|
||||
dataIndex: 'uploadTime',
|
||||
key: 'uploadTime',
|
||||
width: 180,
|
||||
customRender: ({ text }: { text: string }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 100
|
||||
width: 80
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -259,12 +373,6 @@
|
||||
key: 'companyCode',
|
||||
align: 'center'
|
||||
},
|
||||
// {
|
||||
// title: '类型',
|
||||
// dataIndex: 'companyType',
|
||||
// key: 'companyType',
|
||||
// align: 'center',
|
||||
// },
|
||||
{
|
||||
title: '推荐',
|
||||
dataIndex: 'recommend',
|
||||
@@ -277,12 +385,6 @@
|
||||
key: 'status',
|
||||
align: 'center'
|
||||
},
|
||||
// {
|
||||
// title: '备注',
|
||||
// dataIndex: 'comments',
|
||||
// key: 'comments',
|
||||
// align: 'center',
|
||||
// },
|
||||
{
|
||||
title: '排序号',
|
||||
dataIndex: 'sortNumber',
|
||||
@@ -325,48 +427,115 @@
|
||||
};
|
||||
|
||||
// 打开文档管理弹窗
|
||||
const openDocManage = (record: OaCompany) => {
|
||||
currentKbId.value = record.kbId; // 使用record中的kbId
|
||||
currentKbName.value = record.companyName; // 使用单位名称作为知识库名称
|
||||
currentPage.value = 1;
|
||||
const openDocManage = async (record: OaCompany) => {
|
||||
currentKbId.value = record.kbId;
|
||||
currentKbName.value = record.companyName;
|
||||
currentCompanyId.value = record.companyId;
|
||||
pagination.value.current = 1;
|
||||
showDocManage.value = true;
|
||||
loadDocuments();
|
||||
|
||||
// 重置选择状态
|
||||
expandedKeys.value = [];
|
||||
selectedKeys.value = [];
|
||||
|
||||
// 加载目录列表
|
||||
await loadAllCloudDocs();
|
||||
};
|
||||
|
||||
// 加载文档列表
|
||||
const loadDocuments = async () => {
|
||||
// 加载所有目录
|
||||
const loadAllCloudDocs = async () => {
|
||||
try {
|
||||
const params = {
|
||||
companyId: currentCompanyId.value
|
||||
// 不传parentId,获取所有目录
|
||||
};
|
||||
const result = await listAiCloudDoc(params);
|
||||
allDirs.value = result || [];
|
||||
|
||||
// 默认展开根节点并选中第一个目录
|
||||
if (allDirs.value.length > 0) {
|
||||
const rootDirs = allDirs.value.filter(item => item.parentId === 0);
|
||||
if (rootDirs.length > 0) {
|
||||
expandedKeys.value = [0]; // 展开根节点
|
||||
selectedKeys.value = [rootDirs[0].id!];
|
||||
loadCloudFiles();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('加载目录列表失败');
|
||||
console.error('加载目录错误:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 树节点展开
|
||||
const onExpand = (keys: (string | number)[]) => {
|
||||
expandedKeys.value = keys;
|
||||
};
|
||||
|
||||
// 树节点选择
|
||||
const onSelect = (keys: (string | number)[], { node }: any) => {
|
||||
selectedKeys.value = keys;
|
||||
pagination.value.current = 1;
|
||||
loadCloudFiles();
|
||||
};
|
||||
|
||||
// 异步加载子节点(如果需要的话)
|
||||
const onLoadData = (node: any) => {
|
||||
return new Promise<void>((resolve) => {
|
||||
// 由于我们一次性加载了所有目录,这里不需要额外加载
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
// 表格分页变化处理
|
||||
const handleTableChange = (pag: any) => {
|
||||
pagination.value.current = pag.current;
|
||||
pagination.value.pageSize = pag.pageSize;
|
||||
loadCloudFiles();
|
||||
};
|
||||
|
||||
// 加载文档列表 - 改为从AiCloudFile表查询
|
||||
const loadCloudFiles = async () => {
|
||||
docLoading.value = true;
|
||||
try {
|
||||
const response = await getKnowledgeBaseDocuments(
|
||||
currentKbId.value,
|
||||
10,
|
||||
currentPage.value
|
||||
);
|
||||
docList.value = Array.isArray(response?.list) ? response.list : [];
|
||||
total.value = response?.count || 0;
|
||||
if (!selectedCategoryId.value) {
|
||||
docList.value = [];
|
||||
pagination.value.total = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const params = {
|
||||
docId: parseInt(selectedCategoryId.value),
|
||||
page: pagination.value.current,
|
||||
pageSize: pagination.value.pageSize
|
||||
};
|
||||
const result = await listAiCloudFile(params);
|
||||
|
||||
// 假设返回的数据结构为 { records: [], total: number }
|
||||
if (result && result.records) {
|
||||
docList.value = result.records;
|
||||
pagination.value.total = result.total;
|
||||
} else {
|
||||
// 如果API没有分页结构,使用全部数据
|
||||
docList.value = result || [];
|
||||
pagination.value.total = docList.value.length;
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('加载文档列表失败');
|
||||
console.error('加载文档错误:', error);
|
||||
message.error('加载文件列表失败');
|
||||
console.error('加载文件错误:', error);
|
||||
} finally {
|
||||
docLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 删除文档
|
||||
const deleteDoc = async (record: any) => {
|
||||
// 删除文档 - 改为调用AiCloudFile的删除接口
|
||||
const deleteDoc = async (record: AiCloudFile) => {
|
||||
try {
|
||||
// 执行删除操作
|
||||
await deleteKnowledgeBaseDocument(currentKbId.value, record.id);
|
||||
await removeAiCloudFile(record.id);
|
||||
|
||||
// 立即本地删除(核心修改)
|
||||
const index = docList.value.findIndex((item) => item.id === record.id);
|
||||
if (index > -1) {
|
||||
docList.value.splice(index, 1);
|
||||
total.value -= 1;
|
||||
}
|
||||
// 重新加载当前页数据
|
||||
await loadCloudFiles();
|
||||
message.success('删除成功');
|
||||
// 阿里云异步删除,需等待异步删除完成再重新查询
|
||||
// await loadDocuments();
|
||||
} catch (error) {
|
||||
message.error('删除失败');
|
||||
console.error(error);
|
||||
@@ -375,9 +544,61 @@
|
||||
|
||||
// 打开导入弹窗
|
||||
const openImport = () => {
|
||||
if (selectedKeys.value.length === 0) {
|
||||
message.info('请先选择一个目录');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selectedDoc.value) {
|
||||
message.info('选中的目录信息不完整');
|
||||
return;
|
||||
}
|
||||
|
||||
showImport.value = true;
|
||||
};
|
||||
|
||||
// 打开新增目录弹窗
|
||||
const openAddDir = () => {
|
||||
if (selectedKeys.value.length === 0) {
|
||||
message.info('请先选择一个目录');
|
||||
return;
|
||||
}
|
||||
dirForm.value.name = '';
|
||||
showAddDir.value = true;
|
||||
};
|
||||
|
||||
// 处理新增目录
|
||||
const handleAddDir = async () => {
|
||||
if (!dirForm.value.name) {
|
||||
message.error('请输入目录名称');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const newDir: AiCloudDoc = {
|
||||
companyId: currentCompanyId.value,
|
||||
parentId: selectedKeys.value[0] as number,
|
||||
name: dirForm.value.name,
|
||||
sortNumber: 0
|
||||
};
|
||||
|
||||
await addAiCloudDoc(newDir);
|
||||
message.success('新增目录成功');
|
||||
showAddDir.value = false;
|
||||
|
||||
// 重新加载目录列表
|
||||
await loadAllCloudDocs();
|
||||
|
||||
// 展开父节点
|
||||
if (!expandedKeys.value.includes(newDir.parentId!)) {
|
||||
expandedKeys.value = [...expandedKeys.value, newDir.parentId!];
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('新增目录失败');
|
||||
console.error('新增目录错误:', error);
|
||||
}
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: OaCompany) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
@@ -428,83 +649,15 @@
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: OaCompany) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
|
||||
const activeTag = ref(1);
|
||||
const tagList = ref([
|
||||
{
|
||||
id: 1,
|
||||
description:
|
||||
'贯彻执行党和国家有关经济方针政策和决策部署,落实局党组、局工作部署要求,推动单位可持续发展情况;',
|
||||
title: '贯彻决策部署'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
description: '单位发展战略规划的制定、执行和效果情况;',
|
||||
title: '单位发展战略执行'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
description:
|
||||
'重大经济事项的决策、执行和效果情况,具体包括重大预算管理、重大项目实施、重大采购项目、重大投资项目、重大外包业务、重大资产处置、大额资金使用的决策和执行情况等;',
|
||||
title: '三重一大执行'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
description: '有关目标责任制完成情况;',
|
||||
title: '目标完成'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
description:
|
||||
'财政财务管理情况。包括预算编制的完整准确、预算调整审批的合规,以及预算支出的真实合法合规情况;财务收支的真实、合法和效益情况;自然资源资产管理和生态环境保护责任的履行情况;对外投资经济活动的真实、合法和效益情况;',
|
||||
title: '财务管理'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
description: '国有资产采购、管理、使用和处置情况;',
|
||||
title: '国资管理'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
description: '重要经济项目的投资、建设、管理及效益情况;',
|
||||
title: '重大投资情况'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
description:
|
||||
'企业法人治理结构、内部控制和风险管理情况。主要包括企业法人治理结构的建立、健全和运行情况,以及财务管理、业务管理、风险管理、内部审计等内部控制制度的制定和执行情况,以及对所属单位有关经济活动的管理和监督情况。业务管理主要包括采购业务、收支业务、资产管理、勘察项目管理、筹资与担保业务管理、合同管理、业务外包、信息系统管理、全面预算等;',
|
||||
title: '治理结构'
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
description:
|
||||
'在预算管理中执行机构编制管理规定情况(主要是对借用人员和编外用工管理,规范人员经费的使用);',
|
||||
title: '人员编制'
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
description:
|
||||
'在经济活动中落实有关党风廉政建设责任和遵守廉洁从业规定情况,主要是在经济活动中领导干部落实职责范围内党风廉政建设责任、遵守中央八项规定及实施细则精神和廉洁从业有关规定情况。',
|
||||
title: '廉政情况'
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
description:
|
||||
'以往审计发现问题的整改情况。包括整改制度的制定、整改工作的实施、整改措施的落实和整改效果等情况。',
|
||||
title: '历史审计问题'
|
||||
}
|
||||
]);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -518,20 +671,171 @@
|
||||
.ant-steps-item-finish
|
||||
> .ant-steps-item-container
|
||||
> .ant-steps-item-tail::after {
|
||||
background-color: red !important; /* 自定义颜色 */
|
||||
background-color: red !important;
|
||||
}
|
||||
|
||||
.tag {
|
||||
color: grey;
|
||||
border: 1px solid grey;
|
||||
padding: 2px 5px;
|
||||
border-radius: 5px;
|
||||
margin: 0 8px 8px 0;
|
||||
cursor: pointer;
|
||||
/* 文档管理布局 */
|
||||
.doc-manage-container {
|
||||
height: 650px; /* 增加高度 */
|
||||
}
|
||||
|
||||
.tag-active {
|
||||
color: #3b82f6 !important;
|
||||
border: 1px solid #3b82f6 !important;
|
||||
.doc-layout {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.dir-tree-panel {
|
||||
width: 280px; /* 稍微加宽目录树 */
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.dir-header {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
background: #fafafa;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.tree-container {
|
||||
flex: 1;
|
||||
padding: 8px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.doc-list-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 6px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.doc-header {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.doc-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.doc-tips {
|
||||
color: #ff4d4f;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.doc-content {
|
||||
flex: 1;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* 树节点激活样式 */
|
||||
:deep(.active-dir) {
|
||||
color: #1890ff;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
:deep(.ant-tree-node-content-wrapper) {
|
||||
border-radius: 4px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
:deep(.ant-tree-node-content-wrapper:hover) {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
:deep(.ant-tree .ant-tree-treenode-selected .ant-tree-node-content-wrapper) {
|
||||
background-color: #e6f7ff;
|
||||
}
|
||||
|
||||
/* 优化表格样式 */
|
||||
:deep(.doc-manage-modal .ant-modal-body) {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-table-wrapper) {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-spin-nested-loading) {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-spin-container) {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-table) {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-table-container) {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-table-body) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-table-thead > tr > th) {
|
||||
background: #fafafa;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-table-tbody > tr > td) {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* 文件名列特殊处理,允许换行 */
|
||||
:deep(.doc-content .ant-table-tbody > tr > td:first-child) {
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
line-height: 1.4;
|
||||
max-width: 400px; /* 限制文件名最大宽度 */
|
||||
}
|
||||
|
||||
/* 分页样式调整 */
|
||||
:deep(.doc-content .ant-pagination) {
|
||||
margin-top: 16px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
:deep(.doc-content .ant-table-pagination) {
|
||||
margin-top: 16px;
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0; /* 防止分页器被压缩 */
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user