<template>
  <div>
    <el-descriptions class="margin-top" :column="2" border>
      <!-- <template #extra>
        <el-button type="primary">Operation</el-button>
      </template> -->
    <el-descriptions-item label="用户头像">
      <el-image v-if="info.avatar" style="width: 100px; height: 100px" :src="info.avatar" fit="contain" hide-on-click-modal :preview-src-list="[info.avatar]"/>
    </el-descriptions-item>
    <el-descriptions-item label="用户名称">{{ info.name }}</el-descriptions-item>
    <el-descriptions-item label="性别">
      <dict-tag v-if="info.sex !== '0'" :type="DICT_TYPE.MENDUNER_SEX" :value="info.sex" />
    </el-descriptions-item>
    <el-descriptions-item label="联系电话">{{ info.phone }}</el-descriptions-item>
    <el-descriptions-item label="邮箱">{{ info.email }}</el-descriptions-item>
    <el-descriptions-item label="企业名称">{{ formatName(info.enterpriseName) }}</el-descriptions-item>
    <el-descriptions-item label="岗位名称">{{ info.postName }}</el-descriptions-item>
    <el-descriptions-item label="账号状态">
      <dict-tag :type="DICT_TYPE.MENDUNER_STATUS" :value="info.status" />
    </el-descriptions-item>
    <el-descriptions-item label="用户类型">{{ info.userType === '1' ? '管理员' : '普通用户' }}</el-descriptions-item>
    <el-descriptions-item label="最后登录IP">{{ info.loginIp }}</el-descriptions-item>
    <el-descriptions-item label="最后登录时间">{{ formatDate(info.loginDate) }}</el-descriptions-item>
  </el-descriptions>
  </div>
</template>

<script setup>
/* 企业用户详情 */
defineOptions({ name: 'EnterpriseUserDetails'})
import { EnterpriseUserBindApi } from '@/api/menduner/system/enterprise/userBind'
import { formatDate } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
import { formatName } from '@/utils'

const props = defineProps({
  id: String
})

const info = ref({})
const getInfo = async () => {
  const data = await EnterpriseUserBindApi.getEnterpriseUserDetails(props.id)
  info.value = data
}
getInfo()
</script>
