refactor(review-meeting): 前端直传会议附件并登记纪要元数据

pull/874/head
Codewoc 2026-03-27 15:30:44 +08:00
parent f12b87129e
commit 8d2964afac
1 changed files with 48 additions and 12 deletions

View File

@ -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<ReviewProject
}
/** 上传固定议程附件(图片/PDF */
export const uploadAgendaAttachment = (file: File): Promise<ReviewMeetingAgendaAttachmentRespVO> => {
const formData = new FormData()
formData.append('file', file)
return request
.upload<any>({ url: '/project/review-meeting/upload-agenda-attachment', data: formData })
.then((res) => res?.data as ReviewMeetingAgendaAttachmentRespVO)
export const uploadAgendaAttachment = async (
file: File
): Promise<ReviewMeetingAgendaAttachmentRespVO> => {
return uploadMeetingAttachmentByPresignedUrl(file)
}
/** 上传会议纪要附件Word/PDF/图片) */
@ -186,14 +188,48 @@ export const uploadMinutesAttachment = (
id: number,
file: File
): Promise<ReviewMeetingAgendaAttachmentRespVO> => {
const formData = new FormData()
formData.append('id', String(id))
formData.append('file', file)
return request
.upload<any>({ url: '/project/review-meeting/upload-minutes-attachment', data: formData })
.then((res) => res?.data as ReviewMeetingAgendaAttachmentRespVO)
return uploadMeetingAttachmentByPresignedUrl(file).then((attachment) =>
request
.put<any>({
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<ReviewMeetingAgendaAttachmentRespVO> => {
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() : ''
}