办学质量监测教学评价系统
shenrongliang
2025-06-13 11d86cc6c26bb4f709e407acadf4805c2024e79f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<script setup lang="ts">
import type { UserProfile } from '#/api/system/profile/model';
 
import { computed } from 'vue';
 
import { preferences, usePreferences } from '@vben/preferences';
 
import {
  Card,
  Descriptions,
  DescriptionsItem,
  Tag,
  Tooltip,
} from 'ant-design-vue';
 
import { userUpdateAvatar } from '#/api/system/profile';
import { CropperAvatar } from '#/components/cropper';
 
const props = defineProps<{ profile?: UserProfile }>();
 
defineEmits<{
  // 头像上传完毕
  uploadFinish: [];
}>();
 
const avatar = computed(
  () => props.profile?.user.avatar || preferences.app.defaultAvatar,
);
 
const { isDark } = usePreferences();
const poetrySrc = computed(() => {
  const color = isDark.value ? 'white' : 'gray';
  return `https://v2.jinrishici.com/one.svg?font-size=12&color=${color}`;
});
</script>
 
<template>
  <Card :loading="!profile" class="h-full lg:w-1/3">
    <div v-if="profile" class="flex flex-col items-center gap-[24px]">
      <div class="flex flex-col items-center gap-[20px]">
        <Tooltip title="点击上传头像">
          <CropperAvatar
            :show-btn="false"
            :upload-api="userUpdateAvatar"
            :value="avatar"
            width="120"
            @change="$emit('uploadFinish')"
          />
        </Tooltip>
        <div class="flex flex-col items-center gap-[8px]">
          <span class="text-foreground text-xl font-bold">
            {{ profile.user.nickName ?? '未知' }}
          </span>
          <!-- https://www.jinrishici.com/doc/#image -->
          <img :src="poetrySrc" />
        </div>
      </div>
      <div class="px-[24px]">
        <Descriptions :column="1">
          <DescriptionsItem label="账号">
            {{ profile.user.userName }}
          </DescriptionsItem>
          <DescriptionsItem label="手机号码">
            {{ profile.user.phonenumber || '未绑定手机号' }}
          </DescriptionsItem>
          <DescriptionsItem label="邮箱">
            {{ profile.user.email || '未绑定邮箱' }}
          </DescriptionsItem>
          <DescriptionsItem label="部门">
            <Tag color="processing">
              {{ profile.user.deptName ?? '未分配部门' }}
            </Tag>
            <Tag v-if="profile.postGroup" color="processing">
              {{ profile.postGroup }}
            </Tag>
          </DescriptionsItem>
          <DescriptionsItem label="上次登录">
            {{ profile.user.loginDate }}
          </DescriptionsItem>
        </Descriptions>
      </div>
    </div>
  </Card>
</template>