|
@@ -1,5 +1,6 @@
|
|
|
<template>
|
|
|
<el-upload
|
|
|
+ ref="uploadRef"
|
|
|
:accept="accept" :action="action" :before-remove="delUploadData" :before-upload="beforeUpload"
|
|
|
:data="uploadData"
|
|
|
:disabled="isCanuploadVal" :file-list="fileListData" :headers="getTokenHeader()" :on-error="uploadError"
|
|
@@ -148,35 +149,51 @@ const uploadPreview = ({ url }) => {
|
|
|
window.open(url, '_blank')
|
|
|
}*/
|
|
|
}
|
|
|
-
|
|
|
+const uploadRef = ref(null)
|
|
|
//删除文件
|
|
|
-const delUploadData = async ({ id }) => {
|
|
|
+const delUploadData = async (res) => {
|
|
|
+ const { id, status } = res
|
|
|
+
|
|
|
if (accept.value === 'application/pdf') {
|
|
|
- loadingText.value = '删除中...'
|
|
|
- uploadDisabled.value = true
|
|
|
- const { error, code } = await wbsApi.delTabById({
|
|
|
- ids: id,
|
|
|
- })
|
|
|
- uploadDisabled.value = false
|
|
|
- if (!error && code === 200) {
|
|
|
- window?.$message?.success('删除成功')
|
|
|
+ if (status === 'uploading') {
|
|
|
+ uploadRef.value.abort()
|
|
|
+ uploadDisabled.value = false
|
|
|
return true
|
|
|
- } else {
|
|
|
- return false
|
|
|
+ } else {
|
|
|
+ loadingText.value = '删除中...'
|
|
|
+ uploadDisabled.value = true
|
|
|
+ const { error, code } = await wbsApi.delTabById({
|
|
|
+ ids: id,
|
|
|
+ })
|
|
|
+ uploadDisabled.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window?.$message?.success('删除成功')
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
- loadingText.value = '删除中...'
|
|
|
- uploadDisabled.value = true
|
|
|
- const { error, code } = await wbsApi.removeBussFile({
|
|
|
- ids: id,
|
|
|
- })
|
|
|
- uploadDisabled.value = false
|
|
|
- if (!error && code === 200) {
|
|
|
- window?.$message?.success('删除成功')
|
|
|
+ if (status === 'uploading') {
|
|
|
+ uploadRef.value.abort()
|
|
|
+ uploadDisabled.value = false
|
|
|
return true
|
|
|
} else {
|
|
|
- return false
|
|
|
+ loadingText.value = '删除中...'
|
|
|
+ uploadDisabled.value = true
|
|
|
+ const { error, code } = await wbsApi.removeBussFile({
|
|
|
+ ids: id,
|
|
|
+ })
|
|
|
+ uploadDisabled.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window?.$message?.success('删除成功')
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|