From ff14fa5e4efaf4e3e6a307473e9bd2881da265c1 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 18 Apr 2025 12:55:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6&=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E7=BB=84=E4=BB=B6=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9C=B0?= =?UTF-8?q?=E5=9D=80&=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/FileUpload/index.vue | 13 ++++++++++++- src/components/ImageUpload/index.vue | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index 2ad850b..3a83b3a 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -5,6 +5,7 @@ :action="uploadFileUrl" :before-upload="handleBeforeUpload" :file-list="fileList" + :data="data" :limit="limit" :on-error="handleUploadError" :on-exceed="handleExceed" @@ -44,6 +45,15 @@ import { getToken } from "@/utils/auth"; const props = defineProps({ modelValue: [String, Object, Array], + // 上传接口地址 + action: { + type: String, + default: "/common/upload" + }, + // 上传携带的参数 + data: { + type: Object + }, // 数量限制 limit: { type: Number, @@ -76,7 +86,7 @@ const emit = defineEmits(); const number = ref(0); const uploadList = ref([]); const baseUrl = import.meta.env.VITE_APP_BASE_API; -const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传文件服务器地址 +const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + props.action); // 上传文件服务器地址 const headers = ref({ Authorization: "Bearer " + getToken() }); const fileList = ref([]); const showTip = computed( @@ -140,6 +150,7 @@ function handleExceed() { // 上传失败 function handleUploadError(err) { proxy.$modal.msgError("上传文件失败"); + proxy.$modal.closeLoading(); } // 上传成功回调 diff --git a/src/components/ImageUpload/index.vue b/src/components/ImageUpload/index.vue index 90999e1..2bedc33 100644 --- a/src/components/ImageUpload/index.vue +++ b/src/components/ImageUpload/index.vue @@ -6,6 +6,7 @@ list-type="picture-card" :on-success="handleUploadSuccess" :before-upload="handleBeforeUpload" + :data="data" :limit="limit" :on-error="handleUploadError" :on-exceed="handleExceed" @@ -51,6 +52,15 @@ import { isExternal } from "@/utils/validate"; const props = defineProps({ modelValue: [String, Object, Array], + // 上传接口地址 + action: { + type: String, + default: "/common/upload" + }, + // 上传携带的参数 + data: { + type: Object + }, // 图片数量限制 limit: { type: Number, @@ -80,7 +90,7 @@ const uploadList = ref([]); const dialogImageUrl = ref(""); const dialogVisible = ref(false); const baseUrl = import.meta.env.VITE_APP_BASE_API; -const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传的图片服务器地址 +const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + props.action); // 上传的图片服务器地址 const headers = ref({ Authorization: "Bearer " + getToken() }); const fileList = ref([]); const showTip = computed(