文件上传

This commit is contained in:
XaoLi717 2024-09-03 08:44:38 +08:00
parent 9272282b1d
commit ce0a7d5156

View File

@ -123,7 +123,9 @@ const handleFileSuccess: UploadProps['onSuccess'] = (res: any): void => {
// //
const index = fileList.value.findIndex((item) => item.response?.data === res.data) const index = fileList.value.findIndex((item) => item.response?.data === res.data)
fileList.value.splice(index, 1) fileList.value.splice(index, 1)
// console.log("res",res) /**
* 拼接更加明显的特殊字符串来便于切割
* */
uploadList.value.push({ name: (res.data[0]+"&&$#$"+res.data[1])+" ", url: (res.data[0]+"&&$#$"+res.data[1])+" "}) uploadList.value.push({ name: (res.data[0]+"&&$#$"+res.data[1])+" ", url: (res.data[0]+"&&$#$"+res.data[1])+" "})
if (uploadList.value.length == uploadNumber.value) { if (uploadList.value.length == uploadNumber.value) {
fileList.value.push(...uploadList.value) fileList.value.push(...uploadList.value)
@ -147,7 +149,7 @@ const excelUploadError: UploadProps['onError'] = (): void => {
const handleRemove = (file: UploadFile) => { const handleRemove = (file: UploadFile) => {
const index = fileList.value.map((f) => f.name).indexOf(file.name) const index = fileList.value.map((f) => f.name).indexOf(file.name)
if (index > -1) { if (index > -1) {
// //
fileList.value.splice(index, 1) fileList.value.splice(index, 1)
MysqlUrl.value.splice(index,1) MysqlUrl.value.splice(index,1)
// console.log("fileList",fileList.value) // console.log("fileList",fileList.value)
@ -176,7 +178,7 @@ watch(
) )
return return
} }
// 2 // 2
fileList.value.push( fileList.value.push(
...(val as string[]).map((url) => ({ name: url.substring(0,url.indexOf("&&$#")),url:url.substring(url.indexOf("&&$#")+5,url.length) })) ...(val as string[]).map((url) => ({ name: url.substring(0,url.indexOf("&&$#")),url:url.substring(url.indexOf("&&$#")+5,url.length) }))
) )
@ -218,6 +220,7 @@ const emitUpdateModelValue2 = () => {
} }
// console.log("result",result) // console.log("result",result)
emit('update:modelValue', result) emit('update:modelValue', result)
// 便
MysqlUrl.value = [] MysqlUrl.value = []
} }