From 52776feb2b61d2e1e3bf0ba480273de2327f9d39 Mon Sep 17 00:00:00 2001 From: biss Date: Tue, 1 Dec 2026 20:03:54 +0800 Subject: [PATCH] Share attachment loading and retry states with student leave requests --- web/src/components.d.ts | 2 +- ...hmentList.vue => RecordAttachmentList.vue} | 8 ++--- web/src/components/StudentLeavePanel.vue | 32 ++++++++----------- web/src/views/ApprovalCenterView.vue | 4 +-- 4 files changed, 20 insertions(+), 26 deletions(-) rename web/src/components/{ApprovalAttachmentList.vue => RecordAttachmentList.vue} (81%) diff --git a/web/src/components.d.ts b/web/src/components.d.ts index bb40539..4e534ea 100644 --- a/web/src/components.d.ts +++ b/web/src/components.d.ts @@ -12,7 +12,6 @@ export {} declare module 'vue' { export interface GlobalComponents { AcademicCalendarReminder: typeof import('./components/AcademicCalendarReminder.vue')['default'] - ApprovalAttachmentList: typeof import('./components/ApprovalAttachmentList.vue')['default'] ApprovalAttachmentPicker: typeof import('./components/ApprovalAttachmentPicker.vue')['default'] AppUpdateManagementPanel: typeof import('./components/AppUpdateManagementPanel.vue')['default'] ArchiveDialog: typeof import('./components/ArchiveDialog.vue')['default'] @@ -80,6 +79,7 @@ declare module 'vue' { NotificationDeliverySettings: typeof import('./components/NotificationDeliverySettings.vue')['default'] NotificationRichTextEditor: typeof import('./components/NotificationRichTextEditor.vue')['default'] PerformanceReportPanel: typeof import('./components/PerformanceReportPanel.vue')['default'] + RecordAttachmentList: typeof import('./components/RecordAttachmentList.vue')['default'] RichMessageContent: typeof import('./components/RichMessageContent.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] diff --git a/web/src/components/ApprovalAttachmentList.vue b/web/src/components/RecordAttachmentList.vue similarity index 81% rename from web/src/components/ApprovalAttachmentList.vue rename to web/src/components/RecordAttachmentList.vue index 0243566..6613714 100644 --- a/web/src/components/ApprovalAttachmentList.vue +++ b/web/src/components/RecordAttachmentList.vue @@ -5,7 +5,7 @@ import { ElMessage } from 'element-plus' import http, { apiErrorMessage } from '../api/http' import AttachmentFileList from './AttachmentFileList.vue' -const props = defineProps<{ type: string; id: string }>() +const props = defineProps<{ endpoint: string; showTitle?: boolean }>() const { t } = useI18n() const files = ref<{ id: string; fileName: string; length: number }[]>([]) const loading = ref(true) @@ -14,7 +14,7 @@ async function loadFiles() { loading.value = true loadError.value = '' try { - files.value = (await http.get(`/approval-attachments/${props.type}/${props.id}`)).data + files.value = (await http.get(props.endpoint)).data } catch (error) { loadError.value = apiErrorMessage(error) } finally { @@ -25,14 +25,14 @@ onMounted(loadFiles) async function download(file: { id: string; fileName: string }) { try { - const response = await http.get(`/approval-attachments/${props.type}/${props.id}/${file.id}`, { responseType: 'blob' }) + const response = await http.get(`${props.endpoint}/${file.id}`, { responseType: 'blob' }) const url = URL.createObjectURL(response.data); const link = document.createElement('a'); link.href = url; link.download = file.fileName; link.click(); setTimeout(() => URL.revokeObjectURL(url), 1000) } catch (e) { ElMessage.error(apiErrorMessage(e)) } }