From 453e65d5df04965234ac4988c25aea834d7b7b82 Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Mon, 24 Aug 2020 19:22:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=BF=87=E6=BB=A4=E9=94=99=E8=AF=AF=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/base/extra/upload/index.tsx | 22 +++++++++++-------- .../component/base/extra/upload/preview.tsx | 8 ++++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/components/apolloTable/component/base/extra/upload/index.tsx b/components/apolloTable/component/base/extra/upload/index.tsx index 99e767e..1713a0a 100644 --- a/components/apolloTable/component/base/extra/upload/index.tsx +++ b/components/apolloTable/component/base/extra/upload/index.tsx @@ -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) { diff --git a/components/apolloTable/component/base/extra/upload/preview.tsx b/components/apolloTable/component/base/extra/upload/preview.tsx index be20902..6987c4a 100644 --- a/components/apolloTable/component/base/extra/upload/preview.tsx +++ b/components/apolloTable/component/base/extra/upload/preview.tsx @@ -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 }); }; -- 2.21.0