From 8d2964afac43878301f20ec30e91c90cd633e40a Mon Sep 17 00:00:00 2001 From: Codewoc <947380458@qq.com> Date: Fri, 27 Mar 2026 15:30:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(review-meeting):=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E7=9B=B4=E4=BC=A0=E4=BC=9A=E8=AE=AE=E9=99=84=E4=BB=B6=E5=B9=B6?= =?UTF-8?q?=E7=99=BB=E8=AE=B0=E7=BA=AA=E8=A6=81=E5=85=83=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/review/meeting.ts | 60 +++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/api/review/meeting.ts b/src/api/review/meeting.ts index b9e320b30..271941415 100644 --- a/src/api/review/meeting.ts +++ b/src/api/review/meeting.ts @@ -1,4 +1,6 @@ import request from '@/config/axios' +import axios from 'axios' +import * as FileApi from '@/api/infra/file' // ============================================================ // 类型定义 @@ -84,6 +86,8 @@ export interface ReviewMeetingAgendaAttachmentRespVO { size: number } +const REVIEW_MEETING_ATTACHMENT_DIR = 'review-meeting/attachment' + // 短信发送状态 VO export interface ReviewMeetingSmsLogRespVO { id: number @@ -173,12 +177,10 @@ export const importProjectsFromExcel = async (file: File): Promise => { - const formData = new FormData() - formData.append('file', file) - return request - .upload({ url: '/project/review-meeting/upload-agenda-attachment', data: formData }) - .then((res) => res?.data as ReviewMeetingAgendaAttachmentRespVO) +export const uploadAgendaAttachment = async ( + file: File +): Promise => { + return uploadMeetingAttachmentByPresignedUrl(file) } /** 上传会议纪要附件(Word/PDF/图片) */ @@ -186,14 +188,48 @@ export const uploadMinutesAttachment = ( id: number, file: File ): Promise => { - const formData = new FormData() - formData.append('id', String(id)) - formData.append('file', file) - return request - .upload({ url: '/project/review-meeting/upload-minutes-attachment', data: formData }) - .then((res) => res?.data as ReviewMeetingAgendaAttachmentRespVO) + return uploadMeetingAttachmentByPresignedUrl(file).then((attachment) => + request + .put({ + url: '/project/review-meeting/minutes-attachment', + params: { id }, + data: attachment + }) + .then((res) => res?.data as ReviewMeetingAgendaAttachmentRespVO) + ) } /** 下载导入模板 */ export const getImportTemplate = () => request.download({ url: '/project/review-meeting/get-import-template' }) + +const uploadMeetingAttachmentByPresignedUrl = async ( + file: File +): Promise => { + const presignedInfo = await FileApi.getFilePresignedUrl(file.name, REVIEW_MEETING_ATTACHMENT_DIR) + await axios.put(presignedInfo.uploadUrl, file, { + headers: { + 'Content-Type': file.type || 'application/octet-stream' + } + }) + + await FileApi.createFile({ + configId: presignedInfo.configId, + url: presignedInfo.url, + path: presignedInfo.path, + name: file.name, + type: file.type || 'application/octet-stream', + size: file.size + }) + + return { + name: file.name, + url: presignedInfo.url, + type: resolveAttachmentType(file.name), + size: file.size + } +} + +const resolveAttachmentType = (fileName: string): string => { + return fileName.includes('.') ? fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase() : '' +}