<template>
    <div>
        <div
          v-for="(item,index) in list"
          style="height: 190px; width: 90%; margin: 30px auto; font-size: 16px;
          background: rgb(212, 211, 211);box-shadow: 5px 5px 5px rgb(201, 199, 199);
          position: relative;"
          >
          <div 
              style="background: #865802fa; width: 100px; height: 50px; 
                      position: absolute; top: 0px; right: 0px;text-align:center;line-height:50px"
                      
            >
            <span v-if="item.application_status == 1">已审核</span>
            <span v-if="item.application_status == 2">未审核</span>
            <span v-if="item.application_status == 3">拒绝</span>
           </div>
        <div style="padding: 10px; ">
           <p>
            <span v-if="item.module == 1">【透析处方】</span>
            <span v-if="item.module == 2">【接诊评估】</span>
            <span v-if="item.module == 3">【透前评估】</span>
            <span v-if="item.module == 4">【临时医嘱】</span>
            <span v-if="item.module == 5">【双人核对】</span>
            <span v-if="item.module == 6">【透析上机】</span>
            <span v-if="item.module == 7">【透析监测】</span>
            <span v-if="item.module == 8">【透析下机】</span>
            <span v-if="item.module == 9">【透后评估】</span>
            <span v-if="item.module == 10">【透析小结】</span>
            <span v-if="item.module == 11">【耗材出库】</span>
            </p>
           <p>患者姓名: {{getPatientName(item.patient_id)}}</p>
           <p>治疗时间:{{getTime(item.record_date)}}</p>
           <p>申&nbsp;请&nbsp;人&nbsp;:{{getUserName(item.checker)}}</p>
           <p>申请时间:{{getTimeOne(item.application_date)}}</p>
           
        </div>
        <div style="text-align: center;padding-bottom: 10px; ">
            <van-button type="primary" style="width: 100px; border: none; background:rgb(36, 127, 247);" @click="checkMobileInformation(item.id)" v-if="item.application_status!=1">通过</van-button>
            <van-button  style="width: 100px; background:rgb(180, 179, 179); border: none;" @click="checkMobileInformationOne(item.id)" v-if="item.application_status!=3">拒绝</van-button>
          
        </div>
      </div>
    </div>
</template>
<script>
import { Button } from 'vant';
import { uParseTime } from "@/utils/tools";
import {Toast} from 'vant'
import {getMobieInformationOne,checkMobileInformation} from "@/api/dialysis"
export default {
    data(){
       return{
         limit:10,
         page:1,
         list:[],
         total:0,
         doclist:[],
         patients:[],
       }  
    },
    created(){
      this.getlist()
    },
    methods:{
       getlist(){
          var params = {
            limit:this.limit,
            page:this.page,
          }
         getMobieInformationOne(params).then(response=>{
           if(response.data.state == 1){
             this.list = response.data.data.information
             this.total = response.data.data.total
             this.doclist = response.data.data.doclist
             this.patients = response.data.data.patients
           }
         })
       },
       getPatientName(id){
         var name = ""
         for(let i=0;i<this.patients.length;i++){
           if(id == this.patients[i].id){
              name = this.patients[i].name
           }
         }
         return name
       },
      getTime(time) {
      // return uParseTime(time, "{y}-{m}-{d} {h}:{i}:{s}");
        return uParseTime(time, "{y}-{m}-{d}");
       },
       getTimeOne(time){
        return uParseTime(time, "{y}-{m}-{d} {h}:{i}");
       },
       getUserName(admin_user_id){
         var user_name = ""
         for(let i=0;i<this.doclist.length;i++){
           if(admin_user_id == this.doclist[i].admin_user_id){
              user_name = this.doclist[i].user_name
           }
         }
         return user_name
       },
       checkMobileInformation(id){
          var params = {
            id:id,
            application_status:1,
          }
        checkMobileInformation(params).then(response=>{
          if(response.data.state == 1){
             var msg = response.data.data.msg
             Toast.success('审核成功')
             this.getlist()
          }
        })
       },
       checkMobileInformationOne(id){
          var params = {
            id:id,
            application_status:3,
          }
        checkMobileInformation(params).then(response=>{
          if(response.data.state == 1){
             var msg = response.data.data.msg
             Toast.success('拒绝成功')
             this.getlist()
          }
        })
       }
    },
    watch:{
      
    }
}
</script>
<style scoped>
  

</style>