UX-3 附件上传删除功能

This commit is contained in:
Cheng Zhou
2025-12-17 16:16:47 +08:00
parent 9ca30d12f8
commit 1e6cae6b6e
39 changed files with 514 additions and 15 deletions
+11 -2
View File
@@ -1,12 +1,21 @@
import { apiGet, apiPost } from "./axios";
import { apiGet, apiPost, apiDelete } from "./axios";
export const fetchAttachments = (studyId: string, entityType: string, entityId: string) =>
apiGet(`/api/v1/studies/${studyId}/${entityType}/${entityId}/attachments`);
export const uploadAttachment = (studyId: string, entityType: string, entityId: string, file: File) => {
export const uploadAttachment = (
studyId: string,
entityType: string,
entityId: string,
file: File,
options?: Record<string, any>
) => {
const formData = new FormData();
formData.append("file", file);
return apiPost(`/api/v1/studies/${studyId}/${entityType}/${entityId}/attachments`, formData, {
headers: { "Content-Type": "multipart/form-data" },
...options,
});
};
export const deleteAttachment = (attachmentId: string) => apiDelete(`/api/v1/attachments/${attachmentId}`);
+2
View File
@@ -52,5 +52,7 @@ export const apiPost = <T = unknown>(url: string, data?: unknown, config?: Axios
instance.post<T>(url, data, config);
export const apiPatch = <T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig) =>
instance.patch<T>(url, data, config);
export const apiDelete = <T = unknown>(url: string, config?: AxiosRequestConfig) =>
instance.delete<T>(url, config);
export default instance;