|
@@ -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"
|
|
@@ -25,6 +26,7 @@ import { getTokenHeader } from '~src/api/request/header'
|
|
|
import wbsApi from '~api/data-fill/wbs'
|
|
|
import { isFileSize } from 'js-fast-way'
|
|
|
import { toPdfPage } from '~uti/btn-auth'
|
|
|
+import { number } from 'echarts'
|
|
|
|
|
|
const props = defineProps({
|
|
|
fileList: {
|
|
@@ -52,6 +54,7 @@ const props = defineProps({
|
|
|
default:'允许格式:jpg/png/pdf/excel/word, 文件大小 小于 60MB',
|
|
|
},
|
|
|
|
|
|
+
|
|
|
})
|
|
|
|
|
|
//事件
|
|
@@ -65,6 +68,7 @@ const acceptTip = ref(props.acceptTip)
|
|
|
const uploadDisabled = ref(false)
|
|
|
const isCanuploadVal = ref(props.isCanupload)
|
|
|
|
|
|
+
|
|
|
//监听
|
|
|
watch(() => [
|
|
|
props.fileList,
|
|
@@ -73,6 +77,7 @@ watch(() => [
|
|
|
props.action,
|
|
|
props.accept,
|
|
|
props.acceptTip,
|
|
|
+
|
|
|
], ([fileList, datas, isCanupload, Action, Accept, Tip]) => {
|
|
|
uploadData.value = datas
|
|
|
fileListData.value = fileList
|
|
@@ -80,6 +85,7 @@ watch(() => [
|
|
|
action.value = Action
|
|
|
accept.value = Accept
|
|
|
acceptTip.value = Tip
|
|
|
+
|
|
|
})
|
|
|
|
|
|
//渲染完成
|
|
@@ -143,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
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|