fix: upload组件resolve问题

This commit is contained in:
SADYX 2024-07-16 10:27:45 +08:00
parent 2154f9c3e7
commit 1ce91dee0a
3 changed files with 10 additions and 7 deletions

View File

@ -97,9 +97,9 @@ const { uploadUrl, httpRequest } = useUpload()
//
const handleRequest = async (f: UploadRequestOptions) => {
if (!!props.categoryPath) {
httpRequest(f, { categoryPath: props.categoryPath })
return httpRequest(f, { categoryPath: props.categoryPath })
} else {
httpRequest(f)
return httpRequest(f)
}
}
@ -136,6 +136,8 @@ const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => {
//
const handleFileSuccess: UploadProps['onSuccess'] = (res: any): void => {
message.success('上传成功')
console.log(fileList.value,res);
//
const index = fileList.value.findIndex((item) => item.response?.data === res.data)
fileList.value.splice(index, 1)
@ -186,7 +188,8 @@ watch(
//
const emitUpdateModelValue = () => {
const result = fileList.value.map(({ name, url }) => ({ name, url }))
console.log(result);
emit('update:modelValue', result)
}
</script>

View File

@ -105,9 +105,9 @@ const { uploadUrl, httpRequest } = useUpload()
//
const handleRequest = async (f: UploadRequestOptions) => {
if (!!props.categoryPath) {
httpRequest(f, { categoryPath: props.categoryPath })
return httpRequest(f, { categoryPath: props.categoryPath })
} else {
httpRequest(f)
return httpRequest(f)
}
}

View File

@ -91,9 +91,9 @@ const uploadList = ref<UploadUserFile[]>([])
//
const handleRequest = async (f: UploadRequestOptions) => {
if (!!props.categoryPath) {
httpRequest(f, { categoryPath: props.categoryPath })
return httpRequest(f, { categoryPath: props.categoryPath })
} else {
httpRequest(f)
return httpRequest(f)
}
}