<template>
  <div style="display:flex">
<!--  全部待审核信息-->
    <div v-if="showModel=='allCheck'" style="flex:2">
      <el-table :data="needCheck" stripe style="width: 100%">
        <el-table-column prop="username" label="发送方" />
        <el-table-column label="发送时间">
          <h5>2022-5-7</h5>
        </el-table-column>
        <el-table-column label="消息类型">
          <h5>医生信息审核</h5>
        </el-table-column>
        <el-table-column label="操作">
          <template #default="scope">
            <el-button size="small" type="" @click="showInfo(scope.row)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

<!--    查看特定人员审核信息-->
    <div v-if="showModel=='oneCheck'" style="flex:2">
      <div>姓名：{{dname}}</div>
      <div style="margin-top: 20px">联系方式：{{phone}}</div>
      <div style="margin-top: 20px">就职医院：{{address}}</div>
      <div style="margin-top: 20px">擅长：{{goodat}}</div>
      <span>
      <el-button style="margin-top: 40px" @click="showModel='allCheck'" type="primary">返回</el-button>
      <el-button style="margin-top: 40px" @click="Agree(this.did)" type="primary">同意</el-button>
      </span>
    </div>
  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  name: "Check",
  mounted:function (){
    this.loadCheck();
  },
  data(){
    return{
      needCheck:[
        {
        }
      ],
      dname:"default",
      phone:"default",
      address:"default",
      goodat:"default",
      did:"",
      showModel:""
    }
  },
  methods:{
    loadCheck(){
      this.showModel='allCheck';
      request.get("/worker/selectUnabled").then(res=>{this.needCheck=res.data})
    },
    loadSpecificCheck(uid){
      request.get("/doctor/get",{params:{userid:uid}}).then(res=>{
        this.dname=res.data.username;
        this.phone=res.data.phonenumber;
        this.address=res.data.hospitalname;
        this.goodat=res.data.description;
        this.did=res.data.userid;
      })
    },
    showInfo(row){
      this.showModel='oneCheck';
      this.loadSpecificCheck(row.userid);
    },
    Agree(docid){
      request.get("/worker/updateEnabled",{params:{userid:docid}});
      window.location.reload();
      this.showModel='allCheck';
    }
  }
}
</script>

<style scoped>

</style>