|
@@ -1,6 +1,6 @@
|
|
<template>
|
|
<template>
|
|
<div class="upload">
|
|
<div class="upload">
|
|
- <el-upload v-if="hidden" :action="action" :headers="headers" :multiple="multiple" :data="data"
|
|
|
|
|
|
+ <el-upload v-if="hidden" :action="newAction" :headers="headers" :multiple="multiple" :data="data"
|
|
:accept="accept" :show-file-list="showFileList" :list-type="listType" :on-progress="onProgress"
|
|
:accept="accept" :show-file-list="showFileList" :list-type="listType" :on-progress="onProgress"
|
|
:on-error="onError" :on-success="onSuccess" :before-upload="beforeUpload" :disabled="disabled">
|
|
:on-error="onError" :on-success="onSuccess" :before-upload="beforeUpload" :disabled="disabled">
|
|
<el-button v-if="listType !== 'picture-card'" :type="btnType">{{ newTitle }}</el-button>
|
|
<el-button v-if="listType !== 'picture-card'" :type="btnType">{{ newTitle }}</el-button>
|
|
@@ -19,6 +19,10 @@ const baseUrl = process.env.VUE_APP_BASE_API
|
|
import { getToken } from "@/utils/auth";
|
|
import { getToken } from "@/utils/auth";
|
|
export default {
|
|
export default {
|
|
props: {
|
|
props: {
|
|
|
|
+ action: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: ''
|
|
|
|
+ },
|
|
// 图片
|
|
// 图片
|
|
url: String,
|
|
url: String,
|
|
// 类型
|
|
// 类型
|
|
@@ -57,7 +61,7 @@ export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
// 上传地址
|
|
// 上传地址
|
|
- action: `${baseUrl}/system/file/picture/upload`,
|
|
|
|
|
|
+ newAction: this.action,
|
|
// 请求头
|
|
// 请求头
|
|
headers: {
|
|
headers: {
|
|
Authorization: "Bearer " + getToken(),
|
|
Authorization: "Bearer " + getToken(),
|
|
@@ -98,16 +102,17 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
- if (this.listType === 'picture-card') {
|
|
|
|
- this.action = `${baseUrl}/system/file/picture/upload`
|
|
|
|
- this.accept = '.jpg, .jpeg, .png, .bmp, .icon, .gif'
|
|
|
|
- } else if (this.listType === 'text') {
|
|
|
|
- this.action = `${baseUrl}/system/file/file/upload`
|
|
|
|
- } else if (this.listType === 'audio') {
|
|
|
|
- this.action = `${baseUrl}/system/file/mp3/upload`
|
|
|
|
- this.accept = '.mp3, .wav, .aiff, .midi, .wma'
|
|
|
|
|
|
+ if (!this.action) {
|
|
|
|
+ if (this.listType === 'picture-card') {
|
|
|
|
+ this.newAction = `${baseUrl}/system/file/picture/upload`
|
|
|
|
+ this.accept = '.jpg, .jpeg, .png, .bmp, .icon, .gif'
|
|
|
|
+ } else if (this.listType === 'text') {
|
|
|
|
+ this.newAction = `${baseUrl}/system/file/file/upload`
|
|
|
|
+ } else if (this.listType === 'audio') {
|
|
|
|
+ this.newAction = `${baseUrl}/system/file/mp3/upload`
|
|
|
|
+ this.accept = '.mp3, .wav, .aiff, .midi, .wma'
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
this.newUrl = this.url ? this.url : ''
|
|
this.newUrl = this.url ? this.url : ''
|
|
this.hidden = this.url ? false : true
|
|
this.hidden = this.url ? false : true
|
|
},
|
|
},
|