<template>
    <div style="background-color: #f0f2f5; padding-bottom: 20px; min-height: 100%; " >
      <div style="padding: 20px; background-color: #fff;">
        用药报告
      </div>
      <div class="my-content"   >
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <el-form-item label="用户昵称"  >
            <el-input :disabled="true" type="text" v-model="user.nickName"  />
          </el-form-item>
          <el-form-item label="患者姓名"  >
            <el-input :disabled="true" type="text" v-model="follow.patientName"  />
          </el-form-item>
          <el-form-item label="咨询总结" prop="reportSummary">
            <el-input type="textarea" placeholder="请输入咨询总结"   maxlength="800" show-word-limit v-model="form.reportSummary"  />
          </el-form-item>
          <el-form-item label="生活建议" prop="reportAdvice">
            <el-input type="textarea" placeholder="请输入生活建议"   maxlength="800" show-word-limit v-model="form.reportAdvice"  />
          </el-form-item>
          <el-form-item label="备注" prop="remark">
            <el-input type="textarea" placeholder="请输入备注"   maxlength="500" show-word-limit v-model="form.remark"  />
          </el-form-item>
        </el-form>
        <div  class="btn-box">
          <el-button type="primary" @click="submitForm">确 定</el-button>
        </div>
      </div>
    </div>
</template>

<script>
  import {getFollowById} from '@/api/follow.js'
  import { addReport} from "@/api/drugReport";
  export default {
    name: "addReport",
    props:["data"],
    data() {
      return {
        followId:null,
        user:null,
        follow:null,
        form: {
          reportSummary:"",
          reportAdvice:"",
          remark:""
        },
        rules: {
          reportSummary: [
            { required: true, message: "咨询总结不能为空", trigger: "blur" }
          ],
        }
      }
    },
    created() {
    },
    methods: {
      getFollowById() {
        getFollowById(this.followId).then(response => {
            this.follow = response.follow;
            this.user=response.user;
        });
      },
      openDrugReport(followId){
        this.followId=followId;
        this.getFollowById();
      },
      submitForm(){
        this.$refs["form"].validate(valid => {
          if (valid) {
            var data={
              followId:this.followId,
              reportSummary:this.form.reportSummary,
              reportAdvice:this.form.reportAdvice,
              remark:this.form.remark
            }
            addReport(data).then(response => {
              this.msgSuccess("提交成功");
            });
          }
        });
      },
    }
  }
</script>
<style lang="scss" scoped>
  .my-content{
      background-color: #fff;
      padding: 20px;
      margin: 20px;
      .btn-box{
        margin:15px 0px;
        text-align:right;
      }
  }
</style>
