<template>
  <div class="plate-box">
    <h2 class="title">
      <span class="line"></span>
      <p>{{ title }}</p>
      <span class="line"></span>
    </h2>
    <div class="plate ">
      <ul>
        <li v-if="isShow('透前体重')">
          <label>透前体重 : </label>
          <span class="content">{{ weight_before ? weight_before : "" }}</span>
          <span class="unit">{{ weight_before ? "kg" : "" }}</span>
        </li>
        <li v-if="this.$store.getters.user.template_info.template_id == 6">
          <label>透前净体重 : </label>
          <span class="content">{{ weight_before ? parseFloat(weight_before - additional_weight).toFixed(1) : "" }}</span>
          <span class="unit">{{ weight_before ? "kg" : "" }}</span>
        </li>
        <li v-if="isShow('收缩压')">
          <label>收缩压 : </label>
          <span class="content">{{
            systolic_blood_pressure ? systolic_blood_pressure : ""
          }}</span>
          <span class="unit">{{ systolic_blood_pressure ? "mmHg" : "" }}</span>
        </li>

        <li v-if="isShow('舒张压')">
          <label>舒张压 : </label>
          <span class="content">{{
            diastolic_blood_pressure ? diastolic_blood_pressure : ""
          }}</span>
          <span class="unit">{{ diastolic_blood_pressure ? "mmHg" : "" }}</span>
        </li>

        <li v-if="isShow('前次透析后')">
          <label>前次透析后: </label>
          <span class="content">{{ last_post_dialysis }}</span>
          <span class="unit"></span>
        </li>
        <li v-if="isShow('导管')">
          <label>导管 : </label>
          <span class="content">{{ catheter }}</span>
          <span class="unit"></span>
        </li>
        <li v-if="isShow('衣物重')">
          <label>衣物重 : </label>
          <span class="content">{{
            additional_weight ? additional_weight : ""
          }}</span>
          <span class="unit">{{ additional_weight ? "kg" : "" }}</span>
        </li>
        <li v-if="isShow('干体重')">
          <label>干体重 : </label>
          <span class="content">{{ dry_weight ? dry_weight : "" }}</span>
          <span class="unit">{{ dry_weight ? "kg" : "" }}</span>
        </li>
        <li v-if="isShow('透析期间')">
          <label>透析期间 : </label>
          <span class="content">{{ dialysis_interphase }}</span>
          <span class="unit"></span>
        </li>

        <!-- </ul>
      <ul> -->
        <li v-if="isShow('体温')">
          <label>体温 : </label>
          <span class="content">{{ temperature ? temperature : "" }}</span>
          <span class="unit">{{ temperature ? "℃" : "" }}</span>
        </li>
        <li v-if="isShow('脉搏')">
          <label>脉搏 : </label>
          <span class="content">{{
            pulse_frequency ? pulse_frequency : ""
          }}</span>
          <span class="unit">{{ pulse_frequency ? "次/分" : "" }}</span>
        </li>

        <li v-if="isShow('呼吸频率')">
          <label>呼吸频率 : </label>
          <span class="content">{{
            breathing_rate ? breathing_rate : ""
          }}</span>
          <span class="unit">{{ breathing_rate ? "次/分" : "" }}</span>
        </li>
        <li v-if="isShow('透析前症状')">
          <label>透析前症状 : </label>
          <span class="content">{{ symptom_before_dialysis }}</span>
          <span class="unit"></span>
        </li>
        <li v-if="isShow('出血')">
          <label>出血:</label>
          <span class="content">{{
            is_hemorrhage ? hemorrhage + ";" + hemorrhage_other : "无"
          }}</span>
          <span class="unit"> </span>
        </li>

        <li v-if="isShow('并发症')">
          <label>并发症: </label>
          <span class="content">{{ complication }}</span>
          <span class="unit"></span>
        </li>


        <!-- </ul>

      <ul> -->

        <li v-if="isShow('透析机型号')">
          <label>透析机型号: </label>
          <span class="content">{{ machine_type ? machine_type : "" }}</span>
          <span class="unit"></span>
        </li>

        <li v-if="isShow('透析频次')">
          <label>透析频次: </label>
          <span class="content">{{
            dialysis_count ? dialysis_count : ""
          }}</span>
          <span class="unit">{{ dialysis_count ? "次/周" : "" }}</span>
        </li>
        <li v-if="isShow('血管通路(内瘘)')">
          <label>血管通路(内瘘) : </label>
          <span class="content">{{ blood_access_internal_fistula }}</span>
        </li>
        <li v-if="isShow('血管杂音')">
          <label>血管杂音 : </label>
          <span class="content">{{
            getBloodAccessNoise(this.record.blood_access_noise)
          }}</span>
        </li>

        <li v-if="isShow('穿刺针')">
          <label>穿刺针 : </label>
          <span class="content">{{ this.record.puncture_needle }}</span>
        </li>

        <li v-if="isShow('穿刺方式')">
          <label>穿刺方式 : </label>
          <span class="content">{{ getWay(this.record.puncture_way) }}</span>
        </li>
        <li v-if="isShow('中心静脉置管')">
          <label>中心静脉置管:</label>
          <span class="content">{{
            getVenousCatheterization(this.record.venous_catheterization)
          }}</span>
          <span class="unit"> </span>
        </li>
        <!--
      </ul>

      <ul > -->
        <li v-if="isShow('位置')">
          <label>位置:</label>
          <span class="content">{{
            getVenousCatheterizationPart(
              this.record.venous_catheterization_part
            )
          }}</span>
          <span class="content">{{ venous_catheterization_part_other }}</span>
        </li>

        <li v-if="isShow('中心静脉导管')">
          <label>中心静脉导管: </label>
          <span class="content">{{ this.record.ductus_arantii }}</span>
        </li>

        <li v-if="isShow('其他中心静脉导管')">
          <label>其他中心静脉导管:</label>
          <span class="content">{{ ductus_arantii_other }}</span>
          <span class="unit"> </span>
        </li>

        <li v-if="isShow('急诊')">
          <label>急诊: </label>
          <span class="content">{{
            getEmergencyTreatment(this.record.emergency_treatment)
          }}</span>
          <span class="content">{{ emergency_treatment_other }}</span>
        </li>

        <li v-if="isShow('感染')">
          <label>感染:</label>
          <span class="content">{{
            this.record.is_infect == 1 ? "无" : "有"
          }}</span>
          <span class="unit"> </span>
        </li>

        <li v-if="isShow('其他感染情况')">
          <label>其他感染情况:</label>
          <span class="content">{{ infect_other }}</span>
          <span class="unit"> </span>
        </li>

        <li v-if="isShow('外露')">
          <label>外露:</label>
          <span class="content">{{
            this.record.exposed ? this.record.exposed : ""
          }}</span>
          <span class="unit">cm</span>
        </li>

        <li v-if="isShow('皮肤')">
          <label>皮肤:</label>
          <span class="content">{{ getSkin(this.record.skin) }}</span>
          <span class="unit"></span>
        </li>

        <li v-if="isShow('其他皮肤情况')">
          <label>其他皮肤情况:</label>
          <span class="content">{{ skin_other }}</span>
          <span class="unit"> </span>
        </li>

        <li  v-if="isShow('血管通路部位')">
          <label>血管通路部位:</label>
          <span class="content">{{ getBloodAccessPart(this.record.blood_access_part_id) }}</span>
          <span class="unit"> </span>
        </li>

        <li  v-if="isShow('血管通路操作')">
          <label>血管通路操作:</label>
          <span class="content">{{ getBloodAccessOpera(this.record.blood_access_part_opera_id) }}</span>
          <span class="unit"> </span>
        </li>
      </ul>
    </div>
    <div class="note">
      备注 : <span>{{ remark }}</span>
    </div>
  </div>
</template>

<script>
  import { getDataConfig } from "@/utils/data";

  export default {
  name: "assessmentBefore",

  data() {
    return {
      title: "透前评估 ",
      template_id: 0
    };
  },
  props: {
    record: {
      type: Object
    },
    dry_weights: {
      type: Object
    }
  },
  created() {
    this.template_id = this.$store.getters.user.template_info.template_id;
  },
  computed: {
    machine_type: function() {
      if (this.record == null || this.record.id == "") {
        return "";
      }
      return this.record.machine_type;
    },
    weight_before: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.weight_before;
    },
    additional_weight: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.additional_weight;
    },
    systolic_blood_pressure: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.systolic_blood_pressure;
    },
    last_post_dialysis: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.last_post_dialysis;
    },

    dry_weight: function() {
      if (this.$store.getters.user.template_info.template_id == 6) {
        if (this.dry_weights != null && this.dry_weights.id > 0) {
          return this.dry_weights.dry_weight;
        } else {
          if (this.record == null || this.record.id == "") {
            return "-";
          }
          return this.record.dry_weight;
        }
      } else {
        if (this.record == null || this.record.id == "") {
          return "-";
        }

        return this.record.dry_weight;
      }
    },
    diastolic_blood_pressure: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.diastolic_blood_pressure;
    },
    dialysis_interphase: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.dialysis_interphase;
    },
    catheter: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.catheter;
    },

    temperature: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.temperature;
    },
    pulse_frequency: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.pulse_frequency;
    },
    breathing_rate: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.breathing_rate;
    },
    symptom_before_dialysis: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.symptom_before_dialysis;
    },
    complication: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.complication;
    },
    internal_fistula: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.internal_fistula;
    },
    is_hemorrhage: function() {
      if (this.record == null || this.record.id == "") {
        return false;
      }
      return this.record.is_hemorrhage == 1;
    },
    hemorrhage: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.hemorrhage;
    },
    hemorrhage_other: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.hemorrhage_other;
    },

    remark: function() {
      if (this.record == null || this.record.id == "") {
        return "";
      }
      return this.record.remark;
    },
    dialysis_count: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.dialysis_count;
    },
    internal_fistula_other: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.internal_fistula_other;
    },
    venous_catheterization_part_other: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.venous_catheterization_part_other;
    },
    emergency_treatment_other: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.emergency_treatment_other;
    },
    blood_access_internal_fistula: function() {
      var name1 = "";
      var name2 = "";

      if (this.record == null || this.record.id == "") {
        return "-";
      }
      if (this.record.blood_access_internal_fistula == undefined) {
        name1 = "";
      } else {
        name1 = this.record.blood_access_internal_fistula + ",";
      }
      if (this.record.internal_fistula_other == undefined) {
        name2 = "";
      } else {
        name2 = this.record.internal_fistula_other;
      }

      return name1 + name2;
    },
    infect_other: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.infect_other;
    },
    skin_other: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.skin_other;
    },
    ductus_arantii_other: function() {
      if (this.record == null || this.record.id == "") {
        return "-";
      }
      return this.record.ductus_arantii_other;
    }
  },
  methods: {
    getBloodAccessPart: function(id) {
      var BloodAccessPart = getDataConfig('hemodialysis', 'vascular_access')
      var BloodAccessPartName = ''
      for (let i = 0; i < BloodAccessPart.length; i++) {
        if (BloodAccessPart[i].id == id) {
          BloodAccessPartName = BloodAccessPart[i].name
        }
      }
      return BloodAccessPartName
    },
    getBloodAccessOpera: function(id) {
      var BloodAccessOpera =  getDataConfig('hemodialysis', 'vascular_access_desc')
      var BloodAccessOperaName = ''
      for (let i = 0; i < BloodAccessOpera.length; i++) {
        if (BloodAccessOpera[i].id == id) {
          BloodAccessOperaName = BloodAccessOpera[i].name
        }
      }
      return BloodAccessOperaName
    },
    isShow(name) {
      var filedList = this.$store.getters.user.fileds;

      for (let i = 0; i < filedList.length; i++) {
        if (
          filedList[i].module == 3 &&
          filedList[i].filed_name_cn == name &&
          filedList[i].is_show == 1
        ) {
          return true;
        }
      }
      return false;
    },
    getBloodAccessInternalFistula: function(id) {
      var BloodAccessInternalFistulaOptions = this.$store.getters
        .blood_access_internal_fistula;
      var BloodAccessInternalFistulaName = "";
      for (let i = 0; i < BloodAccessInternalFistulaOptions.length; i++) {
        if (BloodAccessInternalFistulaOptions[i].id == id) {
          BloodAccessInternalFistulaName =
            BloodAccessInternalFistulaOptions[i].name;
        }
      }
      return BloodAccessInternalFistulaName;
    },
    getBloodAccessNoise: function(id) {
      var BloodAccessNoiseOptions = this.$store.getters.blood_access_noise;
      var BloodAccessNoiseName = "";
      for (let i = 0; i < BloodAccessNoiseOptions.length; i++) {
        if (BloodAccessNoiseOptions[i].id == id) {
          BloodAccessNoiseName = BloodAccessNoiseOptions[i].name;
        }
      }
      return BloodAccessNoiseName;
    },
    getVenousCatheterization: function(id) {
      var VenousCatheterizationOptions = this.$store.getters
        .venous_catheterization;
      var VenousCatheterizationName = "";
      for (let i = 0; i < VenousCatheterizationOptions.length; i++) {
        if (VenousCatheterizationOptions[i].id == id) {
          VenousCatheterizationName = VenousCatheterizationOptions[i].name;
        }
      }
      return VenousCatheterizationName;
    },
    getWay: function(id) {
      var PunctureWayOptions = this.$store.getters.puncture_way;
      var PunctureWayOptionsName = "";
      for (let i = 0; i < PunctureWayOptions.length; i++) {
        if (PunctureWayOptions[i].id == id) {
          PunctureWayOptionsName = PunctureWayOptions[i].name;
        }
      }
      return PunctureWayOptionsName;
    },
    getVenousCatheterizationPart: function(id) {
      var venousCatheterizationPartOptions = this.$store.getters
        .venous_catheterization_part;
      var venousCatheterizationPartName = "";
      for (let i = 0; i < venousCatheterizationPartOptions.length; i++) {
        if (venousCatheterizationPartOptions[i].id == id) {
          venousCatheterizationPartName =
            venousCatheterizationPartOptions[i].name;
        }
      }
      return venousCatheterizationPartName;
    },
    getDuctusArantii: function(id) {
      var ductusArantiiOptions = this.$store.getters.ductus_arantii;
      var ductusArantiiOptionsName = "";
      for (let i = 0; i < ductusArantiiOptions.length; i++) {
        if (ductusArantiiOptions[i].id == id) {
          ductusArantiiOptionsName = ductusArantiiOptions[i].name;
        }
      }
      return ductusArantiiOptionsName;
    },
    getEmergencyTreatment: function(id) {
      var emergencyTreatmentOptions = this.$store.getters.emergency_treatment;
      var emergencyTreatmentName = "";
      for (let i = 0; i < emergencyTreatmentOptions.length; i++) {
        if (emergencyTreatmentOptions[i].id == id) {
          emergencyTreatmentName = emergencyTreatmentOptions[i].name;
        }
      }
      return emergencyTreatmentName;
    },
    getSkin: function(id) {
      var skinOptions = this.$store.getters.skin;
      var skinName = "";
      for (let i = 0; i < skinOptions.length; i++) {
        if (skinOptions[i].id == id) {
          skinName = skinOptions[i].name;
        }
      }
      return skinName;
    }
    // setRecord(record) {
    //   if (record == null) {
    //     this.info1[0].content = "0"
    //     this.info1[1].content = "0"
    //     this.info1[2].content = "0"
    //     // this.info1[3].content = ""

    //     this.info2[0].content = "0"
    //     this.info2[1].content = "0"
    //     this.info2[2].content = ""
    //     this.info2[3].content = ""

    //     this.info3[0].content = "0"
    //     this.info3[1].content = "0"
    //     this.info3[2].content = ""
    //     this.info3[3].content = ""

    //     this.note = ""

    //   } else {
    //     this.info1[0].content = record.weight_before
    //     this.info1[1].content = record.systolic_blood_pressure
    //     this.info1[2].content = record.last_post_dialysis
    //     // this.info1[3].content = ""

    //     this.info2[0].content = record.additional_weight
    //     this.info2[1].content = record.diastolic_blood_pressure
    //     this.info2[2].content = record.dialysis_interphase
    //     this.info2[3].content = record.catheter

    //     this.info3[0].content = record.temperature
    //     this.info3[1].content = record.breathing_rate
    //     this.info3[2].content = record.symptom_before_dialysis
    //     this.info3[3].content = record.complication

    //     this.note = record.remark
    //   }
    // }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped></style>
