支持文件&图片组件自定义地址&参数

This commit is contained in:
RuoYi 2025-04-18 13:25:28 +08:00
parent 90922844ea
commit bbd112d5a3
2 changed files with 23 additions and 3 deletions

View File

@ -5,6 +5,7 @@
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:data="data"
:limit="limit"
:on-error="handleUploadError"
:on-exceed="handleExceed"
@ -48,6 +49,15 @@ export default {
props: {
//
value: [String, Object, Array],
//
action: {
type: String,
default: "/file/upload"
},
//
data: {
type: Object
},
//
limit: {
type: Number,
@ -78,7 +88,7 @@ export default {
return {
number: 0,
uploadList: [],
uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload", //
uploadFileUrl: process.env.VUE_APP_BASE_API + this.action, //
headers: {
Authorization: "Bearer " + getToken(),
},
@ -152,7 +162,7 @@ export default {
//
handleUploadError(err) {
this.$modal.msgError("上传文件失败,请重试");
this.$modal.closeLoading()
this.$modal.closeLoading();
},
//
handleUploadSuccess(res, file) {

View File

@ -6,6 +6,7 @@
list-type="picture-card"
:on-success="handleUploadSuccess"
:before-upload="handleBeforeUpload"
:data="data"
:limit="limit"
:on-error="handleUploadError"
:on-exceed="handleExceed"
@ -48,6 +49,15 @@ import { getToken } from "@/utils/auth";
export default {
props: {
value: [String, Object, Array],
//
action: {
type: String,
default: "/file/upload"
},
//
data: {
type: Object
},
//
limit: {
type: Number,
@ -76,7 +86,7 @@ export default {
dialogImageUrl: "",
dialogVisible: false,
hideUpload: false,
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", //
uploadImgUrl: process.env.VUE_APP_BASE_API + this.action, //
headers: {
Authorization: "Bearer " + getToken(),
},