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,25 +133,24 @@
></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>--> <!-- <a-radio :value="20">单位</a-radio>-->
<!-- <a-radio :value="20">单位</a-radio>--> <!-- </a-radio-group>-->
<!-- </a-radio-group>--> <!-- <a-input-->
<!-- <a-input--> <!-- allow-clear-->
<!-- allow-clear--> <!-- placeholder="请输入类型 10单位 20政府单位"-->
<!-- placeholder="请输入类型 10单位 20政府单位"--> <!-- v-model:value="form.companyType"-->
<!-- v-model:value="form.companyType"--> <!-- />-->
<!-- />--> <!-- </a-form-item>-->
<!-- </a-form-item>--> <!-- <a-form-item label="应用标识" name="companyLogo">-->
<!-- <a-form-item label="应用标识" name="companyLogo">--> <!-- <a-input-->
<!-- <a-input--> <!-- allow-clear-->
<!-- allow-clear--> <!-- placeholder="请输入应用标识"-->
<!-- placeholder="请输入应用标识"--> <!-- v-model:value="form.companyLogo"-->
<!-- v-model:value="form.companyLogo"--> <!-- />-->
<!-- />--> <!-- </a-form-item>-->
<!-- </a-form-item>-->
<a-form-item label="网站域名" name="domain"> <a-form-item label="网站域名" name="domain">
<a-input <a-input
allow-clear allow-clear
@@ -141,13 +158,13 @@
v-model:value="form.domain" v-model:value="form.domain"
/> />
</a-form-item> </a-form-item>
<!-- <a-form-item label="联系电话" name="phone">--> <!-- <a-form-item label="联系电话" name="phone">-->
<!-- <a-input--> <!-- <a-input-->
<!-- allow-clear--> <!-- allow-clear-->
<!-- placeholder="请输入联系电话"--> <!-- placeholder="请输入联系电话"-->
<!-- v-model:value="form.phone"--> <!-- v-model:value="form.phone"-->
<!-- />--> <!-- />-->
<!-- </a-form-item>--> <!-- </a-form-item>-->
<a-form-item label="座机电话" name="tel"> <a-form-item label="座机电话" name="tel">
<a-input <a-input
allow-clear allow-clear
@@ -155,20 +172,20 @@
v-model:value="form.tel" v-model:value="form.tel"
/> />
</a-form-item> </a-form-item>
<!-- <a-form-item label="邮箱" name="email">--> <!-- <a-form-item label="邮箱" name="email">-->
<!-- <a-input--> <!-- <a-input-->
<!-- allow-clear--> <!-- allow-clear-->
<!-- placeholder="请输入邮箱"--> <!-- placeholder="请输入邮箱"-->
<!-- v-model:value="form.email"--> <!-- v-model:value="form.email"-->
<!-- />--> <!-- />-->
<!-- </a-form-item>--> <!-- </a-form-item>-->
<!-- <a-form-item label="发票抬头" name="invoiceHeader">--> <!-- <a-form-item label="发票抬头" name="invoiceHeader">-->
<!-- <a-input--> <!-- <a-input-->
<!-- allow-clear--> <!-- allow-clear-->
<!-- placeholder="请输入发票抬头"--> <!-- placeholder="请输入发票抬头"-->
<!-- v-model:value="form.invoiceHeader"--> <!-- v-model:value="form.invoiceHeader"-->
<!-- />--> <!-- />-->
<!-- </a-form-item>--> <!-- </a-form-item>-->
<a-form-item label="企业法人" name="businessEntity"> <a-form-item label="企业法人" name="businessEntity">
<a-input <a-input
allow-clear allow-clear
@@ -176,27 +193,27 @@
v-model:value="form.businessEntity" v-model:value="form.businessEntity"
/> />
</a-form-item> </a-form-item>
<!-- <a-form-item label="所在省份" name="province">--> <!-- <a-form-item label="所在省份" name="province">-->
<!-- <a-input--> <!-- <a-input-->
<!-- allow-clear--> <!-- allow-clear-->
<!-- placeholder="请输入所在省份"--> <!-- placeholder="请输入所在省份"-->
<!-- v-model:value="form.province"--> <!-- v-model:value="form.province"-->
<!-- />--> <!-- />-->
<!-- </a-form-item>--> <!-- </a-form-item>-->
<!-- <a-form-item label="所在城市" name="city">--> <!-- <a-form-item label="所在城市" name="city">-->
<!-- <a-input--> <!-- <a-input-->
<!-- allow-clear--> <!-- allow-clear-->
<!-- placeholder="请输入所在城市"--> <!-- placeholder="请输入所在城市"-->
<!-- v-model:value="form.city"--> <!-- v-model:value="form.city"-->
<!-- />--> <!-- />-->
<!-- </a-form-item>--> <!-- </a-form-item>-->
<!-- <a-form-item label="所在辖区" name="region">--> <!-- <a-form-item label="所在辖区" name="region">-->
<!-- <a-input--> <!-- <a-input-->
<!-- allow-clear--> <!-- allow-clear-->
<!-- placeholder="请输入所在辖区"--> <!-- placeholder="请输入所在辖区"-->
<!-- v-model:value="form.region"--> <!-- v-model:value="form.region"-->
<!-- />--> <!-- />-->
<!-- </a-form-item>--> <!-- </a-form-item>-->
<a-form-item label="详细地址" name="address"> <a-form-item label="详细地址" name="address">
<a-input <a-input
allow-clear allow-clear
@@ -242,8 +259,8 @@
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types'; import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
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,19 +511,18 @@
() => props.visible, () => props.visible,
async (visible) => { async (visible) => {
if (visible) { if (visible) {
// 等待资料库列表加载完成后再设置回显 // 等待资料库列表加载完成后再设置回显
await fetchLibraries(); await fetchLibraries();
images.value = []; images.value = [];
if (props.data) { if (props.data) {
assignObject(form, props.data); assignObject(form, props.data);
if(props.data.companyLogo){ if (props.data.companyLogo) {
images.value.push({ images.value.push({
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
@@ -203,83 +223,99 @@
</template> </template>
<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 {
import type { EleProTable } from 'ele-admin-pro'; ExclamationCircleOutlined,
import { toDateString } from 'ele-admin-pro'; PlusOutlined,
import type { UploadOutlined,
EditOutlined,
DeleteOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction, DatasourceFunction,
ColumnItem ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types'; } from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue'; import Search from './components/search.vue';
import OaCompanyEdit from './components/oaCompanyEdit.vue'; import OaCompanyEdit from './components/oaCompanyEdit.vue';
// 导入Import2组件和API // 导入Import2组件和API
import Import2 from './components/Import2.vue'; import Import2 from './components/Import2.vue';
import { import {
pageOaCompany, pageOaCompany,
removeOaCompany, removeOaCompany,
removeBatchOaCompany removeBatchOaCompany
} from '@/api/oa/oaCompany'; } from '@/api/oa/oaCompany';
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 {
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model'; listAiCloudDoc,
// 导入AiCloudFile API addAiCloudDoc,
import { listAiCloudFile, removeAiCloudFile } from '@/api/ai/aiCloudFile'; updateAiCloudDoc,
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model'; removeAiCloudDoc
} from '@/api/ai/aiCloudDoc';
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
// 导入AiCloudFile API
import { pageAiCloudFile, 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);
// 表格选中数据 // 表格选中数据
const selection = ref<OaCompany[]>([]); const selection = ref<OaCompany[]>([]);
// 当前编辑数据 // 当前编辑数据
const current = ref<OaCompany | null>(null); const current = ref<OaCompany | null>(null);
// 是否显示编辑弹窗 // 是否显示编辑弹窗
const showEdit = ref(false); const showEdit = ref(false);
// 是否显示批量移动弹窗 // 是否显示批量移动弹窗
const showMove = ref(false); const showMove = ref(false);
// 文档管理相关响应式变量 // 文档管理相关响应式变量
const showDocManage = ref(false); // 是否显示文档管理弹窗 const showDocManage = ref(false); // 是否显示文档管理弹窗
const showImport = ref(false); // 是否显示导入弹窗 const showImport = ref(false); // 是否显示导入弹窗
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑) const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
// 加载状态 // 加载状态
const loading = ref(true); const loading = ref(true);
// 文档管理相关变量 // 文档管理相关变量
const currentKbId = ref(''); // 当前知识库ID const currentKbId = ref(''); // 当前知识库ID
const currentKbName = ref(''); // 当前知识库名称 const currentKbName = ref(''); // 当前知识库名称
const currentCompanyId = ref<number>(); // 当前单位ID 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)[]>([]);
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 isEditingDir = ref(false); // 是否为编辑模式
const currentDirId = ref<number>(); // 当前操作的目录ID const currentDirId = ref<number>(); // 当前操作的目录ID
// 目录表单 // 目录表单
const dirForm = ref({ const dirForm = ref({
name: '', name: '',
sortNumber: 0 sortNumber: 0
}); });
// 计算目录弹窗标题 // 计算目录弹窗标题
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}`;
}); });
// 分页配置 // 分页配置
const pagination = ref({ const pagination = ref({
current: 1, current: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
@@ -287,56 +323,60 @@ const pagination = ref({
showQuickJumper: true, showQuickJumper: true,
showTotal: (total: number) => `${total}`, showTotal: (total: number) => `${total}`,
pageSizeOptions: ['10', '20', '50', '100'] pageSizeOptions: ['10', '20', '50', '100']
}); });
// 计算树形数据 // 计算树形数据
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);
}); });
// 选中的目录名称 // 选中的目录名称
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 || '';
}); });
// 计算选中的目录ID用于文件上传 // 计算选中的目录ID用于文件上传
const selectedCategoryId = computed(() => { const selectedCategoryId = computed(() => {
if (selectedKeys.value.length === 0) return ''; if (selectedKeys.value.length === 0) return '';
return selectedKeys.value[0].toString(); return selectedKeys.value[0].toString();
}); });
// 计算选中的文档对象 // 计算选中的文档对象
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);
}; };
// 文档表格列配置 - 去掉固定宽度,使用自适应 // 文档表格列配置 - 去掉固定宽度,使用自适应
const docColumns = ref([ const docColumns = ref([
{ {
title: '文件名', title: '文件名',
dataIndex: 'fileName', dataIndex: 'fileName',
@@ -375,10 +415,10 @@ const docColumns = ref([
key: 'action', key: 'action',
width: 80 width: 80
} }
]); ]);
// 表格数据源 // 表格数据源
const datasource: DatasourceFunction = ({ const datasource: DatasourceFunction = ({
page, page,
limit, limit,
where, where,
@@ -394,10 +434,10 @@ const datasource: DatasourceFunction = ({
page, page,
limit limit
}); });
}; };
// 表格列配置 // 表格列配置
const columns = ref<ColumnItem[]>([ const columns = ref<ColumnItem[]>([
{ {
title: 'ID', title: 'ID',
dataIndex: 'companyId', dataIndex: 'companyId',
@@ -458,31 +498,32 @@ const columns = ref<ColumnItem[]>([
align: 'center', align: 'center',
hideInSetting: true hideInSetting: true
} }
]); ]);
/* 搜索 */ /* 搜索 */
const reload = (where?: OaCompanyParam) => { const reload = (where?: OaCompanyParam) => {
selection.value = []; selection.value = [];
tableRef?.value?.reload({ where: where }); tableRef?.value?.reload({ where: where });
}; };
/* 打开编辑弹窗 */ /* 打开编辑弹窗 */
const openEdit = (row?: OaCompany) => { const openEdit = (row?: OaCompany) => {
current.value = row ?? null; current.value = row ?? null;
showEdit.value = true; showEdit.value = true;
}; };
/* 打开批量移动弹窗 */ /* 打开批量移动弹窗 */
const openMove = () => { const openMove = () => {
showMove.value = true; showMove.value = true;
}; };
// 打开文档管理弹窗 // 打开文档管理弹窗
const openDocManage = async (record: OaCompany) => { const openDocManage = async (record: OaCompany) => {
currentKbId.value = record.kbId; currentKbId.value = record.kbId;
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;
// 重置选择状态 // 重置选择状态
@@ -491,10 +532,10 @@ const openDocManage = async (record: OaCompany) => {
// 加载目录列表 // 加载目录列表
await loadAllCloudDocs(true); await loadAllCloudDocs(true);
}; };
// 加载所有目录 // 加载所有目录
const loadAllCloudDocs = async (resetState = false) => { const loadAllCloudDocs = async (resetState = false) => {
try { try {
const params = { const params = {
companyId: currentCompanyId.value companyId: currentCompanyId.value
@@ -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!];
@@ -519,37 +560,42 @@ const loadAllCloudDocs = async (resetState = false) => {
message.error('加载目录列表失败'); message.error('加载目录列表失败');
console.error('加载目录错误:', error); console.error('加载目录错误:', error);
} }
}; };
// 树节点展开 // 树节点展开
const onExpand = (keys: (string | number)[]) => { const onExpand = (keys: (string | number)[]) => {
expandedKeys.value = keys; expandedKeys.value = keys;
}; };
// 树节点选择 // 树节点选择
const onSelect = (keys: (string | number)[], { node }: any) => { const onSelect = (keys: (string | number)[], { node }: any) => {
selectedKeys.value = keys; selectedKeys.value = keys;
pagination.value.current = 1; pagination.value.current = 1;
loadCloudFiles(); loadCloudFiles();
}; };
// 异步加载子节点(如果需要的话) // 异步加载子节点(如果需要的话)
const onLoadData = (node: any) => { const onLoadData = (node: any) => {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
// 由于我们一次性加载了所有目录,这里不需要额外加载 // 由于我们一次性加载了所有目录,这里不需要额外加载
resolve(); resolve();
}); });
}; };
// 表格分页变化处理 // 表格分页变化处理
const handleTableChange = (pag: any) => { const handleTableChange = (pag: any) => {
pagination.value.current = pag.current; pagination.value.current = pag.current;
pagination.value.pageSize = pag.pageSize; pagination.value.pageSize = pag.pageSize;
loadCloudFiles(); loadCloudFiles();
}; };
// 加载文档列表 - 改为从AiCloudFile表查询 const handleDocSearch = () => {
const loadCloudFiles = async () => { pagination.value.current = 1;
loadCloudFiles();
};
// 加载文档列表 - 改为从AiCloudFile表查询
const loadCloudFiles = async () => {
docLoading.value = true; docLoading.value = true;
try { try {
if (!selectedCategoryId.value) { if (!selectedCategoryId.value) {
@@ -561,29 +607,22 @@ 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);
} finally { } finally {
docLoading.value = false; docLoading.value = false;
} }
}; };
// 删除文档 - 改为调用AiCloudFile的删除接口 // 删除文档 - 改为调用AiCloudFile的删除接口
const deleteDoc = async (record: AiCloudFile) => { const deleteDoc = async (record: AiCloudFile) => {
try { try {
await removeAiCloudFile(record.id); await removeAiCloudFile(record.id);
@@ -594,10 +633,10 @@ const deleteDoc = async (record: AiCloudFile) => {
message.error('删除失败'); message.error('删除失败');
console.error(error); console.error(error);
} }
}; };
// 打开导入弹窗 // 打开导入弹窗
const openImport = () => { const openImport = () => {
if (selectedKeys.value.length === 0) { if (selectedKeys.value.length === 0) {
message.info('请先选择一个目录'); message.info('请先选择一个目录');
return; return;
@@ -609,10 +648,10 @@ const openImport = () => {
} }
showImport.value = true; showImport.value = true;
}; };
// 打开新增目录弹窗 // 打开新增目录弹窗
const openAddDir = () => { const openAddDir = () => {
if (selectedKeys.value.length === 0) { if (selectedKeys.value.length === 0) {
message.info('请先选择一个目录'); message.info('请先选择一个目录');
return; return;
@@ -622,16 +661,18 @@ const openAddDir = () => {
dirForm.value.name = ''; dirForm.value.name = '';
dirForm.value.sortNumber = 0; dirForm.value.sortNumber = 0;
showDirModal.value = true; showDirModal.value = true;
}; };
// 打开编辑目录弹窗 // 打开编辑目录弹窗
const openEditDir = () => { const openEditDir = () => {
if (selectedKeys.value.length === 0) { if (selectedKeys.value.length === 0) {
message.info('请先选择一个目录'); message.info('请先选择一个目录');
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;
@@ -642,34 +683,36 @@ const openEditDir = () => {
dirForm.value.name = selectedDir.name || ''; dirForm.value.name = selectedDir.name || '';
dirForm.value.sortNumber = selectedDir.sortNumber || 0; dirForm.value.sortNumber = selectedDir.sortNumber || 0;
showDirModal.value = true; showDirModal.value = true;
}; };
// 删除选中目录 // 删除选中目录
const deleteSelectedDir = async () => { const deleteSelectedDir = async () => {
if (selectedKeys.value.length === 0) { if (selectedKeys.value.length === 0) {
message.info('请先选择一个目录'); message.info('请先选择一个目录');
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;
} }
await deleteDir(selectedDir.id!, selectedDir.name || ''); await deleteDir(selectedDir.id!, selectedDir.name || '');
}; };
// 关闭目录弹窗 // 关闭目录弹窗
const closeDirModal = () => { const closeDirModal = () => {
showDirModal.value = false; showDirModal.value = false;
dirForm.value.name = ''; dirForm.value.name = '';
dirForm.value.sortNumber = 0; dirForm.value.sortNumber = 0;
currentDirId.value = undefined; currentDirId.value = undefined;
}; };
// 处理保存目录(新增/编辑) // 处理保存目录(新增/编辑)
const handleSaveDir = async () => { const handleSaveDir = async () => {
if (!dirForm.value.name) { if (!dirForm.value.name) {
message.error('请输入目录名称'); message.error('请输入目录名称');
return; return;
@@ -713,14 +756,16 @@ const handleSaveDir = async () => {
message.error(isEditingDir.value ? '修改目录失败' : '新增目录失败'); message.error(isEditingDir.value ? '修改目录失败' : '新增目录失败');
console.error('目录操作错误:', error); console.error('目录操作错误:', error);
} }
}; };
// 删除目录 // 删除目录
const deleteDir = async (dirId: number, dirName: string) => { 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;
} }
@@ -750,10 +795,10 @@ const deleteDir = async (dirId: number, dirName: string) => {
} }
} }
}); });
}; };
/* 删除单个 */ /* 删除单个 */
const remove = (row: OaCompany) => { const remove = (row: OaCompany) => {
const hide = message.loading('请求中..', 0); const hide = message.loading('请求中..', 0);
removeOaCompany(row.companyId) removeOaCompany(row.companyId)
.then((msg) => { .then((msg) => {
@@ -765,10 +810,10 @@ const remove = (row: OaCompany) => {
hide(); hide();
message.error(e.message); message.error(e.message);
}); });
}; };
/* 批量删除 */ /* 批量删除 */
const removeBatch = () => { const removeBatch = () => {
if (!selection.value.length) { if (!selection.value.length) {
message.error('请至少选择一条数据'); message.error('请至少选择一条数据');
return; return;
@@ -792,15 +837,15 @@ const removeBatch = () => {
}); });
} }
}); });
}; };
/* 查询 */ /* 查询 */
const query = () => { const query = () => {
loading.value = true; loading.value = true;
}; };
/* 自定义行属性 */ /* 自定义行属性 */
const customRow = (record: OaCompany) => { const customRow = (record: OaCompany) => {
return { return {
onClick: () => { onClick: () => {
// console.log(record); // console.log(record);
@@ -809,45 +854,45 @@ const customRow = (record: OaCompany) => {
openEdit(record); openEdit(record);
} }
}; };
}; };
query(); query();
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'OaCompany' name: 'OaCompany'
}; };
</script> </script>
<style scoped> <style scoped>
/* 修改已完成步骤的连接线颜色 */ /* 修改已完成步骤的连接线颜色 */
.ant-steps-item-finish .ant-steps-item-finish
> .ant-steps-item-container > .ant-steps-item-container
> .ant-steps-item-tail::after { > .ant-steps-item-tail::after {
background-color: red !important; background-color: red !important;
} }
/* 文档管理布局 */ /* 文档管理布局 */
.doc-manage-container { .doc-manage-container {
height: 650px; /* 增加高度 */ height: 670px; /* 增加高度 */
} }
.doc-layout { .doc-layout {
display: flex; display: flex;
height: 100%; height: 100%;
gap: 16px; gap: 16px;
} }
.dir-tree-panel { .dir-tree-panel {
width: 280px; /* 稍微加宽目录树 */ width: 280px; /* 稍微加宽目录树 */
border: 1px solid #e8e8e8; border: 1px solid #e8e8e8;
border-radius: 6px; border-radius: 6px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex-shrink: 0; flex-shrink: 0;
} }
.dir-header { .dir-header {
padding: 12px 16px; padding: 12px 16px;
border-bottom: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8;
background: #fafafa; background: #fafafa;
@@ -855,15 +900,15 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
font-weight: 500; font-weight: 500;
} }
.tree-container { .tree-container {
flex: 1; flex: 1;
padding: 8px; padding: 8px;
overflow: auto; overflow: auto;
} }
.doc-list-panel { .doc-list-panel {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -871,130 +916,139 @@ export default {
border-radius: 6px; border-radius: 6px;
min-width: 0; min-width: 0;
overflow: hidden; overflow: hidden;
} }
.doc-header { .doc-header {
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 {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 12px; gap: 12px;
} }
.doc-tips { .doc-search {
width: 280px;
flex-shrink: 0;
}
.doc-tips {
color: #ff4d4f; color: #ff4d4f;
font-size: 12px; font-size: 12px;
} }
.doc-content { .doc-content {
flex: 1; flex: 1;
padding: 16px; padding: 16px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow: hidden; overflow: hidden;
min-width: 0; min-width: 0;
} }
/* 树节点激活样式 */ /* 树节点激活样式 */
:deep(.active-dir) { :deep(.active-dir) {
color: #1890ff; color: #1890ff;
font-weight: 500; font-weight: 500;
} }
: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%; width: 100%;
} }
:deep(.ant-tree-node-content-wrapper:hover) { :deep(.ant-tree-node-content-wrapper:hover) {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
:deep(.ant-tree .ant-tree-treenode-selected .ant-tree-node-content-wrapper) { :deep(.ant-tree .ant-tree-treenode-selected .ant-tree-node-content-wrapper) {
background-color: #e6f7ff; background-color: #e6f7ff;
} }
/* 优化表格样式 */ /* 优化表格样式 */
:deep(.doc-manage-modal .ant-modal-body) { :deep(.doc-manage-modal .ant-modal-body) {
padding: 16px; padding: 16px;
} }
:deep(.doc-content .ant-table-wrapper) { :deep(.doc-content .ant-table-wrapper) {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-width: 0; min-width: 0;
} }
:deep(.doc-content .ant-spin-nested-loading) { :deep(.doc-content .ant-spin-nested-loading) {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-width: 0; min-width: 0;
} }
:deep(.doc-content .ant-spin-container) { :deep(.doc-content .ant-spin-container) {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
min-width: 0; min-width: 0;
} }
:deep(.doc-content .ant-table) { :deep(.doc-content .ant-table) {
width: 100%; width: 100%;
flex: 1; flex: 1;
} }
:deep(.doc-content .ant-table-container) { :deep(.doc-content .ant-table-container) {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
:deep(.doc-content .ant-table-body) { :deep(.doc-content .ant-table-body) {
flex: 1; flex: 1;
} }
:deep(.doc-content .ant-table-thead > tr > th) { :deep(.doc-content .ant-table-thead > tr > th) {
background: #fafafa; background: #fafafa;
font-weight: 600; font-weight: 600;
white-space: nowrap; white-space: nowrap;
} }
:deep(.doc-content .ant-table-tbody > tr > td) { :deep(.doc-content .ant-table-tbody > tr > td) {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
/* 文件名列特殊处理,允许换行 */ /* 文件名列特殊处理,允许换行 */
:deep(.doc-content .ant-table-tbody > tr > td:first-child) { :deep(.doc-content .ant-table-tbody > tr > td:first-child) {
white-space: normal; white-space: normal;
word-break: break-word; word-break: break-word;
line-height: 1.4; line-height: 1.4;
max-width: 400px; /* 限制文件名最大宽度 */ max-width: 400px; /* 限制文件名最大宽度 */
} }
/* 分页样式调整 */ /* 分页样式调整 */
:deep(.doc-content .ant-pagination) { :deep(.doc-content .ant-pagination) {
margin-top: 16px; margin-top: 16px;
margin-bottom: 0; margin-bottom: 0;
} }
:deep(.doc-content .ant-table-pagination) { :deep(.doc-content .ant-table-pagination) {
margin-top: 16px; margin-top: 16px;
margin-bottom: 0; margin-bottom: 0;
flex-shrink: 0; /* 防止分页器被压缩 */ flex-shrink: 0; /* 防止分页器被压缩 */
} }
/* 删除按钮样式 */ /* 删除按钮样式 */
:deep(.ele-text-danger) { :deep(.ele-text-danger) {
color: #ff4d4f; color: #ff4d4f;
} }
</style> </style>