|
@@ -66,6 +66,11 @@ export default {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
},
|
|
|
+ // 文件名
|
|
|
+ name: {
|
|
|
+ type: String,
|
|
|
+ default: 'multipartFile'
|
|
|
+ },
|
|
|
// 图片尺寸
|
|
|
width: Number,
|
|
|
height: Number,
|
|
@@ -76,10 +81,11 @@ export default {
|
|
|
return {
|
|
|
// 上传类型
|
|
|
obj: {
|
|
|
- 'text': `${baseUrl}/system/file/file/upload`,
|
|
|
- 'picture-card': `${baseUrl}/system/file/picture/upload`,
|
|
|
- 'audio': `${baseUrl}/system/file/mp3/upload`,
|
|
|
- 'zip': `${baseUrl}/system/file/file/uploadFolderZip`
|
|
|
+ 'text': `${baseUrl}/system/file/file/upload`, // 文件上传
|
|
|
+ 'picture-card': `${baseUrl}/system/file/picture/upload`, // 图片上传
|
|
|
+ 'audio': `${baseUrl}/system/file/mp3/upload`, // 音频上传
|
|
|
+ 'zip': `${baseUrl}/system/file/file/uploadFolderZip`, // 压缩包上传
|
|
|
+ 'mp3': `${baseUrl}/admin/program/batch/upload` // 歌曲批量上传
|
|
|
},
|
|
|
// 上传地址
|
|
|
action: '#',
|
|
@@ -89,8 +95,6 @@ export default {
|
|
|
},
|
|
|
// 额外参数
|
|
|
data: {},
|
|
|
- // 文件名
|
|
|
- name: 'multipartFile',
|
|
|
// 进度条
|
|
|
percentage: 0,
|
|
|
title: '',
|
|
@@ -107,7 +111,7 @@ export default {
|
|
|
watch: {
|
|
|
url(val) {
|
|
|
this.form.file = val
|
|
|
- if(!val) {
|
|
|
+ if (!val) {
|
|
|
this.percentage = 0
|
|
|
}
|
|
|
},
|
|
@@ -167,8 +171,14 @@ export default {
|
|
|
|
|
|
// 上传成功
|
|
|
onSuccess(file) {
|
|
|
- this.form.file = file.data
|
|
|
- this.$emit('upload', this.form)
|
|
|
+ if (file.code === 0) {
|
|
|
+ this.form.file = file.data
|
|
|
+ this.$emit('upload', this.form)
|
|
|
+ this.title = '上传成功'
|
|
|
+ this.type = 'success'
|
|
|
+ }else{
|
|
|
+ this.onError()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 上传失败
|
|
@@ -192,7 +202,7 @@ export default {
|
|
|
|
|
|
// 上传按钮
|
|
|
isBtn() {
|
|
|
- return ['text', 'audio', 'zip'].includes(this.listType) || (this.listType === 'picture-card' && this.percentage == 0 && !this.form.file)
|
|
|
+ return ['text', 'audio', 'zip', 'mp3'].includes(this.listType) || (this.listType === 'picture-card' && this.percentage == 0 && !this.form.file)
|
|
|
},
|
|
|
// 显示进度条
|
|
|
isPercentage() {
|