import React, { Component } from 'react'; import {Button, Card, Row, Col ,Upload,Icon,message,Tabs,Form,Input,Modal} from 'antd'; import axios from 'axios'; import {getImageUrl,getUrl,WordNumberTextarea} from 'educoder'; class Osshackathonmodel extends Component{ constructor(props) { super(props) this.state={ title_num: 0, title_value: undefined, Textarea_comment:undefined } } componentDidUpdate =(prevState)=>{ // if(prevState!=this.props){ // let name=this.props&&this.props.modelname; // let mdvalue=this.props&&this.props.modeldescription; // this.setState({ // title_value:name, // Textarea_comment:mdvalue // }) // } } componentDidMount(){ if(this.props.modelid===undefined){ this.setState({ title_value:undefined, Textarea_comment:undefined }) }else{ let url=`/osshackathon/${this.props.modelid}/edit.json`; axios.get(url).then((result)=>{ if(result.status==200){ this.setState({ title_value:result.data.name, Textarea_comment:result.data.description }) } }) } } handleSubmit = () => { let {title_value,Textarea_comment}=this.state; // if(mdContnet.length>10000){ // this.props.showNotification("内容超过10000个字"); // return // } // if(this.props.modelid===undefined){ let url=`/osshackathon.json`; axios.post(url,{ name:title_value, description:Textarea_comment, } ).then((response) => { if(response.data.status===0){ this.props.getosshackathon() this.props.hideeditSignupentry() this.props.showNotification(`提交成功`); } }).catch((error) => { console.log(error) }) }else{ let url=`/osshackathon/${this.props.modelid}.json` axios.put(url,{ name:title_value, description:Textarea_comment, } ).then((response) => { if(response.data.status===0){ this.props.getosshackathon() this.props.hideeditSignupentry() this.props.showNotification(`提交成功`); } }).catch((error) => { console.log(error) }) } } changeTitle=(e)=>{ this.setState({ title_value:e.target.value, title_num:e.target.value.length, }) } Textarea_comment=(e)=>{ this.setState({ Textarea_comment:e.target.value, }) } render() { let {textareavaltype}=this.state; // console.log(this.props.tabkey) // console.log(this.props.Osshackathonmodeltype) return (
名称
this.changeTitle(e)} className={"Osshackathonmodelinput"} style={{"width": "100%"}} maxLength="60" addonAfter={String(this.state.title_value===undefined?0:this.state.title_value.length)+"/60"} />描述