修复文件重复上传
This commit is contained in:
@@ -35,7 +35,7 @@ export default {
|
||||
expandBtn: v => v.expand ? "收起" : "展开",
|
||||
isNeedPosition: v => ["1"].includes(v.app.ability),
|
||||
btns: v => [
|
||||
{label: "文件", icon: "https://cdn.sinoecare.com/i/2024/07/04/668663436e46e.png", click: () => v.files.length == 0 ? v.$refs.uploadTrigger.click() : v.$message.error("只允许添加一个文件")},
|
||||
{label: "文件", icon: "https://cdn.sinoecare.com/i/2024/07/04/668663436e46e.png", click: v.handleUpload},
|
||||
{label: "位置", icon: "https://cdn.sinoecare.com/i/2024/08/19/66c2f907bd444.png", hide: !v.isNeedPosition, click: () => v.locate = true}
|
||||
].filter(e => e.hide !== true),
|
||||
rowBtns: v => [
|
||||
@@ -140,7 +140,11 @@ export default {
|
||||
//清理发送消息缓存
|
||||
this.prompt = ""
|
||||
this.files = []
|
||||
this.$refs.uploader?.clearFiles()
|
||||
this.$refs.uploader?.handleClear()
|
||||
},
|
||||
handleUpload() {
|
||||
if (this.$refs.uploader.checkUpload()) this.$refs.uploadTrigger.click()
|
||||
else this.$message.error("最多上传一个文件")
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -175,7 +179,7 @@ export default {
|
||||
</div>
|
||||
<thinking-bar v-show="loading"/>
|
||||
<div class="flex content">
|
||||
<div class="left" :class="{expand}" v-loading="loading" element-loading-text="小助手正在思考中.."
|
||||
<div class="left" :class="{expand}" v-loading="loading" element-loading-text="小助理正在思考中.."
|
||||
element-loading-spinner="el-icon-loading" element-loading-background="rgba(255,255,255,0.8)">
|
||||
<div class="profile">
|
||||
<div v-text="profile.name"/>
|
||||
|
||||
@@ -289,7 +289,6 @@ export default {
|
||||
getExtension(name) {
|
||||
return name.substring(name.lastIndexOf('.'))
|
||||
},
|
||||
|
||||
onOverSize(e) {
|
||||
const isLt10M = e.size / 1024 / 1024 < this.maxSize
|
||||
const suffixName = this.getExtension(e.name)
|
||||
@@ -307,16 +306,13 @@ export default {
|
||||
|
||||
return true
|
||||
},
|
||||
|
||||
onBeforeUpload(event) {
|
||||
return this.onOverSize(event)
|
||||
},
|
||||
|
||||
onClose() {
|
||||
this.fileList = []
|
||||
this.dialog = false
|
||||
},
|
||||
|
||||
submitUpload(file) {
|
||||
let formData = new FormData()
|
||||
formData.append('file', file.file)
|
||||
@@ -402,8 +398,8 @@ export default {
|
||||
parent.$emit.apply(parent, [eventName].concat(params));
|
||||
}
|
||||
},
|
||||
clearFiles() {
|
||||
this.$refs.upload.clearFiles()
|
||||
checkUpload() {
|
||||
return this.limit > this.fileList.length
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user