1、单位信息新增归属单位、单位编号

2、文档管理新增搜索、文件在线查看
This commit is contained in:
2026-04-30 22:37:39 +08:00
parent b74bc2d1e7
commit 13b0c103c4
4 changed files with 992 additions and 908 deletions

View File

@@ -47,6 +47,7 @@ export interface AiCloudFileParam extends PageParam {
id?: number; id?: number;
keywords?: string; keywords?: string;
docId?: number; docId?: number;
fileName?: string;
workspaceId?: number; workspaceId?: number;
fileType?: string; fileType?: string;
} }

View File

@@ -10,6 +10,10 @@ export interface OaCompany {
shortName?: string; shortName?: string;
// 企业全称 // 企业全称
companyName?: string; companyName?: string;
// 归属单位
parentCompany?: string;
// 单位编号
companyNo?: string;
// 企业标识 // 企业标识
companyCode?: string; companyCode?: string;
// 类型 10企业 20政府单位 // 类型 10企业 20政府单位

View File

@@ -35,6 +35,13 @@
v-model:value="form.companyName" v-model:value="form.companyName"
/> />
</a-form-item> </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-form-item label="简称" name="shortName">
<a-input <a-input
allow-clear allow-clear
@@ -49,6 +56,13 @@
v-model:value="form.companyCode" v-model:value="form.companyCode"
/> />
</a-form-item> </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"> <a-form-item label="企业性质" name="companyType">
<DictSelect <DictSelect
@@ -80,7 +94,11 @@
<a-form-item label="知识库ID" name="kbId"> <a-form-item label="知识库ID" name="kbId">
<a-input <a-input
:class="{ 'disabled-text': !form.kbId }" :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 ? '' : '未创建'" :placeholder="form.kbId ? '' : '未创建'"
:value="form.kbId" :value="form.kbId"
readonly readonly
@@ -115,7 +133,6 @@
></a-select> ></a-select>
</a-form-item> </a-form-item>
<!-- <a-form-item label="类型" name="companyType">--> <!-- <a-form-item label="类型" name="companyType">-->
<!-- <a-radio-group v-model:value="form.companyType">--> <!-- <a-radio-group v-model:value="form.companyType">-->
<!-- <a-radio :value="10">企业</a-radio>--> <!-- <a-radio :value="10">企业</a-radio>-->
@@ -243,7 +260,7 @@
import { FormInstance } from 'ant-design-vue/es/form'; import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model'; import { FileRecord } from '@/api/system/file/model';
import { listPwlProjectLibrary } from '@/api/pwl/pwlProjectLibrary'; import { listPwlProjectLibrary } from '@/api/pwl/pwlProjectLibrary';
import DictSelect from "@/components/DictSelect/index.vue"; import DictSelect from '@/components/DictSelect/index.vue';
// 是否是修改 // 是否是修改
const isUpdate = ref(false); const isUpdate = ref(false);
@@ -282,7 +299,9 @@
companyId: undefined, companyId: undefined,
shortName: undefined, shortName: undefined,
companyName: undefined, companyName: undefined,
parentCompany: '本单位',
companyCode: undefined, companyCode: undefined,
companyNo: undefined,
companyType: undefined, companyType: undefined,
companyTypeMultiple: undefined, companyTypeMultiple: undefined,
companyLogo: undefined, companyLogo: undefined,
@@ -330,13 +349,9 @@
tenantId: undefined, tenantId: undefined,
createTime: undefined, createTime: undefined,
updateTime: undefined, updateTime: undefined,
oaCompanyId: undefined,
oaCompanyName: '', oaCompanyName: '',
status: 0,
comments: '',
sortNumber: 100,
kbId: undefined, kbId: undefined,
libraryIds: undefined, libraryIds: undefined
}); });
/* 更新visible */ /* 更新visible */
@@ -372,21 +387,21 @@
// 获取资料库列表 // 获取资料库列表
const fetchLibraries = () => { const fetchLibraries = () => {
return listPwlProjectLibrary().then(res => { return listPwlProjectLibrary().then((res) => {
allLibraries.value = res; allLibraries.value = res;
// 过滤行业库 (type='biz') // 过滤行业库 (type='biz')
bizLibList.value = res bizLibList.value = res
.filter(item => item.type === 'biz') .filter((item) => item.type === 'biz')
.map(item => ({ .map((item) => ({
label: item.name, label: item.name,
value: String(item.id) // 将 ID 转换为字符串 value: String(item.id) // 将 ID 转换为字符串
})); }));
// 过滤公共库 (type='pub') // 过滤公共库 (type='pub')
pubLibList.value = res pubLibList.value = res
.filter(item => item.type === 'pub') .filter((item) => item.type === 'pub')
.map(item => ({ .map((item) => ({
label: item.name, label: item.name,
value: String(item.id) // 将 ID 转换为字符串 value: String(item.id) // 将 ID 转换为字符串
})); }));
@@ -411,12 +426,13 @@
const allLibraryIds = [ const allLibraryIds = [
...(form.bizLibIds || []), ...(form.bizLibIds || []),
...(form.pubLibIds || []) ...(form.pubLibIds || [])
] ];
const formData = { const formData = {
...form, ...form,
libraryIds: allLibraryIds.join(','), // 保存为逗号分隔的字符串 libraryIds: allLibraryIds.join(',') // 保存为逗号分隔的字符串
}; };
if (!formData.parentCompany) formData.parentCompany = '本单位';
const saveOrUpdate = isUpdate.value ? updateOaCompany : addOaCompany; const saveOrUpdate = isUpdate.value ? updateOaCompany : addOaCompany;
saveOrUpdate(formData) saveOrUpdate(formData)
.then((msg) => { .then((msg) => {
@@ -438,18 +454,24 @@
if (props.data?.libraryIds) { if (props.data?.libraryIds) {
// 如果是字符串,按逗号分割成数组 // 如果是字符串,按逗号分割成数组
if (typeof props.data.libraryIds === 'string') { 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.bizLibIds = [];
form.pubLibIds = []; 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) { if (isBizLib) {
form.bizLibIds.push(String(id)); // 确保存储为字符串 form.bizLibIds.push(String(id)); // 确保存储为字符串
@@ -463,9 +485,13 @@
form.bizLibIds = []; form.bizLibIds = [];
form.pubLibIds = []; form.pubLibIds = [];
props.data.libraryIds.forEach(id => { props.data.libraryIds.forEach((id) => {
const isBizLib = bizLibList.value.some(lib => lib.value === String(id)); const isBizLib = bizLibList.value.some(
const isPubLib = pubLibList.value.some(lib => lib.value === String(id)); (lib) => lib.value === String(id)
);
const isPubLib = pubLibList.value.some(
(lib) => lib.value === String(id)
);
if (isBizLib) { if (isBizLib) {
form.bizLibIds.push(String(id)); form.bizLibIds.push(String(id));
@@ -485,7 +511,6 @@
() => props.visible, () => props.visible,
async (visible) => { async (visible) => {
if (visible) { if (visible) {
// 等待资料库列表加载完成后再设置回显 // 等待资料库列表加载完成后再设置回显
await fetchLibraries(); await fetchLibraries();
@@ -497,7 +522,7 @@
uid: uuid(), uid: uuid(),
url: props.data.companyLogo, url: props.data.companyLogo,
status: 'done' status: 'done'
}) });
} }
// 设置资料库回显 // 设置资料库回显

View File

@@ -119,10 +119,16 @@
:load-data="onLoadData" :load-data="onLoadData"
@expand="onExpand" @expand="onExpand"
@select="onSelect" @select="onSelect"
:field-names="{ title: 'name', key: 'id', children: 'children' }" :field-names="{
title: 'name',
key: 'id',
children: 'children'
}"
> >
<template #title="{ name, id }"> <template #title="{ name, id }">
<span :class="{ 'active-dir': selectedKeys[0] === id }">{{ name }}</span> <span :class="{ 'active-dir': selectedKeys[0] === id }">{{
name
}}</span>
</template> </template>
</a-tree> </a-tree>
<a-empty v-else :image="simpleImage" description="暂无目录" /> <a-empty v-else :image="simpleImage" description="暂无目录" />
@@ -139,6 +145,13 @@
</a-button> </a-button>
<span class="doc-tips">请选择分类上传资料</span> <span class="doc-tips">请选择分类上传资料</span>
</div> </div>
<a-input-search
v-model:value="docSearchForm.fileName"
class="doc-search"
allow-clear
placeholder="请输入文件名搜索"
@search="handleDocSearch"
/>
</div> </div>
<div class="doc-content"> <div class="doc-content">
<a-table <a-table
@@ -152,6 +165,13 @@
size="middle" size="middle"
> >
<template #bodyCell="{ column, record }"> <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'"> <template v-if="column.key === 'action'">
<a-space> <a-space>
<a-popconfirm <a-popconfirm
@@ -205,7 +225,13 @@
<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, 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 type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro'; import { toDateString } from 'ele-admin-pro';
import type { import type {
@@ -224,10 +250,15 @@ 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, updateAiCloudDoc, removeAiCloudDoc } 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 { pageAiCloudFile, removeAiCloudFile } from '@/api/ai/aiCloudFile';
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model'; import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
// 表格实例 // 表格实例
@@ -255,6 +286,9 @@ const currentCompanyId = ref<number>(); // 当前单位ID
const docList = ref<AiCloudFile[]>([]); // 文档列表数据改为使用AiCloudFile类型 const docList = ref<AiCloudFile[]>([]); // 文档列表数据改为使用AiCloudFile类型
const docLoading = ref(false); // 文档加载状态 const docLoading = ref(false); // 文档加载状态
const allDirs = ref<AiCloudDoc[]>([]); // 所有目录列表 const allDirs = ref<AiCloudDoc[]>([]); // 所有目录列表
const docSearchForm = ref({
fileName: ''
});
// 树形结构相关 // 树形结构相关
const expandedKeys = ref<(string | number)[]>([]); const expandedKeys = ref<(string | number)[]>([]);
@@ -274,7 +308,9 @@ const dirForm = ref({
// 计算目录弹窗标题 // 计算目录弹窗标题
const dirModalTitle = computed(() => { const dirModalTitle = computed(() => {
const mode = isEditingDir.value ? '编辑' : '新增'; const mode = isEditingDir.value ? '编辑' : '新增';
const location = selectedDirName.value ? `在『${selectedDirName.value}』下` : '在根目录下'; const location = selectedDirName.value
? `在『${selectedDirName.value}』下`
: '在根目录下';
return `${mode}目录 - ${location}`; return `${mode}目录 - ${location}`;
}); });
@@ -293,13 +329,15 @@ const pagination = ref({
const treeData = computed(() => { const treeData = computed(() => {
const buildTree = (parentId: number = 0): any[] => { const buildTree = (parentId: number = 0): any[] => {
return allDirs.value return allDirs.value
.filter(item => item.parentId === parentId) .filter((item) => item.parentId === parentId)
.map(item => ({ .map((item) => ({
...item, ...item,
key: item.id, key: item.id,
title: item.name, title: item.name,
children: buildTree(item.id), 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); return buildTree(0);
@@ -309,7 +347,7 @@ const treeData = computed(() => {
const selectedDirName = computed(() => { const selectedDirName = computed(() => {
if (selectedKeys.value.length === 0) return ''; if (selectedKeys.value.length === 0) return '';
const selectedId = selectedKeys.value[0]; 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 || ''; return dir?.name || '';
}); });
@@ -323,16 +361,18 @@ const selectedCategoryId = computed(() => {
const selectedDoc = computed(() => { const selectedDoc = computed(() => {
if (selectedKeys.value.length === 0) return null; if (selectedKeys.value.length === 0) return null;
const selectedId = selectedKeys.value[0]; const selectedId = selectedKeys.value[0];
const doc = allDirs.value.find(item => item.id === selectedId); const doc = allDirs.value.find((item) => item.id === selectedId);
return doc ? { return doc
? {
id: doc.id!, id: doc.id!,
categoryId: doc.categoryId || '' // 假设 AiCloudDoc 有 categoryId 字段 categoryId: doc.categoryId || '' // 假设 AiCloudDoc 有 categoryId 字段
} : null; }
: null;
}); });
// 检查目录是否有子目录(简化版,只检查子目录) // 检查目录是否有子目录(简化版,只检查子目录)
const checkDirHasChildren = (dirId: number): boolean => { 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; currentKbName.value = record.companyName;
currentCompanyId.value = record.companyId; currentCompanyId.value = record.companyId;
pagination.value.current = 1; pagination.value.current = 1;
docSearchForm.value.fileName = '';
showDocManage.value = true; showDocManage.value = true;
// 重置选择状态 // 重置选择状态
@@ -507,7 +548,7 @@ const loadAllCloudDocs = async (resetState = false) => {
// 只在首次加载时重置状态 // 只在首次加载时重置状态
// 默认展开根节点并选中第一个目录 // 默认展开根节点并选中第一个目录
if (allDirs.value.length > 0) { 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) { if (rootDirs.length > 0) {
expandedKeys.value = [rootDirs[0].id!]; // 展开根节点 expandedKeys.value = [rootDirs[0].id!]; // 展开根节点
selectedKeys.value = [rootDirs[0].id!]; selectedKeys.value = [rootDirs[0].id!];
@@ -548,6 +589,11 @@ const handleTableChange = (pag: any) => {
loadCloudFiles(); loadCloudFiles();
}; };
const handleDocSearch = () => {
pagination.value.current = 1;
loadCloudFiles();
};
// 加载文档列表 - 改为从AiCloudFile表查询 // 加载文档列表 - 改为从AiCloudFile表查询
const loadCloudFiles = async () => { const loadCloudFiles = async () => {
docLoading.value = true; docLoading.value = true;
@@ -561,19 +607,12 @@ const loadCloudFiles = async () => {
const params = { const params = {
docId: parseInt(selectedCategoryId.value), docId: parseInt(selectedCategoryId.value),
page: pagination.value.current, page: pagination.value.current,
pageSize: pagination.value.pageSize limit: pagination.value.pageSize,
fileName: docSearchForm.value.fileName?.trim() || undefined
}; };
const result = await listAiCloudFile(params); const result = await pageAiCloudFile(params);
docList.value = result?.list || [];
// 假设返回的数据结构为 { records: [], total: number } pagination.value.total = result?.count || 0;
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) { } catch (error) {
message.error('加载文件列表失败'); message.error('加载文件列表失败');
console.error('加载文件错误:', error); console.error('加载文件错误:', error);
@@ -631,7 +670,9 @@ const openEditDir = () => {
return; 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) { if (!selectedDir) {
message.error('未找到选中的目录'); message.error('未找到选中的目录');
return; return;
@@ -651,7 +692,9 @@ const deleteSelectedDir = async () => {
return; 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) { if (!selectedDir) {
message.error('未找到选中的目录'); message.error('未找到选中的目录');
return; return;
@@ -720,7 +763,9 @@ const deleteDir = async (dirId: number, dirName: string) => {
// 检查目录是否有子目录 // 检查目录是否有子目录
const hasChildren = checkDirHasChildren(dirId); const hasChildren = checkDirHasChildren(dirId);
if (hasChildren) { if (hasChildren) {
message.error(`目录「${dirName}」包含子目录,无法删除。请先删除该目录下的所有子目录。`); message.error(
`目录「${dirName}」包含子目录,无法删除。请先删除该目录下的所有子目录。`
);
return; return;
} }
@@ -829,7 +874,7 @@ export default {
/* 文档管理布局 */ /* 文档管理布局 */
.doc-manage-container { .doc-manage-container {
height: 650px; /* 增加高度 */ height: 670px; /* 增加高度 */
} }
.doc-layout { .doc-layout {
@@ -877,6 +922,10 @@ export default {
padding: 12px 16px; padding: 12px 16px;
border-bottom: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8;
background: #fafafa; background: #fafafa;
display: flex;
justify-content: space-between;
align-items: center;
gap: 16px;
} }
.doc-actions { .doc-actions {
@@ -885,6 +934,11 @@ export default {
gap: 12px; gap: 12px;
} }
.doc-search {
width: 280px;
flex-shrink: 0;
}
.doc-tips { .doc-tips {
color: #ff4d4f; color: #ff4d4f;
font-size: 12px; font-size: 12px;