<template>
  <div class="newDryWeight">
    <div>
      <div class="adviceBox" v-if="tableList.length > 0">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <div class="adviceMain">
            <div
              class="adviceOne"
              v-for="(item, index) in tableList"
              :key="index"
            >
              <div class="statOrder" @click="toDetail(item.id,item.patient_id)">
                <div class="weightContent">
                    <ul>
                      <li><p>建立日期:{{getTime(item.start_time)}}</p></li>  
                       <li><p>血管通路:{{item.blood_access_part_opera_id}}</p></li>  
                       <li><p>血管通路部位:{{item.blood_access_part_id}}</p></li>  
                       <li><p>流入-流出道:{{item.inflow_pass}}</p></li>
                       <li><p>首次启用日期:{{getTime(item.first_start_time)}}</p></li>
                       <li>
                           <p>默认到处方:
                               <span v-if="item.user_status == 1">启用</span>
                               <span v-if="item.user_status == 2">停止</span>
                           </p> 
                       </li>
                       <li>
                           <p>停用日期:<span v-if="item.stop_time>0">{{item.stop_time}}</span>
                                     <span v-if="item.stop_time<0"></span>
                           </p>
                       </li>
                       <li><p>停用原因:<span>{{item.stop_reason}}</span></p></li>
                       <li><p>使用寿命(天): 
                           <span v-if="item.stop_time>0&&(item.stop_time - item.start_time)/86400 == 0"></span> 
                           <span v-if="item.stop_time>0&&(item.stop_time - item.start_time)/86400 != 0">{{(item.stop_time - item.start_time)/86400}}</span>
                        </p></li>
                       <li><p>备注:{{item.remark}}</p></li>
                       <li><p>创建人:{{getDoctor(item.creator)}}</p></li>

                    </ul>
                </div>
              
              
              </div>
            </div>
          </div>
        </van-list>
      </div>

      <div class="noimgBox" v-else>
        <img src="../../../assets/images/none.png" alt />
      </div>
    </div>
  </div>
</template>

<script>
import { getVascularlAccess } from '@/api/patient/patient'
import { uParseTime } from '@/utils/tools'
import { Dialog } from 'vant'
const moment = require('moment')
export default {
  props: {
    active: Number,
    dryId: String
  },
  data () {
    return {
      newShow: false,
      startShow: false,
      endShow: false,
      page: 1,
      limit: 100,
      patient_id: '',
      total: 0,
      list: [],
      loading: false,
      finished: false,
      patient_name: '',
      tableList:[],
      doctorList:[],
      date:""
    }
  },
  methods: {
    onLoad () {
      setTimeout(() => {
        this.page++
        if (this.page <= Math.ceil(this.total / 10)) {
          this.getDryWeight(
            this.patient_id,
            this.startTime,
            this.endTimes,
            this.limit,
            this.page
          )
        } else {
          this.loading = false
          this.finished = true
        }
      }, 1000)
    },
    getTime (time) {
      // return uParseTime(time, "{y}-{m}-{d} {h}:{i}:{s}");
      return uParseTime(time, '{y}-{m}-{d}')
    },
    getVascularlAccess(id){
         const params = {
             page:this.page,
             limit:this.limit,
             patient_id:id,
         }
       getVascularlAccess(params).then(response=>{
         if(response.data.state ==1){
           var list =  response.data.data.list
           console.log("离愁",list)
           this.tableList = list
           var total =  response.data.data.total
           console.log("total",total)
           this.total = total
           var doctor = response.data.data.doctor
           console.log("doctor",doctor)
           this.doctorList = doctor
         }
       })
    },

     getDoctor(id){
       var name = ""
       for(let i=0;i<this.doctorList.length;i++){
          if(id == this.doctorList[i].admin_user_id){
             name = this.doctorList[i].user_name
          }
       }
       return name
     },

     toDetail(id,patient_id){
       this.$router.push({path:"/passAssessmentDetail?id="+id+"&patient_id="+patient_id+"&date="+this.date})
     }
   
  },
  created () {
    var patientid = this.$route.query.patient_id
    this.getVascularlAccess(patientid)
    var date = this.$route.query.date
    this.date = date
  }
}
</script>

<style lang="scss" scoped>
.newDryWeight {
  height: 100%;
  overflow-y: auto;
  background: #fff;
  padding-top:2.75rem;
  .toolBox {
    display: flex;
    height: 3.125rem;
    align-items: center;
    .toolOne {
      width: 6.25rem;
      height: 1.875rem;
      background: rgba(246, 246, 246, 1);
      border-radius: 5px;
      text-align: center;
      font-size: 0.8125rem;
      color: #8d8d8d;
      display: flex;
      align-items: center;
      justify-content: space-around;
      margin-left: 0.8125rem;
    }
  }
  .adviceBox {
    padding: 0 1.125rem;
    margin-bottom: 3.125rem;
  }
  .adviceMain {
    > div:last-child {
      border: none;
    }
  }
  .adviceOne {
    // box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 0.625rem;
  }
  .adviceTitle {
    padding-top: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    p {
      color: #000000;
      font-weight: bold;
      font-size: 0.9375rem;
    }
    .ellipsis {
      font-size: 1.25rem;
      color: #cccccc;
    }
  }
  .statOrderTitle {
    color: #5b98ff;
    font-size: 0.8125rem;
    font-weight: bold;
    margin: 0.625rem 0;
  }
  .longOrderTitle {
    color: #ff964a;
    font-size: 0.8125rem;
    font-weight: bold;
    margin: 0.625rem 0;
  }
  .weightContent {
    font-size: 0.875rem;
    color: rgba(49, 50, 52, 1);
    display: flex;
    p {
      line-height: 1.125rem;
      margin-right: 0.625rem;
      margin-top: 0.375rem;
    }
  }
  .doctorBox {
    font-size: 0.75rem;
    color: rgba(152, 152, 152, 1);
    line-height: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.625rem;
  }
  .all {
    font-size: 0.8125rem;
    color: #5b98ff;
    margin-top: 0.625rem;
  }
  .noimgBox {
    margin-top: 40%;
    img {
      width: 9.375rem;
      height: 9.375rem;
      margin: 0 auto;
      display: block;
    }
  }
  .van-popup {
    border-radius: 0;
    transform: translate3d(0, 0, 0);
    top: initial;
  }

}
::-webkit-scrollbar {
  width: 0;
}
</style>

