文件上传
This commit is contained in:
parent
9272282b1d
commit
ce0a7d5156
@ -123,7 +123,9 @@ const handleFileSuccess: UploadProps['onSuccess'] = (res: any): void => {
|
||||
// 删除自身
|
||||
const index = fileList.value.findIndex((item) => item.response?.data === res.data)
|
||||
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])+" "})
|
||||
if (uploadList.value.length == uploadNumber.value) {
|
||||
fileList.value.push(...uploadList.value)
|
||||
@ -147,7 +149,7 @@ const excelUploadError: UploadProps['onError'] = (): void => {
|
||||
const handleRemove = (file: UploadFile) => {
|
||||
const index = fileList.value.map((f) => f.name).indexOf(file.name)
|
||||
if (index > -1) {
|
||||
//删除文件链接已选择删除的链接
|
||||
//删除文件链接已选择删除的链接索引
|
||||
fileList.value.splice(index, 1)
|
||||
MysqlUrl.value.splice(index,1)
|
||||
// console.log("fileList",fileList.value)
|
||||
@ -176,7 +178,7 @@ watch(
|
||||
)
|
||||
return
|
||||
}
|
||||
// 情况2:数组
|
||||
// 情况2:数组 利用拼接的特殊字符串来切割
|
||||
fileList.value.push(
|
||||
...(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)
|
||||
emit('update:modelValue', result)
|
||||
// 多了一步就是清空就文件链接以便于再次删除后不会出现重复
|
||||
MysqlUrl.value = []
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user