update:不允许上传或选择大小为0的文件

This commit is contained in:
2026-04-15 15:53:09 +08:00
parent d71b9c8d03
commit f65fed0956
2 changed files with 14 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ import FilePreview from '@/components/common/filePreview/index.vue';
import { downloadFileById } from '@/utils/file';
import { isArray } from 'lodash-es';
import FileIcon from '@/components/common/fileIcon/index.vue';
import { ElMessage } from 'element-plus';
interface Props {
modelValue: any;
@@ -121,6 +122,12 @@ const removeRepeatFun = () => {
};
const changeFun = (data: any, dataList: any) => {
if (data.size === 0) {
ElMessage.warning('不允许选择大小为0的文件');
const index = fileList.value.findIndex((i: any) => i.name === data.name);
removeFun(index);
return;
}
emit('change', data);
const fileNum = dataList.filter((item: any) => item.name === data.name);
if (fileNum.length > 1) {

View File

@@ -47,6 +47,7 @@ import FilePreview from '@/components/common/filePreview/index.vue';
import { View, Delete, Download } from '@element-plus/icons-vue';
import { downloadFileById } from '@/utils/file';
import { uploadAttachmentApi, getFileBaseInfoApi, deleteAttachmentApi } from '@/api/data/data';
import { ElMessage } from 'element-plus';
interface Props {
modelValue: any;
@@ -116,6 +117,12 @@ watch(
);
const changeFun = async (file: any) => {
if (file.size === 0) {
ElMessage.warning('不允许选择大小为0的文件');
const index = fileList.value.findIndex((i: any) => i.name === file.name);
removeFun(index);
return;
}
const fileId = await uploadFun(file);
file.fileId = fileId;
emit('change', file);