From 72586f082fc01bf7b82de2a25752da541ae28146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 30 Aug 2019 16:33:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/user/usersInfo/InfosTopics.js | 2 +- .../user/usersInfo/banks/BanksIndex.js | 13 +++ .../usersInfo/banks/GtaskBanksEditEdit.js | 100 ++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 public/react/src/modules/user/usersInfo/banks/GtaskBanksEditEdit.js diff --git a/public/react/src/modules/user/usersInfo/InfosTopics.js b/public/react/src/modules/user/usersInfo/InfosTopics.js index ba445e386..9b0e2948e 100644 --- a/public/react/src/modules/user/usersInfo/InfosTopics.js +++ b/public/react/src/modules/user/usersInfo/InfosTopics.js @@ -501,7 +501,7 @@ class InfosTopics extends Component{ import('./GtaskBanksEditEdit'), + loading: Loading, +}) + class BanksIndex extends Component{ constructor(props){ super(props); @@ -79,6 +84,14 @@ class BanksIndex extends Component{

+ {/*毕设任务编辑*/} + { + return () + } + }> + { diff --git a/public/react/src/modules/user/usersInfo/banks/GtaskBanksEditEdit.js b/public/react/src/modules/user/usersInfo/banks/GtaskBanksEditEdit.js new file mode 100644 index 000000000..3035e9867 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/GtaskBanksEditEdit.js @@ -0,0 +1,100 @@ +import React, { Component } from 'react'; +import axios from 'axios' + + +import NewWorkForm from '../../../courses/busyWork/NewWorkForm'; + +class GtaskBanksEditEdit extends Component { + constructor(props){ + super(props); + this.state = { + isPublic: undefined, + isGroup: false + } + } + componentDidMount = () =>{ + let workId = this.props.match.params.workId; + this.initData(workId); + } + + initData = (workId) =>{ + + let url = `/task_banks/${workId}.json`; + axios.get(url).then((result)=>{ + if(result){ + const crumbData={ + title:'编辑', + is_public:result && result.data && result.data.is_public, + crumbArray:[ + {to:`/banks/task/${workId}/edit`,content:'详情'}, + {content:'编辑'} + ] + } + this.props.initPublic(crumbData); + result.data.isEdit = true; + result.data.ref_attachments = result.data.reference_attachments + this.setState({ isGroup: result.data.min_num || result.data.max_num }) + this.newWorkFormRef.initValue(result.data); + } + }).catch((error)=>{ + console.log(error) + }) + } + + + doNew = () => { + } + doEdit = (params) => { + const workId = this.props.match.params.workId + const newUrl = `/homework_banks/${workId}.json` + + // const isGroup = this.props.isGroup() + axios.put(newUrl, params) + .then((response) => { + if (response.data.status == 0) { + this.props.showNotification('保存成功') + this.toWorkDetail() + } + }) + .catch(function (error) { + console.log(error); + }); + } + toWorkDetail = () => { + this.props.history.push(`/banks/task/${this.props.match.params.workId}`) + } + onCancel = () => { + this.toWorkDetail() + } + isGroup = () => { + return this.state.isGroup; + } + render(){ + let { bankId } = this.props.match.params + const common = { + onCancel:this.onCancel, + isGroup: this.isGroup, + doNew: this.doNew, + doEdit: this.doEdit, + } + return( +
+ + this.newWorkFormRef = ref} + topicId={bankId} + > +
+ ) + } +} +export default GtaskBanksEditEdit; \ No newline at end of file