调整 公告栏

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

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

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

Loading…
Cancel
Save