From be00690f223000b34b94140f1256bacdb25626e8 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 6 Jul 2019 17:02:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=BD=9C=E5=93=81=E9=A1=B5=E9=9D=A2=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=AD=A6=E7=94=9F=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E8=83=BD=E4=B8=8A=E4=BC=A0=E5=90=8C=E5=90=8D?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E6=96=B0=E5=BB=BA=E5=92=8C=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E9=A1=B5=E9=9D=A2=E9=83=BD=E9=9C=80=E8=A6=81=E5=81=9A?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/busyWork/CommonWorkPost.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkPost.js b/public/react/src/modules/courses/busyWork/CommonWorkPost.js index 2e882e819..125975ae9 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkPost.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkPost.js @@ -293,9 +293,11 @@ class CommonWorkPost extends Component{ } // 附件相关 START handleChange = (info) => { - let fileList = info.fileList; + if (info.file.status === 'uploading') { + let fileList = info.fileList; - this.setState({ fileList: appendFileSizeToUploadFileAll(fileList) }); + this.setState({ fileList: appendFileSizeToUploadFileAll(fileList) }); + } } onAttachmentRemove = (file) => { @@ -587,6 +589,18 @@ render(){ onChange: this.handleChange, onRemove: this.onAttachmentRemove, beforeUpload: (file) => { + // TODO 文件存在则提示并退出 + let gotSameFile = false; + this.state.fileList && this.state.fileList.some((item) => { + if (item.name && item.name.startsWith(file.name)) { + gotSameFile = true; + return true + } + }) + if (gotSameFile) { + this.props.showNotification("该附件已被上传!") + return false + } console.log('beforeUpload', file.name); const isLt150M = file.size / 1024 / 1024 < 150; if (!isLt150M) {