m0_59524973
2021-06-28 14:49
采纳率: 75%
浏览 50

react提交表单数据到后台保存后,页面为什么不显示数据

 /** [handleSubmit]表单提交数据函数 */
  handleSubmit = (e)=>{
    let self = this;
    e.preventDefault();
    this.props.form.validateFieldsAndScroll((err, values) => {
      if(typeof values.consultationDate != "string"){
        var consultationDate = values['consultationDate'].format('YYYY-MM-DD HH:mm:ss');
        values['consultationDate']=consultationDate;
      }
      if (!err) {
        this.addFollowUp(values);
      }
    });
  }
  /** [addFollowUp] 获取表单数据并传输到后台进行保存 */
  addFollowUp = (formData)=>{
    let followUpReplyDetails = [];
    console.log("followUpReplyDetails",followUpReplyDetails)
    formData.answerList.map((answer,index)=>{
      let followUpReplyDetail = {
        'replyid':this.props.data.id,
        'deptcode': window.sessionStorage.getItem('deptid'),
        'doctorid': window.sessionStorage.getItem('userid'),
        'doctorname': window.sessionStorage.getItem('username'),
        'creator': window.sessionStorage.getItem('userid'),
        'updator': window.sessionStorage.getItem('userid'),
        'questionname': this.state.symptomsData[index].questionname,
        'questionid': this.state.symptomsData[index].questionid,
        'answer': answer.vname?answer.vname:answer.answer,
        'answerid': answer.valueid?answer.valueid:answer.answerid,
      }
      followUpReplyDetails.push(followUpReplyDetail)
    })
    let dataSource={
      'id':this.props.data.id,
      'followupid':this.props.data.followupid,
      'orgid':this.props.data.orgid,
      'registerid':this.props.data.registerid,
      "doctorid": window.sessionStorage.getItem('userid'),
      "doctorname": window.sessionStorage.getItem('username'),
      "deptcode":this.props.data.deptcode,
      "creator":window.sessionStorage.getItem('userid'),
      "updator": window.sessionStorage.getItem('userid'),
      "advice":formData.allergichistory,
      "ispatient":formData.patientReport,
      "writeTime":this.props.data.writeTime,
      "useflag":this.props.data.useflag,
      "ctstamp":this.props.data.ctstamp,
      "followUpReplyDetails":followUpReplyDetails,
      }
    let params = {
      url: 'BuFollowUpReplyReplyController/putData',
      contentType: "application/json;charset=UTF-8",
      type: 'PUT',
      data: JSON.stringify(dataSource),
    };
    let than = this;
    function callBack(res){  
      if(res.result){
        notification.info({
          message: "提示",
          description: "提交成功",
          placement: "bottomRight",
          duration: 2
        });
        than.setState({disabled:true})
        // than.props.setModule({module:''})
      }else{
        notification.error({
          message: "提示",
          description: "提交失败",
          placement: "bottomRight",
          duration: 2
        });
      }
    };
    ajaxGetResource(params, callBack);
  }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 已采纳

    提交成功后,后台应该会返回值,如果不是后端返回,需要,前端记录下来,提交的值。然后接口提交成功后,拿到这个值。渲染就行,用标签渲染

    let value={ //这个是提交的值
     id:111,
     name:"00"
    }
    
    //渲染
    
    <div>{{value.id}}</div>
    <div>{{value.name}}</div>
    点赞 打赏 评论
  • Lei4Real 2021-06-28 14:51

    提交之后 需要把数据渲染到页面上

    点赞 打赏 评论

相关推荐 更多相似问题