|
|
|
@ -4,6 +4,9 @@ import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder';
|
|
|
|
|
import './myysleduinforms.css'
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import TPMMDEditor from "../../tpm/challengesnew/TPMMDEditor";
|
|
|
|
|
import Bullsubdirectory from "./Bullsubdirectory";
|
|
|
|
|
import moment from "../new/CoursesNew";
|
|
|
|
|
import Fileslistitem from "../Resource/Fileslistitem";
|
|
|
|
|
// 公告栏
|
|
|
|
|
class Eduinforms extends Component{
|
|
|
|
|
constructor(props){
|
|
|
|
@ -14,33 +17,57 @@ class Eduinforms extends Component{
|
|
|
|
|
description:null,
|
|
|
|
|
isSpin:true,
|
|
|
|
|
whethertoedit:false,
|
|
|
|
|
|
|
|
|
|
addonAfter:0,
|
|
|
|
|
eduintit:"",
|
|
|
|
|
informs:[],
|
|
|
|
|
yslbool:false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
console.log("获取到数据");
|
|
|
|
|
console.log(this.props);
|
|
|
|
|
let url = `/courses/${this.props.match.params.coursesId}/informs.json`;
|
|
|
|
|
|
|
|
|
|
this.getinputdata();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getyslbooltrue(){
|
|
|
|
|
console.log("调用了getyslbooltrue");
|
|
|
|
|
this.setState({
|
|
|
|
|
yslbool:true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getyslboolfalse(){
|
|
|
|
|
console.log("调用了getyslboolfalse");
|
|
|
|
|
this.setState({
|
|
|
|
|
yslbool:false,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
getinputdata=()=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpin:true,
|
|
|
|
|
})
|
|
|
|
|
let url = `/courses/${this.props.match.params.coursesId}/informs.json`;
|
|
|
|
|
//
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(response.data){
|
|
|
|
|
this.setState({
|
|
|
|
|
informs:response.data.informs,
|
|
|
|
|
isSpin:false,
|
|
|
|
|
})
|
|
|
|
|
}else {
|
|
|
|
|
this.setState({
|
|
|
|
|
informs:[],
|
|
|
|
|
isSpin:false,
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
this.setState({
|
|
|
|
|
description:null,
|
|
|
|
|
informs:[],
|
|
|
|
|
isSpin:false,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -48,14 +75,12 @@ class Eduinforms extends Component{
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
this.setState({
|
|
|
|
|
description:null,
|
|
|
|
|
informs:[],
|
|
|
|
|
isSpin:false,
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate = (prevProps) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -65,32 +90,60 @@ class Eduinforms extends Component{
|
|
|
|
|
this.setState({
|
|
|
|
|
whethertoedit:bians,
|
|
|
|
|
})
|
|
|
|
|
if(bians===true){
|
|
|
|
|
this.getyslbooltrue();
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
this.getyslboolfalse();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
changeTopicName = (e) => {
|
|
|
|
|
console.log("调用了changeTopicName");
|
|
|
|
|
let num = parseInt(e.target.value.length);
|
|
|
|
|
if(num>60){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
addonAfter: num < 0 ? 0 : num
|
|
|
|
|
});
|
|
|
|
|
this.setState({
|
|
|
|
|
eduintit: e.target.value
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.props.form.setFieldsValue({
|
|
|
|
|
eduintits: e.target.value,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
handleSubmit=(e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
|
|
if (!err) {
|
|
|
|
|
console.log(values.description);
|
|
|
|
|
if(values.eduintits === undefined|| values.eduintits === "" || values.eduintits ===null){
|
|
|
|
|
this.props.showNotification(`请输入标题`);
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(values.description === undefined|| values.description === "" || values.description ===null){
|
|
|
|
|
this.props.showNotification(`请输入提交内容`);
|
|
|
|
|
this.props.showNotification(`请输入内容`);
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var id=this.props.match.params.coursesId
|
|
|
|
|
|
|
|
|
|
var url = `/courses/${id}/update_informs.json`;
|
|
|
|
|
var url = `/courses/${id}/new_informs.json`;
|
|
|
|
|
axios.post(url,{
|
|
|
|
|
name:values.eduintits,
|
|
|
|
|
description:values.description,
|
|
|
|
|
}).then((result) => {
|
|
|
|
|
if(result){
|
|
|
|
|
if(result.data){
|
|
|
|
|
if(result.data.status === 0){
|
|
|
|
|
this.setState({
|
|
|
|
|
description:values.description,
|
|
|
|
|
whethertoedit:false,
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
this.getinputdata();
|
|
|
|
|
this.getyslboolfalse();
|
|
|
|
|
this.props.showNotification(result.data.message);
|
|
|
|
|
}else {
|
|
|
|
|
this.props.showNotification(result.data.message);
|
|
|
|
@ -111,7 +164,7 @@ class Eduinforms extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
let{description,whethertoedit} =this.state;
|
|
|
|
|
let{description,whethertoedit,addonAfter,eduintit,informs,yslbool} =this.state;
|
|
|
|
|
const {getFieldDecorator} = this.props.form;
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
@ -123,10 +176,13 @@ class Eduinforms extends Component{
|
|
|
|
|
<span className="font-18 fl color-dark-21">公告栏</span>
|
|
|
|
|
{
|
|
|
|
|
this.props.isAdmin()===true?
|
|
|
|
|
<li className="btn colorblue font-16 fr" style={{cursor: "default"}}
|
|
|
|
|
onClick={() => this.bianji(true)}>
|
|
|
|
|
编辑
|
|
|
|
|
</li>
|
|
|
|
|
(this.state.yslbool===false?
|
|
|
|
|
<li className="btn colorblue font-16 fr bluebkbk" style={{cursor: "default"}}
|
|
|
|
|
onClick={() => this.bianji(true)}>
|
|
|
|
|
发布公告
|
|
|
|
|
</li>
|
|
|
|
|
:"")
|
|
|
|
|
|
|
|
|
|
:""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -138,36 +194,73 @@ class Eduinforms extends Component{
|
|
|
|
|
|
|
|
|
|
<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 yslminHeigth"} style={{minHeight:"400px"}} dangerouslySetInnerHTML={{__html: markdownToHTML(description).replace(/▁/g, "▁▁▁")}}>
|
|
|
|
|
whethertoedit === false?""
|
|
|
|
|
:
|
|
|
|
|
<div className="edu-back-white bor-bottom-greyE">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
:
|
|
|
|
|
<div>
|
|
|
|
|
<Form layout='vertical' onSubmit={this.handleSubmit} >
|
|
|
|
|
|
|
|
|
|
<div className="edu-back-white ">
|
|
|
|
|
<div className={"yslmt16px"}>
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`.ant-form-item{
|
|
|
|
|
margin-bottom:0px !important;
|
|
|
|
|
}
|
|
|
|
|
.chooseDestwo .ant-form-item{
|
|
|
|
|
margin-bottom:0px !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.chooseDestwo .ant-form-item-control-wrapper .ant-form-item-control .ant-form-explain{
|
|
|
|
|
padding-left: 25px !important;
|
|
|
|
|
}
|
|
|
|
|
.ant-form-vertical .ant-form-item {
|
|
|
|
|
margin-bottom:0px !important;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<Form.Item
|
|
|
|
|
style={{"borderBottom":'none'}}
|
|
|
|
|
className="chooseDestwo "
|
|
|
|
|
>
|
|
|
|
|
{getFieldDecorator('eduintits', {
|
|
|
|
|
rules: [{
|
|
|
|
|
required: true, message: '请在此输入标题,最多60个字符',
|
|
|
|
|
}, {
|
|
|
|
|
max: 60, message: '最大限制为60个字符',
|
|
|
|
|
}],
|
|
|
|
|
})(
|
|
|
|
|
<div className="ysleduinwh">
|
|
|
|
|
<div className="yslduinlefts">
|
|
|
|
|
<span className="yslduincolorred">*</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="yslduinleft">
|
|
|
|
|
<Input placeholder="请在此输入标题,最多60个字符" maxLength="60"
|
|
|
|
|
style={{ textAlign: "left",width:"100%",}}
|
|
|
|
|
onInput={this.changeTopicName}
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
suffix={String(addonAfter)+"/60"}
|
|
|
|
|
value={eduintit}
|
|
|
|
|
className="searchViewAfter"></Input>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="edu-back-white ">
|
|
|
|
|
<div className={"yslmt16px"}>
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
|
.ant-form-item-children {
|
|
|
|
|
position: unset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.chooseDes .ant-form-item{
|
|
|
|
|
margin-bottom:0px !important;
|
|
|
|
|
}
|
|
|
|
|
.rememberTip{
|
|
|
|
|
position:absolute;
|
|
|
|
|
right:0px;
|
|
|
|
@ -206,41 +299,66 @@ class Eduinforms extends Component{
|
|
|
|
|
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>
|
|
|
|
|
}
|
|
|
|
|
</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>
|
|
|
|
|
<div className="clearfix mt28 fr pb50 mr25" 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>
|
|
|
|
|
{
|
|
|
|
|
informs === null || informs=== undefined ||informs.length === 0 ?
|
|
|
|
|
<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 ">
|
|
|
|
|
{ informs&&informs.map((item, index) => {
|
|
|
|
|
return (
|
|
|
|
|
<Bullsubdirectory {...this.state} {...this.props} key={index} yslbool={yslbool} id={item.id} myname={item.name} mydescription={item.description}
|
|
|
|
|
getyslbooltrue={()=>this.getyslbooltrue()}
|
|
|
|
|
getyslboolfalse={()=>this.getyslboolfalse()}
|
|
|
|
|
getinputdata={()=>this.getinputdata()} ></Bullsubdirectory>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
@ -257,3 +375,7 @@ class Eduinforms extends Component{
|
|
|
|
|
}
|
|
|
|
|
const Eduinformss = Form.create({ name: 'eduinforms' })(Eduinforms);
|
|
|
|
|
export default Eduinformss;
|
|
|
|
|
{/*<div key={index} className="bor-bottom-greyE" >*/}
|
|
|
|
|
{/* {item.name===""?"":item.name===undefined?"":item.name===null?"":<div className="ysltitbt"><span >{item.name}</span></div>}*/}
|
|
|
|
|
{/* <div id="MakedownHTML" key={index} className={"markdown-body fonttext yslmtopcg yslminHeigth markdownysltext"} dangerouslySetInnerHTML={{__html: markdownToHTML(item.description).replace(/▁/g, "▁▁▁")}}/>*/}
|
|
|
|
|
{/*</div>*/}
|