fix(用例管理): 修复文件显示和上传校验问题问题

--bug=1036831 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001036831
--bug=1036717 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001036717
This commit is contained in:
guoyuqi 2024-03-06 18:12:43 +08:00 committed by Craftsman
parent 669f992b6c
commit 825aea38d2
3 changed files with 15 additions and 19 deletions

View File

@ -266,18 +266,7 @@
});
function handleChange(_fileList: MsFileItem[], fileItem: MsFileItem) {
//
const isRepeat = _fileList.filter((item) => item.name === fileItem.name).length > 1;
if (isRepeat) {
Message.error(t('ms.add.attachment.repeatFileTip'));
innerFileList.value = _fileList.reduce((prev: MsFileItem[], current: MsFileItem) => {
const isExist = prev.find((item: any) => item.name === current.name);
if (!isExist) {
prev.push(current);
}
return prev;
}, []);
} else if (props.multiple) {
if (props.multiple) {
innerFileList.value.push(fileItem);
inputFiles.value.push({
...fileItem,

View File

@ -224,14 +224,14 @@
});
function getUploadDesc(item: MsFileItem) {
if (props.showUploadTypeDesc) {
if (item.local !== undefined ) {
return item.local ? t('ms.upload.uploadAt') : t('ms.upload.associatedAt');
}
return t('ms.upload.uploadAt');
}
function showUploadSuccess(item: MsFileItem) {
if (props.showUploadTypeDesc) {
return !!item.local;
if (item.local !== undefined ) {
return item.local ;
}
return true;
}

View File

@ -124,9 +124,17 @@
});
async function beforeUpload(file: File) {
if (!props.multiple && innerFileList.value.length > 0) {
//
innerFileList.value = [];
if (innerFileList.value.length > 0) {
//
const isRepeat = innerFileList.value.filter((item) => item.name === file.name && item.local).length >= 1;
if (isRepeat) {
Message.warning(t('ms.add.attachment.repeatFileTip'));
return Promise.resolve(false);
}
if (!props.multiple) {
//
innerFileList.value = [];
}
}
const maxSize = props.maxSize || defaultMaxSize;
const _maxSize = props.sizeUnit === 'MB' ? maxSize * 1024 * 1024 : maxSize * 1024;
@ -141,7 +149,6 @@
Message.error(props.fileTypeTip ? props.fileTypeTip : t('ms.upload.fileTypeValidate', { type: props.accept }));
return Promise.resolve(false);
}
//
return Promise.resolve(true);
}