refactor: 上传文件支持多选

This commit is contained in:
CaptainB 2024-12-04 14:36:11 +08:00
parent 6b4cee1412
commit b35b57fcd0

View File

@ -75,9 +75,9 @@
<div class="operate flex align-center"> <div class="operate flex align-center">
<span v-if="props.applicationDetails.file_upload_enable" class="flex align-center"> <span v-if="props.applicationDetails.file_upload_enable" class="flex align-center">
<!-- accept="image/jpeg, image/png, image/gif"-->
<el-upload <el-upload
action="#" action="#"
multiple
:auto-upload="false" :auto-upload="false"
:show-file-list="false" :show-file-list="false"
:accept="getAcceptList()" :accept="getAcceptList()"
@ -246,23 +246,23 @@ const uploadFile = async (file: any, fileList: any) => {
fileList.splice(0, fileList.length) fileList.splice(0, fileList.length)
return return
} }
const formData = new FormData()
for (const file of fileList) {
formData.append('file', file.raw, file.name)
//
const extension = file.name.split('.').pop().toLowerCase() //
if (imageExtensions.includes(extension)) { const formData = new FormData()
uploadImageList.value.push(file) formData.append('file', file.raw, file.name)
} else if (documentExtensions.includes(extension)) { //
uploadDocumentList.value.push(file) const extension = file.name.split('.').pop().toLowerCase() //
} else if (videoExtensions.includes(extension)) {
// videos.push(file) if (imageExtensions.includes(extension)) {
} else if (audioExtensions.includes(extension)) { uploadImageList.value.push(file)
// audios.push(file) } else if (documentExtensions.includes(extension)) {
} uploadDocumentList.value.push(file)
} else if (videoExtensions.includes(extension)) {
// videos.push(file)
} else if (audioExtensions.includes(extension)) {
// audios.push(file)
} }
if (!chatId_context.value) { if (!chatId_context.value) {
const res = await props.openChatId() const res = await props.openChatId()
chatId_context.value = res chatId_context.value = res