From eff37f283d50c423aa1a7795f12e07f0576763bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 3 Sep 2019 18:18:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tasks/GraduationTasksSubmitedit.js | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js index 9cc8bc2ab..c99885d4c 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js @@ -134,7 +134,18 @@ class GraduationTasksSubmitedit extends Component{ } } + onAttachmentRemoves = (file) => { + if(!file.percent || file.percent == 100){ + this.setState({ + Modalstype:true, + Modalstopval:'确定要删除这个附件吗?', + ModalSave: ()=>this.deleteAttachments(file), + ModalCancel:this.cancelAttachment + }) + return false; + } + } cancelAttachment=()=>{ this.setState({ Modalstype:false, @@ -144,6 +155,53 @@ class GraduationTasksSubmitedit extends Component{ }) } + deleteAttachments = (id) => { + + let {attachments,fileList}=this.state; + + const url = `/attachments/${id}.json` + axios.delete(url, { + }) + .then((response) => { + if (response.data) { + // const { status } = response.data; + if (response.data.status === 0) { + console.log('--- success') + let newattachments=attachments; + if(file.uid===undefined){ + for(var i=0; i { + const index = state.fileList.indexOf(file); + const newFileList = state.fileList.slice(); + newFileList.splice(index, 1); + return { + fileList: newFileList, + }; + }); + } + } + }) + .catch(function (error) { + console.log(error); + }); + + + } deleteAttachment = (file) => { if(!file.percent || file.percent == 100){ let {attachments,fileList}=this.state; @@ -640,7 +698,7 @@ class GraduationTasksSubmitedit extends Component{ {item.delete===true? this.onAttachmentRemove(item.id)} + onClick={()=>this.onAttachmentRemoves(item.id)} aria-hidden="true"> :""}