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