增加loading
This commit is contained in:
@@ -89,7 +89,6 @@
|
||||
|
||||
<script>
|
||||
import {VueCropper} from 'vue-cropper'
|
||||
import Vue from "vue";
|
||||
|
||||
export default {
|
||||
name: 'AiUploader',
|
||||
@@ -132,7 +131,8 @@ export default {
|
||||
default: false
|
||||
},
|
||||
clearable: {default: true},
|
||||
valueIsUrl: Boolean
|
||||
valueIsUrl: Boolean,
|
||||
showLoading: Boolean
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -277,7 +277,6 @@ export default {
|
||||
const viewer = this.$el.querySelector('.images').$viewer
|
||||
viewer.view(index)
|
||||
},
|
||||
|
||||
handleRemove(file, fileList) {
|
||||
this.fileList = fileList
|
||||
this.emitChange(fileList)
|
||||
@@ -322,6 +321,10 @@ export default {
|
||||
submitUpload(file) {
|
||||
let formData = new FormData()
|
||||
formData.append('file', file.file)
|
||||
let loading
|
||||
if (this.showLoading) {
|
||||
loading = this.$loading({lock: true, text: '上传中...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)'})
|
||||
}
|
||||
this.instance.post(this.url, formData, {
|
||||
withCredentials: false
|
||||
}).then(res => {
|
||||
@@ -343,7 +346,6 @@ export default {
|
||||
this.$message.success('上传成功')
|
||||
return false
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(res.data) === '[object Object]') {
|
||||
this.fileList.forEach(item => {
|
||||
if (item.uid === file.file.uid) {
|
||||
@@ -366,11 +368,10 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.emitChange(this.fileList)
|
||||
this.$message.success('上传成功')
|
||||
}
|
||||
})
|
||||
}).finally(() => loading?.close())
|
||||
},
|
||||
previewCrop() {
|
||||
this.$refs.cropper.getCropBlob(data => {
|
||||
|
||||
Reference in New Issue
Block a user