增加loading
This commit is contained in:
@@ -22,7 +22,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
dialogTitle: v => v.form?.id ? "编辑应用" : "新增应用",
|
||||
rules: v => ({
|
||||
rules: () => ({
|
||||
appId: {required: true, message: "请输入AB_appid", trigger: "blur"},
|
||||
appName: {required: true, message: "请输入应用名称", trigger: "blur"},
|
||||
appIconUrl: {required: true, message: "请输入应用图标", trigger: "blur"},
|
||||
@@ -132,7 +132,7 @@ export default {
|
||||
<ai-select v-model="form.ability" dict="copilotAbility"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="应用图标" prop="appIconUrl">
|
||||
<ai-uploader v-model="form.appIconUrl" :instance="instance" :limit="1"/>
|
||||
<ai-uploader v-model="form.appIconUrl" :instance="instance" :limit="1" showLoading/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ai-dialog>
|
||||
|
||||
@@ -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