Files
aurora-admin/frameworks/EmployeeCard.jsx
T

60 lines
2.3 KiB
React
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React from 'react';
import './EmployeeCard.css';
/**
* Aurora Admin EmployeeCard(React)
* 对齐 组件9.txt EmployeeCard 规范:头像/姓名/工号/部门/职位/状态、悬停快捷操作、标签、可显联系方式、圆角8px/阴影低/内边距16px
* employee: { name, empId, dept, position, status:'active'|'left', avatar?, tags?, phone?, email? }
*/
export default function EmployeeCard({ employee, showContact = false, onMessage, onView, onEdit }) {
const statusText = employee.status === 'left' ? '离职' : '在职';
return (
<div className="aa-emp-card">
<div className="aa-emp-actions">
<button onClick={() => onMessage && onMessage(employee)}>发消息</button>
<button onClick={() => onView && onView(employee)}>详情</button>
<button onClick={() => onEdit && onEdit(employee)}>编辑</button>
</div>
<div className="aa-emp-top">
<div className="aa-emp-avatar">
{employee.avatar
? <img src={employee.avatar} alt={employee.name} />
: <span>{(employee.name || '?').charAt(0)}</span>}
</div>
<div>
<div className="aa-emp-name">
{employee.name}
<span className={`aa-emp-status ${employee.status}`}>{statusText}</span>
</div>
<div className="aa-emp-id">工号:{employee.empId}</div>
</div>
</div>
<div className="aa-emp-meta">
部门:{employee.dept}<br />职位:{employee.position}
</div>
{employee.tags && employee.tags.length > 0 && (
<div className="aa-emp-tags">
{employee.tags.map((t) => <span key={t} className="aa-emp-tag">{t}</span>)}
</div>
)}
{showContact && (employee.phone || employee.email) && (
<div className="aa-emp-contact">
{employee.phone && <div>电话:{employee.phone}</div>}
{employee.email && <div>邮箱:{employee.email}</div>}
</div>
)}
</div>
);
}
/*
用法示例:
import EmployeeCard from './EmployeeCard';
const emp = { name: '张伟', empId: 'E1001', dept: '技术中心 · 前端组', position: '高级前端工程师', status: 'active', tags: ['React','TS'] };
<EmployeeCard employee={emp} showContact onEdit={(e) => console.log(e)} />
*/