<template>
  <div class="plate-box">
    <h2 class="DetailsTit"><span>{{ title }}</span></h2>
    <div class="plate ">
      <ul>
        <li v-if="isShow('班次')">
          <label>班次 : </label>
          <span class="content">{{ schedual_type }}</span>
        </li>
        <li v-if="isShow('上机床位')">
          <label>上机床位 : </label>
          <span class="content">{{ device_number }}</span>
        </li>
        <li v-if="isShow('上机护士')">
          <label>上机护士 : </label>
          <span class="content">{{ nurse }}</span>
        </li>
      </ul>
      <ul>
        <li v-if="isShow('穿刺者')">
          <label>穿刺者 : </label>
          <span class="content">{{ puncture_nurse }}</span>
        </li>
        <li v-if="isShow('冲管护士')">
          <label>冲管护士 : </label>
          <span class="content">{{ washpipe_nurse }}</span>
        </li>

        <li v-if="isShow('换药护士')">
          <label>换药护士 : </label>
          <span class="content">{{ change_nurse }}</span>
        </li>

       <li v-if="isShow('疑难穿刺护士')">
          <label>疑难穿刺护士 : </label>
          <span class="content">{{ difficult_puncture_nurse }}</span>
        </li>
        <li v-if="isShow('新开瘘护士')">
          <label>新开瘘护士 : </label>
          <span class="content">{{ new_fistula_nurse }}</span>
        </li>
        <li>
          <label>状态 : </label>
          <span class="content">{{ stage }}</span>
        </li>
      </ul>
      <ul>
        <li v-if="isShow('上机时间')">
          <label>上机时间 : </label>
          <span class="content">{{start_time}}</span>
        </li>
      </ul>
    </div>
    <div class="middleLine"></div>
  </div>
</template>

<script>
  import { parseTime } from '@/utils'
  import store from '@/store'

  export default {
    name: 'DialysisComputer',
    data() {
      return {
        title: '透析上机 '
      }
    },
    props: {
      record: {
        type: Object
      },
      admin_map: {
        type: Object
      },
      device_number_map: {
        type: Object
      }
    },
    computed: {
      schedual_type: function() {

        if (this.record.id == 0) {
          return '-'
        }

        switch (this.record.schedual_type) {
          case 1:
            return '上午'
            break
          case 2:
            return '下午'

            break
          case 3:
            return '晚上'

            break

        }

      },
      device_number: function() {
        if (this.record.id == 0) {
          return '-'
        }

        if (this.device_number_map[this.record.bed_id].number.indexOf(this.device_number_map[this.record.bed_id].zone_name) == -1) {

          return this.device_number_map[this.record.bed_id] == null ? '' : this.device_number_map[this.record.bed_id].zone_name + '-' + this.device_number_map[this.record.bed_id].number

        } else {

          return this.device_number_map[this.record.bed_id].number

        }

      },
      nurse: function() {
        if (this.record.id == 0) {
          return '-'
        }
        return this.admin_map[this.record.start_nurse] == null ? '' : this.admin_map[this.record.start_nurse].name
      },
      stage: function() {
        if (this.record.id == 0) {
          return '未上机'
        }
        return this.record.stage == 1 ? '已上机' : '已下机'
      }, start_time: function() {
        if (this.record == null || this.record.id == '') {
          return '-'
        }
        return parseTime(this.record.start_time, '{y}年{m}月{d}日 {h}时{i}分')

      }, puncture_nurse: function() {
        if (this.record.id == 0) {
          return '-'
        }
        return this.admin_map[this.record.puncture_nurse] == null ? '' : this.admin_map[this.record.puncture_nurse].name
      },
       washpipe_nurse: function() {
        if (this.record.id == 0) {
          return '-'
        }
        return this.admin_map[this.record.washpipe_nurse] == null ? '' : this.admin_map[this.record.washpipe_nurse].name
      },
      change_nurse:function(){
         if (this.record.id == 0) {
          return '-'
        }
        return this.admin_map[this.record.change_nurse] == null ? '' : this.admin_map[this.record.change_nurse].name
      },
      difficult_puncture_nurse:function(){
        if (this.record.id == 0) {
          return '-'
        }
        return this.admin_map[this.record.difficult_puncture_nurse] == null ? '' : this.admin_map[this.record.difficult_puncture_nurse].name
      },
      new_fistula_nurse:function(){
         if (this.record.id == 0) {
          return '-'
        }
        return this.admin_map[this.record.new_fistula_nurse] == null ? '' : this.admin_map[this.record.new_fistula_nurse].name
      }
    },
    methods: {
      isShow(name) {
        var filedList = store.getters.xt_user.fileds
        var arr = []
        for (let i = 0; i < filedList.length; i++) {
          if (
            filedList[i].module == 7 &&
            filedList[i].filed_name_cn == name &&
            filedList[i].is_show == 1
          ) {
            return true
          }
        }
        return false
      }

    }
  }
</script>

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



