import React,{ Component } from "react"; 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, } } componentDidMount() { console.log("获取到数据"); console.log(this.props); 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, }) } }else { this.setState({ description:null, isSpin:false, }) } }).catch((error) => { console.log(error) this.setState({ description:null, isSpin:false, }) }); } componentDidUpdate = (prevProps) => { } 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(

公告栏 { this.props.isAdmin()===true?

  • this.bianji(true)}> 编辑
  • :"" }

    { whethertoedit === false?
    { description === null || description=== undefined ||description === "" ?

    暂时还没有相关数据哦!

    :
    }
    :
    {getFieldDecorator('description', { rules: [{ required: true, message: '请在此输入内容,最多5000个字符', }, { max: 5000, message: '最大限制为5000个字符', }], })( )}
    }
    ) } } const Eduinformss = Form.create({ name: 'eduinforms' })(Eduinforms); export default Eduinformss;