DESKTOP-SVI9JE1\muzen 2 лет назад
Родитель
Сommit
fd67e103e4
2 измененных файлов с 21 добавлено и 11 удалено
  1. 20 10
      src/components/Upload/index.vue
  2. 1 1
      src/views/music/list/index.vue

+ 20 - 10
src/components/Upload/index.vue

@@ -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() {

+ 1 - 1
src/views/music/list/index.vue

@@ -27,7 +27,7 @@
           v-hasPermi="['music:list:up']">批量上架</el-button>
         <el-button type="primary" :disabled="obj.id === ''" @click="getChange(obj, 2)"
           v-hasPermi="['music:list:down']">批量下架</el-button>
-        <Upload style="margin-left: 10px;" @loading="loading = true" @upload="loading = false" />
+        <Upload listType="mp3" multiple name="multipartFiles" @upload="getList()" style="margin-left: 10px;">批量上传</Upload>
       </el-form-item>
     </el-form>
     <!-- 列表 -->