封装open pdf 新开页下载

dev_oauth
杨树明 6 years ago
parent 0c193369b4
commit 54121df076

@ -549,6 +549,7 @@ a:hover.task-btn-orange{background: #459BE6;}
a.user_bluebg_btn{background-color:#4CACFF;color: #fff;}
a.user_orangebg_btn{background-color:#FF6800;color: #fff;}
a.user_greybg_btn{background-color:#747A7F;color: #fff;}
/*.user_white_btn{border: 1px solid #ffffff;color: #ffffff!important;}*/
.pointer{cursor: pointer}

@ -826,7 +826,9 @@ class CoursesIndex extends Component{
}
></Route>
{/*新建金品课堂*/}
<Route path="/courses/newgold"
{/*coursesId 课堂id */}
{/*id 是否是私有或者公有*/}
<Route path="/courses/:coursesId/newgold/:id"
render={
(props) => (<WrappedCoursesNewAppGoldclass {...this.props} {...props} {...this.state} />)
}
@ -837,8 +839,12 @@ class CoursesIndex extends Component{
(props) => (<WrappedCoursesNewApp {...this.props} {...props} {...this.state} />)
}
></Route>
{/*修改金品课堂*/}
<Route path="/courses/:coursesId/newgold/settings/:id"
render={
(props) => (<WrappedCoursesNewAppGoldclass {...this.props} {...props} {...this.state} />)
}
></Route>
{/* 实训作业子页面*/}
<Route path="/courses/:coursesId/shixun_homework/:category_id"
render={

@ -37,6 +37,10 @@ const Eduinforms= Loadable({
loader: () => import('./gradinforms/Eduinforms.js'),
loading: Loading,
});
const Elearning= Loadable({
loader: () => import('./elearning/Elearning.js'),
loading: Loading,
});
//
const Exercise= Loadable({
loader: () => import('./exercise/Exercise'),
@ -245,11 +249,19 @@ class ListPageIndex extends Component{
{/*公告栏列表*/}
<Route path="/courses/:id/informs"
<Route path="/courses/:coursesId/informs"
render={
(props) => (<Eduinforms {...this.props} {...props} {...this.state} />)
}
></Route>
{/*在线学习*/}
<Route
path="/courses/:coursesId/online_learning"
render={
(props) => (<Elearning {...this.props} {...props} {...this.state} />)
}
>
</Route>
{/* 实训作业页面*/}
<Route path="/courses/:coursesId/shixun_homeworks/:main_id"
render={

@ -11,7 +11,7 @@ import Modals from "../../modals/Modals";
import Guide from './CoursesGuide';
import AddStudentModal from '../members/modal/AddStudentModal'
import AddTeacherModal from '../members/modal/AddTeacherModal'
import Jointheclass from './Jointheclass'
// 点击按钮复制功能
// function jsCopy(){
// var e = document.getElementById("copy_invite_code");
@ -45,7 +45,9 @@ class CoursesBanner extends Component {
modalsBottomval: "",
antIcon:false,
coursedata:undefined,
is_guide:false
is_guide:false,
excellent:false,//是否是金品课堂
yslJointhe:false,
}
}
componentDidMount() {
@ -69,7 +71,7 @@ class CoursesBanner extends Component {
let data = result.data;
this.setState({
coursedata: data,
excellent:data.excellent,
})
}else{
this.onloadupdatabanner()
@ -107,6 +109,13 @@ class CoursesBanner extends Component {
}
};
//金品课堂的弹框
myyslgradin=()=>{
this.setState({
yslJointhe:true
})
}
showActionPoll=(i,s,ss)=>{
this.setState({
@ -342,17 +351,44 @@ class CoursesBanner extends Component {
}
postsettings=()=>{
window.location.href = "/courses/" + this.props.match.params.coursesId + "/settings";
}
};
postsettingstwo=()=>{
var id =1;
try {
if(this.state.coursedata.is_public){
id=1;
}else {
id=0;
}
}catch (e) {
}
window.location.href = " /courses/" + this.props.match.params.coursesId + "/newgold/settings"+id;
};
hideAccountProfile=()=>{
hideAccountProfile=()=>{
this.setState({
AccountProfiletype:false
})
}
};
ysljoinmodalCancel=()=>{
this.setState({
yslJointhe:false
})
};
ysljoinmodalCanceltwo=()=>{
this.setState({
yslJointhe:false
})
window.location.reload();
};
render() {
let { Addcoursestypes, coursedata, modalsType, modalsTopval, loadtype,modalsBottomval,antIcon,is_guide,AccountProfiletype} = this.state;
let { Addcoursestypes, coursedata,excellent, modalsType, modalsTopval, loadtype,modalsBottomval,antIcon,is_guide,AccountProfiletype} = this.state;
return (
<div>
@ -383,6 +419,7 @@ class CoursesBanner extends Component {
modalSave={this.ModalAction}
antIcon={antIcon}
></Modals>
<Jointheclass {...this.props} {...this.state} ysljoinmodalCancel={()=>this.ysljoinmodalCancel()} ysljoinmodalCanceltwo={()=>this.ysljoinmodalCanceltwo()}></Jointheclass>
<AddTeacherModal ref="addTeacherModal"
{...this.props}
isTeacher={this.state.isTeacher}
@ -437,7 +474,7 @@ class CoursesBanner extends Component {
</div>
{excellent===false?
<div>
{coursedata.switch_to_student === true ?
<Tooltip placement="bottom" title={
@ -485,6 +522,31 @@ class CoursesBanner extends Component {
> 退出课堂 </a>:""}
</div>
:
<div>
<style>
{
`
.user_white_btn{border: 1px solid #ffffff;color: #ffffff!important;}
`
}
</style>
{/*coursedata.course_identity === 6 是非课堂成员*/}
{coursedata.course_identity === 6&&coursedata.educoder_teacher===false?
<a className="fr user_default_btn user_white_btn mr20 font-18" style={{width:"130px"}}
onClick={() => this.myyslgradin()}>加入课堂</a>: ""}
{coursedata.course_identity === 6&&coursedata.educoder_teacher===true?
<a className="fr user_default_btn user_white_btn mr20 font-18" style={{width:"130px"}}
onClick={() => this.myyslgradin()}>加入课堂</a>: ""}
{this.props.isStudent()?<a className="fr user_default_btn user_blue_btn mr20 font-18"
onClick={() => this.exitclass()}
> 退出课堂 </a>:""}
</div>
}
<style>
{
@ -583,10 +645,10 @@ class CoursesBanner extends Component {
<li className={"mt7 mr10im"}>
<a onClick={()=>this.addStudent()}>
<span className="color-white fl font-16 bannerurli width100f">添加学生</span>
<span className={"color-white fl font-16 bannerurli width100f"}>添加学生</span>
</a>
</li>
{excellent===false?
<li className={"mt7 mr10im ml10"} style={{overflow:"hidden"}}>
<a>
<span className="color-grey-c fl font-16" style={{marginRight: "10px"}}>邀请码</span>
@ -612,7 +674,7 @@ class CoursesBanner extends Component {
<input id="copy_invite_code" value={coursedata.invite_code}/>
</span>
</a>
</li>
</li>:""}
<li className={"mt7 ml10 mr0 "}>
<style>
@ -623,6 +685,7 @@ class CoursesBanner extends Component {
}
</style>
<Popover placement="bottom" content={
excellent===false?
<ul className="sandianbox" style={{
display: 'block',
right: "-113px",
@ -646,6 +709,16 @@ class CoursesBanner extends Component {
{coursedata.is_admin===true?coursedata.course_identity <3?<div className={"defaults"} onClick={() => this.ActionPoll(1)}>删除</div>
:"":""}
</ul>
:
<ul className="sandianbox" style={{
display: 'block',
right: "-113px",
top: "20px"
}}>
<div className={"defaults"} onClick={this.postsettingstwo}>设置</div>
{coursedata.is_admin===true?coursedata.course_identity <3?<div className={"defaults"} onClick={() => this.ActionPoll(1)}>删除</div>
:"":""}
</ul>
} trigger="hover">
<i className="iconfont icon-weibiaoti12 color-white font-14 relative"></i>
</Popover>

@ -0,0 +1,70 @@
import React, { Component } from 'react';
import { Modal} from 'antd';
import axios from 'axios';
//加入金品课堂
class Jointheclass extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
// console.log("加入金品课堂");
// console.log(this.props);
}
modalCancel=()=>{
this.props.ysljoinmodalCancel();
};
setDownload=()=>{
var id=this.props.match.params.coursesId
var url = `/courses/${id}/join_excellent_course.json`;
axios.post(url).then((result) => {
if(result){
if(result.data){
if(result.data.status === 0){
this.props.showNotification(result.data.message);
this.props.ysljoinmodalCanceltwo();
}else {
this.props.showNotification(result.data.message);
}
}
}
}).catch((error) => {
console.log(error)
})
}
render() {
// console.log("加入金品课堂2");
// console.log(this.props);
return(
<Modal
keyboard={false}
closable={false}
footer={null}
destroyOnClose={true}
title="提示"
centered={true}
visible={this.props.yslJointhe===undefined?false:this.props.yslJointhe}
width="600px"
>
<div className="educouddiv">
<div className={"tabeltext-alignleft"}><p style={{fontSize: "16px",marginTop:"46px"}}>是否确认该加入课堂?</p></div>
<div className="clearfix edu-txt-center" style={{marginTop:"98px"}}>
<a className="task-btn mr30" onClick={()=>this.modalCancel()}>取消</a>
<a className="task-btn task-btn-orange" onClick={()=>this.setDownload()}>确认</a>
</div>
</div>
</Modal>
)
}
}
export default Jointheclass;

@ -0,0 +1,322 @@
import React,{ Component } from "react";
import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin,Button,Form,Icon,message,Progress} from "antd";
import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder';
import './myelearning.css'
import axios from 'axios';
import YslDetailCards from "./YslDetailCards.js";
import Jointheclass from '../coursesDetail/Jointheclass'
//在线学习
class Elearning extends Component{
constructor(props){
super(props);
this.state={
description:"", //简介
isSpin:true,
start_learning:undefined, //是否要开始学习 没开始学习 点击第一个是开始学习 就是学习下面的从第一个开始
learned:0, //学习进度
last_shixun:"", //上次学习的实训
stages:[], //实践课程的章节
yslJointhe:false,
shixunsreplace:false,
hidestartshixunsreplacevalue:"",
shixunsmessage:"",
startshixunCombattype:false,
isSpins:false,
}
}
componentDidMount() {
// 记得删除退出课堂
console.log("获取到数据");
console.log(this.props);
let url = `/courses/${this.props.match.params.coursesId}/online_learning.json`;
// //
axios.get(url).then((response) => {
if(response){
if(response.data){
console.log("获取到到数据");
console.log(response);
this.setState({
description: response.data.description,
start_learning:response.data.start_learning,
learned:response.data.learned,
last_shixun:response.data.last_shixun,
stages:response.data.stages,
});
}
}
this.setState({
isSpin:false,
})
}).catch((error) => {
console.log(error);
this.setState({
isSpin:false,
})
});
}
componentDidUpdate = (prevProps) => {
};
//开始学习
Startlearning=()=>{
if(this.props.isNotMember()===true){
this.setState({
yslJointhe:true
})
}else {
let {stages}=this.state;
if(stages.length>0){
for(var i=0;i<stages.length;i++){
if(i===0){
var id=stages[0].shixuns_list[0].identifier;
let url = "/shixuns/" + id + "/shixun_exec.json";
axios.get(url).then((response) => {
if (response.data.status === -2) {
this.setState({
shixunsreplaces:true,
hidestartshixunsreplacevalues:response.data.message+".json"
})
} else if (response.data.status === -1) {
console.log(response)
}else if(response.data.status===-3){
this.setState({
shixunsmessages:response.data.message,
startshixunCombattypes:true,
})
} else {
console.log("开始学习了");
window.open("/tasks/" + response.data.game_identifier,'_blank');
//这个是传过来 调用刷新
this.Myreload();
// window.location.href = path
// let path="/tasks/"+response.data.game_identifier;
// this.props.history.push(path);
}
}).catch((error) => {
});
break;
}
console.log("这是"+i);
}
}
}
};
Startlearningtwo=()=>{
this.setState({
yslJointhe:true
})
};
ysljoinmodalCancel=()=>{
this.setState({
yslJointhe:false
})
};
ysljoinmodalCanceltwo=()=>{
this.setState({
yslJointhe:false
})
window.location.reload();
};
Myreload = ()=>{
window.location.reload();
};
hidestartshixunsreplace=(url)=>{
this.setState({
isSpins:true,
})
axios.get(url).then((response) => {
// debugger
if(response.status===200){
// let path="/shixuns/"+response.data.shixun_identifier+"/challenges";
// this.props.history.push(path);
message.success('重置成功,正在进入实训!');
this.startgameid(response.data.shixun_identifier);
this.setState({
shixunsreplaces:false,
isSpins:false,
})
// message.success('重置成功,正在进入实训!');
// this.startshixunCombat();
}}
).catch((error) => {
this.setState({
isSpins:false,
shixunsreplaces:false,
})
});
};
startgameid=(id)=>{
if(this.props.isNotMember()===true){
//这个是外部传过来的
this.Startlearningtwo();
return
}
let url = "/shixuns/" + id + "/shixun_exec.json";
axios.get(url).then((response) => {
if (response.data.status === -2) {
this.setState({
shixunsreplaces:true,
hidestartshixunsreplacevalues:response.data.message+".json"
})
} else if (response.data.status === -1) {
console.log(response)
}else if(response.data.status===-3){
this.setState({
shixunsmessages:response.data.message,
startshixunCombattypes:true,
})
} else {
console.log("开始学习了");
window.open("/tasks/" + response.data.game_identifier,'_blank');
//这个是传过来 调用刷新
this.Myreload();
// window.location.href = path
// let path="/tasks/"+response.data.game_identifier;
// this.props.history.push(path);
}
}).catch((error) => {
});
};
hidestartshixunCombattype=()=>{
this.setState({
startshixunCombattypes:false
})
}
render(){
let{description,whethertoedit,isSpin,start_learning,hidestartshixunsreplacevalues,learned,last_shixun} =this.state;
const isNotMembers=this.props.isNotMember();//非课堂成员
const antIcon = <Icon type="loading" style={{ fontSize: 24 }} spin />;
return(
<React.Fragment >
<div id={"zhudiv"}>
<Jointheclass {...this.props} {...this.state} ysljoinmodalCancel={()=>this.ysljoinmodalCancel()} ysljoinmodalCanceltwo={()=>this.ysljoinmodalCanceltwo()}></Jointheclass>
<Modal
keyboard={false}
title="提示"
visible={this.state.startshixunCombattypes}
closable={false}
footer={null}
>
<div className="task-popup-content">
<p className="task-popup-text-center font-16 pb20">本实训的开启时间{this.state.shixunsmessages} <br/>开启时间之前不能挑战 </p>
</div>
<div className="task-popup-submit clearfix">
{/*<a onClick={this.hidestartshixunCombattype} className="task-btn fl">取消</a>*/}
<a className="task-btn task-btn-orange fr"
style={{marginRight:'51px'}}
onClick={this.hidestartshixunCombattype}>知道了</a>
</div>
{/*<p className="inviteTipbtn with100 fl">*/}
{/*<a onClick={this.hidestartshixunCombattype}>知道了</a>*/}
{/*</p>*/}
</Modal>
<Modal
keyboard={false}
title="提示"
visible={this.state.shixunsreplaces}
closable={false}
footer={null}
>
<Spin indicator={antIcon} spinning={this.state.isSpins}>
<div className="task-popup-content">
<p className="task-popup-text-center font-16 pb20">实训已经更新了正在为您重置!</p>
</div>
<div className="task-popup-submit clearfix">
<a className="task-btn task-btn-orange fr"
style={{marginRight:'51px'}}
onClick={() => this.hidestartshixunsreplace(hidestartshixunsreplacevalues)}>知道了</a>
</div>
</Spin>
</Modal>
<div className="edu-back-white">
{
this.props.isAdmin()===true?"":
<div>
{
start_learning===undefined?"":start_learning===false?
<div className="clearfix padding30 bor-bottom-greyE" style={{textAlign: "center"}}>
<div style={{height: '40px',textAlign: "center"}}>
<span className=" fl color-dark-21 " style={{height: '40px', textAlign: "center",fontSize:"19px"}}>还未开始学习</span>
<Button className="ant-btn defalutSubmitbtn ant-btn-primary colorblue font-16 fr" onClick={()=>this.Startlearning()}>
<span>开始学习</span></Button>
</div>
</div>
:
<div className="clearfix padding30 bor-bottom-greyE" style={{textAlign: "center"}}>
<div style={{height: '40px',textAlign: "left"}}>
<span className=" color-dark-21 " style={{height: '40px', textAlign: "center",fontSize:"19px",color:"#05101A"}}>已学{learned}%</span>
</div>
<div style={{marginTop:"7px",width:"401px"}}>
<Progress percent={learned} showInfo={false} />
</div>
<div style={{marginTop:"7px",textAlign: "left"}}>
<span className="font-16">上次学至</span><span style={{color:"#4CADFF",marginLeft:"25px"}}>{last_shixun}</span>
</div>
</div>
}
</div>
}
{/*简介*/}
<div className="clearfix pl30 pr30" style={{paddingBottom:"22px"}}>
<div style={{textAlign: "left",marginTop:"10px",paddingBottom: "10px"}}>
<span className=" color-dark-21 " style={{textAlign: "center",fontSize:"19px"}}>简介</span>
</div>
<div className="edu-back-white new_li editormd-html-preview " >
<p className="markdown-body fonttext " dangerouslySetInnerHTML={{__html: markdownToHTML(description).replace(/▁/g,"▁▁▁")}}>
</p>
</div>
</div>
</div>
<Spin size="large" spinning={isSpin} id={"cdiv"}>
<div className=" clearfix" style={{marginTop:"10px"}}>
<div>
{/*开始学习*/}
<YslDetailCards {...this.state} {...this.props} Startlearningtwo={()=>this.Startlearningtwo()} Myreload={()=>this.Myreload()} ></YslDetailCards>
</div>
</div>
</Spin>
</div>
</React.Fragment>
)
}
}
const Elearningss = Form.create({ name: 'elearning' })(Elearning);
export default Elearningss;

@ -0,0 +1,217 @@
import React, { Component } from 'react';
import {getImageUrl} from 'educoder';
import { Tooltip,Modal,Icon,Spin,message} from 'antd';
import '../../paths/ShixunPaths.css';
import axios from 'axios';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
class YslDetailCards extends Component{
constructor(props){
super(props)
this.state={
showparagraph:false,
showparagraphkey:"",
showparagraphindex:"",
shixunsreplace:false,
hidestartshixunsreplacevalue:"",
shixunsmessage:"",
startshixunCombattype:false,
isSpin:false,
}
}
showparagraph =(key,index)=>{
this.setState({
showparagraph:true,
showparagraphkey:key,
showparagraphindex:index
})
};
hideparagraph=()=>{
this.setState({
showparagraph:false
})
};
startgameid=(id)=>{
if(this.props.isNotMember()===true){
//这个是外部传过来的
this.props.Startlearningtwo();
return
}
let url = "/shixuns/" + id + "/shixun_exec.json";
axios.get(url).then((response) => {
if (response.data.status === -2) {
this.setState({
shixunsreplace:true,
hidestartshixunsreplacevalue:response.data.message+".json"
})
} else if (response.data.status === -1) {
console.log(response)
}else if(response.data.status===-3){
this.setState({
shixunsmessage:response.data.message,
startshixunCombattype:true,
})
} else {
console.log("开始学习了");
window.open("/tasks/" + response.data.game_identifier,'_blank');
//这个是传过来 调用刷新
this.props.Myreload();
// window.location.href = path
// let path="/tasks/"+response.data.game_identifier;
// this.props.history.push(path);
}
}).catch((error) => {
});
};
componentDidMount(){
}
hidestartshixunsreplace=(url)=>{
this.setState({
isSpin:true,
})
axios.get(url).then((response) => {
// debugger
if(response.status===200){
// let path="/shixuns/"+response.data.shixun_identifier+"/challenges";
// this.props.history.push(path);
message.success('重置成功,正在进入实训!');
this.startgameid(response.data.shixun_identifier);
this.setState({
shixunsreplace:false,
isSpin:false,
startbtn:false,
})
// message.success('重置成功,正在进入实训!');
// this.startshixunCombat();
}}
).catch((error) => {
this.setState({
isSpin:false,
shixunsreplace:false,
})
});
}
hidestartshixunCombattype=()=>{
this.setState({
startshixunCombattype:false
})
}
render(){
let{showparagraph,showparagraphkey,showparagraphindex,hidestartshixunsreplacevalue} =this.state;
let { stages }=this.props;
const antIcon = <Icon type="loading" style={{ fontSize: 24 }} spin />;
return(
<div className="lesson-saved-list">
<Modal
keyboard={false}
title="提示"
visible={this.state.startshixunCombattype}
closable={false}
footer={null}
>
<div className="task-popup-content">
<p className="task-popup-text-center font-16 pb20">本实训的开启时间{this.state.shixunsmessage} <br/>开启时间之前不能挑战 </p>
</div>
<div className="task-popup-submit clearfix">
{/*<a onClick={this.hidestartshixunCombattype} className="task-btn fl">取消</a>*/}
<a className="task-btn task-btn-orange fr"
style={{marginRight:'51px'}}
onClick={this.hidestartshixunCombattype}>知道了</a>
</div>
{/*<p className="inviteTipbtn with100 fl">*/}
{/*<a onClick={this.hidestartshixunCombattype}>知道了</a>*/}
{/*</p>*/}
</Modal>
<Modal
keyboard={false}
title="提示"
visible={this.state.shixunsreplace}
closable={false}
footer={null}
>
<Spin indicator={antIcon} spinning={this.state.isSpin}>
<div className="task-popup-content">
<p className="task-popup-text-center font-16 pb20">实训已经更新了正在为您重置!</p>
</div>
<div className="task-popup-submit clearfix">
<a className="task-btn task-btn-orange fr"
style={{marginRight:'51px'}}
onClick={() => this.hidestartshixunsreplace(hidestartshixunsreplacevalue)}>知道了</a>
</div>
</Spin>
</Modal>
{
stages && stages.map((item,key)=>{
return(
<div className={"lesson-saved-list-item"} id={"stage_div_"+key} >
<p className="clearfix title-line">
<a className="fl ring-blue mr10 mt2">
<img src={getImageUrl("images/educoder/icon/charpter-white.svg")} className="fl ml3 mt3"/>
</a>
<span className="font-18 font-bd lessonvalue" title={item.stage_name}>{item.stage_name}</span>
</p>
<div className="detail_for_paragraph clearfix" id={"detail_for_paragraph_"+key}>
<p className="color-dark-grey mt20 mb25 ml20 mr20 pl28 justify font-15">{item.stage_description}</p>
<div>
{
item.shixuns_list && item.shixuns_list.map((line,index)=>{
return(
<div className="clearfix paragraph lineh-30" onMouseEnter={()=>this.showparagraph(key,index)} onMouseLeave={this.hideparagraph}>
<li className="fl li-width63">
<span className="progressRing mr10">
{
line.complete_status === 1 ?<i className="iconfont icon-wancheng progressRing-over font-18 mt10"></i>
:<i className="iconfont icon-bofang progressRing-part font-18 mt10"></i>
}
</span>
<span className={this.props.current_user&&this.props.current_user.admin===false&&line.shixun_status==="暂未公开"?"paragraph_name color204":"paragraph_name color-grey3"}>
<span className="subject_stage_shixun_index">{key+1}</span>-{index+1}&nbsp;&nbsp;{line.shixun_name}
</span>
</li>
{
this.props.current_user&&this.props.current_user.admin===false&&line.shixun_status==="暂未公开"?
<li className="fr status_li"><span className="fr color204">暂未公开</span></li>
:
<li className={showparagraph===false?"none":"fr status_li"}>
{
showparagraphkey===key&&showparagraphindex===index?<div>
<Link to={'/shixuns/'+line.identifier+'/challenges'} className="mr30 color-blue_4C shixun_detail pointer fl" target="_blank">查看详情</Link>
{line.shixun_status==="暂未公开"?"":<a onClick={()=>this.startgameid(line.identifier)} className="btn_auto user_bluebg_btn fl" id="shixun_operation" >开始学习</a>}
</div>:""
}
</li>
}
</div>)
})
}
</div>
</div>
</div>
)
})
}
</div>
)
}
}
export default YslDetailCards;

@ -1,13 +1,19 @@
import React,{ Component } from "react";
import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin } from "antd";
import { WordsBtn,on, off, trigger } from 'educoder';
import '../css/members.css';
import '../css/busyWork.css'
import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin,Button,Form } from "antd";
import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder';
import './myysleduinforms.css'
import axios from 'axios';
import TPMMDEditor from "../../tpm/challengesnew/TPMMDEditor";
// 公告栏
class Eduinforms extends Component{
constructor(props){
super(props);
this.messageRef = React.createRef();
this.state={
description:null,
isSpin:true,
whethertoedit:false,
}
}
@ -15,15 +21,37 @@ class Eduinforms extends Component{
componentDidMount() {
console.log("获取到数据");
console.log(this.props);
// let url = "/courses/:id/informs.json";
//
// axios.get(url).then((response) => {
// if(response){
let url = `/courses/${this.props.match.params.coursesId}/informs.json`;
//
// }
// }).catch((error) => {
// console.log(error)
// });
axios.get(url).then((response) => {
if(response){
if(response.data){
this.setState({
description:response.data.description,
isSpin:false,
})
}else {
this.setState({
description:null,
isSpin:false,
})
}
}else {
this.setState({
description:null,
isSpin:false,
})
}
}).catch((error) => {
console.log(error)
this.setState({
description:null,
isSpin:false,
})
});
}
@ -33,35 +61,198 @@ class Eduinforms extends Component{
}
bianji = (bians)=>{
this.setState({
whethertoedit:bians,
})
};
handleSubmit=(e) => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
console.log(values.description);
if(values.description === undefined|| values.description === "" || values.description ===null){
this.props.showNotification(`请输入提交内容`);
return
}
var id=this.props.match.params.coursesId
var url = `/courses/${id}/update_informs.json`;
axios.post(url,{
description:values.description,
}).then((result) => {
if(result){
if(result.data){
if(result.data.status === 0){
this.setState({
description:values.description,
whethertoedit:false,
})
this.props.showNotification(result.data.message);
}else {
this.props.showNotification(result.data.message);
}
}
}
}).catch((error) => {
console.log(error)
})
}else{
console.log(err);
}
});
}
render(){
let{description,whethertoedit} =this.state;
const {getFieldDecorator} = this.props.form;
return(
<React.Fragment >
<div>
<div id={"zhudiv"}>
<div className="edu-back-white">
<p className="clearfix padding30 bor-bottom-greyE">
<p style={{height: '20px'}}>
<span className="font-18 fl color-dark-21">公告栏</span>
<li class="btn colorblue font-16 fr">
编辑
</li>
{
this.props.isAdmin()===true?
<li className="btn colorblue font-16 fr" style={{cursor: "default"}}
onClick={() => this.bianji(true)}>
编辑
</li>
:""
}
</p>
</p>
</div>
{/*<Spin size="large" spinning={this.state.isSpin}>*/}
<Spin size="large" spinning={this.state.isSpin} id={"cdiv"}>
<div id={"cdiv1"}>
{
whethertoedit === false?
<div>
{
description === null || description=== undefined ||description === "" ?
<div className="alltask ">
<div className="edu-tab-con-box clearfix edu-txt-center"><img className="edu-nodata-img mb20"
src={getImageUrl("images/educoder/nodata.png")} />
<p className="edu-nodata-p mb20">暂时还没有相关数据哦</p></div>
</div>
:
<div className="edu-back-white ">
<div id="MakedownHTML" className={"markdown-body fonttext yslmtopcg"} dangerouslySetInnerHTML={{__html: markdownToHTML(description).replace(/▁/g, "▁▁▁")}}>
</div>
</div>
}
</div>
:
<div>
<Form layout='vertical' onSubmit={this.handleSubmit} >
<div className="edu-back-white ">
<div className={"yslmt16px"}>
<style>
{
`
.ant-form-item-children {
position: unset;
}
.rememberTip{
position:absolute;
right:0px;
bottom:-10px;
}
.chooseDes .ant-form-explain{
position:absolute;
bottom:-10px;
left:0px;
}
.ant-form-vertical .ant-form-explain {
margin-top: 0px !important;
margin-bottom: 0px !important;
padding-left: 0px !important;
}
.chooseDes .ant-form-item-with-help {
margin-bottom: 24px !important;
}
.courseMessageMD .ant-form-item-with-help {
margin-bottom: 24px !important;
}
.chooseDes .editormd-toolbar {
width: 100%;
min-height: 37px;
background: #fff;
display: none;
position: absolute;
left: 0;
z-index: 10;
border-bottom: 1px solid #ddd;
}
.yslmt16px .ant-form-item-with-help
{
margin-bottom: 24px !important;
}
`
}
</style>
<Form.Item
style={{"borderBottom":'none'}}
className="chooseDes "
>
{getFieldDecorator('description', {
rules: [{
required: true, message: '请在此输入内容,最多5000个字符',
}, {
max: 5000, message: '最大限制为5000个字符',
}],
})(
<TPMMDEditor ref={this.messageRef}
placeholder={'请在此输入内容,最多5000个字符'}
initValue={description}
mdID={'courseMessageMD'}
className="courseMessageMD "
height={518}
></TPMMDEditor>
)}
</Form.Item>
</div>
</div>
<Form.Item>
<div className="clearfix mt28 fr" style={{display:"block;"}}>
<a className="defalutCancelbtn fl mr20" onClick={()=>this.bianji(false)}>取消</a>
<Button htmlType="submit" className="ant-btn defalutSubmitbtn fl ant-btn-primary">
<span> </span></Button>
</div>
</Form.Item>
</Form>
</div>
}
</div>
{/*</Spin>*/}
</Spin>
</div>
</React.Fragment>
)
}
}
export default Eduinforms;
const Eduinformss = Form.create({ name: 'eduinforms' })(Eduinforms);
export default Eduinformss;

@ -0,0 +1,13 @@
.yslmt16px{
padding-top: 16px !important;
padding-left: 25px !important;
padding-right: 25px !important;
padding-bottom: 1px !important;
}
.yslmtopcg
{
padding: 25px !important;
}

@ -67,18 +67,24 @@ class Goldsubject extends Component {
checkboxgroup: data.course_module_types,
Realnamecertification: data.authentication,
Professionalcertification:data.professional_certification,
starttime: data.start_date === undefined ? "" : moment(data.start_date, dateFormat),
endtime: data.end_date === undefined ? "" : moment(data.end_date, dateFormat),
school:data.school
});
// starttime
this.setState({
datatimetwo: data.start_date,
datatime: data.end_date,
datatimetwo: data.end_date,
is_public: 1,
Realnamecertification: data.authentication,
Professionalcertification:data.professional_certification,
})
name: data.name,
class_period: data.class_period,
credit: parseFloat(data.credit),
course_module_types: data.course_module_types,
school:data.school
});
this.handleSearchschool(data.school);
}).catch((error) => {
console.log(error);

@ -511,7 +511,7 @@
height: 53%;
}
.ysldiv71024{
margin-top: 31%;
margin-top: 31% ;
margin-left: 27%;
margin-right: 0;
height: 40%;

@ -551,7 +551,7 @@ a:hover.task-btn-orange{background: #459BE6;}
a.user_bluebg_btn{background-color:#4CACFF;color: #fff;}
a.user_orangebg_btn{background-color:#FF6800;color: #fff;}
a.user_greybg_btn{background-color:#747A7F;color: #fff;}
/*.user_white_btn{border: 1px solid #ffffff;color: #ffffff!important;}*/
.pointer{cursor: pointer}
.cdefault{cursor: default}

Loading…
Cancel
Save