refactor(review-meeting): 前端直传会议附件并登记纪要元数据
parent
f12b87129e
commit
8d2964afac
|
|
@ -1,4 +1,6 @@
|
||||||
import request from '@/config/axios'
|
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
|
size: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const REVIEW_MEETING_ATTACHMENT_DIR = 'review-meeting/attachment'
|
||||||
|
|
||||||
// 短信发送状态 VO
|
// 短信发送状态 VO
|
||||||
export interface ReviewMeetingSmsLogRespVO {
|
export interface ReviewMeetingSmsLogRespVO {
|
||||||
id: number
|
id: number
|
||||||
|
|
@ -173,12 +177,10 @@ export const importProjectsFromExcel = async (file: File): Promise<ReviewProject
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 上传固定议程附件(图片/PDF) */
|
/** 上传固定议程附件(图片/PDF) */
|
||||||
export const uploadAgendaAttachment = (file: File): Promise<ReviewMeetingAgendaAttachmentRespVO> => {
|
export const uploadAgendaAttachment = async (
|
||||||
const formData = new FormData()
|
file: File
|
||||||
formData.append('file', file)
|
): Promise<ReviewMeetingAgendaAttachmentRespVO> => {
|
||||||
return request
|
return uploadMeetingAttachmentByPresignedUrl(file)
|
||||||
.upload<any>({ url: '/project/review-meeting/upload-agenda-attachment', data: formData })
|
|
||||||
.then((res) => res?.data as ReviewMeetingAgendaAttachmentRespVO)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 上传会议纪要附件(Word/PDF/图片) */
|
/** 上传会议纪要附件(Word/PDF/图片) */
|
||||||
|
|
@ -186,14 +188,48 @@ export const uploadMinutesAttachment = (
|
||||||
id: number,
|
id: number,
|
||||||
file: File
|
file: File
|
||||||
): Promise<ReviewMeetingAgendaAttachmentRespVO> => {
|
): Promise<ReviewMeetingAgendaAttachmentRespVO> => {
|
||||||
const formData = new FormData()
|
return uploadMeetingAttachmentByPresignedUrl(file).then((attachment) =>
|
||||||
formData.append('id', String(id))
|
request
|
||||||
formData.append('file', file)
|
.put<any>({
|
||||||
return request
|
url: '/project/review-meeting/minutes-attachment',
|
||||||
.upload<any>({ url: '/project/review-meeting/upload-minutes-attachment', data: formData })
|
params: { id },
|
||||||
.then((res) => res?.data as ReviewMeetingAgendaAttachmentRespVO)
|
data: attachment
|
||||||
|
})
|
||||||
|
.then((res) => res?.data as ReviewMeetingAgendaAttachmentRespVO)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 下载导入模板 */
|
/** 下载导入模板 */
|
||||||
export const getImportTemplate = () =>
|
export const getImportTemplate = () =>
|
||||||
request.download({ url: '/project/review-meeting/get-import-template' })
|
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() : ''
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue