优化公共库管理页面
This commit is contained in:
@@ -63,25 +63,86 @@
|
|||||||
<a-modal
|
<a-modal
|
||||||
v-model:visible="showDocManage"
|
v-model:visible="showDocManage"
|
||||||
:title="`文档管理 - ${currentKbName}`"
|
:title="`文档管理 - ${currentKbName}`"
|
||||||
width="800px"
|
width="1200px"
|
||||||
:footer="null"
|
:footer="null"
|
||||||
|
wrap-class-name="doc-manage-modal"
|
||||||
>
|
>
|
||||||
<div style="margin-bottom: 16px;">
|
<div class="doc-manage-container">
|
||||||
<a-button type="primary" @click="openImport">新增文档</a-button>
|
<div class="doc-layout">
|
||||||
|
<!-- 左侧目录树 -->
|
||||||
|
<div class="dir-tree-panel">
|
||||||
|
<div class="dir-header">
|
||||||
|
<span>文档目录</span>
|
||||||
|
<a-space>
|
||||||
|
<a-button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
@click="openEditDir"
|
||||||
|
title="编辑目录"
|
||||||
|
:disabled="!selectedKeys.length"
|
||||||
|
>
|
||||||
|
<template #icon><EditOutlined /></template>
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
@click="openAddDir"
|
||||||
|
title="新增目录"
|
||||||
|
>
|
||||||
|
<template #icon><PlusOutlined /></template>
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
@click="deleteSelectedDir"
|
||||||
|
title="删除目录"
|
||||||
|
:disabled="!selectedKeys.length"
|
||||||
|
class="ele-text-danger"
|
||||||
|
>
|
||||||
|
<template #icon><DeleteOutlined /></template>
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
</div>
|
</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
|
<a-table
|
||||||
:dataSource="docList"
|
:dataSource="docList"
|
||||||
:columns="docColumns"
|
:columns="docColumns"
|
||||||
:loading="docLoading"
|
:loading="docLoading"
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
:pagination="{
|
:scroll="{ y: 500 }"
|
||||||
current: currentPage,
|
:pagination="pagination"
|
||||||
pageSize: 10,
|
@change="handleTableChange"
|
||||||
total: total,
|
size="middle"
|
||||||
showSizeChanger: false,
|
|
||||||
showTotal: (total) => `共 ${total} 条`
|
|
||||||
}"
|
|
||||||
@change="(pag) => { currentPage = pag.current; loadDocuments(); }"
|
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.key === 'action'">
|
<template v-if="column.key === 'action'">
|
||||||
@@ -96,18 +157,49 @@
|
|||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
|
|
||||||
<!-- 导入弹窗 -->
|
<!-- 导入弹窗 -->
|
||||||
<Import v-model:visible="showImport" @done="loadDocuments" :kbId="currentKbId"/>
|
<Import2
|
||||||
|
v-model:visible="showImport"
|
||||||
|
@done="loadCloudFiles"
|
||||||
|
:doc="selectedDoc"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 新增/编辑目录弹窗 -->
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="showDirModal"
|
||||||
|
:title="dirModalTitle"
|
||||||
|
width="400px"
|
||||||
|
@ok="handleSaveDir"
|
||||||
|
@cancel="closeDirModal"
|
||||||
|
>
|
||||||
|
<a-form :model="dirForm" layout="vertical">
|
||||||
|
<a-form-item label="目录名称">
|
||||||
|
<a-input v-model:value="dirForm.name" placeholder="请输入目录名称" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="排序号">
|
||||||
|
<a-input-number
|
||||||
|
v-model:value="dirForm.sortNumber"
|
||||||
|
placeholder="请输入排序号"
|
||||||
|
:min="0"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { createVNode, ref } from 'vue';
|
import { createVNode, ref, computed } from 'vue';
|
||||||
import { message, Modal } from 'ant-design-vue';
|
import { message, Modal, Empty } from 'ant-design-vue';
|
||||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
import { ExclamationCircleOutlined, PlusOutlined, UploadOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||||
import type { EleProTable } from 'ele-admin-pro';
|
import type { EleProTable } from 'ele-admin-pro';
|
||||||
import {toDateString} from 'ele-admin-pro';
|
import {toDateString} from 'ele-admin-pro';
|
||||||
import type {
|
import type {
|
||||||
@@ -118,8 +210,11 @@
|
|||||||
import PwlProjectLibraryEdit from './components/pwlProjectLibraryEdit.vue';
|
import PwlProjectLibraryEdit from './components/pwlProjectLibraryEdit.vue';
|
||||||
import { pagePwlProjectLibrary, removePwlProjectLibrary, removeBatchPwlProjectLibrary } from '@/api/pwl/pwlProjectLibrary';
|
import { pagePwlProjectLibrary, removePwlProjectLibrary, removeBatchPwlProjectLibrary } from '@/api/pwl/pwlProjectLibrary';
|
||||||
import type { PwlProjectLibrary, PwlProjectLibraryParam } from '@/api/pwl/pwlProjectLibrary/model';
|
import type { PwlProjectLibrary, PwlProjectLibraryParam } from '@/api/pwl/pwlProjectLibrary/model';
|
||||||
import Import from '@/views/oa/oaCompany/components/Import.vue';
|
import Import2 from '@/views/oa/oaCompany/components/Import2.vue';
|
||||||
import {getKnowledgeBaseDocuments, deleteKnowledgeBaseDocument} from '@/api/ai/knowledgeBase';
|
import { listAiCloudDoc, addAiCloudDoc, updateAiCloudDoc, removeAiCloudDoc } from '@/api/ai/aiCloudDoc';
|
||||||
|
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
||||||
|
import { listAiCloudFile, removeAiCloudFile } from '@/api/ai/aiCloudFile';
|
||||||
|
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
||||||
|
|
||||||
// 表格实例
|
// 表格实例
|
||||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||||
@@ -138,37 +233,129 @@
|
|||||||
// 文档管理相关响应式变量
|
// 文档管理相关响应式变量
|
||||||
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
||||||
const showImport = ref(false); // 是否显示导入弹窗
|
const showImport = ref(false); // 是否显示导入弹窗
|
||||||
// 新增分页状态变量
|
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
|
||||||
const currentPage = ref(1);
|
|
||||||
const total = ref(0);
|
|
||||||
|
|
||||||
// 文档管理相关变量
|
// 文档管理相关变量
|
||||||
const currentKbId = ref(''); // 当前知识库ID
|
const currentKbId = ref(''); // 当前知识库ID
|
||||||
const currentKbName = ref(''); // 当前知识库名称
|
const currentKbName = ref(''); // 当前知识库名称
|
||||||
const docList = ref<any[]>([]); // 文档列表数据
|
const currentCompanyId = ref<number>(0); // 当前单位ID - 固定为0
|
||||||
|
const docList = ref<AiCloudFile[]>([]); // 文档列表数据
|
||||||
const docLoading = ref(false); // 文档加载状态
|
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 isEditingDir = ref(false); // 是否为编辑模式
|
||||||
|
const currentDirId = ref<number>(); // 当前操作的目录ID
|
||||||
|
|
||||||
|
// 目录表单
|
||||||
|
const dirForm = ref({
|
||||||
|
name: '',
|
||||||
|
sortNumber: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
// 计算目录弹窗标题
|
||||||
|
const dirModalTitle = computed(() => {
|
||||||
|
const mode = isEditingDir.value ? '编辑' : '新增';
|
||||||
|
const location = selectedDirName.value ? `在『${selectedDirName.value}』下` : '在根目录下';
|
||||||
|
return `${mode}目录 - ${location}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 分页配置
|
||||||
|
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 || ''
|
||||||
|
} : null;
|
||||||
|
});
|
||||||
|
|
||||||
// 文档表格列配置
|
// 文档表格列配置
|
||||||
const docColumns = ref([
|
const docColumns = ref([
|
||||||
{
|
{
|
||||||
title: '文件名',
|
title: '文件名',
|
||||||
dataIndex: 'name', // 改为接口返回的name字段
|
dataIndex: 'fileName',
|
||||||
key: 'fileName',
|
key: 'fileName',
|
||||||
|
ellipsis: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '文件大小',
|
title: '文件大小',
|
||||||
dataIndex: 'size', // 改为接口返回的size字段
|
dataIndex: 'fileSize',
|
||||||
key: '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: '上传时间',
|
title: '上传时间',
|
||||||
dataIndex: 'gmtModified', // 改为接口返回的gmtModified字段
|
dataIndex: 'uploadTime',
|
||||||
key: 'createTime',
|
key: 'uploadTime',
|
||||||
customRender: ({ text }) => toDateString(text) // 添加时间格式化
|
width: 180,
|
||||||
|
customRender: ({ text }: { text: string }) => toDateString(text)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
width: 100,
|
width: 80
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -276,48 +463,111 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 打开文档管理弹窗
|
// 打开文档管理弹窗
|
||||||
const openDocManage = (record: PwlProjectLibrary) => {
|
const openDocManage = async (record: PwlProjectLibrary) => {
|
||||||
currentKbId.value = record.kbId; // 使用record中的kbId
|
currentKbId.value = record.kbId;
|
||||||
currentKbName.value = record.name; // 使用单位名称作为知识库名称
|
currentKbName.value = record.name;
|
||||||
currentPage.value = 1;
|
currentCompanyId.value = 0; // 固定为0
|
||||||
|
pagination.value.current = 1;
|
||||||
showDocManage.value = true;
|
showDocManage.value = true;
|
||||||
loadDocuments();
|
|
||||||
|
// 重置选择状态
|
||||||
|
expandedKeys.value = [];
|
||||||
|
selectedKeys.value = [];
|
||||||
|
|
||||||
|
// 加载目录列表
|
||||||
|
await loadAllCloudDocs(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 加载所有目录
|
||||||
|
const loadAllCloudDocs = async (resetState = false) => {
|
||||||
|
try {
|
||||||
|
const params = {
|
||||||
|
companyId: 0 // 固定为0
|
||||||
|
};
|
||||||
|
const result = await listAiCloudDoc(params);
|
||||||
|
allDirs.value = result || [];
|
||||||
|
|
||||||
|
if (resetState) {
|
||||||
|
// 默认展开根节点并选中第一个目录
|
||||||
|
if (allDirs.value.length > 0) {
|
||||||
|
const rootDirs = allDirs.value.filter(item => item.parentId === 0);
|
||||||
|
if (rootDirs.length > 0) {
|
||||||
|
expandedKeys.value = [rootDirs[0].id!];
|
||||||
|
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();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载文档列表
|
// 加载文档列表
|
||||||
const loadDocuments = async () => {
|
const loadCloudFiles = async () => {
|
||||||
docLoading.value = true;
|
docLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const response = await getKnowledgeBaseDocuments(
|
if (!selectedCategoryId.value) {
|
||||||
currentKbId.value,
|
docList.value = [];
|
||||||
10,
|
pagination.value.total = 0;
|
||||||
currentPage.value
|
return;
|
||||||
);
|
}
|
||||||
docList.value = Array.isArray(response?.list) ? response.list : [];
|
|
||||||
total.value = response?.count || 0;
|
const params = {
|
||||||
|
docId: parseInt(selectedCategoryId.value),
|
||||||
|
page: pagination.value.current,
|
||||||
|
pageSize: pagination.value.pageSize
|
||||||
|
};
|
||||||
|
const result = await listAiCloudFile(params);
|
||||||
|
|
||||||
|
if (result && result.records) {
|
||||||
|
docList.value = result.records;
|
||||||
|
pagination.value.total = result.total;
|
||||||
|
} else {
|
||||||
|
docList.value = result || [];
|
||||||
|
pagination.value.total = docList.value.length;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('加载文档列表失败');
|
message.error('加载文件列表失败');
|
||||||
console.error('加载文档错误:', error);
|
console.error('加载文件错误:', error);
|
||||||
} finally {
|
} finally {
|
||||||
docLoading.value = false;
|
docLoading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除文档
|
// 删除文档
|
||||||
const deleteDoc = async (record: any) => {
|
const deleteDoc = async (record: AiCloudFile) => {
|
||||||
try {
|
try {
|
||||||
// 执行删除操作
|
await removeAiCloudFile(record.id);
|
||||||
await deleteKnowledgeBaseDocument(currentKbId.value, record.id);
|
await loadCloudFiles();
|
||||||
|
|
||||||
// 立即本地删除(核心修改)
|
|
||||||
const index = docList.value.findIndex(item => item.id === record.id);
|
|
||||||
if (index > -1) {
|
|
||||||
docList.value.splice(index, 1);
|
|
||||||
total.value -= 1;
|
|
||||||
}
|
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
// 阿里云异步删除,需等待异步删除完成再重新查询
|
|
||||||
// await loadDocuments();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('删除失败');
|
message.error('删除失败');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -326,9 +576,150 @@
|
|||||||
|
|
||||||
// 打开导入弹窗
|
// 打开导入弹窗
|
||||||
const openImport = () => {
|
const openImport = () => {
|
||||||
|
if (selectedKeys.value.length === 0) {
|
||||||
|
message.info('请先选择一个目录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedDoc.value) {
|
||||||
|
message.info('选中的目录信息不完整');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
showImport.value = true;
|
showImport.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 打开新增目录弹窗
|
||||||
|
const openAddDir = () => {
|
||||||
|
if (selectedKeys.value.length === 0) {
|
||||||
|
message.info('请先选择一个目录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isEditingDir.value = false;
|
||||||
|
currentDirId.value = undefined;
|
||||||
|
dirForm.value.name = '';
|
||||||
|
dirForm.value.sortNumber = 0;
|
||||||
|
showDirModal.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 打开编辑目录弹窗
|
||||||
|
const openEditDir = () => {
|
||||||
|
if (selectedKeys.value.length === 0) {
|
||||||
|
message.info('请先选择一个目录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedDir = allDirs.value.find(item => item.id === selectedKeys.value[0]);
|
||||||
|
if (!selectedDir) {
|
||||||
|
message.error('未找到选中的目录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isEditingDir.value = true;
|
||||||
|
currentDirId.value = selectedDir.id;
|
||||||
|
dirForm.value.name = selectedDir.name || '';
|
||||||
|
dirForm.value.sortNumber = selectedDir.sortNumber || 0;
|
||||||
|
showDirModal.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除选中目录
|
||||||
|
const deleteSelectedDir = async () => {
|
||||||
|
if (selectedKeys.value.length === 0) {
|
||||||
|
message.info('请先选择一个目录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedDir = allDirs.value.find(item => item.id === selectedKeys.value[0]);
|
||||||
|
if (!selectedDir) {
|
||||||
|
message.error('未找到选中的目录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await deleteDir(selectedDir.id!, selectedDir.name || '');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 关闭目录弹窗
|
||||||
|
const closeDirModal = () => {
|
||||||
|
showDirModal.value = false;
|
||||||
|
dirForm.value.name = '';
|
||||||
|
dirForm.value.sortNumber = 0;
|
||||||
|
currentDirId.value = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理保存目录(新增/编辑)
|
||||||
|
const handleSaveDir = async () => {
|
||||||
|
if (!dirForm.value.name) {
|
||||||
|
message.error('请输入目录名称');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isEditingDir.value) {
|
||||||
|
const updateData: AiCloudDoc = {
|
||||||
|
id: currentDirId.value,
|
||||||
|
name: dirForm.value.name,
|
||||||
|
sortNumber: dirForm.value.sortNumber || 0
|
||||||
|
};
|
||||||
|
await updateAiCloudDoc(updateData);
|
||||||
|
message.success('修改目录成功');
|
||||||
|
} else {
|
||||||
|
const newDir: AiCloudDoc = {
|
||||||
|
companyId: 0, // 固定为0
|
||||||
|
parentId: selectedKeys.value[0] as number,
|
||||||
|
name: dirForm.value.name,
|
||||||
|
sortNumber: dirForm.value.sortNumber || 0
|
||||||
|
};
|
||||||
|
await addAiCloudDoc(newDir);
|
||||||
|
message.success('新增目录成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
showDirModal.value = false;
|
||||||
|
await loadAllCloudDocs(false);
|
||||||
|
|
||||||
|
if (!isEditingDir.value) {
|
||||||
|
const parentId = selectedKeys.value[0] as number;
|
||||||
|
if (!expandedKeys.value.includes(parentId)) {
|
||||||
|
expandedKeys.value = [...expandedKeys.value, parentId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error(isEditingDir.value ? '修改目录失败' : '新增目录失败');
|
||||||
|
console.error('目录操作错误:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除目录
|
||||||
|
const deleteDir = async (dirId: number, dirName: string) => {
|
||||||
|
const hasChildren = allDirs.value.some(item => item.parentId === dirId);
|
||||||
|
if (hasChildren) {
|
||||||
|
message.error(`目录「${dirName}」包含子目录,无法删除。请先删除该目录下的所有子目录。`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除目录「${dirName}」吗?`,
|
||||||
|
icon: createVNode(ExclamationCircleOutlined),
|
||||||
|
maskClosable: true,
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
await removeAiCloudDoc(dirId);
|
||||||
|
message.success('删除目录成功');
|
||||||
|
await loadAllCloudDocs(false);
|
||||||
|
|
||||||
|
if (selectedKeys.value.includes(dirId)) {
|
||||||
|
selectedKeys.value = [];
|
||||||
|
docList.value = [];
|
||||||
|
pagination.value.total = 0;
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error.message || '删除目录失败');
|
||||||
|
console.error('删除目录错误:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* 删除单个 */
|
/* 删除单个 */
|
||||||
const remove = (row: PwlProjectLibrary) => {
|
const remove = (row: PwlProjectLibrary) => {
|
||||||
@@ -399,4 +790,175 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
/* 文档管理布局 */
|
||||||
|
.doc-manage-container {
|
||||||
|
height: 650px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
: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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 删除按钮样式 */
|
||||||
|
:deep(.ele-text-danger) {
|
||||||
|
color: #ff4d4f;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user