feat:单位信息-文档管理-优化目录新增、编辑、删除功能
This commit is contained in:
@@ -80,9 +80,35 @@
|
|||||||
<div class="dir-tree-panel">
|
<div class="dir-tree-panel">
|
||||||
<div class="dir-header">
|
<div class="dir-header">
|
||||||
<span>文档目录</span>
|
<span>文档目录</span>
|
||||||
<a-button type="link" size="small" @click="openAddDir" title="新增目录">
|
<a-space>
|
||||||
<template #icon><PlusOutlined /></template>
|
<a-button
|
||||||
</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">
|
<div class="tree-container">
|
||||||
<a-tree
|
<a-tree
|
||||||
@@ -151,18 +177,26 @@
|
|||||||
:doc="selectedDoc"
|
:doc="selectedDoc"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 新增目录弹窗 -->
|
<!-- 新增/编辑目录弹窗 -->
|
||||||
<a-modal
|
<a-modal
|
||||||
v-model:visible="showAddDir"
|
v-model:visible="showDirModal"
|
||||||
:title="`新增目录 - ${selectedDirName ? '在『' + selectedDirName + '』下' : '在根目录下'}`"
|
:title="dirModalTitle"
|
||||||
width="400px"
|
width="400px"
|
||||||
@ok="handleAddDir"
|
@ok="handleSaveDir"
|
||||||
@cancel="showAddDir = false"
|
@cancel="closeDirModal"
|
||||||
>
|
>
|
||||||
<a-form :model="dirForm" layout="vertical">
|
<a-form :model="dirForm" layout="vertical">
|
||||||
<a-form-item label="目录名称">
|
<a-form-item label="目录名称">
|
||||||
<a-input v-model:value="dirForm.name" placeholder="请输入目录名称" />
|
<a-input v-model:value="dirForm.name" placeholder="请输入目录名称" />
|
||||||
</a-form-item>
|
</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-form>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</a-page-header>
|
</a-page-header>
|
||||||
@@ -171,7 +205,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { createVNode, ref, computed } from 'vue';
|
import { createVNode, ref, computed } from 'vue';
|
||||||
import { message, Modal, Empty } from 'ant-design-vue';
|
import { message, Modal, Empty } from 'ant-design-vue';
|
||||||
import { ExclamationCircleOutlined, PlusOutlined, UploadOutlined } 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 {
|
||||||
@@ -190,7 +224,7 @@ import {
|
|||||||
import type { OaCompany, OaCompanyParam } from '@/api/oa/oaCompany/model';
|
import type { OaCompany, OaCompanyParam } from '@/api/oa/oaCompany/model';
|
||||||
import { getPageTitle, isImage } from '@/utils/common';
|
import { getPageTitle, isImage } from '@/utils/common';
|
||||||
// 导入AiCloudDoc API
|
// 导入AiCloudDoc API
|
||||||
import { listAiCloudDoc, addAiCloudDoc } from '@/api/ai/aiCloudDoc';
|
import { listAiCloudDoc, addAiCloudDoc, updateAiCloudDoc, removeAiCloudDoc } from '@/api/ai/aiCloudDoc';
|
||||||
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
||||||
// 导入AiCloudFile API
|
// 导入AiCloudFile API
|
||||||
import { listAiCloudFile, removeAiCloudFile } from '@/api/ai/aiCloudFile';
|
import { listAiCloudFile, removeAiCloudFile } from '@/api/ai/aiCloudFile';
|
||||||
@@ -210,7 +244,7 @@ const showMove = ref(false);
|
|||||||
// 文档管理相关响应式变量
|
// 文档管理相关响应式变量
|
||||||
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
||||||
const showImport = ref(false); // 是否显示导入弹窗
|
const showImport = ref(false); // 是否显示导入弹窗
|
||||||
const showAddDir = ref(false); // 是否显示新增目录弹窗
|
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
|
||||||
// 加载状态
|
// 加载状态
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
|
|
||||||
@@ -227,9 +261,21 @@ const expandedKeys = ref<(string | number)[]>([]);
|
|||||||
const selectedKeys = ref<(string | number)[]>([]);
|
const selectedKeys = ref<(string | number)[]>([]);
|
||||||
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;
|
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;
|
||||||
|
|
||||||
// 新增目录表单
|
// 目录弹窗相关
|
||||||
|
const isEditingDir = ref(false); // 是否为编辑模式
|
||||||
|
const currentDirId = ref<number>(); // 当前操作的目录ID
|
||||||
|
|
||||||
|
// 目录表单
|
||||||
const dirForm = ref({
|
const dirForm = ref({
|
||||||
name: ''
|
name: '',
|
||||||
|
sortNumber: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
// 计算目录弹窗标题
|
||||||
|
const dirModalTitle = computed(() => {
|
||||||
|
const mode = isEditingDir.value ? '编辑' : '新增';
|
||||||
|
const location = selectedDirName.value ? `在『${selectedDirName.value}』下` : '在根目录下';
|
||||||
|
return `${mode}目录 - ${location}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 分页配置
|
// 分页配置
|
||||||
@@ -284,6 +330,11 @@ const selectedDoc = computed(() => {
|
|||||||
} : null;
|
} : null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 检查目录是否有子目录(简化版,只检查子目录)
|
||||||
|
const checkDirHasChildren = (dirId: number): boolean => {
|
||||||
|
return allDirs.value.some(item => item.parentId === dirId);
|
||||||
|
};
|
||||||
|
|
||||||
// 文档表格列配置 - 去掉固定宽度,使用自适应
|
// 文档表格列配置 - 去掉固定宽度,使用自适应
|
||||||
const docColumns = ref([
|
const docColumns = ref([
|
||||||
{
|
{
|
||||||
@@ -439,11 +490,11 @@ const openDocManage = async (record: OaCompany) => {
|
|||||||
selectedKeys.value = [];
|
selectedKeys.value = [];
|
||||||
|
|
||||||
// 加载目录列表
|
// 加载目录列表
|
||||||
await loadAllCloudDocs();
|
await loadAllCloudDocs(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载所有目录
|
// 加载所有目录
|
||||||
const loadAllCloudDocs = async () => {
|
const loadAllCloudDocs = async (resetState = false) => {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
companyId: currentCompanyId.value
|
companyId: currentCompanyId.value
|
||||||
@@ -452,13 +503,16 @@ const loadAllCloudDocs = async () => {
|
|||||||
const result = await listAiCloudDoc(params);
|
const result = await listAiCloudDoc(params);
|
||||||
allDirs.value = result || [];
|
allDirs.value = result || [];
|
||||||
|
|
||||||
// 默认展开根节点并选中第一个目录
|
if (resetState) {
|
||||||
if (allDirs.value.length > 0) {
|
// 只在首次加载时重置状态
|
||||||
const rootDirs = allDirs.value.filter(item => item.parentId === 0);
|
// 默认展开根节点并选中第一个目录
|
||||||
if (rootDirs.length > 0) {
|
if (allDirs.value.length > 0) {
|
||||||
expandedKeys.value = [0]; // 展开根节点
|
const rootDirs = allDirs.value.filter(item => item.parentId === 0);
|
||||||
selectedKeys.value = [rootDirs[0].id!];
|
if (rootDirs.length > 0) {
|
||||||
loadCloudFiles();
|
expandedKeys.value = [rootDirs[0].id!]; // 展开根节点
|
||||||
|
selectedKeys.value = [rootDirs[0].id!];
|
||||||
|
loadCloudFiles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -563,42 +617,141 @@ const openAddDir = () => {
|
|||||||
message.info('请先选择一个目录');
|
message.info('请先选择一个目录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
isEditingDir.value = false;
|
||||||
|
currentDirId.value = undefined;
|
||||||
dirForm.value.name = '';
|
dirForm.value.name = '';
|
||||||
showAddDir.value = true;
|
dirForm.value.sortNumber = 0;
|
||||||
|
showDirModal.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理新增目录
|
// 打开编辑目录弹窗
|
||||||
const handleAddDir = async () => {
|
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) {
|
if (!dirForm.value.name) {
|
||||||
message.error('请输入目录名称');
|
message.error('请输入目录名称');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const newDir: AiCloudDoc = {
|
if (isEditingDir.value) {
|
||||||
companyId: currentCompanyId.value,
|
// 编辑目录
|
||||||
parentId: selectedKeys.value[0] as number,
|
const updateData: AiCloudDoc = {
|
||||||
name: dirForm.value.name,
|
id: currentDirId.value,
|
||||||
sortNumber: 0
|
name: dirForm.value.name,
|
||||||
};
|
sortNumber: dirForm.value.sortNumber || 0
|
||||||
|
};
|
||||||
|
await updateAiCloudDoc(updateData);
|
||||||
|
message.success('修改目录成功');
|
||||||
|
} else {
|
||||||
|
// 新增目录
|
||||||
|
const newDir: AiCloudDoc = {
|
||||||
|
companyId: currentCompanyId.value,
|
||||||
|
parentId: selectedKeys.value[0] as number,
|
||||||
|
name: dirForm.value.name,
|
||||||
|
sortNumber: dirForm.value.sortNumber || 0
|
||||||
|
};
|
||||||
|
await addAiCloudDoc(newDir);
|
||||||
|
message.success('新增目录成功');
|
||||||
|
}
|
||||||
|
|
||||||
await addAiCloudDoc(newDir);
|
showDirModal.value = false;
|
||||||
message.success('新增目录成功');
|
|
||||||
showAddDir.value = false;
|
|
||||||
|
|
||||||
// 重新加载目录列表
|
// 重新加载目录列表,但不重置状态
|
||||||
await loadAllCloudDocs();
|
await loadAllCloudDocs(false);
|
||||||
|
|
||||||
// 展开父节点
|
if (!isEditingDir.value) {
|
||||||
if (!expandedKeys.value.includes(newDir.parentId!)) {
|
// 新增目录时展开父节点
|
||||||
expandedKeys.value = [...expandedKeys.value, newDir.parentId!];
|
const parentId = selectedKeys.value[0] as number;
|
||||||
|
if (!expandedKeys.value.includes(parentId)) {
|
||||||
|
expandedKeys.value = [...expandedKeys.value, parentId];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('新增目录失败');
|
message.error(isEditingDir.value ? '修改目录失败' : '新增目录失败');
|
||||||
console.error('新增目录错误:', error);
|
console.error('目录操作错误:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 删除目录
|
||||||
|
const deleteDir = async (dirId: number, dirName: string) => {
|
||||||
|
// 检查目录是否有子目录
|
||||||
|
const hasChildren = checkDirHasChildren(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: OaCompany) => {
|
const remove = (row: OaCompany) => {
|
||||||
const hide = message.loading('请求中..', 0);
|
const hide = message.loading('请求中..', 0);
|
||||||
@@ -755,6 +908,7 @@ export default {
|
|||||||
:deep(.ant-tree-node-content-wrapper) {
|
:deep(.ant-tree-node-content-wrapper) {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.ant-tree-node-content-wrapper:hover) {
|
:deep(.ant-tree-node-content-wrapper:hover) {
|
||||||
@@ -838,4 +992,9 @@ export default {
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
flex-shrink: 0; /* 防止分页器被压缩 */
|
flex-shrink: 0; /* 防止分页器被压缩 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 删除按钮样式 */
|
||||||
|
:deep(.ele-text-danger) {
|
||||||
|
color: #ff4d4f;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1537,19 +1537,19 @@ const changeTable3 = (title) => {
|
|||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '公司制定',
|
title: '公司制度',
|
||||||
dataIndex: 'companyFormulation',
|
dataIndex: 'companyFormulation',
|
||||||
key: 'companyFormulation',
|
key: 'companyFormulation',
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '检查的证据及测试内容',
|
title: '公司执行情况',
|
||||||
dataIndex: 'checkEvidence',
|
dataIndex: 'checkEvidence',
|
||||||
key: 'checkEvidence',
|
key: 'checkEvidence',
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '测试结果',
|
title: '执行结果',
|
||||||
dataIndex: 'testResult',
|
dataIndex: 'testResult',
|
||||||
key: 'testResult',
|
key: 'testResult',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
|
|||||||
Reference in New Issue
Block a user