|
|
|
@ -11,23 +11,23 @@ const confirm = Modal.confirm;
|
|
|
|
|
const $ = window.$
|
|
|
|
|
const MAX_TITLE_LENGTH = 60;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
需要注意的props
|
|
|
|
|
isGroup
|
|
|
|
|
*/
|
|
|
|
|
*/
|
|
|
|
|
class NewWorkForm extends Component{
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props);
|
|
|
|
|
this.contentMdRef = React.createRef();
|
|
|
|
|
this.answerMdRef = React.createRef();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.state={
|
|
|
|
|
title_value:"",
|
|
|
|
|
title_num: 0,
|
|
|
|
|
contentFileList: [],
|
|
|
|
|
answerFileList: [],
|
|
|
|
|
workLoaded: false,
|
|
|
|
|
base_on_project: true,
|
|
|
|
|
base_on_project: false,
|
|
|
|
|
category: {},
|
|
|
|
|
min_num: 2,
|
|
|
|
|
max_num: 10,
|
|
|
|
@ -73,7 +73,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// this._scrollToTop()
|
|
|
|
|
// 阻止setValue的滚动
|
|
|
|
|
// $(window).scroll( function() {
|
|
|
|
|
// $(window).scroll( function() {
|
|
|
|
|
// $("html").scrollTop(0)
|
|
|
|
|
// $(window).unbind("scroll");
|
|
|
|
|
// });
|
|
|
|
@ -87,13 +87,13 @@ class NewWorkForm extends Component{
|
|
|
|
|
// $('.editormd').parent().css('position', '').css('left', 'auto')
|
|
|
|
|
// }, 100);
|
|
|
|
|
// }, 500)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.props.form.setFieldsValue({
|
|
|
|
|
title: data.name,
|
|
|
|
|
description: data.description || '',
|
|
|
|
|
reference_answer: data.reference_answer || '',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
} else { // new
|
|
|
|
|
|
|
|
|
@ -116,7 +116,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
}
|
|
|
|
|
handleSubmit = () => {
|
|
|
|
|
const courseId = this.state.course_id || this.props.match.params.coursesId ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.props.form.validateFieldsAndScroll((err, values) => {
|
|
|
|
|
if(err && err.personNum) delete err.personNum;
|
|
|
|
|
console.log(values)
|
|
|
|
@ -124,7 +124,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
console.log(mdContnet)
|
|
|
|
|
values.description = mdContnet;
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* max={has_commit ? init_min_num : null } */}
|
|
|
|
|
{/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */}
|
|
|
|
|
// 已有提交作品,人数范围只能扩大
|
|
|
|
@ -143,8 +143,8 @@ class NewWorkForm extends Component{
|
|
|
|
|
} else if (max_num < min_num) {
|
|
|
|
|
this.props.showNotification('最大人数不能小于最小人数');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (has_commit) {
|
|
|
|
|
if (max_num < init_max_num || min_num > init_min_num) {
|
|
|
|
|
this.props.showNotification(`已有提交作品,人数范围只能扩大(原设置为:${init_min_num} - ${init_max_num})`)
|
|
|
|
@ -160,7 +160,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
} else {
|
|
|
|
|
this.doNew(courseId, values)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$("html").animate({ scrollTop: $('html').scrollTop() - 100 })
|
|
|
|
|
}
|
|
|
|
@ -181,7 +181,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
type: isGroup ? 3 : 1,
|
|
|
|
|
name: values.title,
|
|
|
|
|
description: values.description,
|
|
|
|
|
reference_answer: values.reference_answer,
|
|
|
|
|
reference_answer: values.reference_answer,
|
|
|
|
|
attachment_ids,
|
|
|
|
|
reference_attachment_ids,
|
|
|
|
|
|
|
|
|
@ -200,12 +200,12 @@ class NewWorkForm extends Component{
|
|
|
|
|
})
|
|
|
|
|
const isGroup = this.props.isGroup()
|
|
|
|
|
const { min_num, max_num, base_on_project, category } = this.state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
type: isGroup ? 3 : 1,
|
|
|
|
|
name: values.title,
|
|
|
|
|
description: values.description,
|
|
|
|
|
reference_answer: values.reference_answer,
|
|
|
|
|
reference_answer: values.reference_answer,
|
|
|
|
|
attachment_ids,
|
|
|
|
|
reference_attachment_ids,
|
|
|
|
|
|
|
|
|
@ -214,7 +214,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
base_on_project
|
|
|
|
|
}
|
|
|
|
|
this.props.doNew && this.props.doNew(params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleContentUploadChange = (info) => {
|
|
|
|
@ -229,12 +229,12 @@ class NewWorkForm extends Component{
|
|
|
|
|
this.setState({ answerFileList: appendFileSizeToUploadFileAll(answerFileList) });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onAttachmentRemove = (file, stateName) => {
|
|
|
|
|
if(!file.percent || file.percent == 100){
|
|
|
|
|
this.props.confirm({
|
|
|
|
|
content: '是否确认删除?',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onOk: () => {
|
|
|
|
|
this.deleteAttachment(file, stateName)
|
|
|
|
|
},
|
|
|
|
@ -255,7 +255,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
const { status } = response.data;
|
|
|
|
|
if (status == 0) {
|
|
|
|
|
console.log('--- success')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.setState((state) => {
|
|
|
|
|
const index = state[stateName].indexOf(file);
|
|
|
|
|
const newFileList = state[stateName].slice();
|
|
|
|
@ -273,13 +273,13 @@ class NewWorkForm extends Component{
|
|
|
|
|
}
|
|
|
|
|
max_num_change = (val) => {
|
|
|
|
|
if (val < 2) {
|
|
|
|
|
// this.setState({
|
|
|
|
|
// this.setState({
|
|
|
|
|
// max_num: 2,
|
|
|
|
|
// })
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const { min_num } = this.state;
|
|
|
|
|
this.setState({
|
|
|
|
|
this.setState({
|
|
|
|
|
max_num: val,
|
|
|
|
|
min_num: val <= min_num ? val - 1 : min_num
|
|
|
|
|
})
|
|
|
|
@ -309,23 +309,23 @@ class NewWorkForm extends Component{
|
|
|
|
|
window.$('.groupSetting .ant-form-item-label > label').addClass('ant-form-item-required')
|
|
|
|
|
this._scrollToTop()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
let {typeId,coursesId,pageType}=this.props.match.params;
|
|
|
|
|
const { getFieldDecorator } = this.props.form;
|
|
|
|
|
const isGroup = this.props.isGroup()
|
|
|
|
|
let{
|
|
|
|
|
title_value, contentFileList, answerFileList, max_num, min_num, base_on_project,
|
|
|
|
|
init_max_num, init_min_num,
|
|
|
|
|
init_max_num, init_min_num,
|
|
|
|
|
title_num, course_name, category, has_commit, has_project
|
|
|
|
|
}=this.state
|
|
|
|
|
const { current_user } = this.props
|
|
|
|
|
|
|
|
|
|
const courseId = this.state.course_id || this.props.match.params.coursesId ;
|
|
|
|
|
const courseId = this.state.course_id || this.props.match.params.coursesId ;
|
|
|
|
|
this.isEdit = this.isEdit || this.props.match.url.indexOf('/edit') != -1
|
|
|
|
|
if ((this.isEdit) && !this.state.description && this.state.description != '') {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const uploadProps = {
|
|
|
|
|
width: 600,
|
|
|
|
|
fileList: contentFileList,
|
|
|
|
@ -367,7 +367,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
@ -383,7 +383,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="标题"
|
|
|
|
|
className="AboutInputForm"
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{getFieldDecorator('title', {
|
|
|
|
|
rules: [{
|
|
|
|
|
required: true, message: '请输入标题'
|
|
|
|
@ -442,7 +442,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
{ <Form.Item
|
|
|
|
|
label="内容"
|
|
|
|
|
className="AboutInputForm workContent mdInForm"
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{getFieldDecorator('description', {
|
|
|
|
|
rules: [{
|
|
|
|
|
required: true, message: '请输入作业内容和要求',
|
|
|
|
@ -450,7 +450,7 @@ class NewWorkForm extends Component{
|
|
|
|
|
max: 5000 , message:'最大限制5000个字符'
|
|
|
|
|
}],
|
|
|
|
|
})(
|
|
|
|
|
<TPMMDEditor ref={this.contentMdRef} placeholder="请在此输入作业内容和要求,最大限制5000个字符" mdID={'courseContentMD'} refreshTimeout={1500}
|
|
|
|
|
<TPMMDEditor ref={this.contentMdRef} placeholder="请在此输入作业内容和要求,最大限制5000个字符" mdID={'courseContentMD'} refreshTimeout={1500}
|
|
|
|
|
initValue={this.state.description} noSetValueOnInit={!!this.isEdit}
|
|
|
|
|
className="courseMessageMD" ></TPMMDEditor>
|
|
|
|
|
)}
|
|
|
|
@ -461,13 +461,13 @@ class NewWorkForm extends Component{
|
|
|
|
|
</Button>
|
|
|
|
|
(单个文件150M以内)
|
|
|
|
|
</Upload>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ isGroup &&
|
|
|
|
|
|
|
|
|
|
{ isGroup &&
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="分组设置"
|
|
|
|
|
className="AboutInputForm groupSetting"
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{getFieldDecorator('personNum', {
|
|
|
|
|
validateTrigger: 'onNone',
|
|
|
|
|
// rules: [{
|
|
|
|
@ -481,11 +481,11 @@ class NewWorkForm extends Component{
|
|
|
|
|
<p className="clearfix">
|
|
|
|
|
<ConditionToolTip condition={has_commit} title={'已有提交作品,人数范围只能扩大'}>
|
|
|
|
|
{/* max={has_commit ? init_min_num : null } */}
|
|
|
|
|
<InputNumber placeholder="请填写每组最小人数" min={1} className="winput-240-40" value={min_num}
|
|
|
|
|
|
|
|
|
|
<InputNumber placeholder="请填写每组最小人数" min={1} className="winput-240-40" value={min_num}
|
|
|
|
|
|
|
|
|
|
onChange={this.min_num_change} style={{width:'180px'}} />
|
|
|
|
|
</ConditionToolTip>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span className="ml15 mr15">~</span>
|
|
|
|
|
{/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */}
|
|
|
|
|
<ConditionToolTip condition={has_commit} title={'已有提交作品,人数范围只能扩大'}>
|
|
|
|
@ -494,18 +494,18 @@ class NewWorkForm extends Component{
|
|
|
|
|
</ConditionToolTip>
|
|
|
|
|
<label className="color-grey-9 ml20 font-14">(学生提交作品时需要关联同组成员,组内成员作品共享)</label>
|
|
|
|
|
</p>
|
|
|
|
|
<p className="mt20">
|
|
|
|
|
<ConditionToolTip condition={has_commit || has_project} title={'已有关联项目或作品,不能修改'}>
|
|
|
|
|
<Checkbox checked={base_on_project} onChange={this.base_on_project_change}
|
|
|
|
|
disabled={has_project || has_commit}
|
|
|
|
|
>基于项目实施</Checkbox>
|
|
|
|
|
</ConditionToolTip>
|
|
|
|
|
|
|
|
|
|
<label className="color-grey-9 ml12 font-14">(选中,则必须在本平台创建项目,项目管理员可以提交作品;不选中,无需在平台创建项目,任意小组成员均可以提交作品)</label>
|
|
|
|
|
</p>
|
|
|
|
|
{/*<p className="mt20">*/}
|
|
|
|
|
{/* <ConditionToolTip condition={has_commit || has_project} title={'已有关联项目或作品,不能修改'}>*/}
|
|
|
|
|
{/* <Checkbox checked={base_on_project} onChange={this.base_on_project_change}*/}
|
|
|
|
|
{/* disabled={has_project || has_commit}*/}
|
|
|
|
|
{/* >基于项目实施</Checkbox>*/}
|
|
|
|
|
{/* </ConditionToolTip>*/}
|
|
|
|
|
{/* */}
|
|
|
|
|
{/* /!*<label className="color-grey-9 ml12 font-14">(选中,则必须在本平台创建项目,项目管理员可以提交作品;不选中,无需在平台创建项目,任意小组成员均可以提交作品)</label>*!/*/}
|
|
|
|
|
{/*</p>*/}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
}
|
|
|
|
|
<div className="edu-back-white">
|
|
|
|
@ -513,13 +513,13 @@ class NewWorkForm extends Component{
|
|
|
|
|
label="参考答案"
|
|
|
|
|
className="AboutInputForm clearPaddingBottom pr"
|
|
|
|
|
style={{"borderBottom":"none"}}
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{getFieldDecorator('reference_answer', {
|
|
|
|
|
rules: [{
|
|
|
|
|
max: 5000 , message:'最大限制5000个字符'
|
|
|
|
|
}],
|
|
|
|
|
})(
|
|
|
|
|
<TPMMDEditor ref={this.answerMdRef} placeholder="请在此输入作业的参考答案,最大限制5000个字符" mdID={'workAnswerMD'}
|
|
|
|
|
<TPMMDEditor ref={this.answerMdRef} placeholder="请在此输入作业的参考答案,最大限制5000个字符" mdID={'workAnswerMD'}
|
|
|
|
|
initValue={this.state.reference_answer || ''} noSetValueOnInit={!!this.isEdit}
|
|
|
|
|
className="courseMessageMD" refreshTimeout={1500} ></TPMMDEditor>
|
|
|
|
|
)}
|
|
|
|
@ -539,10 +539,10 @@ class NewWorkForm extends Component{
|
|
|
|
|
</div>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const WrappedWorkForm = Form.create({ name: 'NewWorkForm' })(NewWorkForm);
|
|
|
|
|
export default WrappedWorkForm;
|
|
|
|
|
export default WrappedWorkForm;
|
|
|
|
|