<template>
  <div class="i_body">
    <div class="i_top">
      <div class="img">
        <img :src="info.headportrait ? info.headportrait : avator" alt="">
      </div>
      <div class="name">
        <span>{{info.username}}</span>
      </div>
      <div class="detail">
        <el-tooltip :content="info.intro ? info.intro : '暂无简介'" placement="top" effect="dark">
          <span>{{info.intro ? info.intro : '暂无简介'}}</span>
        </el-tooltip>
      </div>
    </div>
    <div class="i_bottom">
        <div class="i_bottom_span">
          <span>教研室</span>
          <el-tooltip :content="info.classname ? info.classname : '暂无'" placement="top" effect="dark">
            <span>{{info.classname ? info.classname : '暂无'}}</span>
          </el-tooltip>
        </div>
        <div v-if="!oidArray.includes(oid)" class="i_bottom_span">
          <span>学科</span>
          <el-tooltip :content="info.subject ? info.subject : '暂无'" placement="top" effect="dark">
            <span>{{info.subject ? info.subject : '暂无'}}</span>
          </el-tooltip>
        </div>
        <div v-if="!oidArray.includes(oid)" class="i_bottom_span">
          <span>职务</span>
          <el-tooltip :content="info.job ? info.job : '暂无'" placement="top" effect="dark">
            <span>{{info.job ? info.job : '暂无'}}</span>
          </el-tooltip>
        </div>
        <div class="i_bottom_btn" @click="openInfo()">
          <span class="edit"></span>
          <span>编辑个人信息</span>
        </div>
    </div>
    <infoDialog :dialogVisibleInfo.sync="dialogVisibleInfo" :userid="userid" :oid="oid"></infoDialog>
  </div>
</template>

<script>
import avator from '../../../../assets/icon/test/teacher.jpg'
import infoDialog from './infoDialog/index.vue'
export default {
  components: {
    infoDialog,
  },
  props: {
    userid: {
      type: String
    },
    oid: {
      type: String
    },
  },
  data() {
    return {
      avator: avator,
      info: {},
      dialogVisibleInfo:false,
      oidArray: ["d67940a5-510c-40ea-9c9a-2631ab03013a"]
    }
  },
  watch: {
    dialogVisibleInfo(newValue, oldValue) {
      this.getData()
    }
  },
  methods: {
    getData() {
      let params = {
        uid: this.userid,
      };
      this.ajax
        .get(this.$store.state.api + "selectTestUser", params)
        .then((res) => {
          this.info = res.data[0][0]
          // 用于存储归类后的数据的对象
  
        })
        .catch((err) => {
          console.error(err);
        });
    },
    openInfo(){
      this.dialogVisibleInfo = true
    }
  },
  mounted () {
    this.getData();
  },
}
</script>

<style scoped>
    .i_body{
        width: 100%;
        height: calc(55% - 10px);
        min-height: 420px;
        background: #fff;
        border-radius: 5px;
        margin-bottom: 10px;
        overflow: hidden;
    }
    .i_top{
      height: 55%;
      width: calc(100% - 20px);
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      padding: 10px 0px 0px;
      justify-content: center;
      align-items: center;
      box-sizing: border-box;
      border-bottom: 1px solid #efefef;
    }

    .i_top > .img{
      width: 80px;
      height: 80px;
      overflow: hidden;
      border-radius: 50%;
    }
    .i_top > .img > img{
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .i_top > .name{
      width: 100%;
      margin: 10px;
      text-align: center;
    }
    .i_top > .name > span{
      display: block;
      max-width: 100%;
      font-size: 22px;
      font-weight: 700;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .i_top > .detail{
      width: 100%;
      text-align: center;
    }

    .i_top > .detail > span{
      /* display: block; */
      max-width: 90%;
      font-size: 12px;
      margin: 0 auto;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      color: #a1a1a1;
      line-height: 20px;
      overflow: hidden;
      word-break: break-all;
    }

    .i_bottom{
      height: 45%;
      width: calc(100% - 20px);
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }

    .i_bottom > .i_bottom_span{
      width: 90%;
      margin: 0 auto;
      display: flex;
      align-items: center;
      font-size: 15px;
    }

    .i_bottom > .i_bottom_span + .i_bottom_span{
      margin-top: 10px;
    }

    .i_bottom > .i_bottom_span > span:nth-child(1){
      width: 50px;
      min-width: 50px;
      text-align: right;
      color: #a1a1a1;
    }
    .i_bottom > .i_bottom_span > span:nth-child(2){
      width: calc(100% - 30px);
      overflow: hidden;
      margin-left: 20px;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .i_bottom > .i_bottom_btn{
      cursor: pointer;
      border-radius: 5px;
      border: 1px solid #dbdbdb;
      box-sizing: border-box;
      width: 90%;
      background: rgb(252, 252, 252);
      margin: 30px auto 0;
      height: 35px;
      font-weight: 600;
      font-size: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .i_bottom > .i_bottom_btn > .edit{ 
      display: block;
      width: 15px;
      height: 15px;
      background-size:100% 100%;
      background-image: url('../../../../assets/icon/test/edit-icon.png');
      margin-right: 10px;
    }
</style>