update:不允许上传或选择大小为0的文件
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user