项目实训#8 健康建议功能+前端界面美化、提高程序健壮性

实现了健康建议功能,患者点击获取健康建议摁扭之后,将医生诊断结果和患者主诉传给后端,后端再传给前端,前端显示得到弹窗上(代码中通过if判断已经处理了诊断结果可能为空的情况)

//健康建议功能代码:

   advise(){
       this.loadingInstance = ElLoading.service({
       fullscreen: true,
       text: '加载中,请耐心等待一分钟...',
       spinner: 'el-icon-loading',
       background: 'rgba(64,34,34,0.36)'
       })

      if(this.form.dia_result)
      {
      this.$axios.get("http://localhost:8000/medic/analyse/",
       { params:
         {
           诊断结果: this.form.dia_result,
           主诉: this.form.chief,
         }
      }).then(
          res=>{
            console.log(res.data)
            this.advice = res.data.advice
            this.dialogVisible = false
            this.dialogVisible2 = true
            this.loadingInstance.close();
            this.loadingInstance = null;
          }
      )
      }
      else
      {
        this.$axios.get("http://localhost:8000/medic/analyse/",
       { params:
         {
           诊断结果: "未诊断",
           主诉: this.form.chief,
         }
      }).then(
          res=>{
            console.log(res.data)
            this.advice = res.data.advice
            this.dialogVisible = false
            this.dialogVisible2 = true
            this.loadingInstance.close();
            this.loadingInstance = null;
          }
      )
      }
   },

前端美化部分:适当调整前端字体、字的大小、某些容器的规模以及加上一些图标el-icon

使得前端看起来更顺眼

//美化后前端图片:

增强程序健壮性:

(1)病历生成时用户不输入病情描述或是不选择医生(参数为空)怎么办?

判断,判断为空则不发送请求并且前端发送弹窗提醒

const initialDoctorList = async() => {
     await axios.get('http://localhost:8000/medic/return_doctor_list/').then(
       res => {
         //console.log(res.data.doctor_list)
         doctorList.value = res.data.doctor_list;
        // console.log(doctorList.value);
       }
  )
}
initialDoctorList()
const handleSubmit = async() => {
  console.log(blogForm.value)
  if(blogForm.value.content ===  "")
  {
    await openAnotherDialog();

  }
  else if(blogForm.value.doctor === "")
  {
    await openOtherDialog();
  }
  else if(blogForm.value.content !==  "" && blogForm.value.doctor !==  "")
  {

       //显示加载界面 element-plus
       loadingInstance = ElLoading.service({
       fullscreen: true,
       text: '正在生成病历,预计等待30秒...',
       spinner: 'el-icon-loading',
       background: 'rgba(0, 0, 0, 0.7)'
       }
   )
  // 在这里传给后端数据
  await axios.post('http://localhost:8000/medic/generate/'+pid.value+'/', querystring.stringify({
        message: blogForm.value.content,
        doctor_id: blogForm.value.doctor
    })).then(res => {
     console.log(res.data)
    theMessage.value = JSON.parse(JSON.stringify(res.data.message));
    console.log(theMessage)
   });

   await openDialog();
   await closeLoading();
  }
};

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值