设置允许最大上传限制
This commit is contained in:
parent
fc16d8ca45
commit
c02d3afc58
@ -113,6 +113,9 @@
|
||||
return props.disabled;
|
||||
});
|
||||
|
||||
/**
|
||||
* 文件列表
|
||||
*/
|
||||
const fileList = computed({
|
||||
get: () => {
|
||||
console.log(props.fileLists);
|
||||
@ -138,6 +141,9 @@
|
||||
const handleHttpUpload = async (options) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
// 设置允许做大上传张数验证
|
||||
onExceed();
|
||||
// 上传文件
|
||||
const formData = new FormData();
|
||||
formData.append('file', options.file.file);
|
||||
formData.append('name', props.name);
|
||||
@ -208,6 +214,9 @@
|
||||
let filePath = props.name + '/' + year + '/' + month + '/' + day + '/' + fileName;
|
||||
loading.value = true;
|
||||
try {
|
||||
// 设置允许做大上传张数验证
|
||||
onExceed();
|
||||
// 文件请求头
|
||||
const headers = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
};
|
||||
@ -325,12 +334,13 @@
|
||||
* 最大上传张数限制
|
||||
*/
|
||||
const onExceed = () => {
|
||||
if (props.limit) {
|
||||
if (props.limit && fileList.value.length >= props.limit) {
|
||||
notification.warning({
|
||||
message: '温馨提示',
|
||||
duration: 2000,
|
||||
description: `最多支持上传${props.limit}张`,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user