Merge remote-tracking branch 'origin/topic_bank' into topic_bank

dev_aliyun_beta
杨树明 5 years ago
commit 2f594f1577

@ -66,7 +66,8 @@ class GraduateTopicNew extends Component{
//编辑,信息显示
getEditInfo=()=>{
const cid = this.props.match.params.coursesId
let topicId=this.props.match.params.topicId
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){
@ -82,11 +83,16 @@ class GraduateTopicNew extends Component{
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(
<div className="newMain ">
@ -157,6 +177,7 @@ class GraduateTopicNew extends Component{
{...common}
wrappedComponentRef={(ref) => this.GraduateTopicNewFromRef = ref}
topicId={topicId}
teacherName={true}
></GraduateTopicNewFrom>
</div>

@ -136,7 +136,7 @@ class GraduateTopicNewForm extends Component{
handleSubmit = (e) => {
e.preventDefault();
const topicId = this.props.match.params.topicId
const topicId = this.props.topicId
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
if (topicId !=undefined) {
@ -149,14 +149,11 @@ class GraduateTopicNewForm extends Component{
})
}
const param = {
graduation_topic:{
...values,
province: values.city==undefined?"":values.city[0],
city: values.city==undefined?"":values.city[1],
},
attachment_ids
}
this.props.editSave(param,topicId);
this.props.editSave && this.props.editSave(param,attachment_ids,topicId);
} else {
// 新建
let attachment_ids = undefined
@ -165,15 +162,12 @@ class GraduateTopicNewForm extends Component{
return item.response.id
})
}
const param = {
graduation_topic:{
const param ={
...values,
province: values.city==undefined?"":values.city[0],
city: values.city==undefined?"":values.city[1],
},
attachment_ids,
}
this.props.newSubmit(param,topicId);
this.props.newSubmit && this.props.newSubmit(param,attachment_ids,topicId);
}
} else {
$("html").animate({ scrollTop: $('html').scrollTop() - 100 })
@ -226,11 +220,13 @@ class GraduateTopicNewForm extends Component{
return isLt150M;
},
};
let { topicId }=this.props;
let { topicId , teacherName }=this.props;
return(
<React.Fragment>
<Form {...formItemLayout} onSubmit={this.handleSubmit}>
<div className="createPage">
{
teacherName &&
<Form.Item
label="指导老师"
>
@ -250,6 +246,7 @@ class GraduateTopicNewForm extends Component{
</Select>
)}
</Form.Item>
}
<style>
{
`
@ -506,7 +503,7 @@ class GraduateTopicNewForm extends Component{
<Form.Item>
<div className="clearfix mt30 mb30">
<Button type="primary" htmlType="submit" className="defalutSubmitbtn fl mr20">{topicId==undefined?"提交":"保存"}</Button>
<a className="defalutCancelbtn fl" onClick={()=>this.props.history.goBack()}>取消</ a>
<a className="defalutCancelbtn fl" onClick={this.props.editCancel}>取消</ a>
</div>
</Form.Item>
</Form>

@ -12,6 +12,7 @@ import "../usersInfo.css"
import "../../../courses/css/members.css"
import "../../../courses/css/Courses.css"
import Loadable from 'react-loadable';
import Loading from '../../../../Loading';
@ -50,6 +51,7 @@ class BanksIndex extends Component{
initPublic:this.initPublic
}
return(
<div className="newMain">
<div className="educontent">
{
crumbData &&
@ -91,6 +93,7 @@ class BanksIndex extends Component{
</Switch>
</div>
</div>
)
}
}

@ -6,25 +6,30 @@ import GraduateTopicNewFrom from '../../../courses/graduation/topics/GraduateTop
class GtopicBanksEdit extends Component{
constructor(props){
super(props);
this.state = {
isPublic:undefined
}
}
componentDidMount = () =>{
let bankId = this.props.match.params.bankId
let bankId = this.props.match.params.bankId;
this.initData(bankId);
}
initData = (bankId) =>{
let url = `/gtopic_banks/${bankId}/edit.json`;
axios.get(url).then((result)=>{
if(result){
const crumbData={
title:'编辑',
is_public:true,
is_public:result && result.selected_data && result.selected_data.is_public,
crumbArray:[
{to:`/banks/gtopic/${bankId}/edit`,content:'详情'},
{content:'编辑'}
]
}
this.props.initPublic(crumbData);
this.initData(bankId);
}
initData = (bankId) =>{
let url = `/gtopic_banks/${bankId}/edit.json`;
axios.get(url).then((result)=>{
if(result){
this.GraduateTopicNewFromRef.initValue(result);
}
}).catch((error)=>{
@ -32,13 +37,43 @@ class GtopicBanksEdit extends Component{
})
}
// 编辑保存
editSave = (param,attachments,bankId) =>{
const url = `/gtopic_banks/${bankId}.json`;
let params = {
gtopic_bank:param,
attachment_ids:attachments
}
axios.put(url,params).then((result)=>{
if(result){
this.props.showNotification('保存成功!');
this.props.history.push(`/banks/gtopic/${bankId}`);
}
}).catch((error)=>{
console.log(error);
})
}
// 取消
editCancel = () =>{
this.props.history.push(`/banks/gtopic/${this.props.match.params.bankId}`);
}
render(){
let { bankId } = this.props.match.params
const common = {
editSave:this.editSave,
editCancel:this.editCancel
}
return(
<div className="courseForm">
<style>
{`
.courseForm .ant-col-sm-24{
text-align:left;
}
`}
</style>
<GraduateTopicNewFrom
{...this.props}
{...this.state}

Loading…
Cancel
Save