|
|
@@ -5,7 +5,6 @@
|
|
|
class="uploader-app"
|
|
|
ref="uploaderRef"
|
|
|
:options="options"
|
|
|
- :opts="opts"
|
|
|
:autoStart="false"
|
|
|
:fileStatusText="fileStatusText"
|
|
|
@files-added="handleFilesAdded"
|
|
|
@@ -77,12 +76,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
- import { ref, computed, defineExpose, nextTick, inject } from 'vue'
|
|
|
+ import { ref, computed, defineExpose, nextTick, inject, getCurrentInstance } from 'vue'
|
|
|
import { message } from 'ant-design-vue'
|
|
|
import { useMyResourceStore } from '@/store/myResource'
|
|
|
import SparkMD5 from 'spark-md5'
|
|
|
- import sysConfig from '@/config/index'
|
|
|
- import rsConfig from '@/config/reSource'
|
|
|
import tool from '@/utils/tool'
|
|
|
import {
|
|
|
UploadOutlined,
|
|
|
@@ -101,7 +98,7 @@
|
|
|
callType: 1,
|
|
|
callback: () => {}
|
|
|
})
|
|
|
-
|
|
|
+ const { proxy } = getCurrentInstance()
|
|
|
const store = useMyResourceStore()
|
|
|
|
|
|
// refs
|
|
|
@@ -130,7 +127,7 @@
|
|
|
})
|
|
|
|
|
|
const options = ref({
|
|
|
- target: `${sysConfig.API_URL}${rsConfig.baseContext}/filetransfer/uploadfile`,
|
|
|
+ target: `${proxy.$RESOURCE_CONFIG.baseContext}/filetransfer/uploadfile`,
|
|
|
chunkSize: 1024 * 1024,
|
|
|
fileParameterName: 'file',
|
|
|
maxChunkRetries: 3,
|
|
|
@@ -163,7 +160,7 @@
|
|
|
})
|
|
|
|
|
|
const attrs = ref({
|
|
|
- accept: 'image/*,application/*,text/*'
|
|
|
+ accept: '*'
|
|
|
})
|
|
|
|
|
|
const panelShow = ref(false)
|
|
|
@@ -261,45 +258,52 @@
|
|
|
}
|
|
|
|
|
|
const handleFilesAdded = (filesSource) => {
|
|
|
- const inconformityFileArr = []
|
|
|
- const files = filesSource.filter((file) => {
|
|
|
- const isFile = isImageOrDocument(file)
|
|
|
- if (isFile) {
|
|
|
- return file
|
|
|
- } else {
|
|
|
- inconformityFileArr.push(file)
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- if (inconformityFileArr.length > 0) {
|
|
|
- filesSource.ignored = true
|
|
|
- message.warning('文件夹中有不符合要求的文件', {
|
|
|
- duration: 0,
|
|
|
- content: '无'
|
|
|
- // content: () => {
|
|
|
- // let warringHtml = ''
|
|
|
- // inconformityFileArr.forEach((item, index) => {
|
|
|
- // warringHtml += `<p><i style="margin-right:5px">${index + 1}.</i>${item.name}</p>`
|
|
|
- // })
|
|
|
- // return (
|
|
|
- // <div>
|
|
|
- // <div style="color:#E6A23C;width:290px">{warringHtml}</div>
|
|
|
- // <p style="color:#f56c6c">只可以上传图片和文档!文件大小不能为0!</p>
|
|
|
- // </div>
|
|
|
- // )
|
|
|
- // }
|
|
|
- })
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- const filesTotalSize = files.reduce((pre, next) => pre + next.size, 0)
|
|
|
+ // const inconformityFileArr = []
|
|
|
+ // const files = filesSource.filter((file) => {
|
|
|
+ // const isFile = isImageOrDocument(file)
|
|
|
+ // if (isFile) {
|
|
|
+ // return file
|
|
|
+ // } else {
|
|
|
+ // inconformityFileArr.push(file)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
+ // if (inconformityFileArr.length > 0) {
|
|
|
+ // filesSource.ignored = true
|
|
|
+ // message.warning('文件夹中有不符合要求的文件', {
|
|
|
+ // duration: 0,
|
|
|
+ // content: '无'
|
|
|
+ // // content: () => {
|
|
|
+ // // let warringHtml = ''
|
|
|
+ // // inconformityFileArr.forEach((item, index) => {
|
|
|
+ // // warringHtml += `<p><i style="margin-right:5px">${index + 1}.</i>${item.name}</p>`
|
|
|
+ // // })
|
|
|
+ // // return (
|
|
|
+ // // <div>
|
|
|
+ // // <div style="color:#E6A23C;width:290px">{warringHtml}</div>
|
|
|
+ // // <p style="color:#f56c6c">只可以上传图片和文档!文件大小不能为0!</p>
|
|
|
+ // // </div>
|
|
|
+ // // )
|
|
|
+ // // }
|
|
|
+ // })
|
|
|
+ // return false
|
|
|
+ // }
|
|
|
+
|
|
|
+ // const filesTotalSize = files.reduce((pre, next) => pre + next.size, 0)
|
|
|
+ const filesTotalSize = filesSource
|
|
|
+ .map((item) => item.size)
|
|
|
+ .reduce((pre, next) => {
|
|
|
+ return pre + next
|
|
|
+ }, 0)
|
|
|
|
|
|
if (remainderStorageValue.value < filesTotalSize) {
|
|
|
- message.warning(`剩余存储空间不足,请重新选择${files.length > 1 ? '批量' : ''}文件`)
|
|
|
- filesSource.ignored = true
|
|
|
+ // 批量选择的文件超出剩余存储空间
|
|
|
+ message.warning(`剩余存储空间不足,请重新选择${filesSource.length > 1 ? '批量' : ''}文件`)
|
|
|
+ filesSource.ignored = true // 本次选择的文件过滤掉
|
|
|
} else {
|
|
|
- filesLength.value += files.length
|
|
|
- files.forEach((file) => {
|
|
|
+ // 批量或单个选择的文件未超出剩余存储空间,正常上传
|
|
|
+ filesLength.value += filesSource.length
|
|
|
+ filesSource.forEach((file) => {
|
|
|
dropBoxShow.value = false
|
|
|
panelShow.value = true
|
|
|
collapse.value = false
|