74 lines
3.5 KiB
Vue
74 lines
3.5 KiB
Vue
<template>
|
||
<div class="aa-emp-card">
|
||
<div class="aa-emp-actions">
|
||
<button @click="emit('message', employee)">发消息</button>
|
||
<button @click="emit('view', employee)">详情</button>
|
||
<button @click="emit('edit', employee)">编辑</button>
|
||
</div>
|
||
|
||
<div class="aa-emp-top">
|
||
<div class="aa-emp-avatar">
|
||
<img v-if="employee.avatar" :src="employee.avatar" :alt="employee.name">
|
||
<span v-else>{{ initial }}</span>
|
||
</div>
|
||
<div>
|
||
<div class="aa-emp-name">
|
||
{{ employee.name }}
|
||
<span class="aa-emp-status" :class="employee.status">{{ statusText }}</span>
|
||
</div>
|
||
<div class="aa-emp-id">工号:{{ employee.empId }}</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="aa-emp-meta">
|
||
部门:{{ employee.dept }}<br>职位:{{ employee.position }}
|
||
</div>
|
||
|
||
<div v-if="employee.tags && employee.tags.length" class="aa-emp-tags">
|
||
<span v-for="t in employee.tags" :key="t" class="aa-emp-tag">{{ t }}</span>
|
||
</div>
|
||
|
||
<div v-if="showContact && (employee.phone || employee.email)" class="aa-emp-contact">
|
||
<div v-if="employee.phone">电话:{{ employee.phone }}</div>
|
||
<div v-if="employee.email">邮箱:{{ employee.email }}</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { computed } from 'vue';
|
||
|
||
const props = defineProps({
|
||
employee: { type: Object, required: true }, // { name, empId, dept, position, status, avatar?, tags?, phone?, email? }
|
||
showContact: { type: Boolean, default: false }
|
||
});
|
||
const emit = defineEmits(['message', 'view', 'edit']);
|
||
|
||
const initial = computed(() => (props.employee.name || '?').charAt(0));
|
||
const statusText = computed(() => (props.employee.status === 'left' ? '离职' : '在职'));
|
||
</script>
|
||
|
||
<!-- 样式对齐 组件9.txt EmployeeCard 规范 -->
|
||
<style scoped>
|
||
.aa-emp-card { width: 280px; background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); padding: 16px; position: relative; box-sizing: border-box; }
|
||
.aa-emp-top { display: flex; align-items: center; gap: 12px; }
|
||
.aa-emp-avatar { width: 48px; height: 48px; border-radius: 50%; background: #F0F5FF; color: #2F54EB; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 18px; flex-shrink: 0; overflow: hidden; }
|
||
.aa-emp-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
||
.aa-emp-name { font-size: 16px; font-weight: 600; color: #1F2329; display: flex; align-items: center; gap: 8px; }
|
||
.aa-emp-status { font-size: 12px; padding: 0 6px; border-radius: 2px; line-height: 18px; }
|
||
.aa-emp-status.active { background: #F6FFED; color: #52C41A; }
|
||
.aa-emp-status.left { background: #F5F5F5; color: #8C8C8C; }
|
||
.aa-emp-id { font-size: 12px; color: #8C8C8C; margin-top: 2px; }
|
||
.aa-emp-meta { margin-top: 12px; font-size: 13px; color: #595959; line-height: 22px; }
|
||
.aa-emp-tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
|
||
.aa-emp-tag { background: #F0F5FF; color: #2F54EB; font-size: 12px; padding: 1px 8px; border-radius: 2px; }
|
||
.aa-emp-contact { margin-top: 12px; font-size: 13px; color: #595959; line-height: 22px; border-top: 1px solid #F0F0F0; padding-top: 10px; }
|
||
.aa-emp-actions {
|
||
position: absolute; top: 12px; right: 12px; display: none; gap: 4px;
|
||
background: #fff; border: 1px solid #E8ECF1; border-radius: 4px; padding: 2px;
|
||
}
|
||
.aa-emp-card:hover .aa-emp-actions { display: flex; }
|
||
.aa-emp-actions button { border: none; background: none; cursor: pointer; color: #8C8C8C; font-size: 12px; padding: 2px 6px; border-radius: 3px; }
|
||
.aa-emp-actions button:hover { color: #2F54EB; background: #F0F5FF; }
|
||
</style>
|