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