调整 公告栏

dev_hs
杨树林 6 years ago
parent 99f940f21a
commit ee4ec2a237

@ -60,20 +60,25 @@ class Bullsubdirectory extends Component{
};
changeTopicName = (e) => {
console.log("调用了changeTopicName");
let num = parseInt(e.target.value.length);
let num = e.target.value.length;
if(num>60){
return;
}
this.setState({
addonAfter: num < 0 ? 0 : num
});
this.setState({
eduintits: e.target.value
})
if(num<=60){
this.setState({
eduintits: e.target.value
})
this.props.form.setFieldsValue({
eduintits: e.target.value,
});
}
this.props.form.setFieldsValue({
eduintits: e.target.value,
});
}
handleSubmit=(e) => {
e.preventDefault();
@ -91,11 +96,25 @@ class Bullsubdirectory extends Component{
}
var id=this.props.match.params.coursesId
var titname="";
try {
if(values.eduintits.length>0){
if( values.eduintits.length>60){
var str=values.eduintits;
titname=str.substring(0,60);
}else {
titname=values.eduintits;
}
}else {
titname=values.eduintits;
}
}catch (e) {
titname=values.eduintits;
}
var url = `/courses/${id}/update_informs.json`;
axios.post(url,{
inform_id:this.state.id,
name:values.eduintits,
name:titname,
description:values.description,
}).then((result) => {
if(result){
@ -103,13 +122,13 @@ class Bullsubdirectory extends Component{
if(result.data.status === 0){
this.props.form.setFieldsValue({
id:this.state.id,
eduintits:values.eduintits,
eduintits:titname,
description:values.description,
});
this.setState({
whethertoeditysl:false,
id:this.state.id,
eduintits:values.eduintits,
eduintits:titname,
description:values.description,
});
this.props.getinputdata();
@ -192,8 +211,6 @@ class Bullsubdirectory extends Component{
{getFieldDecorator('eduintits',{ initialValue: this.state.eduintits }, {
rules: [{
required: true, message: '请在此输入标题,最多60个字符',
}, {
max: 60, message: '最大限制为60个字符',
}],
})(
<div className="ysleduinwh">
@ -275,7 +292,7 @@ class Bullsubdirectory extends Component{
rules: [{
required: true, message: '请在此输入内容,最多5000个字符',
}, {
max: 5000, message: '最大限制为5000个字符',
len: 5000, message: '最大限制为5000个字符',
}],
})(
<TPMMDEditor ref={this.messageRef}

@ -8,6 +8,8 @@ import Bullsubdirectory from "./Bullsubdirectory";
import moment from "../new/CoursesNew";
import Fileslistitem from "../Resource/Fileslistitem";
// 公告栏
// var isOnComposition = false;
// const isChrome = !!window.chrome && !!window.chrome.webstore
class Eduinforms extends Component{
constructor(props){
super(props);
@ -18,7 +20,7 @@ class Eduinforms extends Component{
isSpin:true,
whethertoedit:false,
addonAfter:0,
eduintit:"",
eduintits:"",
informs:[],
yslbool:false,
}
@ -90,7 +92,7 @@ class Eduinforms extends Component{
this.setState({
whethertoedit:bians,
description:"",
eduintit:"",
eduintits:"",
addonAfter:0,
});
this.props.form.setFieldsValue({
@ -106,21 +108,51 @@ class Eduinforms extends Component{
};
changeTopicName = (e) => {
console.log("调用了changeTopicName");
let num = parseInt(e.target.value.length);
let num = e.target.value.length;
if(num>60){
return;
}
this.setState({
addonAfter: num < 0 ? 0 : num
});
this.setState({
eduintit: e.target.value
})
if(num<=60){
this.setState({
eduintits: e.target.value
})
this.props.form.setFieldsValue({
eduintits: e.target.value,
});
}
this.props.form.setFieldsValue({
eduintits: e.target.value,
});
}
};
// handleComposition=(e)=>{
// if (e.type === 'compositionend') {
// // composition is end
// isOnComposition = false
//
// if (!isOnComposition && isChrome) {
// // fire onChange
// console.log(!isOnComposition);
// this.changeTopicName(e);
// }
// } else {
// // in composition
// isOnComposition = true
// }
// };
// handleComposition = (e) => {
// console.log(e.type + ": " + e.target.value);
// if (e.type === 'compositionend') {
// // composition is end
// const value = e.target.value;
// this.setState({ isOnComposition: false },()=>{
// // this.handleFixedChange(value);
// });
// } else {
// // in composition
// this.setState({ isOnComposition: true });
// }
// }
handleSubmit=(e) => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
@ -137,10 +169,24 @@ class Eduinforms extends Component{
}
var id=this.props.match.params.coursesId
var titname="";
try {
if(values.eduintits.length>0){
if( values.eduintits.length>60){
var str=values.eduintits;
titname=str.substring(0,60);
}else {
titname=values.eduintits;
}
}else {
titname=values.eduintits;
}
}catch (e) {
titname=values.eduintits;
}
var url = `/courses/${id}/new_informs.json`;
axios.post(url,{
name:values.eduintits,
name:titname,
description:values.description,
}).then((result) => {
if(result){
@ -172,7 +218,7 @@ class Eduinforms extends Component{
render(){
let{description,whethertoedit,addonAfter,eduintit,informs,yslbool} =this.state;
let{description,whethertoedit,addonAfter,eduintits,informs,yslbool} =this.state;
const {getFieldDecorator} = this.props.form;
return(
@ -234,8 +280,6 @@ class Eduinforms extends Component{
{getFieldDecorator('eduintits', {
rules: [{
required: true, message: '请在此输入标题,最多60个字符',
}, {
max: 60, message: '最大限制为60个字符',
}],
})(
<div className="ysleduinwh">
@ -243,12 +287,12 @@ class Eduinforms extends Component{
<span className="yslduincolorred">*</span>
</div>
<div className="yslduinleft">
<Input placeholder="请在此输入标题最多60个字符" maxLength="60"
<Input placeholder="请在此输入标题最多60个字符" maxLength={60}
style={{ textAlign: "left",width:"100%",}}
onInput={this.changeTopicName}
autoComplete="off"
suffix={String(addonAfter)+"/60"}
value={eduintit}
value={eduintits}
className="searchViewAfter"></Input>
</div>

Loading…
Cancel
Save