|
|
|
@ -18,7 +18,8 @@ class NewGtaskForms extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initValue = (data) => {
|
|
|
|
|
if (data.isEdit) {
|
|
|
|
|
|
|
|
|
|
if (data.isEdit===true) {
|
|
|
|
|
const contentFileList = data.attachments.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
id: item.id,
|
|
|
|
@ -31,10 +32,10 @@ class NewGtaskForms extends Component{
|
|
|
|
|
})
|
|
|
|
|
this.setState({
|
|
|
|
|
...data,
|
|
|
|
|
base_on_project: data.group_info.base_on_project,
|
|
|
|
|
base_on_project: data.task_type===2?data.group_info.base_on_project:undefined,
|
|
|
|
|
title_num: parseInt(data.name.length),
|
|
|
|
|
min_num: data.group_info.min_number,
|
|
|
|
|
max_num: data.group_info.max_number,
|
|
|
|
|
min_num: data.task_type===2?data.group_info.min_number:undefined,
|
|
|
|
|
max_num: data.task_type===2?data.group_info.max_number:undefined,
|
|
|
|
|
contentFileList,
|
|
|
|
|
}, () => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
@ -47,9 +48,9 @@ class NewGtaskForms extends Component{
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
} else { // new
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -109,44 +110,41 @@ class NewGtaskForms extends Component{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleSubmit = () => {
|
|
|
|
|
debugger
|
|
|
|
|
|
|
|
|
|
let {contentFileList,min_num,max_num,base_on_project}=this.state;
|
|
|
|
|
let {data}=this.props;
|
|
|
|
|
let task_type=data.task_type
|
|
|
|
|
let topicId=this.props.topicId
|
|
|
|
|
this.props.form.validateFieldsAndScroll((err, values) => {
|
|
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
|
|
|
|
|
|
|
const mdContnet = this.contentMdRef.current.getValue().trim();
|
|
|
|
|
|
|
|
|
|
values.description = mdContnet;
|
|
|
|
|
|
|
|
|
|
if (!err) {
|
|
|
|
|
if (this.state.isEdit) {
|
|
|
|
|
if (this.props.data.isEdit===true) {
|
|
|
|
|
let url="/task_banks/"+topicId+".json";
|
|
|
|
|
axios.put(url, {
|
|
|
|
|
gtask_bank: {
|
|
|
|
|
name: values.title,
|
|
|
|
|
description: values.description,
|
|
|
|
|
min_num:task_type===1?undefined:min_num,
|
|
|
|
|
max_num:task_type===1?undefined:max_num,
|
|
|
|
|
base_on_project: task_type===1?undefined:base_on_project===true?1:0
|
|
|
|
|
},
|
|
|
|
|
attachment_ids:contentFileList
|
|
|
|
|
gtask_bank: {
|
|
|
|
|
name: values.title,
|
|
|
|
|
description: values.description,
|
|
|
|
|
min_num:task_type===1?undefined:min_num,
|
|
|
|
|
max_num:task_type===1?undefined:max_num,
|
|
|
|
|
base_on_project: task_type===1?undefined:base_on_project===true?1:0
|
|
|
|
|
},
|
|
|
|
|
attachment_ids:contentFileList
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if(response.data.status===0){
|
|
|
|
|
this.props.showNotification(response.data.message)
|
|
|
|
|
}else{
|
|
|
|
|
this.props.showNotification(response.data.message)
|
|
|
|
|
}
|
|
|
|
|
if(response.data.status===0){
|
|
|
|
|
this.props.showNotification(response.data.message)
|
|
|
|
|
}else{
|
|
|
|
|
this.props.showNotification(response.data.message)
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$("html").animate({ scrollTop: $('html').scrollTop() - 100 })
|
|
|
|
|
}
|
|
|
|
@ -222,7 +220,7 @@ class NewGtaskForms extends Component{
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<Form className="courseForm">
|
|
|
|
|
<Form className="courseForm" onClick={this.handleSubmit} >
|
|
|
|
|
<div className={"ant-row ant-form-item AboutInputForm newAboutInputForm "}>
|
|
|
|
|
<div className="ant-col ant-form-item-label margin0">
|
|
|
|
|
<label htmlFor="coursesNew_course" className="ant-form-item-required ">类型</label> <span className={"tasktypes"}>{this.props.data&&this.props.data.task_type===1?"普通作业":this.props.data&&this.props.data.task_type===2?"分组作业":""}</span>
|
|
|
|
@ -342,7 +340,7 @@ class NewGtaskForms extends Component{
|
|
|
|
|
<Form.Item>
|
|
|
|
|
<div className="clearfix mt30 mb30">
|
|
|
|
|
{/* htmlType="submit" */}
|
|
|
|
|
<Button type="primary" onClick={this.handleSubmit} className="defalutSubmitbtn fl mr20">提交</Button>
|
|
|
|
|
<Button type="primary" htmlType="submit" className="defalutSubmitbtn fl mr20">提交</Button>
|
|
|
|
|
<a className="defalutCancelbtn fl" onClick={() => this.props.onCancel()}>取消</ a>
|
|
|
|
|
</div>
|
|
|
|
|
</Form.Item>
|
|
|
|
|