<template>
  <!-- 通讯录成员 -->
  <div class="flex items-center py-2 border border-transparent w-full" @click="handleClick(member)">
    <app-icon
      type="png"
      :path="require('@/assets/icons/avator.png')"
      class-name="w-9 h-9"
    />
    <div class="ml-3">{{ member.name }}</div>
    <div
      v-if="[0, 1].indexOf(member.role) > -1"
      class="tag ml-1.5 text-xs text-white px-1 py-0.5 bg-color-primary rounded"
    >
      {{ tagName(member) }}
    </div>
    <div
      v-if="member.isDepAdmin"
      class="tag ml-1.5 text-xs text-white px-1 py-0.5 bg-color-primary rounded"
    >
      主管
    </div>
    <div v-if="!member.isActivated" class="tag ml-1.5 text-xs text-text-secondary px-1 py-0.5 bg-mygray rounded">
      未激活
    </div>
  </div>
</template>

<script lang="ts">
import Vue from 'vue'
import { Staff } from '@/Interface'

export default Vue.extend({
  name: 'ContactMember',
  components: {
    'app-icon': () => import('@/components/common/Icon.vue')
    // 'main-page': () => import('@/layout/main-page.vue')
  },
  props: {
    member: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  methods: {
    handleClick(member: Staff) {
      this.$emit('click', member)
    },
    tagName(member: Staff) {
      let role = ''
      switch (member.role) {
        case 0:
          role = '负责人'
          break
        case 1:
          role = '管理员'
          break
        default:
          role = ''
      }
      return role
    }
  }
})
</script>

<style lang="less">

</style>
