Merge branches 'dev_Ysl' and 'topic_bank' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_Ysl
# Conflicts: # public/react/src/modules/user/usersInfo/banks/BanksIndex.jsdev_aliyun_beta
commit
201b820b87
@ -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(
|
||||
<div className="courseForm">
|
||||
<style>
|
||||
{`
|
||||
.courseForm .ant-col-sm-24{
|
||||
text-align:left;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
<NewWorkForm
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
{...common}
|
||||
wrappedComponentRef={(ref) => this.newWorkFormRef = ref}
|
||||
topicId={bankId}
|
||||
></NewWorkForm>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default GtaskBanksEditEdit;
|
Loading…
Reference in new issue