<template>
  <el-dialog
    :visible.sync="visibility"
    width="500px"
    :modal-append-to-body="false"
    :append-to-body="true"
  >
    <div>
      <div class="DialogTit">
        <div class="back" @click="cancle()">
          <span class="iconfont">&#xe720; </span>返回
        </div>
        <h1 class="name">
          {{ patient_prop.name }} [透析号 {{ patient_prop.dialysis_no }} ]
        </h1>
        <span @click="comfirm" class="success" style="visibility: hidden;"
          >确定</span
        >
      </div>

      <div class="DialogContent">
        <div class="item">
          <label class="name" for="txms">本次透析日期</label>
          <div class="content">
            <span class="text" id="txms"> {{ dialysis_date }}</span>
          </div>
        </div>
        <div class="item">
          <label class="name" for="txms">透前称重（kg）</label>
          <div class="content">
            <span class="text" id="txms">{{ predialysis.weight_before }}</span>
          </div>
        </div>
        <div class="item">
          <label class="name" for="txms">干体重（kg）</label>
          <div class="content">
            <span class="text" id="txms">{{
              last_predialysis.dry_weight
            }}</span>
          </div>
        </div>
        <div class="item">
          <label class="name" for="txms">衣物重（kg）</label>
          <div class="content">
            <span class="text" id="txms">{{
              predialysis.additional_weight
            }}</span>
          </div>
        </div>
        <div class="item">
          <label class="name" for="txms">体重增加（kg）</label>
          <div class="content">
            <span class="text" id="txms">{{ add_weight }}</span>
          </div>
        </div>
        <div class="item">
          <label class="name" for="txms">透后称重（kg）</label>
          <div class="content">
            <span class="text" id="txms">{{ record.weight_after }}</span>
          </div>
        </div>
        <div class="item">
          <label class="name" for="txms">体重减少（kg）</label>
          <div class="content">
            <span class="text" id="txms">{{ record.weight_loss }}</span>
          </div>
        </div>
        <div class="item">
          <label class="name" for="txms">上次透后称重（kg）</label>
          <div class="content">
            <span class="text" id="txms">{{ last_record.weight_after }}</span>
          </div>
        </div>
      </div>
    </div>
  </el-dialog>
</template>

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

export default {
  name: "MsgTip",
  created() {
    if (
      this.predialysis.weight_before > 0 &&
      this.last_record.weight_after > 0
    ) {
      this.add_weight = parseFloat(
        this.predialysis.weight_before - this.last_record.weight_after
      ).toFixed(2);
    }
  },
  data() {
    return {
      result: [],
      id: 0,
      selectName: "",
      add_weight: 0
    };
  },
  props: {
    predialysis: {
      type: Object
    },
    visibility: {
      type: Boolean,
      default: false
    },
    last_predialysis: {
      type: Object
    },
    record: {
      type: Object
    },
    last_record: {
      type: Object
    },
    patient_prop: {
      type: Object
    },
    prescription_prop: {
      type: Object
    }
  },
  computed: {
    dialysis_date: function() {
      return parseTime(this.$route.query.date, "{y}/{m}/{d}");
    }
  },
  methods: {
    cancle: function() {
      this.$emit("menu-msg-tip");
    },
    comfirm: function() {
      this.$emit("menu-msg-tip");
    },
    getValue: function() {
      const form = {};

      let results = [];

      for (let i = 0; i < this.propsForm.list.length; i++) {
        for (let a = 0; a < this.propsForm.result.length; a++) {
          if (this.propsForm.list[i].id == this.propsForm.result[a]) {
            results.push(this.propsForm.list[i]);
          }
        }
      }

      var obj5 = {};
      results = results.reduce((cur, next) => {
        obj5[next.id] ? "" : (obj5[next.id] = true && cur.push(next));
        return cur;
      }, []);

      results;

      return results;
    }
  },
  watch: {
    visibility(val) {
      // 初始化数据操作
    }
  }
};
</script>

<style scoped></style>
