|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import {Button, Card, Row, Col ,Upload,Icon,message} from 'antd';
|
|
|
|
|
import {Button, Card, Row, Col ,Upload,Icon,message,Tabs} from 'antd';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import {getImageUrl,getUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder';
|
|
|
|
|
|
|
|
|
|
const { TabPane } = Tabs;
|
|
|
|
|
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
|
|
|
|
|
|
|
|
|
|
class CompetitionContentsMd extends Component{
|
|
|
|
@ -10,17 +10,48 @@ class CompetitionContentsMd extends Component{
|
|
|
|
|
super(props)
|
|
|
|
|
this.contentMdRef = React.createRef();
|
|
|
|
|
this.state={
|
|
|
|
|
contentFileList:[]
|
|
|
|
|
contentFileList:[],
|
|
|
|
|
chartmodule_id:undefined
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
componentDidUpdate =(prevState)=>{
|
|
|
|
|
if(prevState.tabkey!=this.props.tabkey){
|
|
|
|
|
this.getchartdata()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
window.document.title = '竞赛';
|
|
|
|
|
let {mdContentdata}=this.props;
|
|
|
|
|
// this.gettitledata()
|
|
|
|
|
|
|
|
|
|
this.getchartdata()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getchartdata=()=>{
|
|
|
|
|
let {mdContentdata,chart_rules}=this.props;
|
|
|
|
|
// is_pdf: false
|
|
|
|
|
//
|
|
|
|
|
if(this.props.module_type==="chart"){
|
|
|
|
|
let type=true;
|
|
|
|
|
chart_rules.rule_contents.map((items,keys)=>{
|
|
|
|
|
if(parseInt(this.props.tabkey)===items.competition_stage_id){
|
|
|
|
|
console.log(items)
|
|
|
|
|
this.contentMdRef.current.setValue(items.content);
|
|
|
|
|
this.setState({
|
|
|
|
|
contentFileList:undefined,
|
|
|
|
|
chartmodule_id:items.id
|
|
|
|
|
})
|
|
|
|
|
type=false;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if(type===true){
|
|
|
|
|
this.contentMdRef.current.setValue("");
|
|
|
|
|
this.setState({
|
|
|
|
|
contentFileList:undefined,
|
|
|
|
|
chartmodule_id:undefined
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
let contentFileList = mdContentdata===undefined?[]:mdContentdata.attachments===undefined?[]:mdContentdata.attachments.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
id: item.id,
|
|
|
|
@ -38,6 +69,7 @@ class CompetitionContentsMd extends Component{
|
|
|
|
|
this.contentMdRef.current.setValue(mdContentdata===undefined?"":mdContentdata.md_content===undefined?"":mdContentdata.md_content || '')
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleContentUploadChange = (info) => {
|
|
|
|
|
let contentFileList = info.fileList;
|
|
|
|
@ -45,7 +77,6 @@ class CompetitionContentsMd extends Component{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onAttachmentRemove = (file, stateName) => {
|
|
|
|
|
debugger
|
|
|
|
|
if(file.response!=undefined){
|
|
|
|
|
this.props.confirm({
|
|
|
|
|
content: '是否确认删除?',
|
|
|
|
@ -90,22 +121,37 @@ class CompetitionContentsMd extends Component{
|
|
|
|
|
handleSubmit = () => {
|
|
|
|
|
let {contentFileList}=this.state;
|
|
|
|
|
const mdContnet = this.contentMdRef.current.getValue().trim();
|
|
|
|
|
let attachment_ids = contentFileList.map(item => {
|
|
|
|
|
let attachment_ids=undefined
|
|
|
|
|
if(contentFileList!=undefined){
|
|
|
|
|
attachment_ids= contentFileList.map(item => {
|
|
|
|
|
return item.response ? item.response.id : item.id
|
|
|
|
|
})
|
|
|
|
|
console.log(attachment_ids)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let url=`/competitions/${this.props.match.params.identifier}/update_md_content.json`;
|
|
|
|
|
axios.post(url,{
|
|
|
|
|
let newstage_id=parseInt(this.props.tabkey)===0||null?undefined:parseInt(this.props.tabkey)
|
|
|
|
|
let data={}
|
|
|
|
|
if(this.props.module_type==="chart"){
|
|
|
|
|
data={
|
|
|
|
|
md_content_id:this.state.chartmodule_id,
|
|
|
|
|
competition_module_id:this.props.module_id,
|
|
|
|
|
stage_id:newstage_id,
|
|
|
|
|
content:mdContnet,
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
data={
|
|
|
|
|
md_content_id:this.props.mdContentdata.md_id,
|
|
|
|
|
competition_module_id:this.props.mdContentdata.id,
|
|
|
|
|
content:mdContnet,
|
|
|
|
|
attachment_ids:attachment_ids
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let url=`/competitions/${this.props.match.params.identifier}/update_md_content.json`;
|
|
|
|
|
axios.post(url,data
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if(response.data.status===0){
|
|
|
|
|
this.props.showNotification(response.data.message);
|
|
|
|
|
this.props.getlistdata(this.props.thiskeys);
|
|
|
|
|
this.props.getlistdata(this.props.thiskeys,this.props.tabkey);
|
|
|
|
|
this.props.hideCompetitionedit();
|
|
|
|
|
}else{
|
|
|
|
|
this.props.showNotification(response.data.message);
|
|
|
|
@ -117,6 +163,7 @@ class CompetitionContentsMd extends Component{
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
let {contentFileList}=this.state;
|
|
|
|
|
let {chart_rules}=this.props;
|
|
|
|
|
const uploadProps = {
|
|
|
|
|
width: 600,
|
|
|
|
|
fileList: contentFileList,
|
|
|
|
@ -136,18 +183,28 @@ class CompetitionContentsMd extends Component{
|
|
|
|
|
return isLt150M;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
console.log(contentFileList)
|
|
|
|
|
// console.log(this.props.tabkey)
|
|
|
|
|
// console.log(chart_rules)
|
|
|
|
|
// console.log(this.props.mdContentdata)
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{chart_rules===undefined?"":this.props.module_type==="chart"?<Tabs activeKey={this.props.tabkey} onChange={(e)=>this.props.Competitioncallback(e)}>
|
|
|
|
|
|
|
|
|
|
{chart_rules.stages.map((item,key)=>{
|
|
|
|
|
return(
|
|
|
|
|
<TabPane tab={item.name} key={item.id===null?0:item.id}></TabPane>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
</Tabs>:""}
|
|
|
|
|
<TPMMDEditor ref={this.contentMdRef} placeholder="请输入任务内容说明,最大限制5000个字符" mdID={'courseContentMD'} refreshTimeout={1500}
|
|
|
|
|
className="courseMessageMD" initValue={this.state.description}></TPMMDEditor>
|
|
|
|
|
<Upload {...uploadProps} className="upload_1 newWorkUpload">
|
|
|
|
|
{this.props.module_type==="chart"?"":<Upload {...uploadProps} className="upload_1 newWorkUpload">
|
|
|
|
|
<Button className="uploadBtn">
|
|
|
|
|
<Icon type="upload" /> 上传附件
|
|
|
|
|
</Button>
|
|
|
|
|
(单个文件150M以内)
|
|
|
|
|
</Upload>
|
|
|
|
|
</Upload>}
|
|
|
|
|
|
|
|
|
|
<div className="clearfix mt30 mb30">
|
|
|
|
|
{/* htmlType="submit" */}
|
|
|
|
|