From ff14fa5e4efaf4e3e6a307473e9bd2881da265c1 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期五, 18 四月 2025 12:55:34 +0800
Subject: [PATCH] 支持文件&图片组件自定义地址&参数
---
src/components/ImageUpload/index.vue | 12 +++++++++++-
src/components/FileUpload/index.vue | 13 ++++++++++++-
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 @@
const props = defineProps({
modelValue: [String, Object, Array],
+ // 涓婁紶鎺ュ彛鍦板潃
+ action: {
+ type: String,
+ default: "/common/upload"
+ },
+ // 涓婁紶鎼哄甫鐨勫弬鏁�
+ data: {
+ type: Object
+ },
// 鏁伴噺闄愬埗
limit: {
type: Number,
@@ -76,7 +86,7 @@
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 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 @@
const props = defineProps({
modelValue: [String, Object, Array],
+ // 涓婁紶鎺ュ彛鍦板潃
+ action: {
+ type: String,
+ default: "/common/upload"
+ },
+ // 涓婁紶鎼哄甫鐨勫弬鏁�
+ data: {
+ type: Object
+ },
// 鍥剧墖鏁伴噺闄愬埗
limit: {
type: Number,
@@ -80,7 +90,7 @@
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(
--
Gitblit v1.9.3