<template>
  <div class="page_organizationInfo">
    <div class="organizationInfoTitle">
      <i class="iconfont icon-zuojiantou jiantou" @click="$router.go(-1)"></i>
      <span class="titleName">组织信息</span>
    </div>
    <div class="organizeBox">
      <div class="organizeBoxOne">
        <div class="organizeBoxOneLeft">
          <span v-if="org_logo == ''"
            ><img src="../../assets/images/m01.png" alt
          /></span>
          <span v-if="org_logo != ''"><img :src="org_logo" alt/></span>
          <p>{{ org_short_name }}</p>
        </div>
        <!-- <van-icon class="arrow" name="arrow" /> -->
      </div>
      <div class="organizeTip">我在该团队的信息</div>
      <div class="organizeBoxTwo">
        <div>名字</div>
        <div class="organizeBoxTwoTxt">
          {{ user_name }}
        </div>
      </div>
      <div class="organizeBoxTwo">
        <div>电话</div>
        <div class="organizeBoxTwoTxt">
          {{ telephone }}
        </div>
      </div>
      <div class="organizeBoxTwo">
        <div>角色</div>
        <div class="rolebox" v-for="(item,index) in Names" :key="index">
          <div class="roleboxBtn" v-if="item!=''">{{item}}</div>
        </div>
      </div>
      <div class="organizeBoxTwo">
        <div>职位</div>
        <div class="organizeBoxTwoTxt" v-if="positionName != ''">
          {{ positionName }}
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getOrgName, getRoleName } from "@/api/patient/patient";
import { setRem } from "@/libs/functionRem";
export default {
  data() {
    return {
      user_name: "",
      org_short_name: "",
      telephone: "",
      role_name: "",
      positionName: "",
      org_logo: "",
      Names: []
    };
  },
  methods: {
    getOrgName(id) {
      getOrgName(id).then(response => {
        if (response.data.state === 1) {
          var name = response.data.data.name;
          this.org_short_name = name.org_name;
          this.org_logo = name.org_logo;
          // console.log("name", name);
        }
      });
    },
    getRoleName(id, orgid) {
      getRoleName(id, orgid).then(response => {
        if (response.data.state === 1) {
          var name = response.data.data.name;
          // console.log("角色", name);
          this.role_name = name.role_name;
          var positionName = response.data.data.positionName;
          // console.log("positionName", positionName);
          this.user_name = positionName.user_name;
          this.positionName = positionName.user_title_name;
          // console.log("职称", positionName);
          var names = response.data.data.names;
          // console.log("names", names);
          var arr = [];
          arr = names.split(",");
          var arr2 = [...new Set(arr)];
          this.Names = arr2;

          var admin = response.data.data.admin;
          // console.log("admin", admin);
          // if (admin.is_super_admin === 1) {
          // this.role_name = "超级管理员";
          // }
        }
      });
    }
  },
  created() {
    setRem();
    // this.user_name = this.$store.getters.user.user.user_name;
    // this.org_short_name = this.$store.getters.user.org.org_short_name;
    var id = this.$route.query.id;
    var orgid = this.$route.query.orgid;
    this.getOrgName(orgid);
    this.getRoleName(id, orgid);
    this.telephone = this.$store.getters.user.admin.mobile;
  }
};
</script>
<style lang="scss" scoped>
.page_organizationInfo {
  height: 100%;
  overflow-y: auto;
  background: #fafafa;
  .organizationInfoTitle {
    background: #fff;
    padding: 0 1.125rem;
    height: 3.125rem;
    display: flex;
    align-items: center;
  }
  .jiantou {
    font-size: 1.5rem;
    font-weight: 600;
    margin-right: 7rem;
  }
  .titleName {
    font-size: 1.125rem;
    font-weight: 600;
  }
  .organizeBox {
    margin-top: 1rem;
    > div:last-child {
      border: none;
    }
    .organizeBoxOne {
      font-size: 1rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 0.875rem;
      height: 4.5rem;
      background: #fff;
      .organizeBoxOneLeft {
        display: flex;
        align-items: center;
        img {
          width: 3rem;
          height: 3rem;
          margin-right: 0.75rem;
        }
      }
      .arrow {
        color: #9f9f9f;
      }
    }
    .organizeTip {
      height: 1.875rem;
      line-height: 1.875rem;
      padding-left: 0.875rem;
      font-size: 0.75rem;
      color: #8d8d8d;
    }
    .organizeBoxTwo {
      font-size: 1rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 2.8125rem;
      background: #fff;
      padding: 0 0.875rem;
      border-bottom: 1px solid #e5e5e5;
      .organizeBoxTwoTxt {
        color: #8d8d8d;
      }
      .rolebox {
        display: flex;
        align-items: center;
      }
      .roleboxBtn {
        padding: 0.5rem 0.75rem;
        background: rgba(51, 138, 251, 0.1);
        border: 1px solid rgba(51, 138, 251, 1);
        border-radius: 0.3125rem;
        text-align: center;
        margin-left: 0.375rem;
        color: #338afb;
        font-size: 0.875rem;
      }
    }
  }
}
</style>
