Commit 453e65d5 authored by zhangwenshuai's avatar zhangwenshuai

修改上传组件过滤错误数据

parent 5806fd56
......@@ -20,15 +20,19 @@ const UploadCom = (props) => {
if (typeof getFormat === 'function') {
return getFormat(fileList);
}
return fileList.map((item: any) => {
return {
name: item.name,
value: item.value,
size: item.size,
uid: item.value,
...checkoutFileType(item.value),
};
});
return fileList
.filter((item: any) => {
return item.value;
})
.map((item: any) => {
return {
name: item.name,
value: item.value,
size: item.size,
uid: item.value,
...checkoutFileType(item.value),
};
});
};
const setFormatFile = (file) => {
if (!file) {
......
......@@ -9,8 +9,10 @@ export default class uploadDetail extends React.Component {
url: '',
};
onPreview = (url, name) => {
const typeArr = (name || url).match(/\.[a-zA-Z]+$/);
onPreview = (url:string, name:string) => {
const nameTypeArr = name.match(/\.[a-zA-Z]+$/);
const urlTypeArr = url.match(/\.[a-zA-Z]+$/);
const typeArr = nameTypeArr || urlTypeArr;
let type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : '';
type = type.toLowerCase();
if (['png', 'gif', 'bmp', 'jpg', 'jpeg'].includes(type)) {
......@@ -24,7 +26,7 @@ export default class uploadDetail extends React.Component {
}
};
handleCancel = (e) => {
handleCancel = (e:any) => {
e.stopPropagation();
this.setState({ showDialog: false });
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment