66 <div
77 class =" p-8-12"
88 v-loading =" localLoading"
9- v-if =" uploadDocumentList.length || uploadImageList.length"
9+ v-if =" uploadDocumentList.length || uploadImageList.length || uploadAudioList.length || uploadVideoList.length "
1010 >
1111 <el-space wrap >
1212 <template v-for =" (item , index ) in uploadDocumentList " :key =" index " >
5353 />
5454 </div >
5555 </template >
56+ <template v-for =" (item , index ) in uploadAudioList " :key =" index " >
57+ <el-card shadow =" never" style =" --el-card-padding : 8px " class =" file cursor" >
58+ <div
59+ class =" flex align-center"
60+ @mouseenter.stop =" mouseenter(item)"
61+ @mouseleave.stop =" mouseleave()"
62+ >
63+ <div
64+ @click =" deleteFile(index, 'audio')"
65+ class =" delete-icon color-secondary"
66+ v-if =" showDelete === item.url"
67+ >
68+ <el-icon ><CircleCloseFilled /></el-icon >
69+ </div >
70+ <img :src =" getImgUrl(item && item?.name)" alt =" " width =" 24" />
71+ <div class =" ml-4 ellipsis" style =" max-width : 160px " :title =" item && item?.name" >
72+ {{ item && item?.name }}
73+ </div >
74+ </div >
75+ </el-card >
76+ </template >
5677 </el-space >
5778 </div >
5879 </el-scrollbar >
@@ -200,7 +221,7 @@ const localLoading = computed({
200221const imageExtensions = [' jpg' , ' jpeg' , ' png' , ' gif' , ' bmp' ]
201222const documentExtensions = [' pdf' , ' docx' , ' txt' , ' xls' , ' xlsx' , ' md' , ' html' , ' csv' ]
202223const videoExtensions = [' mp4' , ' avi' , ' mov' , ' mkv' , ' flv' ]
203- const audioExtensions = [' mp3' , ' wav ' , ' aac ' , ' flac ' ]
224+ const audioExtensions = [' mp3' ]
204225
205226const getAcceptList = () => {
206227 const { image, document, audio, video } = props .applicationDetails .file_upload_setting
@@ -227,14 +248,14 @@ const getAcceptList = () => {
227248const checkMaxFilesLimit = () => {
228249 return (
229250 props .applicationDetails .file_upload_setting .maxFiles <=
230- uploadImageList .value .length + uploadDocumentList .value .length
251+ uploadImageList .value .length + uploadDocumentList .value .length + uploadAudioList . value . length + uploadVideoList . value . length
231252 )
232253}
233254
234255const uploadFile = async (file : any , fileList : any ) => {
235256 const { maxFiles, fileLimit } = props .applicationDetails .file_upload_setting
236257 // 单次上传文件数量限制
237- const file_limit_once = uploadImageList .value .length + uploadDocumentList .value .length
258+ const file_limit_once = uploadImageList .value .length + uploadDocumentList .value .length + uploadAudioList . value . length + uploadVideoList . value . length
238259 if (file_limit_once >= maxFiles ) {
239260 MsgWarning (' 最多上传' + maxFiles + ' 个文件' )
240261 fileList .splice (0 , fileList .length )
@@ -257,9 +278,9 @@ const uploadFile = async (file: any, fileList: any) => {
257278 } else if (documentExtensions .includes (extension )) {
258279 uploadDocumentList .value .push (file )
259280 } else if (videoExtensions .includes (extension )) {
260- // videos .push(file)
281+ uploadVideoList . value .push (file )
261282 } else if (audioExtensions .includes (extension )) {
262- // audios .push(file)
283+ uploadAudioList . value .push (file )
263284 }
264285
265286
@@ -297,7 +318,20 @@ const uploadFile = async (file: any, fileList: any) => {
297318 file .file_id = f [0 ].file_id
298319 }
299320 })
300- console .log (uploadDocumentList .value , uploadImageList .value )
321+ uploadAudioList .value .forEach ((file : any ) => {
322+ const f = response .data .filter ((f : any ) => f .name === file .name )
323+ if (f .length > 0 ) {
324+ file .url = f [0 ].url
325+ file .file_id = f [0 ].file_id
326+ }
327+ })
328+ uploadVideoList .value .forEach ((file : any ) => {
329+ const f = response .data .filter ((f : any ) => f .name === file .name )
330+ if (f .length > 0 ) {
331+ file .url = f [0 ].url
332+ file .file_id = f [0 ].file_id
333+ }
334+ })
301335 })
302336}
303337const recorderTime = ref (0 )
@@ -306,6 +340,8 @@ const recorderLoading = ref(false)
306340const inputValue = ref <string >(' ' )
307341const uploadImageList = ref <Array <any >>([])
308342const uploadDocumentList = ref <Array <any >>([])
343+ const uploadVideoList = ref <Array <any >>([])
344+ const uploadAudioList = ref <Array <any >>([])
309345const mediaRecorderStatus = ref (true )
310346const showDelete = ref (' ' )
311347
@@ -433,11 +469,15 @@ function sendChatHandle(event: any) {
433469 if (inputValue .value .trim ()) {
434470 props .sendMessage (inputValue .value , {
435471 image_list: uploadImageList .value ,
436- document_list: uploadDocumentList .value
472+ document_list: uploadDocumentList .value ,
473+ audio_list: uploadAudioList .value ,
474+ video_list: uploadVideoList .value ,
437475 })
438476 inputValue .value = ' '
439477 uploadImageList .value = []
440478 uploadDocumentList .value = []
479+ uploadAudioList .value = []
480+ uploadVideoList .value = []
441481 quickInputRef .value .textareaStyle .height = ' 45px'
442482 }
443483 }
@@ -452,6 +492,10 @@ function deleteFile(index: number, val: string) {
452492 uploadImageList .value .splice (index , 1 )
453493 } else if (val === ' document' ) {
454494 uploadDocumentList .value .splice (index , 1 )
495+ } else if (val === ' video' ) {
496+ uploadVideoList .value .splice (index , 1 )
497+ } else if (val === ' audio' ) {
498+ uploadAudioList .value .splice (index , 1 )
455499 }
456500}
457501function mouseenter(row : any ) {
0 commit comments