From 3ef6a3a2bac778e2a224d6e437305b9f71d3799c Mon Sep 17 00:00:00 2001 From: 曹睿 <360930172@qq.com> Date: 星期一, 07 七月 2025 15:30:23 +0800 Subject: [PATCH] feat: 【来票台账】添加附件上传 --- src/views/procurementManagement/procurementInvoiceLedger/Modal/UploadModal.vue | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/views/procurementManagement/procurementInvoiceLedger/Modal/UploadModal.vue b/src/views/procurementManagement/procurementInvoiceLedger/Modal/UploadModal.vue index ba06618..594ba6c 100644 --- a/src/views/procurementManagement/procurementInvoiceLedger/Modal/UploadModal.vue +++ b/src/views/procurementManagement/procurementInvoiceLedger/Modal/UploadModal.vue @@ -2,12 +2,15 @@ <el-dialog v-model="upload.open" :title="upload.title" :width="500"> <FileUpload ref="fileUploadRef" - accept=".xlsx, .xls" + accept=".xlsx, .xls, .pdf" :headers="upload.headers" - :action="upload.url + '?updateSupport=' + upload.updateSupport" + :autoUpload="true" + :action="upload.url" :disabled="upload.isUploading" :showTip="false" + :limit="10" @success="handleFileSuccess" + @remove="removeFile" /> <template #footer> <div class="dialog-footer"> @@ -23,11 +26,17 @@ import { getToken } from "@/utils/auth.js"; import { FileUpload } from "@/components/Upload"; import { ElMessage } from "element-plus"; +import { ref } from "vue"; +import useFormData from "@/hooks/useFormData"; defineOptions({ name: "鏉ョエ鍙拌处闄勪欢琛ュ厖", }); +const { form, resetForm } = useFormData({ + id: undefined, + tempFileIds: [], +}); const emits = defineEmits(["uploadSuccess"]); const fileUploadRef = ref(); const upload = reactive({ @@ -40,29 +49,36 @@ // 璁剧疆涓婁紶鐨勮姹傚ご閮� headers: { Authorization: "Bearer " + getToken() }, // 涓婁紶鐨勫湴鍧� - url: import.meta.env.VITE_APP_BASE_API + "/system/supplier/import", + url: import.meta.env.VITE_APP_BASE_API + "/file/upload", }); // 鐐瑰嚮瀵煎叆 -const handleImport = () => { +const handleImport = (id) => { + form.id = id; upload.open = true; upload.title = "鏉ョエ鍙拌处闄勪欢琛ュ厖"; }; const submitFileForm = () => { - fileUploadRef.value.uploadApi(); + upload.open = false; + resetForm(); + emits("uploadSuccess", form); }; const handleFileSuccess = (response) => { const { code, msg } = response; + form.tempFileIds.push(response.data.tempId); if (code == 200) { ElMessage({ message: "瀵煎叆鎴愬姛", type: "success" }); - upload.open = false; - emits("uploadSuccess"); } else { ElMessage({ message: msg, type: "error" }); } }; +const removeFile = (file) => { + const { tempId } = file.response.data; + form.tempFileIds = form.tempFileIds.filter((item) => item !== tempId); +}; + defineExpose({ handleImport, }); -- Gitblit v1.9.3