From bf4cf0ff9bad5ced0032c55261041328b9604cee Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 30 Aug 2019 15:54:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/usersInfo/banks/BanksIndex.js | 12 ++- .../user/usersInfo/banks/HomeworkBanksEdit.js | 100 ++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 public/react/src/modules/user/usersInfo/banks/HomeworkBanksEdit.js diff --git a/public/react/src/modules/user/usersInfo/banks/BanksIndex.js b/public/react/src/modules/user/usersInfo/banks/BanksIndex.js index 58100c41a..6b636dca2 100644 --- a/public/react/src/modules/user/usersInfo/banks/BanksIndex.js +++ b/public/react/src/modules/user/usersInfo/banks/BanksIndex.js @@ -30,6 +30,10 @@ const GtopicBanksEdit = Loadable({ loader: () => import('./GtopicBanksEdit'), loading: Loading, }) +const HomeworkBanksEdit = Loadable({ + loader: () => import('./HomeworkBanksEdit'), + loading: Loading, +}) class BanksIndex extends Component{ constructor(props){ @@ -75,7 +79,13 @@ class BanksIndex extends Component{

- + { + return () + } + }> + { diff --git a/public/react/src/modules/user/usersInfo/banks/HomeworkBanksEdit.js b/public/react/src/modules/user/usersInfo/banks/HomeworkBanksEdit.js new file mode 100644 index 000000000..c94e8d740 --- /dev/null +++ b/public/react/src/modules/user/usersInfo/banks/HomeworkBanksEdit.js @@ -0,0 +1,100 @@ +import React, { Component } from 'react'; +import axios from 'axios' + + +import NewWorkForm from '../../../courses/busyWork/NewWorkForm' + +class HomeworkBanksEdit 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 = `/homework_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/homework/${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/homework/${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 HomeworkBanksEdit; \ No newline at end of file