Commit 453e65d5 authored by zhangwenshuai's avatar zhangwenshuai

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

parent 5806fd56
...@@ -20,7 +20,11 @@ const UploadCom = (props) => { ...@@ -20,7 +20,11 @@ const UploadCom = (props) => {
if (typeof getFormat === 'function') { if (typeof getFormat === 'function') {
return getFormat(fileList); return getFormat(fileList);
} }
return fileList.map((item: any) => { return fileList
.filter((item: any) => {
return item.value;
})
.map((item: any) => {
return { return {
name: item.name, name: item.name,
value: item.value, value: item.value,
......
...@@ -9,8 +9,10 @@ export default class uploadDetail extends React.Component { ...@@ -9,8 +9,10 @@ export default class uploadDetail extends React.Component {
url: '', url: '',
}; };
onPreview = (url, name) => { onPreview = (url:string, name:string) => {
const typeArr = (name || url).match(/\.[a-zA-Z]+$/); 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('.', '') : ''; let type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : '';
type = type.toLowerCase(); type = type.toLowerCase();
if (['png', 'gif', 'bmp', 'jpg', 'jpeg'].includes(type)) { if (['png', 'gif', 'bmp', 'jpg', 'jpeg'].includes(type)) {
...@@ -24,7 +26,7 @@ export default class uploadDetail extends React.Component { ...@@ -24,7 +26,7 @@ export default class uploadDetail extends React.Component {
} }
}; };
handleCancel = (e) => { handleCancel = (e:any) => {
e.stopPropagation(); e.stopPropagation();
this.setState({ showDialog: false }); 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