<template>
  <div class="popup-content">
    <h2 class="title">
      <span class="line"></span>
      <p>{{ title }}</p>
      <span class="line"></span>
    </h2>
    <div class="content">
      <div class="cell inline ">
        <label>透析物品核查 : </label>
        <div class="check ">
          <el-radio v-model="doubleReview.dialysis_item_check" label="1"
            >正确</el-radio
          >
          <el-radio v-model="doubleReview.dialysis_item_check" label="2"
            >错误</el-radio
          >
        </div>
        <span class="name ">差错描述</span>
        <input
          type="text"
          class="des "
          v-model="doubleReview.dialysis_item_desc"
        />
      </div>

      <div class="cell inline">
        <label>透析参数核查 : </label>
        <div class="check">
          <el-radio v-model="doubleReview.dialysis_parameter_check" label="1"
            >正确</el-radio
          >
          <el-radio v-model="doubleReview.dialysis_parameter_check" label="2"
            >错误</el-radio
          >
        </div>
        <span class="name ">差错描述</span>
        <input
          type="text"
          class="des "
          v-model="doubleReview.dialysis_parameter_desc"
        />
      </div>

      <div class="cell inline">
        <label>血管通路核查 : </label>
        <div class="check">
          <el-radio
            v-model="doubleReview.vascular_access_verification"
            label="1"
            >正确</el-radio
          >
          <el-radio
            v-model="doubleReview.vascular_access_verification"
            label="2"
            >错误</el-radio
          >
        </div>
        <span class="name ">差错描述</span>
        <input
          type="text"
          class="des "
          v-model="doubleReview.vascular_access_desc"
        />
      </div>

      <div class="cell inline">
        <label>管道连接核查 : </label>
        <div class="check">
          <el-radio v-model="doubleReview.pipeline_connection_check" label="1"
            >正确</el-radio
          >
          <el-radio v-model="doubleReview.pipeline_connection_check" label="2"
            >错误</el-radio
          >
        </div>
        <span class="name ">差错描述</span>
        <input
          type="text"
          class="des "
          v-model="doubleReview.pipeline_connection_desc"
        />
      </div>

      <div class="cell width center">
        <button @click="commitInfo">提交</button>
      </div>
    </div>
  </div>
</template>

<script>
import { commitDoubleCheck } from "@/api/dialysis";

import { Toast } from "vant";

const rsfsOptions = ["正确", "整改"];
const brysOptions = ["正确", "整改"];
const brsyOptions = ["正确", "整改"];
const brqkOptions = ["正确", "整改"];
export default {
  name: "AcceptsAssessment",
  data() {
    return {
      doubleReview: {
        dialysis_item_check: "1",
        dialysis_parameter_check: "1",
        vascular_access_verification: "1",
        pipeline_connection_check: "1",
        dialysis_item_desc: "",
        dialysis_parameter_desc: "",
        vascular_access_desc: "",
        pipeline_connection_desc: "",
        collator: ""
      },
      title: "双人核对 ",
      patient: {
        id: 0
      },
      doctor: "",
      record_date: ""
    };
  },
  props: {
    record: {
      type: Object
    },
    patient_prop: {
      type: Object
    }
  },
  created() {
    if (this.record == null) {
      this.doubleReview.dialysis_item_check = "1";
      this.doubleReview.dialysis_parameter_check = "1";
      this.doubleReview.vascular_access_verification = "1";
      this.doubleReview.pipeline_connection_check = "1";
      this.doubleReview.dialysis_item_desc = "";
      this.doubleReview.dialysis_parameter_desc = "";
      this.doubleReview.vascular_access_desc = "";
      this.doubleReview.pipeline_connection_desc = "";
    } else {
      this.doubleReview.dialysis_item_check =
        this.record.dialysis_item_check + "";
      this.doubleReview.dialysis_parameter_check =
        this.record.dialysis_parameter_check + "";
      this.doubleReview.vascular_access_verification =
        this.record.vascular_access_verification + "";
      this.doubleReview.pipeline_connection_check =
        this.record.pipeline_connection_check + "";
      this.doubleReview.dialysis_item_desc = this.record.dialysis_item_desc;
      this.doubleReview.dialysis_parameter_desc = this.record.dialysis_parameter_desc;
      this.doubleReview.vascular_access_desc = this.record.vascular_access_desc;
      this.doubleReview.pipeline_connection_desc = this.record.pipeline_connection_desc;
    }

    var date = this.$route.query && this.$route.query.date;
    date *= 1000;
    var newDate = new Date(date);
    var y = newDate.getFullYear();
    var m = newDate.getMonth() + 1;
    var d = newDate.getDate();
    if (isNaN(y) || isNaN(m) || isNaN(d)) {
      newDate = new Date();
      y = newDate.getFullYear();
      m = newDate.getMonth() + 1;
      d = newDate.getDate();
    }
    this.record_date =
      y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
    // this.patient.id = this.patient_prop.id
  },
  methods: {
    // initData(doubleReview, patient, doctor) {
    //   //上层传值
    //   this.patient = patient;
    //   this.doubleReview = doubleReview;
    //   this.doctor = doctor;
    // },
    commitInfo: function() {
      let ParamsQuery = this.doubleReview;
      ParamsQuery["patient"] = this.$route.query.patient_id;
      ParamsQuery["record_date"] = this.record_date;
      commitDoubleCheck(ParamsQuery).then(response => {
        if (response.data.state == 0) {
          // this.$toast({message: response.data.msg});
          Toast.fail(response.data.msg);
          return false;
        } else {
          Toast.success("提交成功");
          this.$emit("doubleReview", response.data.data.doubleCheck);
          // console.log(response.data.data.doubleCheck)
          for (const key in response.data.data.doubleCheck) {
            this.record[key] = response.data.data.doubleCheck[key];
          }
        }
      });
    }
  }
};
</script>

<style style="stylesheet/scss" lang="scss" scoped>
.popup-content {
  .content {
    .cell {
      label {
        margin: 0 0.2rem 0 0;
        display: inline-block !important;
      }
      span {
        margin: 0.07rem 0 0 0;
      }
      select {
        width: 3.2rem;
      }
      .textarea {
        height: 2.16rem;
      }
    }
    .inline {
      // display: inline-block !important;
      width: 96% !important;
      @include display-flex;
      label {
        display: inline;
      }
    }
    .check {
      // display: inline-block;
    }
    .des {
      border: 1px $border-color solid;
      border-radius: 2px;
      padding: 0.18rem 0 0.18rem 10px;
      margin-left: 5px;
      @include flex;
    }
  }
}
</style>
