设置允许最大上传限制

This commit is contained in:
zjl 2024-12-23 13:42:23 +08:00
parent fc16d8ca45
commit c02d3afc58

View File

@ -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;
} }
}; };