<!-- 基本信息 -->
<template>
  <div class="d-flex">
    <!-- 头像 -->
    <div class="avatarsBox">
      <v-badge
        v-if="info?.person?.sex === '1' || info?.person?.sex === '2'"
        bordered 
        offset-x="-25" 
        offset-y="33" 
        :color="info?.person?.sex ? (info?.person?.sex === '1' ? '#1867c0' : 'error') : 'error'" 
        :icon="info?.person?.sex ? (info?.person?.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'">
        <v-avatar size=80 :image="getUserAvatar(info?.person?.avatar, info?.person?.sex)"></v-avatar>
      </v-badge>
      <v-avatar v-else size="80" :image="getUserAvatar(info?.person?.avatar, info?.person?.sex)"></v-avatar>
    </div>
    <!-- 信息 -->
    <div style="flex: 1;">
      <span style="font-size: 20px; font-weight: 600;color: var(--color-666);">{{ info?.person?.name }}</span>
      <div class="d-flex mt-2 listBox">
        <span>{{ info?.schoolDept?.name }}</span>
        <span v-if="info?.schoolDept?.name && info?.major?.nameCn" class="mx-3">|</span>
        <span>{{ info?.major?.nameCn }}</span>
      </div>
      <view class="mt-2 listBox">{{ info?.schoolClass?.name }}</view>
    </div>
  </div>
</template>

<script setup>
defineOptions({name: 'studentList-student-details-baseInfo'})
import { ref } from 'vue'
import { getUserAvatar } from '@/utils/avatar'

const props = defineProps({
  data: Object
})
const info = ref({})
if (props.data && Object.keys(props.data).length) {
  info.value = props.data
  info.value.sex = info.value?.person?.sex === '男' ? '1' : info.value?.person?.sex === '女' ? '2' : info.value?.person?.sex || null
}
</script>

<style lang="scss" scoped>
.avatarsBox {
  height: 80px;
  width: 80px;
  position: relative;
  // margin: 32px;
  margin-right: 40px;
  .img {
    width: 100%;
    height: 100%;
  }
  .mdi {
    font-size: 42px;
    color: #fff;
  }
  div {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
  }
}
.listBox {
  display: flex;
  flex-wrap: wrap; /* 允许换行 */
  width: 100%; /* 设置容器宽度 */
  // height: 68px;
  overflow: hidden;
  color: var(--color-777);
  div {
    margin-right: 50px;
    span {
      height: 32px;
      line-height: 32px;
    }
    .mdi {
      font-size: 22px;
      margin-right: 8px;
    }
  }
}
</style>
