Merge branches 'dev_aliyun' and 'master' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
cb0a10fbc5
@ -1,238 +1,241 @@
|
||||
import React,{ Component } from "react";
|
||||
import { Modal,Radio,Input,Tooltip } from "antd";
|
||||
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
|
||||
import SendPanel from "./sendPanel.js";
|
||||
import { getImageUrl } from 'educoder';
|
||||
import axios from 'axios';
|
||||
import Modals from '../../modals/Modals';
|
||||
import './DetailTop.css';
|
||||
|
||||
const Search = Input.Search;
|
||||
const RadioGroup = Radio.Group;
|
||||
class DetailTop extends Component{
|
||||
constructor(props){
|
||||
super(props)
|
||||
this.state={
|
||||
cardsModalcancel:this.cardsModalcancel,
|
||||
cardsModalsave:this.cardsModalsave,
|
||||
Modalstype:false,
|
||||
Modalstopval:"",
|
||||
Modalsbottomval:'',
|
||||
loadtype:false,
|
||||
deletepathtype:false,
|
||||
cardsModalsavetype:false
|
||||
}
|
||||
}
|
||||
|
||||
allow_deletepath=()=>{
|
||||
this.setState({
|
||||
Modalstype:true,
|
||||
Modalstopval:"是否删除路径?",
|
||||
deletepathtype:true
|
||||
})
|
||||
}
|
||||
|
||||
applyissuePath=()=>{
|
||||
this.setState({
|
||||
Modalstype:true,
|
||||
Modalstopval:"发布申请已提交,请等待管理员的审核",
|
||||
Modalsbottomval:"• 我们将在1-2个工作日内完成审核",
|
||||
loadtype:true
|
||||
})
|
||||
}
|
||||
|
||||
cancelissuePath=()=>{
|
||||
let pathId=this.props.match.params.pathId;
|
||||
let url ="/paths/"+pathId+"/cancel_publish.json";
|
||||
axios.get(url).then((result)=>{
|
||||
if(result.status===200){
|
||||
if(result.data.status===0){
|
||||
|
||||
}else if(result.data.status===1){
|
||||
window.location.href = "/paths/" + result.data.subject_id
|
||||
}
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
reovkissuePath=()=>{
|
||||
|
||||
this.setState({
|
||||
Modalstype:true,
|
||||
Modalstopval:"是否确认撤销发布",
|
||||
Modalsbottomval:"确认后,回退到编辑状态",
|
||||
cardsModalsavetype:true,
|
||||
})
|
||||
|
||||
}
|
||||
reovkissuePaths=()=>{
|
||||
let pathId=this.props.match.params.pathId;
|
||||
let url ="/paths/"+pathId+"/cancel_has_publish.json";
|
||||
axios.get(url).then((result)=>{
|
||||
if(result.status===200){
|
||||
if(result.data.status===0){
|
||||
|
||||
}else if(result.data.status===1){
|
||||
this.setState({
|
||||
cardsModalsavetype:false,
|
||||
loadtype:false,
|
||||
deletepathtype:false
|
||||
})
|
||||
window.location.href = "/paths/" + result.data.subject_id
|
||||
}
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
cardsModalcancel=()=>{
|
||||
this.setState({
|
||||
Modalstype:false,
|
||||
Modalsbottomval:'',
|
||||
loadtype:false,
|
||||
deletepathtype:false
|
||||
})
|
||||
}
|
||||
|
||||
cardsModalsave=()=>{
|
||||
let {loadtype,deletepathtype}=this.state;
|
||||
|
||||
//删除路径
|
||||
if(deletepathtype===true){
|
||||
let pathid=this.props.match.params.pathId;
|
||||
const deleteUrl = `/paths/`+pathid+`.json`;
|
||||
axios.delete(deleteUrl).then((response) => {
|
||||
const status = response.data.status
|
||||
if (status === 1) {
|
||||
window.location.href = "/paths";
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
|
||||
//申请发布
|
||||
if(loadtype===true){
|
||||
|
||||
let pathid=this.props.match.params.pathId;
|
||||
let url ="/paths/"+pathid+"/publish.json";
|
||||
axios.get(url).then((result)=>{
|
||||
if(result.status===200){
|
||||
if(result.data.status===0){
|
||||
this.setState({
|
||||
Modalstype:true,
|
||||
Modalstopval: result.data.message,
|
||||
})
|
||||
}else if(result.data.status===1){
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
|
||||
}
|
||||
this.setState({
|
||||
Modalstype:false,
|
||||
Modalsbottomval:''
|
||||
})
|
||||
}
|
||||
|
||||
render(){
|
||||
let{detailInfoList}=this.props;
|
||||
let{Modalstype,Modalstopval,cardsModalcancel,cardsModalsave,Modalsbottomval,cardsModalsavetype,loadtype}=this.state;
|
||||
const radioStyle = {
|
||||
display: 'block',
|
||||
height: '30px',
|
||||
lineHeight: '30px',
|
||||
};
|
||||
|
||||
return(
|
||||
<div className="subhead">
|
||||
<Modals
|
||||
modalsType={Modalstype}
|
||||
modalsTopval={Modalstopval}
|
||||
modalsBottomval={Modalsbottomval}
|
||||
modalCancel={cardsModalcancel}
|
||||
modalSave={cardsModalsavetype===true?this.reovkissuePaths:this.cardsModalsave}
|
||||
loadtype={loadtype}
|
||||
>
|
||||
</Modals>
|
||||
{
|
||||
detailInfoList &&
|
||||
<div className="subhead_content">
|
||||
<div className="font-28 color-white clearfix">
|
||||
<span className="fl lineh-40">
|
||||
{detailInfoList.name}
|
||||
|
||||
</span>
|
||||
{detailInfoList===undefined?"":detailInfoList.allow_statistics===true?
|
||||
<Link to={"/paths/"+this.props.match.params.pathId+"/edit"} className="ml10 ring-green fl mt10" data-tip-down="编辑">
|
||||
<img src={getImageUrl("images/educoder/icon/edit.svg")} className="fl mt3 ml2" />
|
||||
</Link>:""
|
||||
}
|
||||
|
||||
{detailInfoList===undefined?"":detailInfoList.allow_statistics===true?
|
||||
<Link to={"/paths/"+this.props.match.params.pathId+"/statistics"} className="user_default_btn edu-greenback-btn fr font-18"
|
||||
>
|
||||
学习统计
|
||||
</Link>:""
|
||||
}
|
||||
|
||||
{ detailInfoList.allow_send === true &&
|
||||
<SendPanel {...this.props} {...this.state}></SendPanel>
|
||||
}
|
||||
|
||||
</div>
|
||||
<div className="clearfix mt20">
|
||||
{
|
||||
detailInfoList &&
|
||||
<ul className="fl color-grey-eb pathInfo">
|
||||
{ detailInfoList.stages_count!=0 ? <li><span>章节</span><span className="ml5">{detailInfoList.stages_count}</span></li> : ""}
|
||||
{ detailInfoList.stage_shixuns_count!=0 ? <li><span>实训</span><span className="ml5">{ detailInfoList.stage_shixuns_count}</span></li> : ""}
|
||||
{ detailInfoList.challenge_choose_count!=0 ? <li><span>选择题任务</span><span>{detailInfoList.challenge_choose_count}</span></li> : ""}
|
||||
{ detailInfoList.challenges_count!=0 ? <li><span>实践任务</span><span>{detailInfoList.challenges_count}</span></li> : ""}
|
||||
{ detailInfoList.subject_score!=0 ? <li><span>经验值</span><span>{detailInfoList.subject_score}</span></li> : ""}
|
||||
{ detailInfoList.member_count!=0 ? <li><span>学习人数</span><span>{detailInfoList.member_count}</span></li> : ""}
|
||||
</ul>
|
||||
}
|
||||
<div className="fr pr">
|
||||
{detailInfoList===undefined?"":detailInfoList.allow_delete===true?<a
|
||||
className={detailInfoList.publish_status===-1?"fl font-18 color-white mt5 mr20":"fl font-18 color-white mt5"}
|
||||
style={{opacity: '0.6'}} onClick={this.allow_deletepath}
|
||||
>删除路径</a>:""}
|
||||
|
||||
{
|
||||
detailInfoList.publish_status===0&&detailInfoList.allow_statistics===true?
|
||||
<a className="user_default_btn user_bluebg_btn font-18 fl ml40 userbluebgfont"
|
||||
onClick={this.applyissuePath}
|
||||
>申请发布</a>:""
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
detailInfoList.publish_status===1 && detailInfoList.allow_statistics===true?
|
||||
<a className="user_default_btn user_grey_btn font-18 fl pointer ml40"
|
||||
onClick={this.cancelissuePath}
|
||||
>撤销申请</a>:""
|
||||
}
|
||||
|
||||
{
|
||||
detailInfoList.publish_status===2 && detailInfoList.allow_statistics===true?
|
||||
<a className="user_default_btn user_grey_btn font-18 fl pointer ml40"
|
||||
onClick={this.reovkissuePath}
|
||||
>撤销发布</a>:""
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
import React,{ Component } from "react";
|
||||
import { Modal,Radio,Input,Tooltip } from "antd";
|
||||
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
|
||||
import SendPanel from "./sendPanel.js";
|
||||
import { getImageUrl } from 'educoder';
|
||||
import axios from 'axios';
|
||||
import Modals from '../../modals/Modals';
|
||||
import './DetailTop.css';
|
||||
|
||||
const Search = Input.Search;
|
||||
const RadioGroup = Radio.Group;
|
||||
class DetailTop extends Component{
|
||||
constructor(props){
|
||||
super(props)
|
||||
this.state={
|
||||
cardsModalcancel:this.cardsModalcancel,
|
||||
cardsModalsave:this.cardsModalsave,
|
||||
Modalstype:false,
|
||||
Modalstopval:"",
|
||||
Modalsbottomval:'',
|
||||
loadtype:false,
|
||||
deletepathtype:false,
|
||||
cardsModalsavetype:false
|
||||
}
|
||||
}
|
||||
|
||||
allow_deletepath=()=>{
|
||||
this.setState({
|
||||
Modalstype:true,
|
||||
Modalstopval:"是否删除路径?",
|
||||
deletepathtype:true
|
||||
})
|
||||
}
|
||||
|
||||
applyissuePath=()=>{
|
||||
this.setState({
|
||||
Modalstype:true,
|
||||
Modalstopval:"发布申请已提交,请等待管理员的审核",
|
||||
Modalsbottomval:"• 我们将在1-2个工作日内完成审核",
|
||||
loadtype:true
|
||||
})
|
||||
}
|
||||
|
||||
cancelissuePath=()=>{
|
||||
let pathId=this.props.match.params.pathId;
|
||||
let url ="/paths/"+pathId+"/cancel_publish.json";
|
||||
axios.get(url).then((result)=>{
|
||||
if(result.status===200){
|
||||
if(result.data.status===0){
|
||||
|
||||
}else if(result.data.status===1){
|
||||
window.location.href = "/paths/" + result.data.subject_id
|
||||
}
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
reovkissuePath=()=>{
|
||||
|
||||
this.setState({
|
||||
Modalstype:true,
|
||||
Modalstopval:"是否确认撤销发布",
|
||||
Modalsbottomval:"确认后,回退到编辑状态",
|
||||
cardsModalsavetype:true,
|
||||
})
|
||||
|
||||
}
|
||||
reovkissuePaths=()=>{
|
||||
let pathId=this.props.match.params.pathId;
|
||||
let url ="/paths/"+pathId+"/cancel_has_publish.json";
|
||||
axios.get(url).then((result)=>{
|
||||
if(result.status===200){
|
||||
if(result.data.status===0){
|
||||
|
||||
}else if(result.data.status===1){
|
||||
this.setState({
|
||||
cardsModalsavetype:false,
|
||||
loadtype:false,
|
||||
deletepathtype:false
|
||||
})
|
||||
window.location.href = "/paths/" + result.data.subject_id
|
||||
}
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
cardsModalcancel=()=>{
|
||||
this.setState({
|
||||
Modalstype:false,
|
||||
Modalsbottomval:'',
|
||||
loadtype:false,
|
||||
deletepathtype:false
|
||||
})
|
||||
}
|
||||
|
||||
cardsModalsave=()=>{
|
||||
let {loadtype,deletepathtype}=this.state;
|
||||
|
||||
//删除路径
|
||||
if(deletepathtype===true){
|
||||
let pathid=this.props.match.params.pathId;
|
||||
const deleteUrl = `/paths/`+pathid+`.json`;
|
||||
axios.delete(deleteUrl).then((response) => {
|
||||
const status = response.data.status
|
||||
if (status === 1) {
|
||||
window.location.href = "/paths";
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
|
||||
//申请发布
|
||||
if(loadtype===true){
|
||||
|
||||
let pathid=this.props.match.params.pathId;
|
||||
let url ="/paths/"+pathid+"/publish.json";
|
||||
axios.get(url).then((result)=>{
|
||||
if(result.status===200){
|
||||
if(result.data.status===0){
|
||||
this.setState({
|
||||
Modalstype:true,
|
||||
Modalstopval: result.data.message,
|
||||
})
|
||||
}else if(result.data.status===1){
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
|
||||
}
|
||||
this.setState({
|
||||
Modalstype:false,
|
||||
Modalsbottomval:''
|
||||
})
|
||||
}
|
||||
|
||||
render(){
|
||||
let{detailInfoList}=this.props;
|
||||
let{Modalstype,Modalstopval,cardsModalcancel,cardsModalsave,Modalsbottomval,cardsModalsavetype,loadtype}=this.state;
|
||||
const radioStyle = {
|
||||
display: 'block',
|
||||
height: '30px',
|
||||
lineHeight: '30px',
|
||||
};
|
||||
|
||||
return(
|
||||
<div className="subhead">
|
||||
<Modals
|
||||
modalsType={Modalstype}
|
||||
modalsTopval={Modalstopval}
|
||||
modalsBottomval={Modalsbottomval}
|
||||
modalCancel={cardsModalcancel}
|
||||
modalSave={cardsModalsavetype===true?this.reovkissuePaths:this.cardsModalsave}
|
||||
loadtype={loadtype}
|
||||
>
|
||||
</Modals>
|
||||
{
|
||||
detailInfoList &&
|
||||
<div className="subhead_content">
|
||||
<div className="font-28 color-white clearfix">
|
||||
<span className="fl lineh-40">
|
||||
{detailInfoList.name}
|
||||
|
||||
</span>
|
||||
{detailInfoList===undefined?"":detailInfoList.allow_statistics===true?
|
||||
<Tooltip placement="bottom" title={"编辑"}>
|
||||
<Link to={"/paths/"+this.props.match.params.pathId+"/edit"} className="ml10 ring-green fl mt10" >
|
||||
<img src={getImageUrl("images/educoder/icon/edit.svg")} className="fl mt3 ml2" />
|
||||
</Link>
|
||||
</Tooltip>
|
||||
:""
|
||||
}
|
||||
|
||||
{detailInfoList===undefined?"":detailInfoList.allow_statistics===true?
|
||||
<Link to={"/paths/"+this.props.match.params.pathId+"/statistics"} className="user_default_btn edu-greenback-btn fr font-18"
|
||||
>
|
||||
学习统计
|
||||
</Link>:""
|
||||
}
|
||||
|
||||
{ detailInfoList.allow_send === true &&
|
||||
<SendPanel {...this.props} {...this.state}></SendPanel>
|
||||
}
|
||||
|
||||
</div>
|
||||
<div className="clearfix mt20">
|
||||
{
|
||||
detailInfoList &&
|
||||
<ul className="fl color-grey-eb pathInfo">
|
||||
{ detailInfoList.stages_count!=0 ? <li><span>章节</span><span className="ml5">{detailInfoList.stages_count}</span></li> : ""}
|
||||
{ detailInfoList.stage_shixuns_count!=0 ? <li><span>实训</span><span className="ml5">{ detailInfoList.stage_shixuns_count}</span></li> : ""}
|
||||
{ detailInfoList.challenge_choose_count!=0 ? <li><span>选择题任务</span><span>{detailInfoList.challenge_choose_count}</span></li> : ""}
|
||||
{ detailInfoList.challenges_count!=0 ? <li><span>实践任务</span><span>{detailInfoList.challenges_count}</span></li> : ""}
|
||||
{ detailInfoList.subject_score!=0 ? <li><span>经验值</span><span>{detailInfoList.subject_score}</span></li> : ""}
|
||||
{ detailInfoList.member_count!=0 ? <li><span>学习人数</span><span>{detailInfoList.member_count}</span></li> : ""}
|
||||
</ul>
|
||||
}
|
||||
<div className="fr pr">
|
||||
{detailInfoList===undefined?"":detailInfoList.allow_delete===true?<a
|
||||
className={detailInfoList.publish_status===-1?"fl font-18 color-white mt5 mr20":"fl font-18 color-white mt5"}
|
||||
style={{opacity: '0.6'}} onClick={this.allow_deletepath}
|
||||
>删除路径</a>:""}
|
||||
|
||||
{
|
||||
detailInfoList.publish_status===0&&detailInfoList.allow_statistics===true?
|
||||
<a className="user_default_btn user_bluebg_btn font-18 fl ml40 userbluebgfont"
|
||||
onClick={this.applyissuePath}
|
||||
>申请发布</a>:""
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
detailInfoList.publish_status===1 && detailInfoList.allow_statistics===true?
|
||||
<a className="user_default_btn user_grey_btn font-18 fl pointer ml40"
|
||||
onClick={this.cancelissuePath}
|
||||
>撤销申请</a>:""
|
||||
}
|
||||
|
||||
{
|
||||
detailInfoList.publish_status===2 && detailInfoList.allow_statistics===true?
|
||||
<a className="user_default_btn user_grey_btn font-18 fl pointer ml40"
|
||||
onClick={this.reovkissuePath}
|
||||
>撤销发布</a>:""
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default DetailTop;
|
Loading…
Reference in new issue