1、单位信息新增归属单位、单位编号
2、文档管理新增搜索、文件在线查看
This commit is contained in:
@@ -47,6 +47,7 @@ export interface AiCloudFileParam extends PageParam {
|
||||
id?: number;
|
||||
keywords?: string;
|
||||
docId?: number;
|
||||
fileName?: string;
|
||||
workspaceId?: number;
|
||||
fileType?: string;
|
||||
}
|
||||
@@ -10,6 +10,10 @@ export interface OaCompany {
|
||||
shortName?: string;
|
||||
// 企业全称
|
||||
companyName?: string;
|
||||
// 归属单位
|
||||
parentCompany?: string;
|
||||
// 单位编号
|
||||
companyNo?: string;
|
||||
// 企业标识
|
||||
companyCode?: string;
|
||||
// 类型 10企业 20政府单位
|
||||
|
||||
@@ -35,6 +35,13 @@
|
||||
v-model:value="form.companyName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="归属单位">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入归属单位(没有时默认'本单位')"
|
||||
v-model:value="form.parentCompany"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="简称" name="shortName">
|
||||
<a-input
|
||||
allow-clear
|
||||
@@ -49,6 +56,13 @@
|
||||
v-model:value="form.companyCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="单位编号" name="companyNo">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入单位编号"
|
||||
v-model:value="form.companyNo"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="企业性质" name="companyType">
|
||||
<DictSelect
|
||||
@@ -80,7 +94,11 @@
|
||||
<a-form-item label="知识库ID" name="kbId">
|
||||
<a-input
|
||||
:class="{ 'disabled-text': !form.kbId }"
|
||||
:style="!form.kbId ? 'cursor: not-allowed; color: #999' : 'background-color: #f5f5f5'"
|
||||
:style="
|
||||
!form.kbId
|
||||
? 'cursor: not-allowed; color: #999'
|
||||
: 'background-color: #f5f5f5'
|
||||
"
|
||||
:placeholder="form.kbId ? '' : '未创建'"
|
||||
:value="form.kbId"
|
||||
readonly
|
||||
@@ -115,7 +133,6 @@
|
||||
></a-select>
|
||||
</a-form-item>
|
||||
|
||||
|
||||
<!-- <a-form-item label="类型" name="companyType">-->
|
||||
<!-- <a-radio-group v-model:value="form.companyType">-->
|
||||
<!-- <a-radio :value="10">企业</a-radio>-->
|
||||
@@ -243,7 +260,7 @@
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
import { listPwlProjectLibrary } from '@/api/pwl/pwlProjectLibrary';
|
||||
import DictSelect from "@/components/DictSelect/index.vue";
|
||||
import DictSelect from '@/components/DictSelect/index.vue';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
@@ -282,7 +299,9 @@
|
||||
companyId: undefined,
|
||||
shortName: undefined,
|
||||
companyName: undefined,
|
||||
parentCompany: '本单位',
|
||||
companyCode: undefined,
|
||||
companyNo: undefined,
|
||||
companyType: undefined,
|
||||
companyTypeMultiple: undefined,
|
||||
companyLogo: undefined,
|
||||
@@ -330,13 +349,9 @@
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined,
|
||||
oaCompanyId: undefined,
|
||||
oaCompanyName: '',
|
||||
status: 0,
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
kbId: undefined,
|
||||
libraryIds: undefined,
|
||||
libraryIds: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
@@ -372,21 +387,21 @@
|
||||
|
||||
// 获取资料库列表
|
||||
const fetchLibraries = () => {
|
||||
return listPwlProjectLibrary().then(res => {
|
||||
return listPwlProjectLibrary().then((res) => {
|
||||
allLibraries.value = res;
|
||||
|
||||
// 过滤行业库 (type='biz')
|
||||
bizLibList.value = res
|
||||
.filter(item => item.type === 'biz')
|
||||
.map(item => ({
|
||||
.filter((item) => item.type === 'biz')
|
||||
.map((item) => ({
|
||||
label: item.name,
|
||||
value: String(item.id) // 将 ID 转换为字符串
|
||||
}));
|
||||
|
||||
// 过滤公共库 (type='pub')
|
||||
pubLibList.value = res
|
||||
.filter(item => item.type === 'pub')
|
||||
.map(item => ({
|
||||
.filter((item) => item.type === 'pub')
|
||||
.map((item) => ({
|
||||
label: item.name,
|
||||
value: String(item.id) // 将 ID 转换为字符串
|
||||
}));
|
||||
@@ -411,12 +426,13 @@
|
||||
const allLibraryIds = [
|
||||
...(form.bizLibIds || []),
|
||||
...(form.pubLibIds || [])
|
||||
]
|
||||
];
|
||||
|
||||
const formData = {
|
||||
...form,
|
||||
libraryIds: allLibraryIds.join(','), // 保存为逗号分隔的字符串
|
||||
libraryIds: allLibraryIds.join(',') // 保存为逗号分隔的字符串
|
||||
};
|
||||
if (!formData.parentCompany) formData.parentCompany = '本单位';
|
||||
const saveOrUpdate = isUpdate.value ? updateOaCompany : addOaCompany;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
@@ -438,18 +454,24 @@
|
||||
if (props.data?.libraryIds) {
|
||||
// 如果是字符串,按逗号分割成数组
|
||||
if (typeof props.data.libraryIds === 'string') {
|
||||
const libraryIdsArray = props.data.libraryIds.split(',').filter(id => id.trim() !== '');
|
||||
const libraryIdsArray = props.data.libraryIds
|
||||
.split(',')
|
||||
.filter((id) => id.trim() !== '');
|
||||
|
||||
// 清空当前的选择
|
||||
form.bizLibIds = [];
|
||||
form.pubLibIds = [];
|
||||
|
||||
// 根据资料库类型分别设置回显
|
||||
libraryIdsArray.forEach(id => {
|
||||
libraryIdsArray.forEach((id) => {
|
||||
// 检查是否在行业库列表中
|
||||
const isBizLib = bizLibList.value.some(lib => lib.value === String(id)); // 转换为字符串比较
|
||||
const isBizLib = bizLibList.value.some(
|
||||
(lib) => lib.value === String(id)
|
||||
); // 转换为字符串比较
|
||||
// 检查是否在公共库列表中
|
||||
const isPubLib = pubLibList.value.some(lib => lib.value === String(id)); // 转换为字符串比较
|
||||
const isPubLib = pubLibList.value.some(
|
||||
(lib) => lib.value === String(id)
|
||||
); // 转换为字符串比较
|
||||
|
||||
if (isBizLib) {
|
||||
form.bizLibIds.push(String(id)); // 确保存储为字符串
|
||||
@@ -463,9 +485,13 @@
|
||||
form.bizLibIds = [];
|
||||
form.pubLibIds = [];
|
||||
|
||||
props.data.libraryIds.forEach(id => {
|
||||
const isBizLib = bizLibList.value.some(lib => lib.value === String(id));
|
||||
const isPubLib = pubLibList.value.some(lib => lib.value === String(id));
|
||||
props.data.libraryIds.forEach((id) => {
|
||||
const isBizLib = bizLibList.value.some(
|
||||
(lib) => lib.value === String(id)
|
||||
);
|
||||
const isPubLib = pubLibList.value.some(
|
||||
(lib) => lib.value === String(id)
|
||||
);
|
||||
|
||||
if (isBizLib) {
|
||||
form.bizLibIds.push(String(id));
|
||||
@@ -485,7 +511,6 @@
|
||||
() => props.visible,
|
||||
async (visible) => {
|
||||
if (visible) {
|
||||
|
||||
// 等待资料库列表加载完成后再设置回显
|
||||
await fetchLibraries();
|
||||
|
||||
@@ -497,7 +522,7 @@
|
||||
uid: uuid(),
|
||||
url: props.data.companyLogo,
|
||||
status: 'done'
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 设置资料库回显
|
||||
|
||||
@@ -119,10 +119,16 @@
|
||||
:load-data="onLoadData"
|
||||
@expand="onExpand"
|
||||
@select="onSelect"
|
||||
:field-names="{ title: 'name', key: 'id', children: 'children' }"
|
||||
:field-names="{
|
||||
title: 'name',
|
||||
key: 'id',
|
||||
children: 'children'
|
||||
}"
|
||||
>
|
||||
<template #title="{ name, id }">
|
||||
<span :class="{ 'active-dir': selectedKeys[0] === id }">{{ name }}</span>
|
||||
<span :class="{ 'active-dir': selectedKeys[0] === id }">{{
|
||||
name
|
||||
}}</span>
|
||||
</template>
|
||||
</a-tree>
|
||||
<a-empty v-else :image="simpleImage" description="暂无目录" />
|
||||
@@ -139,6 +145,13 @@
|
||||
</a-button>
|
||||
<span class="doc-tips">请选择分类上传资料</span>
|
||||
</div>
|
||||
<a-input-search
|
||||
v-model:value="docSearchForm.fileName"
|
||||
class="doc-search"
|
||||
allow-clear
|
||||
placeholder="请输入文件名搜索"
|
||||
@search="handleDocSearch"
|
||||
/>
|
||||
</div>
|
||||
<div class="doc-content">
|
||||
<a-table
|
||||
@@ -152,6 +165,13 @@
|
||||
size="middle"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'fileName'">
|
||||
<a
|
||||
:href="`http://view.officeapps.live.com/op/view.aspx?src=${record.fileUrl}`"
|
||||
target="_blank"
|
||||
>{{ record.fileName }}</a
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-popconfirm
|
||||
@@ -205,7 +225,13 @@
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref, computed } from 'vue';
|
||||
import { message, Modal, Empty } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined, PlusOutlined, UploadOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
PlusOutlined,
|
||||
UploadOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
@@ -224,10 +250,15 @@ import {
|
||||
import type { OaCompany, OaCompanyParam } from '@/api/oa/oaCompany/model';
|
||||
import { getPageTitle, isImage } from '@/utils/common';
|
||||
// 导入AiCloudDoc API
|
||||
import { listAiCloudDoc, addAiCloudDoc, updateAiCloudDoc, removeAiCloudDoc } from '@/api/ai/aiCloudDoc';
|
||||
import {
|
||||
listAiCloudDoc,
|
||||
addAiCloudDoc,
|
||||
updateAiCloudDoc,
|
||||
removeAiCloudDoc
|
||||
} from '@/api/ai/aiCloudDoc';
|
||||
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
||||
// 导入AiCloudFile API
|
||||
import { listAiCloudFile, removeAiCloudFile } from '@/api/ai/aiCloudFile';
|
||||
import { pageAiCloudFile, removeAiCloudFile } from '@/api/ai/aiCloudFile';
|
||||
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
||||
|
||||
// 表格实例
|
||||
@@ -255,6 +286,9 @@ const currentCompanyId = ref<number>(); // 当前单位ID
|
||||
const docList = ref<AiCloudFile[]>([]); // 文档列表数据改为使用AiCloudFile类型
|
||||
const docLoading = ref(false); // 文档加载状态
|
||||
const allDirs = ref<AiCloudDoc[]>([]); // 所有目录列表
|
||||
const docSearchForm = ref({
|
||||
fileName: ''
|
||||
});
|
||||
|
||||
// 树形结构相关
|
||||
const expandedKeys = ref<(string | number)[]>([]);
|
||||
@@ -274,7 +308,9 @@ const dirForm = ref({
|
||||
// 计算目录弹窗标题
|
||||
const dirModalTitle = computed(() => {
|
||||
const mode = isEditingDir.value ? '编辑' : '新增';
|
||||
const location = selectedDirName.value ? `在『${selectedDirName.value}』下` : '在根目录下';
|
||||
const location = selectedDirName.value
|
||||
? `在『${selectedDirName.value}』下`
|
||||
: '在根目录下';
|
||||
return `${mode}目录 - ${location}`;
|
||||
});
|
||||
|
||||
@@ -293,13 +329,15 @@ const pagination = ref({
|
||||
const treeData = computed(() => {
|
||||
const buildTree = (parentId: number = 0): any[] => {
|
||||
return allDirs.value
|
||||
.filter(item => item.parentId === parentId)
|
||||
.map(item => ({
|
||||
.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
|
||||
isLeaf:
|
||||
allDirs.value.filter((child) => child.parentId === item.id)
|
||||
.length === 0
|
||||
}));
|
||||
};
|
||||
return buildTree(0);
|
||||
@@ -309,7 +347,7 @@ const treeData = computed(() => {
|
||||
const selectedDirName = computed(() => {
|
||||
if (selectedKeys.value.length === 0) return '';
|
||||
const selectedId = selectedKeys.value[0];
|
||||
const dir = allDirs.value.find(item => item.id === selectedId);
|
||||
const dir = allDirs.value.find((item) => item.id === selectedId);
|
||||
return dir?.name || '';
|
||||
});
|
||||
|
||||
@@ -323,16 +361,18 @@ const selectedCategoryId = computed(() => {
|
||||
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 ? {
|
||||
const doc = allDirs.value.find((item) => item.id === selectedId);
|
||||
return doc
|
||||
? {
|
||||
id: doc.id!,
|
||||
categoryId: doc.categoryId || '' // 假设 AiCloudDoc 有 categoryId 字段
|
||||
} : null;
|
||||
}
|
||||
: null;
|
||||
});
|
||||
|
||||
// 检查目录是否有子目录(简化版,只检查子目录)
|
||||
const checkDirHasChildren = (dirId: number): boolean => {
|
||||
return allDirs.value.some(item => item.parentId === dirId);
|
||||
return allDirs.value.some((item) => item.parentId === dirId);
|
||||
};
|
||||
|
||||
// 文档表格列配置 - 去掉固定宽度,使用自适应
|
||||
@@ -483,6 +523,7 @@ const openDocManage = async (record: OaCompany) => {
|
||||
currentKbName.value = record.companyName;
|
||||
currentCompanyId.value = record.companyId;
|
||||
pagination.value.current = 1;
|
||||
docSearchForm.value.fileName = '';
|
||||
showDocManage.value = true;
|
||||
|
||||
// 重置选择状态
|
||||
@@ -507,7 +548,7 @@ const loadAllCloudDocs = async (resetState = false) => {
|
||||
// 只在首次加载时重置状态
|
||||
// 默认展开根节点并选中第一个目录
|
||||
if (allDirs.value.length > 0) {
|
||||
const rootDirs = allDirs.value.filter(item => item.parentId === 0);
|
||||
const rootDirs = allDirs.value.filter((item) => item.parentId === 0);
|
||||
if (rootDirs.length > 0) {
|
||||
expandedKeys.value = [rootDirs[0].id!]; // 展开根节点
|
||||
selectedKeys.value = [rootDirs[0].id!];
|
||||
@@ -548,6 +589,11 @@ const handleTableChange = (pag: any) => {
|
||||
loadCloudFiles();
|
||||
};
|
||||
|
||||
const handleDocSearch = () => {
|
||||
pagination.value.current = 1;
|
||||
loadCloudFiles();
|
||||
};
|
||||
|
||||
// 加载文档列表 - 改为从AiCloudFile表查询
|
||||
const loadCloudFiles = async () => {
|
||||
docLoading.value = true;
|
||||
@@ -561,19 +607,12 @@ const loadCloudFiles = async () => {
|
||||
const params = {
|
||||
docId: parseInt(selectedCategoryId.value),
|
||||
page: pagination.value.current,
|
||||
pageSize: pagination.value.pageSize
|
||||
limit: pagination.value.pageSize,
|
||||
fileName: docSearchForm.value.fileName?.trim() || undefined
|
||||
};
|
||||
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;
|
||||
}
|
||||
const result = await pageAiCloudFile(params);
|
||||
docList.value = result?.list || [];
|
||||
pagination.value.total = result?.count || 0;
|
||||
} catch (error) {
|
||||
message.error('加载文件列表失败');
|
||||
console.error('加载文件错误:', error);
|
||||
@@ -631,7 +670,9 @@ const openEditDir = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedDir = allDirs.value.find(item => item.id === selectedKeys.value[0]);
|
||||
const selectedDir = allDirs.value.find(
|
||||
(item) => item.id === selectedKeys.value[0]
|
||||
);
|
||||
if (!selectedDir) {
|
||||
message.error('未找到选中的目录');
|
||||
return;
|
||||
@@ -651,7 +692,9 @@ const deleteSelectedDir = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedDir = allDirs.value.find(item => item.id === selectedKeys.value[0]);
|
||||
const selectedDir = allDirs.value.find(
|
||||
(item) => item.id === selectedKeys.value[0]
|
||||
);
|
||||
if (!selectedDir) {
|
||||
message.error('未找到选中的目录');
|
||||
return;
|
||||
@@ -720,7 +763,9 @@ const deleteDir = async (dirId: number, dirName: string) => {
|
||||
// 检查目录是否有子目录
|
||||
const hasChildren = checkDirHasChildren(dirId);
|
||||
if (hasChildren) {
|
||||
message.error(`目录「${dirName}」包含子目录,无法删除。请先删除该目录下的所有子目录。`);
|
||||
message.error(
|
||||
`目录「${dirName}」包含子目录,无法删除。请先删除该目录下的所有子目录。`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -829,7 +874,7 @@ export default {
|
||||
|
||||
/* 文档管理布局 */
|
||||
.doc-manage-container {
|
||||
height: 700px; /* 增加高度 */
|
||||
height: 670px; /* 增加高度 */
|
||||
}
|
||||
|
||||
.doc-layout {
|
||||
@@ -877,6 +922,10 @@ export default {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
background: #fafafa;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.doc-actions {
|
||||
@@ -885,6 +934,11 @@ export default {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.doc-search {
|
||||
width: 280px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.doc-tips {
|
||||
color: #ff4d4f;
|
||||
font-size: 12px;
|
||||
|
||||
Reference in New Issue
Block a user