-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {chart_rules===undefined?"":
this.props.Competitioncallback(e)} activeKey={this.props.tabkey} tabBarExtraContent={this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true?this.props.Competitionedittype===false?operations:"":""}>
+
+ {chart_rules.stages.map((item,key)=>{
+ return(
+
+ {chart_rules.rule_contents.map((items,keys)=>{
+ if(item.id===items.competition_stage_id){
+ return(
+
+
+ )
+ }else if(item.id===null&&items.competition_stage_id===0){
+ return(
+
+
+ )
+ }
+ })}
+
+ )
+ })}
+
+ }
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js
index 8a1bd9fd6..52ac666c1 100644
--- a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js
+++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js
@@ -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,33 +10,65 @@ 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,
- uid: item.id,
- name: appendFileSizeToUploadFile(item),
- url: item.url,
- filesize: item.filesize,
- status: 'done',
- response:{id: item.id}
- }
- })
- this.setState({
- contentFileList:contentFileList
- })
- this.contentMdRef.current.setValue(mdContentdata===undefined?"":mdContentdata.md_content===undefined?"":mdContentdata.md_content || '')
+ return {
+ id: item.id,
+ uid: item.id,
+ name: appendFileSizeToUploadFile(item),
+ url: item.url,
+ filesize: item.filesize,
+ status: 'done',
+ response:{id: item.id}
+ }
+ })
+ this.setState({
+ contentFileList:contentFileList
+ })
+ this.contentMdRef.current.setValue(mdContentdata===undefined?"":mdContentdata.md_content===undefined?"":mdContentdata.md_content || '')
+ }
}
handleContentUploadChange = (info) => {
@@ -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 => {
- return item.response ? item.response.id : item.id
- })
- console.log(attachment_ids)
+ let attachment_ids=undefined
+ if(contentFileList!=undefined){
+ attachment_ids= contentFileList.map(item => {
+ return item.response ? item.response.id : item.id
+ })
+ }
- let url=`/competitions/${this.props.match.params.identifier}/update_md_content.json`;
- axios.post(url,{
- md_content_id:this.props.mdContentdata.md_id,
- competition_module_id:this.props.mdContentdata.id,
- content:mdContnet,
- attachment_ids:attachment_ids
+ 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 (
+ {chart_rules===undefined?"":this.props.module_type==="chart"?
this.props.Competitioncallback(e)}>
+
+ {chart_rules.stages.map((item,key)=>{
+ return(
+
+ )
+ })}
+ :""}
-
+ {this.props.module_type==="chart"?"":
(单个文件150M以内)
-
+ }
{/* htmlType="submit" */}
diff --git a/public/react/src/modules/competitions/Competitions.js b/public/react/src/modules/competitions/Competitions.js
index bc9623e6f..4ec33b43b 100644
--- a/public/react/src/modules/competitions/Competitions.js
+++ b/public/react/src/modules/competitions/Competitions.js
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { Redirect } from 'react-router';
-import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom";
+import { Route, Link, Switch } from "react-router-dom";
import Loading from '../../Loading';
@@ -41,8 +41,7 @@ class Competitions extends Component {
}
componentDidMount(){
- console.log("Competitions竞赛");
- console.log(this.props);
+
window.document.title = '竞赛';
}