From 268a36f9aa34bd6f289c7108a8a8d237e319a98a Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Thu, 29 Aug 2019 11:05:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E5=BA=93-=E6=AF=95=E8=AE=BE=E9=80=89?= =?UTF-8?q?=E9=A2=98=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graduation/topics/GraduateTopicNew.js | 59 ++++++++++----- .../graduation/topics/GraduateTopicNewFrom.js | 59 +++++++-------- .../user/usersInfo/banks/BanksIndex.js | 73 ++++++++++--------- .../user/usersInfo/banks/GtopicBanksEdit.js | 57 ++++++++++++--- 4 files changed, 152 insertions(+), 96 deletions(-) diff --git a/public/react/src/modules/courses/graduation/topics/GraduateTopicNew.js b/public/react/src/modules/courses/graduation/topics/GraduateTopicNew.js index 8eeae8095..02fc5018e 100644 --- a/public/react/src/modules/courses/graduation/topics/GraduateTopicNew.js +++ b/public/react/src/modules/courses/graduation/topics/GraduateTopicNew.js @@ -66,27 +66,33 @@ class GraduateTopicNew extends Component{ //编辑,信息显示 getEditInfo=()=>{ const cid = this.props.match.params.coursesId - let topicId=this.props.match.params.topicId - let url=`/courses/${cid}/graduation_topics/${topicId}/edit.json`; - axios.get((url)).then((result)=>{ - if(result){ - this.setState({ - left_banner_id:result.data.left_banner_id, - course_name:result.data.course_name, - left_banner_name:result.data.left_banner_name - }) - this.GraduateTopicNewFromRef.initValue(result); - - } - }).catch((error)=>{ - console.log(error); - }) + let topicId=this.props.match.params.topicId; + if(topicId){ + let url=`/courses/${cid}/graduation_topics/${topicId}/edit.json`; + axios.get((url)).then((result)=>{ + if(result){ + this.setState({ + left_banner_id:result.data.left_banner_id, + course_name:result.data.course_name, + left_banner_name:result.data.left_banner_name + }) + this.GraduateTopicNewFromRef.initValue(result); + + } + }).catch((error)=>{ + console.log(error); + }) + } } // 编辑保存 - editSave = (params,topicId) =>{ + editSave = (param,attachments,topicId) =>{ const cid = this.props.match.params.coursesId const editUrl = `/courses/${cid}/graduation_topics/${topicId}.json` + let params = { + graduation_topic:param, + attachment_ids:attachments + } axios.put(editUrl, params).then((response) => { if (response.status == 200) { const { id } = response.data; @@ -101,9 +107,13 @@ class GraduateTopicNew extends Component{ } // 新建提交 - newSubmit = (params,topicId) =>{ + newSubmit = (param,attachments,topicId) =>{ const cid = this.props.match.params.coursesId const url = `/courses/${cid}/graduation_topics.json` + let params = { + graduation_topic:param, + attachment_ids:attachments + } axios.post(url, params).then((response) => { if (response.data) { const { id } = response.data; @@ -116,6 +126,16 @@ class GraduateTopicNew extends Component{ console.log(error); }); } + // 取消编辑或者新建 + editCancel = () =>{ + const cid = this.props.match.params.coursesId; + let topicId=this.props.match.params.topicId; + if(topicId){ + this.props.history.push(`/courses/${cid}/graduation_topics/${topicId}/detail`); + }else{ + this.props.history.push(`/courses/${cid}/graduation_topics/${this.state.left_banner_id}`); + } + } render() { @@ -127,9 +147,9 @@ class GraduateTopicNew extends Component{ const { current_user } = this.props let{ topicId,coursesId }=this.props.match.params const common={ - handleSubmit:this.handleSubmit, editSave:this.editSave, - newSubmit:this.newSubmit + newSubmit:this.newSubmit, + editCancel:this.editCancel } return(