diff --git a/bx-mobile/src/views/reimburse/ReimburseApplyPage.vue b/bx-mobile/src/views/reimburse/ReimburseApplyPage.vue index 26d800372..814ae1348 100644 --- a/bx-mobile/src/views/reimburse/ReimburseApplyPage.vue +++ b/bx-mobile/src/views/reimburse/ReimburseApplyPage.vue @@ -262,6 +262,68 @@ + +
+
+

申请附件(可选)

+
+

补充行程单、说明截图、合同等;与发票夹无关。

+
+ + + +
+
+
+ +
+ {{ applyAttachment.fileExt(file.fileName) }} + {{ file.fileName }} +
+
+ + 上传中 +
+ +
+
+
+
@@ -364,10 +426,39 @@ import { type ExpenseItem, } from '@/hooks/useExpenseItemTree' import { useApplicantOptions } from '@/hooks/useApplicantOptions' +import { useAttachment } from '@/hooks/useAttachment' import { useAuthStore } from '@/stores/auth' import { SUBMIT_APPROVE_BUTTON_COLOR } from '@/constants/dialog' import BottomActionBar from '@/components/mobile/BottomActionBar.vue' +const MAX_ATTACHMENTS = 10 + +/** 与 Web BxAttachmentUpload 对齐:图片/视频/文档/压缩包 */ +const attachmentAccept = [ + 'image/*', + 'video/*', + 'application/pdf', + 'application/msword', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.ms-powerpoint', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'text/plain', + 'text/csv', + 'application/rtf', + 'application/zip', + 'application/x-zip-compressed', + 'application/x-rar-compressed', + 'application/x-7z-compressed', + '.pdf', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', + '.txt', '.csv', '.rtf', '.wps', '.et', '.dps', + '.zip', '.rar', '.7z', + '.mp4', '.webm', '.mov', '.avi', +].join(',') + +const applyAttachment = useAttachment() + const router = useRouter() const route = useRoute() const auth = useAuthStore() @@ -660,6 +751,28 @@ function removeInvoicePick(key: string) { selectedInvoicePicks.value = selectedInvoicePicks.value.filter((p) => p.key !== key) } +function beforeReadApplyAttachment(file: File | File[]) { + const batch = Array.isArray(file) ? file : [file] + const remain = MAX_ATTACHMENTS - applyAttachment.files.value.length + if (remain <= 0) { + showToast(`最多上传 ${MAX_ATTACHMENTS} 个附件`) + return false + } + if (batch.length > remain) { + showToast(`还可上传 ${remain} 个附件,超出部分已忽略`) + return Promise.resolve(batch.slice(0, remain)) + } + return true +} + +async function onAfterReadApplyAttachment(uploadFile: any) { + const files = Array.isArray(uploadFile) ? uploadFile : [uploadFile] + for (const f of files) { + if (!f?.file) continue + await applyAttachment.upload(f.file) + } +} + function lineExpenseDisplay(id: number | string): string { if (id === '' || id == null) return '' return formatExpenseName(id, flatList.value)