|
|
|
@ -1,31 +1,33 @@
|
|
|
|
|
import React,{Component} from "React";
|
|
|
|
|
import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal} from "antd";
|
|
|
|
|
import React, {Component} from "React";
|
|
|
|
|
import {Form, Select, Input, Button, Checkbox, Upload, Icon, message, Modal} from "antd";
|
|
|
|
|
import {Link} from 'react-router-dom';
|
|
|
|
|
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
|
|
|
|
|
import { WordsBtn,getUrl} from 'educoder';
|
|
|
|
|
import {WordsBtn, getUrl} from 'educoder';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import Modals from '../../../modals/Modals';
|
|
|
|
|
import '../../css/Courses.css';
|
|
|
|
|
const { Option} = Select;
|
|
|
|
|
|
|
|
|
|
const {Option} = Select;
|
|
|
|
|
const CheckboxGroup = Checkbox.Group;
|
|
|
|
|
const confirm = Modal.confirm;
|
|
|
|
|
let GraduationTasksnewtype=true;
|
|
|
|
|
class GraduationTasksnew extends Component{
|
|
|
|
|
let GraduationTasksnewtype = true;
|
|
|
|
|
|
|
|
|
|
class GraduationTasksnew extends Component {
|
|
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
|
this.state={
|
|
|
|
|
coursename:"",
|
|
|
|
|
coursesearch:"",
|
|
|
|
|
title_num:60,
|
|
|
|
|
title_value:"",
|
|
|
|
|
this.state = {
|
|
|
|
|
coursename: "",
|
|
|
|
|
coursesearch: "",
|
|
|
|
|
title_num: 60,
|
|
|
|
|
title_value: "",
|
|
|
|
|
fileList: [],
|
|
|
|
|
contents: [{val:"",id:1}],
|
|
|
|
|
type:true
|
|
|
|
|
contents: [{val: "", id: 1}],
|
|
|
|
|
type: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
// const query =this.props.location.search;
|
|
|
|
|
//
|
|
|
|
|
// const type = query.split('&');
|
|
|
|
@ -39,57 +41,57 @@ class GraduationTasksnew extends Component{
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scrollToAnchors=(anchorName)=>{
|
|
|
|
|
scrollToAnchors = (anchorName) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
anchor:anchorName
|
|
|
|
|
anchor: anchorName
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleSubmit=(e) => {
|
|
|
|
|
let {fileList}=this.state;
|
|
|
|
|
let listid=[]
|
|
|
|
|
handleSubmit = (e) => {
|
|
|
|
|
let {fileList} = this.state;
|
|
|
|
|
let listid = []
|
|
|
|
|
|
|
|
|
|
for(var list of fileList){
|
|
|
|
|
for (var list of fileList) {
|
|
|
|
|
listid.push(list.response.id)
|
|
|
|
|
}
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if( GraduationTasksnewtype===true){
|
|
|
|
|
if (GraduationTasksnewtype === true) {
|
|
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
|
|
if (!err) {
|
|
|
|
|
if(values.tasktype===undefined){
|
|
|
|
|
if (values.tasktype === undefined) {
|
|
|
|
|
this.scrollToAnchors("tasktypes");
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(values.name===undefined){
|
|
|
|
|
if (values.name === undefined) {
|
|
|
|
|
this.scrollToAnchors("nametypes");
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(values.description===undefined){
|
|
|
|
|
if (values.description === undefined) {
|
|
|
|
|
this.scrollToAnchors("descriptiontypes");
|
|
|
|
|
return
|
|
|
|
|
}else if(values.description.length>5000){
|
|
|
|
|
} else if (values.description.length > 5000) {
|
|
|
|
|
this.scrollToAnchors("descriptiontypes");
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
console.log('Received values of form: ', values);
|
|
|
|
|
console.log(fileList);
|
|
|
|
|
const course_id=this.props.match.params.coursesId;
|
|
|
|
|
const course_id = this.props.match.params.coursesId;
|
|
|
|
|
|
|
|
|
|
let url="/courses/"+course_id+"/graduation_tasks.json"
|
|
|
|
|
let url = "/courses/" + course_id + "/graduation_tasks.json"
|
|
|
|
|
axios.post(url, {
|
|
|
|
|
task_type:parseInt(values.tasktype),
|
|
|
|
|
name:values.name,
|
|
|
|
|
description:values.description,
|
|
|
|
|
attachment_ids:listid,
|
|
|
|
|
task_type: parseInt(values.tasktype),
|
|
|
|
|
name: values.name,
|
|
|
|
|
description: values.description,
|
|
|
|
|
attachment_ids: listid,
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if(response.status===200) {
|
|
|
|
|
GraduationTasksnewtype=false;
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
GraduationTasksnewtype = false;
|
|
|
|
|
// this.goback();
|
|
|
|
|
this.props.history.push("/courses/"+this.props.match.params.coursesId+"/graduation_tasks/"+this.props.match.params.category_id+"/"+response.data.task_id+"/setting");
|
|
|
|
|
this.props.history.push("/courses/" + this.props.match.params.coursesId + "/graduation_tasks/" + this.props.match.params.category_id + "/" + response.data.task_id + "/setting");
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
@ -103,20 +105,20 @@ class GraduationTasksnew extends Component{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
goback=()=>{
|
|
|
|
|
let courseId=this.props.match.params.coursesId;
|
|
|
|
|
let category_id=this.props.match.params.category_id;
|
|
|
|
|
goback = () => {
|
|
|
|
|
let courseId = this.props.match.params.coursesId;
|
|
|
|
|
let category_id = this.props.match.params.category_id;
|
|
|
|
|
|
|
|
|
|
window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id;
|
|
|
|
|
window.location.href = "/courses/" + courseId + "/graduation_tasks/" + category_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 输入title
|
|
|
|
|
changeTitle=(e)=>{
|
|
|
|
|
changeTitle = (e) => {
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
title_num:60-parseInt(e.target.value.length),
|
|
|
|
|
title_value:e.target.value
|
|
|
|
|
title_num: 60 - parseInt(e.target.value.length),
|
|
|
|
|
title_value: e.target.value
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -127,7 +129,7 @@ class GraduationTasksnew extends Component{
|
|
|
|
|
// for(var list of fileList ){
|
|
|
|
|
// console.log(list)
|
|
|
|
|
// }
|
|
|
|
|
this.setState({ fileList });
|
|
|
|
|
this.setState({fileList});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onAttachmentRemove = (file) => {
|
|
|
|
@ -146,30 +148,29 @@ class GraduationTasksnew extends Component{
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
Modalstype:true,
|
|
|
|
|
Modalstopval:'确定要删除这个附件吗?',
|
|
|
|
|
ModalSave: ()=>this.deleteAttachment(file),
|
|
|
|
|
ModalCancel:this.cancelAttachment
|
|
|
|
|
Modalstype: true,
|
|
|
|
|
Modalstopval: '确定要删除这个附件吗?',
|
|
|
|
|
ModalSave: () => this.deleteAttachment(file),
|
|
|
|
|
ModalCancel: this.cancelAttachment
|
|
|
|
|
})
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cancelAttachment=()=>{
|
|
|
|
|
cancelAttachment = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
Modalstype:false,
|
|
|
|
|
Modalstopval:'确定要删除这个附件吗?',
|
|
|
|
|
ModalSave:"",
|
|
|
|
|
ModalCancel:""
|
|
|
|
|
Modalstype: false,
|
|
|
|
|
Modalstopval: '确定要删除这个附件吗?',
|
|
|
|
|
ModalSave: "",
|
|
|
|
|
ModalCancel: ""
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteAttachment = (file) => {
|
|
|
|
|
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
|
|
|
|
|
axios.delete(url, {
|
|
|
|
|
})
|
|
|
|
|
axios.delete(url, {})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.data) {
|
|
|
|
|
const { status } = response.data;
|
|
|
|
|
const {status} = response.data;
|
|
|
|
|
if (status == 0) {
|
|
|
|
|
console.log('--- success')
|
|
|
|
|
|
|
|
|
@ -188,12 +189,13 @@ class GraduationTasksnew extends Component{
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//滚动
|
|
|
|
|
ifHasAnchorJustScorll() {
|
|
|
|
|
// let anchor = this.getURLStuff("anchor");
|
|
|
|
|
|
|
|
|
|
let anchor = this.state.anchor;
|
|
|
|
|
console.log("anchor ", anchor);
|
|
|
|
|
// console.log("anchor ", anchor);
|
|
|
|
|
// 对应id的话, 滚动到相应位置
|
|
|
|
|
if (!!anchor) {
|
|
|
|
|
let anchorElement = document.getElementById(anchor);
|
|
|
|
@ -206,16 +208,19 @@ class GraduationTasksnew extends Component{
|
|
|
|
|
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
render(){
|
|
|
|
|
const { getFieldDecorator } = this.props.form;
|
|
|
|
|
let {coursename,coursesearch,title_num,title_value,pageType,fileList,contents,type,
|
|
|
|
|
Modalstype,Modalstopval,ModalCancel,ModalSave} =this.state;
|
|
|
|
|
|
|
|
|
|
let {coursedata}=this.props;
|
|
|
|
|
render() {
|
|
|
|
|
const {getFieldDecorator} = this.props.form;
|
|
|
|
|
let {
|
|
|
|
|
coursename, coursesearch, title_num, title_value, pageType, fileList, contents, type,
|
|
|
|
|
Modalstype, Modalstopval, ModalCancel, ModalSave
|
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
|
|
let {coursedata} = this.props;
|
|
|
|
|
|
|
|
|
|
let courseId=this.props.match.params.coursesId;
|
|
|
|
|
let position=this.props.match.params.position;
|
|
|
|
|
let category_id=this.props.match.params.category_id;
|
|
|
|
|
let courseId = this.props.match.params.coursesId;
|
|
|
|
|
let position = this.props.match.params.position;
|
|
|
|
|
let category_id = this.props.match.params.category_id;
|
|
|
|
|
const uploadProps = {
|
|
|
|
|
width: 600,
|
|
|
|
|
fileList,
|
|
|
|
@ -235,10 +240,10 @@ render(){
|
|
|
|
|
return isLt150M;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
this.ifHasAnchorJustScorll();
|
|
|
|
|
// this.ifHasAnchorJustScorll();
|
|
|
|
|
// console.log(this.props.current_user.course_name)
|
|
|
|
|
return(
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
{/*提示*/}
|
|
|
|
@ -252,45 +257,70 @@ render(){
|
|
|
|
|
<div className={"educontent mb20"}>
|
|
|
|
|
|
|
|
|
|
<p className="clearfix mt10">
|
|
|
|
|
<WordsBtn style="grey" className="fl"> <Link to={"/courses/"+courseId+"/students"} className="color-grey-6">{this.props.current_user&&this.props.current_user.course_name}</Link></WordsBtn>
|
|
|
|
|
<WordsBtn style="grey" className="fl"> <Link to={"/courses/" + courseId + "/students"}
|
|
|
|
|
className="color-grey-6">{this.props.current_user && this.props.current_user.course_name}</Link></WordsBtn>
|
|
|
|
|
<span className="color-grey-9 fl ml3 mr3">></span>
|
|
|
|
|
<WordsBtn style="grey" className="fl"> <Link to={"/courses/"+courseId+"/graduation_tasks/"+category_id} className="color-grey-6">毕设任务</Link></WordsBtn>
|
|
|
|
|
<WordsBtn style="grey" className="fl"> <Link
|
|
|
|
|
to={"/courses/" + courseId + "/graduation_tasks/" + category_id} className="color-grey-6">毕设任务</Link></WordsBtn>
|
|
|
|
|
<span className="color-grey-9 fl ml3 mr3">></span>
|
|
|
|
|
<span>{"新建"}</span>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<div style={{ width:'100%',height:'75px'}} >
|
|
|
|
|
<p className=" fl color-black mt25 summaryname">新建毕设任务</p>
|
|
|
|
|
<div style={{width: '100%', height: '60px'}}>
|
|
|
|
|
<p className=" fl color-black mt20 summaryname">新建毕设任务</p>
|
|
|
|
|
<a className="color-grey-6 fr font-16 ml30 mt10 mr20" onClick={this.goback}>返回</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Form labelCol={{ span: 5 }} wrapperCol={{ span: 12 }} onSubmit={GraduationTasksnewtype===true?this.handleSubmit:""} >
|
|
|
|
|
|
|
|
|
|
<Form labelCol={{span: 5}} wrapperCol={{span: 12}}
|
|
|
|
|
onSubmit={GraduationTasksnewtype === true ? this.handleSubmit : ""}>
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`.ant-form-item-label{
|
|
|
|
|
text-align: right;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
padding: 0px 0px 20px 0px;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
line-height: 20px; */
|
|
|
|
|
}
|
|
|
|
|
.ant-form-item-control{
|
|
|
|
|
line-height: 39.9999px;
|
|
|
|
|
position: relative;
|
|
|
|
|
zoom: 1;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
{/*内容*/}
|
|
|
|
|
<div className="stud-class-set bor-bottom-greyE pd20 edu-back-white">
|
|
|
|
|
<div className="stud-class-set bor-bottom-greyE pt20 pl20 pr20 edu-back-white">
|
|
|
|
|
|
|
|
|
|
<Form.Item label="类型">
|
|
|
|
|
<Form.Item label="类型" >
|
|
|
|
|
{getFieldDecorator('tasktype', {
|
|
|
|
|
rules: [{ required: true, message: "请选择任务类型" }],
|
|
|
|
|
})(<Select className={"greyInput"}
|
|
|
|
|
style={{width:'20%'}}
|
|
|
|
|
rules: [{required: true, message: "请选择任务类型"}],
|
|
|
|
|
})(<Select className={"greyInput mb20"}
|
|
|
|
|
style={{width: '20%'}}
|
|
|
|
|
placeholder="请选择任务类型">
|
|
|
|
|
<Option value="1">普通</Option>
|
|
|
|
|
<Option value="2">分组</Option>
|
|
|
|
|
</Select>)}
|
|
|
|
|
<input type="hidden" id='tasktypes' />
|
|
|
|
|
<input type="hidden" id='tasktypes'/>
|
|
|
|
|
<span className={"newcoursestitle"}>(选择确认后,无法修改)</span>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item label="任务标题" >
|
|
|
|
|
{getFieldDecorator('name', {
|
|
|
|
|
rules: [{ required: true, message: "不能为空" }],
|
|
|
|
|
})(<Input placeholder="请输入任务名称,最大限制60个字符" value={title_value} onInput={this.changeTitle} className="searchView searchViewAfter" style={{"width":"100%"}} maxLength="60" addonAfter={String(title_num)}/>)}
|
|
|
|
|
rules: [{required: true, message: "不能为空"}],
|
|
|
|
|
})(<Input placeholder="请输入任务名称,最大限制60个字符" value={title_value} onInput={this.changeTitle}
|
|
|
|
|
className="searchView searchViewAfter mb20 h40" style={{"width": "100%"}} maxLength="60"
|
|
|
|
|
addonAfter={String(title_num)}/>)}
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<input type="hidden" id='nametypes' />
|
|
|
|
|
<input type="hidden" id='nametypes'/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="stud-class-set pd20 coursenavbox edu-back-white">
|
|
|
|
|
<div className="stud-class-set pt20 pl20 pr20 coursenavbox edu-back-white">
|
|
|
|
|
<style>{`
|
|
|
|
|
.uploadBtn.ant-btn {
|
|
|
|
|
border: none;
|
|
|
|
@ -324,10 +354,10 @@ render(){
|
|
|
|
|
mdID={'courseMessageMD'} className="courseMessageMD"></TPMMDEditor>
|
|
|
|
|
)}
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<input type="hidden" id='descriptiontypes' />
|
|
|
|
|
<input type="hidden" id='descriptiontypes'/>
|
|
|
|
|
<Upload {...uploadProps} className="upload_1 ml5">
|
|
|
|
|
<Button className="uploadBtn">
|
|
|
|
|
<Icon type="upload" /> 上传附件
|
|
|
|
|
<Icon type="upload"/> 上传附件
|
|
|
|
|
</Button>
|
|
|
|
|
(单个文件150M以内)
|
|
|
|
|
</Upload>
|
|
|
|
@ -346,10 +376,11 @@ render(){
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const GraduationTasksnewApp = Form.create({ name: 'coursesNew' })(GraduationTasksnew);
|
|
|
|
|
|
|
|
|
|
const GraduationTasksnewApp = Form.create({name: 'coursesNew'})(GraduationTasksnew);
|
|
|
|
|
export default GraduationTasksnewApp;
|