diff --git a/src/api/ai/aiCloudFile/index.ts b/src/api/ai/aiCloudFile/index.ts index cb9ded2..8bcaa66 100644 --- a/src/api/ai/aiCloudFile/index.ts +++ b/src/api/ai/aiCloudFile/index.ts @@ -8,8 +8,8 @@ import { MODULES_API_URL } from '@/config/setting'; */ export async function pageAiCloudFile(params: AiCloudFileParam) { const res = await request.get>>( - MODULES_API_URL + '/ai/file/page', - { params } + MODULES_API_URL + '/ai/file/page', + { params } ); if (res.data.code === 0) { return res.data.data; @@ -22,8 +22,8 @@ export async function pageAiCloudFile(params: AiCloudFileParam) { */ export async function listAiCloudFile(params?: AiCloudFileParam) { const res = await request.get>( - MODULES_API_URL + '/ai/file', - { params } + MODULES_API_URL + '/ai/file', + { params } ); if (res.data.code === 0 && res.data.data) { return res.data.data; @@ -34,22 +34,28 @@ export async function listAiCloudFile(params?: AiCloudFileParam) { /** * 上传文件到云中心 */ -export async function uploadFiles(docId: number, categoryId: string, files: File[]) { +export async function uploadFiles( + docId: number, + categoryId: string, + files: File[], + onUploadProgress?: (event: ProgressEvent) => void +) { const formData = new FormData(); formData.append('docId', docId); formData.append('categoryId', categoryId); - files.forEach(file => { + files.forEach((file) => { formData.append('files', file); }); const res = await request.post>( - MODULES_API_URL + '/ai/file/uploadFiles', - formData, - { - headers: { - 'Content-Type': 'multipart/form-data' - } - } + MODULES_API_URL + '/ai/file/uploadFiles', + formData, + { + headers: { + 'Content-Type': 'multipart/form-data' + }, + onUploadProgress + } ); if (res.data.code === 0) { return res.data.message; @@ -62,7 +68,7 @@ export async function uploadFiles(docId: number, categoryId: string, files: File */ export async function removeAiCloudFile(id?: number) { const res = await request.delete>( - MODULES_API_URL + '/ai/file/' + id + MODULES_API_URL + '/ai/file/' + id ); if (res.data.code === 0) { return res.data.message; @@ -75,7 +81,7 @@ export async function removeAiCloudFile(id?: number) { */ export async function getAiCloudFile(id: number) { const res = await request.get>( - MODULES_API_URL + '/ai/file/' + id + MODULES_API_URL + '/ai/file/' + id ); if (res.data.code === 0 && res.data.data) { return res.data.data; @@ -88,8 +94,8 @@ export async function getAiCloudFile(id: number) { */ export async function updateAiCloudFile(data: AiCloudFile) { const res = await request.put>( - MODULES_API_URL + '/ai/file', - data + MODULES_API_URL + '/ai/file', + data ); if (res.data.code === 0) { return res.data.message; diff --git a/src/views/oa/oaCompany/components/Import2.vue b/src/views/oa/oaCompany/components/Import2.vue index d683a86..1bbbb6f 100644 --- a/src/views/oa/oaCompany/components/Import2.vue +++ b/src/views/oa/oaCompany/components/Import2.vue @@ -1,114 +1,197 @@ - const files = [...uploadQueue]; - uploadQueue.length = 0; // 清空队列 - - loading.value = true; - try { - // 修改:传入 doc.id 和 doc.categoryId - const msg = await uploadFiles(props.doc.id, props.doc.categoryId, files); - message.success(msg || '上传成功'); - updateVisible(false); - emit('done'); - } catch (e: any) { - message.error(e.message || '上传失败'); - } finally { - loading.value = false; - } -}, 500); - -// 修改后的上传方法 -const doUpload = ({ file }: { file: File }) => { - // 检查文件类型 - const allowedTypes = [ - 'application/pdf', - 'application/msword', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'text/plain', - 'text/markdown', - 'application/vnd.ms-excel', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' - ]; - - const allowedExtensions = ['.pdf', '.doc', '.docx', '.txt', '.md', '.xls', '.xlsx']; - const fileExtension = '.' + file.name.split('.').pop()?.toLowerCase(); - - if (!allowedTypes.includes(file.type) && !allowedExtensions.includes(fileExtension)) { - message.error('只能上传文档文件(PDF、Word、Excel、TXT、MD)'); - return false; + diff --git a/src/views/oa/oaCompany/index.vue b/src/views/oa/oaCompany/index.vue index 5b3362d..d667690 100644 --- a/src/views/oa/oaCompany/index.vue +++ b/src/views/oa/oaCompany/index.vue @@ -44,13 +44,13 @@ 修改 - 文档管理 - + + + + + + + - +
- {{ activeSource === 'company' ? '公司文档目录' : '公共库目录' }} + {{ + activeSource === 'company' ? '项目文档目录' : '公共库目录' + }}
当前已选择 {{ checkedDirKeys.length }} 个目录, {{ selectedFileList.length }} 个文件;合计 - {{ mergedDirKeys.length }} 个目录,{{ mergedFileKeys.length }} 个文件 清空当前 @@ -79,9 +84,7 @@ :loading="docLoading" rowKey="id" :scroll=" - activeSource === 'public' - ? { x: 2300, y: 400 } - : { y: 400 } + activeSource === 'public' ? { x: 2300, y: 400 } : { y: 400 } " :pagination="pagination" @change="handleTableChange" @@ -307,7 +310,8 @@ width: 160, ellipsis: true, customRender: ({ record, text }: { record: AiCloudFile; text: any }) => - text || renderDocText(record, ['version', 'versionNumber', 'versionName']) + text || + renderDocText(record, ['version', 'versionNumber', 'versionName']) }, { title: '成文日期', @@ -352,7 +356,12 @@ width: 220, ellipsis: true, customRender: ({ record, text }: { record: AiCloudFile; text: any }) => - text || renderDocText(record, ['relatedDocuments', 'relatedDoc', 'relatedFiles']) + text || + renderDocText(record, [ + 'relatedDocuments', + 'relatedDoc', + 'relatedFiles' + ]) }, { title: '适用区域', @@ -382,7 +391,9 @@ ]; const currentDocColumns = computed(() => { - return activeSource.value === 'public' ? publicDocColumns : companyDocColumns; + return activeSource.value === 'public' + ? publicDocColumns + : companyDocColumns; }); // 计算树形数据 @@ -406,12 +417,7 @@ return buildTree(0); }); - const selectionStateMap = ref< - Record< - string, - FileSelectionStatePayload - > - >({}); + const selectionStateMap = ref>({}); const selectedDocList = ref([]); const selectedFileList = ref([]); const selectedFileKeys = ref([]); @@ -491,7 +497,8 @@ sourceState.fileKeys = [...getAllSelectedFileKeys(sourceState)]; sourceState.currentDirKey = selectedKeys.value[0] !== undefined ? selectedKeys.value[0] : undefined; - selectionStateMap.value[getSelectionStorageKey()] = getMergedSelectionPayload(); + selectionStateMap.value[getSelectionStorageKey()] = + getMergedSelectionPayload(); }; const restoreSelectionState = () => { @@ -528,9 +535,13 @@ const loadAllCloudDocs = async () => { try { - const params = activeSource.value === 'public' + const params = + activeSource.value === 'public' ? { companyId: 0 } - : { companyId: props.currentCompanyId, projectId: props.currentProjectId }; + : { + companyId: props.currentCompanyId, + projectId: props.currentProjectId + }; const result = await listAiCloudDoc(params); allDirs.value = result || []; @@ -541,10 +552,14 @@ sourceState.dirFileSelections || {} ).find((key) => { const dirId = Number(key); - return sourceState.dirFileSelections[key]?.length > 0 && availableIds.has(dirId); + return ( + sourceState.dirFileSelections[key]?.length > 0 && + availableIds.has(dirId) + ); }); const preferredSelectedKey = - (selectedKeys.value[0] && availableIds.has(selectedKeys.value[0] as number) + (selectedKeys.value[0] && + availableIds.has(selectedKeys.value[0] as number) ? selectedKeys.value[0] : undefined) || (sourceState.currentDirKey !== undefined && @@ -640,7 +655,9 @@ addedKeys.map((key) => getDirFileKeys(key)) ); addedKeys.forEach((key, index) => { - sourceState.dirFileSelections[String(key)] = [...addedFileGroups[index]]; + sourceState.dirFileSelections[String(key)] = [ + ...addedFileGroups[index] + ]; }); removedKeys.forEach((key) => { delete sourceState.dirFileSelections[String(key)]; @@ -679,9 +696,7 @@ }; // 文件选择变化 - const onFileSelectionChange = ( - selectedRowKeys: SelectionKey[] - ) => { + const onFileSelectionChange = (selectedRowKeys: SelectionKey[]) => { const currentDirKey = getCurrentDirKey(); if (!currentDirKey) return; @@ -689,9 +704,7 @@ sourceState.dirFileSelections[currentDirKey] = [...selectedRowKeys]; sourceState.fileKeys = getAllSelectedFileKeys(sourceState); selectedFileKeys.value = selectedRowKeys; - selectedFileList.value = sourceState.fileKeys.map((key) => - key.toString() - ); + selectedFileList.value = sourceState.fileKeys.map((key) => key.toString()); saveSelectionState(); }; @@ -766,5 +779,4 @@ }; defineExpose({ open }); - diff --git a/src/views/pwl/pwlProject/index.vue b/src/views/pwl/pwlProject/index.vue index 51be0bf..1184cda 100644 --- a/src/views/pwl/pwlProject/index.vue +++ b/src/views/pwl/pwlProject/index.vue @@ -268,11 +268,7 @@ >