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

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条回答 默认 最新

  • 崽崽的谷雨 2021-06-29 10:00
    关注

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

    let value={ //这个是提交的值
     id:111,
     name:"00"
    }
    
    //渲染
    
    <div>{{value.id}}</div>
    <div>{{value.name}}</div>
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误