dev_home
杨树林 6 years ago
parent 4be7c249c3
commit 6bc07511da

@ -24,25 +24,28 @@ class Bullsubdirectory extends Component{
Modalstopval:"是否确认删除?", Modalstopval:"是否确认删除?",
ModalCancel:"", ModalCancel:"",
ModalSave:"", ModalSave:"",
index:0,
} }
//不能显示数据编辑的时候没有赋值
//没加initialValue 输入不能赋值到from 上
} }
componentDidMount() { componentDidMount() {
console.log("获取到数据"); console.log("获取到数据");
console.log(this.props); console.log(this.props);
let{id,myname,mydescription} =this.props let{id,myname,mydescription,index,item} =this.props
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
id:id, id:id,
eduintits:myname, eduintits:item.name,
description:mydescription, description:item.description,
}); });
// this.contentMdRef.current.setValue(mydescription);
this.setState({ this.setState({
id:id, id:id,
eduintits:myname, eduintits:item.name,
description:mydescription, description:item.description,
index:index
}) })
if(myname!=undefined){ if(myname!=undefined){
this.setState({ this.setState({
@ -108,10 +111,20 @@ class Bullsubdirectory extends Component{
} }
bianji = (bians)=>{ bianji = (bians,i)=>{
console.log("bianji");
console.log(this.props.myname);
console.log(this.props.mydescription);
this.setState({ this.setState({
whethertoeditysl:bians, whethertoeditysl:bians,
}) eduintits:this.props.myname,
description:this.props.mydescription,
index:i
});
this.props.form.setFieldsValue({
eduintits:this.props.myname,
description:this.props.mydescription,
});
if(bians===true){ if(bians===true){
this.props.getyslbooltrue(); this.props.getyslbooltrue();
}else { }else {
@ -143,6 +156,7 @@ class Bullsubdirectory extends Component{
handleSubmit=(e) => { handleSubmit=(e) => {
e.preventDefault(); e.preventDefault();
this.props.form.validateFields((err, values) => { this.props.form.validateFields((err, values) => {
debugger
if (!err) { if (!err) {
console.log(values.description); console.log(values.description);
if(values.eduintits === undefined|| values.eduintits === "" || values.eduintits ===null){ if(values.eduintits === undefined|| values.eduintits === "" || values.eduintits ===null){
@ -180,11 +194,11 @@ class Bullsubdirectory extends Component{
if(result){ if(result){
if(result.data){ if(result.data){
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:titname, // eduintits:titname,
description:values.description, // description:values.description,
}); // });
this.setState({ this.setState({
whethertoeditysl:false, whethertoeditysl:false,
id:this.state.id, id:this.state.id,
@ -266,15 +280,19 @@ class Bullsubdirectory extends Component{
render(){ render(){
let{description,whethertoeditysl,addonAfter,eduintits,informs,isSpinysl} =this.state; let{description,whethertoeditysl,addonAfter,eduintits,informs,isSpinysl,index} =this.state;
let{myname,mydescription,id}=this.props; let{myname,mydescription,id}=this.props;
const {getFieldDecorator} = this.props.form; const {getFieldDecorator} = this.props.form;
// console.log("Bullsubdirectory"); // console.log("Bullsubdirectory");
// console.log(this.props.isAdmin()); // console.log(this.props.isAdmin());
// console.log(this.props); console.log(this.props);
console.log(whethertoeditysl);
console.log(this.state.eduintits);
console.log(this.state.description);
return( return(
<React.Fragment > <React.Fragment key={this.props.index} id={this.props.id}>
<div > <div key={this.props.index} id={this.props.id}>
{this.state.Modalstype&&this.state.Modalstype===true?<Modals {this.state.Modalstype&&this.state.Modalstype===true?<Modals
modalsType={this.state.Modalstype} modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval} modalsTopval={this.state.Modalstopval}
@ -282,10 +300,12 @@ class Bullsubdirectory extends Component{
modalSave={this.state.ModalSave} modalSave={this.state.ModalSave}
/>:""} />:""}
<Spin size="large" spinning={isSpinysl} > <Spin size="large" spinning={isSpinysl} >
<div className="edu-back-white "> <div className="edu-back-white " id={
index
}>
{ {
whethertoeditysl === false? whethertoeditysl === false?
<div> <div id={this.props.index}>
<div className="fudonyingxiangysls"> <div className="fudonyingxiangysls">
<div className="fudonyingxiangysl"> <div className="fudonyingxiangysl">
<div style={{marginRight:"60px"}}> <div style={{marginRight:"60px"}}>
@ -299,7 +319,7 @@ class Bullsubdirectory extends Component{
<Tooltip placement="bottom" title={<div> <Tooltip placement="bottom" title={<div>
编辑 编辑
</div>}> </div>}>
<i className="iconfont icon-bianji1 newbianji1" onClick={()=>this.bianji(true)}></i> <i className="iconfont icon-bianji1 newbianji1" onClick={()=>this.bianji(true,this.props.index)}></i>
</Tooltip> </Tooltip>
: :
"" ""
@ -366,8 +386,9 @@ class Bullsubdirectory extends Component{
{parseInt(this.props&&this.props.informs.length)===parseInt(this.props&&this.props.index+1)?"":<div className="bor-bottom-greyE mr25 ml25"></div>} {parseInt(this.props&&this.props.informs.length)===parseInt(this.props&&this.props.index+1)?"":<div className="bor-bottom-greyE mr25 ml25"></div>}
</div> </div>
: :
<div className="edu-back-white "> whethertoeditysl === true?
<Form layout='vertical' onSubmit={this.handleSubmit} > <div className="edu-back-white " key={this.props.index} id={this.props.id}>
<Form layout='vertical' onSubmit={this.handleSubmit} key={this.props.index}>
<style> <style>
{ {
`.ant-form-item{ `.ant-form-item{
@ -390,8 +411,9 @@ class Bullsubdirectory extends Component{
<Form.Item <Form.Item
style={{"borderBottom":'none'}} style={{"borderBottom":'none'}}
className="chooseDestwo " className="chooseDestwo "
key={this.props.index}
> >
{getFieldDecorator('eduintits',{ initialValue: this.state.eduintits }, { {getFieldDecorator('eduintits', { initialValue: eduintits}, {
rules: [{ rules: [{
required: true, message: '请在此输入标题,最多60个字符', required: true, message: '请在此输入标题,最多60个字符',
}], }],
@ -409,7 +431,7 @@ class Bullsubdirectory extends Component{
} }
` `
}</style> }</style>
<Input placeholder="请在此输入标题最多60个字符" maxLength="60" <Input placeholder="请在此输入标题最多60个字符" key={this.props.index} maxLength="60"
style={{ textAlign: "left",width:"100%",}} style={{ textAlign: "left",width:"100%",}}
onInput={this.changeTopicName} onInput={this.changeTopicName}
autoComplete="off" autoComplete="off"
@ -423,7 +445,7 @@ class Bullsubdirectory extends Component{
</Form.Item> </Form.Item>
<div className="edu-back-white "> <div className="edu-back-white " key={this.props.index}>
<div className={"yslmt16px"}> <div className={"yslmt16px"}>
<style> <style>
{ {
@ -478,8 +500,9 @@ class Bullsubdirectory extends Component{
<Form.Item <Form.Item
style={{"borderBottom":'none'}} style={{"borderBottom":'none'}}
className="chooseDes " className="chooseDes "
key={this.props.index}
> >
{getFieldDecorator('description', { initialValue: this.state.description },{ {getFieldDecorator('description', { initialValue: description},{
rules: [{ rules: [{
required: true, message: '请在此输入内容,最多5000个字符', required: true, message: '请在此输入内容,最多5000个字符',
}, { }, {
@ -487,20 +510,24 @@ class Bullsubdirectory extends Component{
}], }],
})( })(
<TPMMDEditor ref={this.messageRef} <TPMMDEditor ref={this.messageRef}
key={this.props.index}
placeholder={'请在此输入内容,最多5000个字符'} placeholder={'请在此输入内容,最多5000个字符'}
initValue={description} initValue={description}
mdID={'courseMessageMD'} mdID={'courseMessageMD'}
className="courseMessageMD " className="courseMessageMD "
height={518} height={518}
></TPMMDEditor> ></TPMMDEditor>
)} )}
</Form.Item> </Form.Item>
</div> </div>
</div> </div>
<Form.Item> <Form.Item>
<div className="clearfix mt28 fr pb50 mr25"> <div className="clearfix mt28 fr pb50 mr25">
<a className="defalutCancelbtn fl mr20 " onClick={()=>this.bianji(false)}>取消</a> <a className="defalutCancelbtn fl mr20 " onClick={()=>this.bianji(false,this.props.index)}>取消</a>
<Button htmlType="submit" className="ant-btn defalutSubmitbtn fl ant-btn-primary"> <Button htmlType="submit" className="ant-btn defalutSubmitbtn fl ant-btn-primary">
<span> </span></Button> <span> </span></Button>
</div> </div>
@ -508,6 +535,7 @@ class Bullsubdirectory extends Component{
</Form> </Form>
<div className="bor-bottom-greyE mr25 ml25"></div> <div className="bor-bottom-greyE mr25 ml25"></div>
</div> </div>
:""
} }
</div> </div>
</Spin> </Spin>

@ -497,6 +497,7 @@ class Eduinforms extends Component{
<Bullsubdirectory {...this.state} {...this.props} key={index} index={index} <Bullsubdirectory {...this.state} {...this.props} key={index} index={index}
length={informs.length} yslbool={yslbool} id={item.id} length={informs.length} yslbool={yslbool} id={item.id}
myname={item.name} mydescription={item.description} myname={item.name} mydescription={item.description}
item={item}
getyslbooltrue={()=>this.getyslbooltrue()} getyslbooltrue={()=>this.getyslbooltrue()}
getyslboolfalse={()=>this.getyslboolfalse()} getyslboolfalse={()=>this.getyslboolfalse()}
getinputdata={()=>this.getinputdata()} ></Bullsubdirectory> getinputdata={()=>this.getinputdata()} ></Bullsubdirectory>

Loading…
Cancel
Save