|
@@ -13,7 +13,7 @@
|
|
|
>
|
|
>
|
|
|
<div style="padding: 40px; text-align: center">
|
|
<div style="padding: 40px; text-align: center">
|
|
|
<span class="text"> 点击上传或将文件拖拽至此区域上传 </span>
|
|
<span class="text"> 点击上传或将文件拖拽至此区域上传 </span>
|
|
|
- <p class="text">按住Ctrl可同时多选,支持上传PPT/excel/pdf/mp4/zip/rar,等单个文件不能超过2G</p>
|
|
|
|
|
|
|
+ <p class="text">按住Ctrl可同时多选,支持上传{{props.upLoadfileLists.join('/')}},等单个文件不能超过2G</p>
|
|
|
</div>
|
|
</div>
|
|
|
</a-upload-dragger>
|
|
</a-upload-dragger>
|
|
|
</a-spin>
|
|
</a-spin>
|
|
@@ -133,7 +133,11 @@
|
|
|
uploadCount: {
|
|
uploadCount: {
|
|
|
type: Number,
|
|
type: Number,
|
|
|
default: () => 10
|
|
default: () => 10
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ upLoadfileLists: {
|
|
|
|
|
+ type: Array,
|
|
|
|
|
+ default: () => ['jpg','png','pdf','mp4','docx','doc','xlsx','xls','pptx','ppt','txt','cad','zip','rar']
|
|
|
|
|
+ },
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const handlerRemoveItem = (index) => {
|
|
const handlerRemoveItem = (index) => {
|
|
@@ -646,9 +650,30 @@
|
|
|
const downloadFile = (url) => {
|
|
const downloadFile = (url) => {
|
|
|
window.location.href = url
|
|
window.location.href = url
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断文件名的后缀是否存在于指定数组中
|
|
|
|
|
+ * @param {string} fileName - 文件名(如 "sss.mp4")
|
|
|
|
|
+ * @param {Array<string>} suffixArray - 后缀数组(如 ['jpg','png','pdf','mp4',...])
|
|
|
|
|
+ * @returns {boolean} - 是否存在
|
|
|
|
|
+ */
|
|
|
|
|
+ const isFileSuffixInArray = (fileName, suffixArray) => {
|
|
|
|
|
+ // 获取文件后缀(包括点号)
|
|
|
|
|
+ const fileSuffix = fileName.split('.').pop();
|
|
|
|
|
+
|
|
|
|
|
+ // 检查后缀是否在数组中(包含点号匹配)
|
|
|
|
|
+ return suffixArray.includes(fileSuffix);
|
|
|
|
|
+ }
|
|
|
const beforeUpload = async (file) => {
|
|
const beforeUpload = async (file) => {
|
|
|
console.log('选择了文件', file)
|
|
console.log('选择了文件', file)
|
|
|
spinning.value = true
|
|
spinning.value = true
|
|
|
|
|
+
|
|
|
|
|
+ // upLoadfileLists
|
|
|
|
|
+ if(!isFileSuffixInArray( file.name,props.upLoadfileLists)){
|
|
|
|
|
+ const fileSuffix = file.name.split('.').pop();
|
|
|
|
|
+ message.error('不允许上传后缀' +fileSuffix)
|
|
|
|
|
+ spinning.value = false
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
if(uploadFileList.value.length >= props.uploadCount){
|
|
if(uploadFileList.value.length >= props.uploadCount){
|
|
|
message.error('超过上传条目' + props.uploadCount + "条")
|
|
message.error('超过上传条目' + props.uploadCount + "条")
|
|
|
spinning.value = false
|
|
spinning.value = false
|