|
@ -65,7 +65,7 @@ const props = defineProps({ |
|
|
drag: propTypes.bool.def(false), // 拖拽上传 |
|
|
drag: propTypes.bool.def(false), // 拖拽上传 |
|
|
isShowTip: propTypes.bool.def(true), // 是否显示提示 |
|
|
isShowTip: propTypes.bool.def(true), // 是否显示提示 |
|
|
isShowFile: propTypes.bool.def(true), // 是否显示上传的文件 |
|
|
isShowFile: propTypes.bool.def(true), // 是否显示上传的文件 |
|
|
|
|
|
checkUploadUrl:propTypes.func.def(), // 校验二次请求的接口 |
|
|
}) |
|
|
}) |
|
|
// ========== 上传相关 ========== |
|
|
// ========== 上传相关 ========== |
|
|
const valueRef = ref(props.modelValue) |
|
|
const valueRef = ref(props.modelValue) |
|
@ -108,19 +108,38 @@ const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => { |
|
|
// uploadRef.value.data.path = uploadFile.name |
|
|
// uploadRef.value.data.path = uploadFile.name |
|
|
// } |
|
|
// } |
|
|
// 文件上传成功 |
|
|
// 文件上传成功 |
|
|
const handleFileSuccess: UploadProps['onSuccess'] = (res: any,uploadFile: any): void => { |
|
|
const handleFileSuccess: UploadProps['onSuccess'] = async (res: any,uploadFile: any): Promise<void> => { |
|
|
|
|
|
console.log('文件上传成功',res) |
|
|
if(res&&res.code==0){ |
|
|
if(res&&res.code==0){ |
|
|
message.success(t('ts.上传成功')) |
|
|
if(res.data&&res.data.code==200&&props.checkUploadUrl){ |
|
|
const fileListNew = fileList.value |
|
|
let checkRes = await props.checkUploadUrl(res.data.data) |
|
|
fileListNew.pop() |
|
|
console.log('checkRes',checkRes) |
|
|
fileList.value = fileListNew |
|
|
console.log('fileList.value',fileList.value) |
|
|
uploadList.value.push({ name: uploadFile.name, url: res.data }) |
|
|
console.log('uploadFile',uploadFile) |
|
|
// if (uploadList.value.length == uploadNumber.value) { |
|
|
ElMessage.closeAll() |
|
|
if(fileList.value.every(it => it.status == 'success')) { |
|
|
if(checkRes['fileExists']=="YES"){ |
|
|
fileList.value = fileList.value.concat(uploadList.value) |
|
|
message.success(t('ts.上传成功')) |
|
|
uploadList.value = [] |
|
|
}else{ |
|
|
uploadNumber.value = 0 |
|
|
|
|
|
emit('update:modelValue', listToString(fileList.value),res,uploadFile) |
|
|
let findItem = fileList.value.find(item=>item.uid == uploadFile.uid) |
|
|
|
|
|
if(findItem){ |
|
|
|
|
|
uploadRef?.value?.handleRemove(findItem) |
|
|
|
|
|
} |
|
|
|
|
|
message.error(checkRes['msg']) |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
message.success(t('ts.上传成功')) |
|
|
|
|
|
const fileListNew = fileList.value |
|
|
|
|
|
fileListNew.pop() |
|
|
|
|
|
fileList.value = fileListNew |
|
|
|
|
|
uploadList.value.push({ name: uploadFile.name, url: res.data }) |
|
|
|
|
|
// if (uploadList.value.length == uploadNumber.value) { |
|
|
|
|
|
if(fileList.value.every(it => it.status == 'success')) { |
|
|
|
|
|
fileList.value = fileList.value.concat(uploadList.value) |
|
|
|
|
|
uploadList.value = [] |
|
|
|
|
|
uploadNumber.value = 0 |
|
|
|
|
|
emit('update:modelValue', listToString(fileList.value),res,uploadFile) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
}else{ |
|
|
message.error(res.msg) |
|
|
message.error(res.msg) |
|
|