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:
parent
669f992b6c
commit
825aea38d2
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue