|
@@ -587,27 +587,35 @@
|
|
|
const fileSize = fileData.size
|
|
const fileSize = fileData.size
|
|
|
// 上传文件
|
|
// 上传文件
|
|
|
uploadFile(fileData).then(response => {
|
|
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) => {
|
|
}).catch((e) => {
|
|
|
console.error(e)
|
|
console.error(e)
|
|
|
})
|
|
})
|