Преглед изворни кода

文件上传失败提示增加

cyy пре 1 година
родитељ
комит
8d6c52aa8f
1 измењених фајлова са 28 додато и 20 уклоњено
  1. 28 20
      src/business/platform/file/uploader/index.vue

+ 28 - 20
src/business/platform/file/uploader/index.vue

@@ -587,27 +587,35 @@
         const fileSize = fileData.size
         // 上传文件
         uploadFile(fileData).then(response => {
-          const data = response.data
-          const fileId = data.id
-          const res = {
-            [this.valueKey]: fileId,
-            [this.labelKey]: this.getFileName(fileName),
-            [this.fileExtKey]: this.getExtName(fileName),
-            [this.fileSizeKey]: fileSize,
-            [this.pathKey]: data[this.pathKey]
-          }
-          this.uploadingFiles.push(res)
-          if (this.multiple) {
-            this.checkbox.push(fileId)
-          } else {
-            this.checkbox.splice(0, 1, fileId)
-          }
-          this.checkUploadedQuantity()
-          // 缓存的文件
-          this.cacheData[data[this.valueKey]] = data
-          if (this.uploadType !== 'attachment') {
-            this.emitInput()
+          if(response.state === 200){
+            const data = response.data
+            const fileId = data.id
+            const res = {
+              [this.valueKey]: fileId,
+              [this.labelKey]: this.getFileName(fileName),
+              [this.fileExtKey]: this.getExtName(fileName),
+              [this.fileSizeKey]: fileSize,
+              [this.pathKey]: data[this.pathKey]
+            }
+            this.uploadingFiles.push(res)
+            if (this.multiple) {
+              this.checkbox.push(fileId)
+            } else {
+              this.checkbox.splice(0, 1, fileId)
+            }
+            this.checkUploadedQuantity()
+            // 缓存的文件
+            this.cacheData[data[this.valueKey]] = data
+            if (this.uploadType !== 'attachment') {
+              this.emitInput()
+            }
+          }else{
+            this.$toast({
+              duration: 1500, // 持续展示 toast
+              message: '上传失败!'
+            })
           }
+          
         }).catch((e) => {
           console.error(e)
         })