| | |
| | | import { uploadAndParse } from '@/api/session'; |
| | | import { useUserStore } from '@/store'; |
| | | import { Message } from '@arco-design/web-vue'; |
| | | import EventBus from '@/utils/EventBus'; |
| | | |
| | | const userStore = useUserStore(); |
| | | const props = defineProps({ |
| | |
| | | url: item, |
| | | })); |
| | | } |
| | | EventBus.on('queryAgent', (eventData) => { |
| | | // 更新组件的数据 |
| | | if (fileList.value.length == 1) { |
| | | fileList.value = []; |
| | | } else { |
| | | fileList.value.forEach((item) => { |
| | | if (item.name != eventData.name) { |
| | | fileList.value = []; |
| | | fileList.value.push(item); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | // console.log(urls.value, 8988); |
| | | const beforeRemove = (file) => { |
| | | emit('handleRemove'); |
| | | fileList.value = []; |
| | | }; |
| | | |
| | | const handleChange = (fileList) => { |
| | | const formData = new FormData(); |
| | | for (let i = 0; i < fileList.length; i++) { |
| | | formData.append('file', fileList[i].file); |
| | | formData.append('conversation_id', props.sessionId); |
| | | } |
| | | const dataFile = compareArr(uploaditemList.value, fileList).uniqueToSecond; |
| | | uploaditemList.value = fileList.map((item, index) => { |
| | | return { |
| | | index: index, |
| | | name: item.name, |
| | | size: (item.file.size / 1024).toFixed(2) + 'K', |
| | | onFileSelectedLoading: false, |
| | | textName: '', |
| | | }; |
| | | }); |
| | | filesData.value = fileList; |
| | | |
| | | emit('selectFileCallback', uploaditemList.value, fileList); |
| | | filesData.value = fileList; |
| | | emit('selectFileCallback', uploaditemList.value, dataFile); |
| | | fileList.value = []; |
| | | }; |
| | | |
| | | //数组比较 |
| | | const compareArr = (arr1, arr2) => { |
| | | const uniqueToFirst = arr1.filter( |
| | | (item1) => !arr2.some((item2) => item1.name == item2.name) |
| | | ); |
| | | |
| | | const uniqueToSecond = arr2.filter( |
| | | (item2) => !arr1.some((item1) => item1.name == item2.name) |
| | | ); |
| | | |
| | | return { |
| | | uniqueToFirst, |
| | | uniqueToSecond, |
| | | }; |
| | | }; |
| | | |
| | | function beforeUpload(resolve) { |
| | |
| | | resolve(true); |
| | | }); |
| | | } |
| | | // if (form.value.maininformation.length > 4) { |
| | | // Message.error('文件不能超过5个'); |
| | | // } else { |
| | | // return new Promise((resolve) => { |
| | | // resolve(true); |
| | | // }); |
| | | // } |
| | | } |
| | | </script> |