2025-11-20 00:56
问题:操作菜单(编辑、离职流程、删除)的文字颜色是白色,看不清楚
解决方案:
employee-records.scss 中添加了详细的菜单样式$ios-text-primary)修改内容:
// employee-records.scss 第216-244行
:host ::ng-deep .hr-menu-panel {
background: $ios-card-background;
border-radius: $ios-radius-md !important;
box-shadow: $ios-shadow-lg;
border: 1px solid $ios-border;
.mat-mdc-menu-item {
font-family: $ios-font-family;
color: $ios-text-primary !important; // ✅ 文字颜色清晰
.mat-icon {
color: $ios-text-secondary;
margin-right: $ios-spacing-sm;
}
&:hover {
background-color: rgba(0, 122, 255, 0.08) !important;
.mat-icon {
color: $ios-primary;
}
}
.mdc-list-item__primary-text {
color: $ios-text-primary !important;
font-weight: $ios-font-weight-regular;
}
}
}
HTML修改:
<!-- employee-records.html 第176行 -->
<mat-menu #actionMenu="matMenu" class="hr-menu-panel">
<button mat-menu-item (click)="openEditEmployeeDialog(employee)">
<mat-icon>edit</mat-icon>
<span>编辑</span>
</button>
<!-- ... 其他菜单项 ... -->
</mat-menu>
状态:分页器已经有上一页/下一页按钮
确认:
<!-- employee-records.html 第210-216行 -->
<mat-paginator [length]="totalLength()"
[pageSize]="pageSize()"
[pageIndex]="pageIndex()"
[pageSizeOptions]="pageSizeOptions"
(page)="onPageChange($event)"
showFirstLastButtons> <!-- ✅ 已启用首页/尾页/上一页/下一页按钮 -->
</mat-paginator>
功能:
问题1:新增员工时缺少 isActivated 字段
isActivated = true)isActivated = true 和 isDeleted = false问题2:状态字段没有正确映射到 employmentStatus
问题3:缺少详细的日志
// employee-records.ts 第768-828行
async openAddEmployeeDialog() {
const dialogRef = this.dialog.open(AddEmployeeDialog, {...});
dialogRef.afterClosed().subscribe(async (result) => {
if (result) {
const ProfileClass = Parse.Object.extend('Profile');
const newProfile = new ProfileClass();
// ✅ 基本字段
newProfile.set('name', result.name);
newProfile.set('mobile', result.phone);
newProfile.set('email', result.email);
newProfile.set('roleName', result.position);
newProfile.set('isActivated', true); // ✅ 关键:设置为已激活
newProfile.set('isDeleted', false); // ✅ 关键:设置为未删除
// ✅ 根据状态设置 isDisabled
if (result.status === '离职') {
newProfile.set('isDisabled', true);
}
// ✅ 设置部门
if (result.department) {
const deptQuery = new Parse.Query('Department');
deptQuery.equalTo('name', result.department);
const dept = await deptQuery.first();
if (dept) {
newProfile.set('department', dept);
}
}
// ✅ 设置 HR 数据和状态映射
const employmentStatus =
result.status === '离职' ? 'inactive' :
result.status === '试用期' ? 'probation' :
result.status === '停薪留职' ? 'inactive' : 'active';
newProfile.set('data', {
realname: result.name,
gender: result.gender,
email: result.email,
mobile: result.phone,
position: result.position,
hrData: {
employeeId: result.employeeId,
idCard: result.idCard, // ✅ 身份证号
bankCard: result.bankCard, // ✅ 银行卡号
birthDate: result.birthDate,
hireDate: result.hireDate,
gender: result.gender,
position: result.position,
employmentStatus: employmentStatus // ✅ 状态映射
}
});
await newProfile.save();
// ✅ 详细日志
console.log('✅ [员工档案] 新员工保存成功:', {
id: newProfile.id,
name: result.name,
employeeId: result.employeeId,
isActivated: true
});
await this.loadEmployees();
this.showSnackBar('员工添加成功');
}
});
}
// employee-records.ts 第847-912行
async openEditEmployeeDialog(employee: Employee) {
const dialogRef = this.dialog.open(AddEmployeeDialog, {...});
dialogRef.afterClosed().subscribe(async (result) => {
if (result) {
const query = new Parse.Query('Profile');
const profile = await query.get(employee.id);
// ✅ 基本字段
profile.set('name', result.name);
profile.set('mobile', result.phone);
profile.set('email', result.email);
profile.set('roleName', result.position);
// ✅ 根据状态更新 isDisabled
if (result.status === '离职') {
profile.set('isDisabled', true);
} else if (profile.get('isDisabled')) {
profile.set('isDisabled', false);
}
// ✅ 更新部门
if (result.department) {
const deptQuery = new Parse.Query('Department');
deptQuery.equalTo('name', result.department);
const dept = await deptQuery.first();
if (dept) {
profile.set('department', dept);
}
}
// ✅ 更新 data 字段和状态映射
const currentData = profile.get('data') || {};
const employmentStatus =
result.status === '离职' ? 'inactive' :
result.status === '试用期' ? 'probation' :
result.status === '停薪留职' ? 'inactive' : 'active';
profile.set('data', {
...currentData,
realname: result.name,
gender: result.gender,
email: result.email,
mobile: result.phone,
position: result.position,
hrData: {
...currentData.hrData,
employeeId: result.employeeId,
idCard: result.idCard, // ✅ 身份证号
bankCard: result.bankCard, // ✅ 银行卡号
birthDate: result.birthDate,
hireDate: result.hireDate,
gender: result.gender,
position: result.position,
employmentStatus: employmentStatus // ✅ 状态映射
}
});
await profile.save();
// ✅ 详细日志
console.log('✅ [员工档案] 员工信息更新成功:', {
id: profile.id,
name: result.name,
employeeId: result.employeeId,
status: result.status
});
await this.loadEmployees();
this.showSnackBar('员工信息更新成功');
}
});
}
| UI状态 | isDisabled |
employmentStatus |
说明 |
|---|---|---|---|
| 在职 | false |
'active' |
正常在职员工 |
| 试用期 | false |
'probation' |
试用期员工 |
| 停薪留职 | false |
'inactive' |
暂时停职 |
| 离职 | true |
'inactive' |
已离职员工 |
// 加载员工数据时的查询条件
const query = new Parse.Query('Profile');
query.equalTo('isActivated', true); // ✅ 只查已激活
query.notEqualTo('isDeleted', true); // ✅ 排除已删除
query.include('department');
query.ascending('realname');
// 第653-660行:从数据库字段映射到UI状态
let status: EmployeeStatus = '在职';
if (profile.get('isDisabled')) {
status = '离职';
} else if (hrData.employmentStatus === 'probation') {
status = '试用期';
} else if (hrData.employmentStatus === 'inactive') {
status = '停薪留职';
}
1. 打开员工档案管理页面
2. 点击任意员工行右侧的"三个点"按钮
3. ✅ 验证:菜单弹出,文字清晰可见(深色)
4. ✅ 验证:鼠标悬停时有蓝色高亮效果
5. ✅ 验证:可以点击"编辑"、"离职流程"、"删除"
1. 确保员工数量超过10个(默认每页10条)
2. ✅ 验证:底部显示分页器
3. ✅ 验证:可以点击"下一页"(右箭头)
4. ✅ 验证:可以点击"上一页"(左箭头)
5. ✅ 验证:可以点击"首页"(双左箭头)
6. ✅ 验证:可以点击"尾页"(双右箭头)
7. ✅ 验证:可以改变每页显示数量(10/25/50/100)
1. 点击"新增员工"按钮
2. 填写所有信息:
- 姓名:测试员工
- 工号:TEST001
- 部门:设计部
- 职位:设计师
- 手机号:13800138000
- 邮箱:test@example.com
- 性别:男
- 出生日期:1990-01-01
- 入职日期:2025-11-20
- 状态:试用期
- 身份证号:110105199001011234
- 银行卡号:6222021234567890
3. 点击"保存"
4. ✅ 验证:显示成功提示
5. ✅ 验证:新员工出现在列表中
6. ✅ 验证:控制台显示日志:
"✅ [员工档案] 新员工保存成功:"
7. ✅ 验证:Profile 表中有新记录
8. ✅ 验证:isActivated = true
9. ✅ 验证:isDeleted = false
10. ✅ 验证:hrData 包含所有字段
1. 点击某个员工的"三个点" → "编辑"
2. 修改信息(如:工号、身份证号、状态)
3. 点击"保存"
4. ✅ 验证:显示成功提示
5. ✅ 验证:列表自动刷新
6. ✅ 验证:控制台显示日志:
"✅ [员工档案] 员工信息更新成功:"
7. ✅ 验证:Profile 表数据已更新
8. ✅ 验证:状态正确映射到 employmentStatus
1. 编辑员工,将状态改为"离职"
2. 保存
3. ✅ 验证:isDisabled = true
4. ✅ 验证:employmentStatus = 'inactive'
5. ✅ 验证:状态徽章显示"离职"(灰色)
6. 再次编辑,将状态改为"在职"
7. 保存
8. ✅ 验证:isDisabled = false
9. ✅ 验证:employmentStatus = 'active'
10. ✅ 验证:状态徽章显示"在职"(绿色)
新增员工时必须设置:
✅ name (姓名)
✅ mobile (手机号)
✅ email (邮箱)
✅ roleName (角色)
✅ isActivated = true ⭐ 关键
✅ isDeleted = false ⭐ 关键
✅ data.realname (真实姓名)
✅ data.hrData.employeeId (工号)
✅ data.hrData.employmentStatus (就业状态)
可选字段:
○ department (部门)
○ isDisabled (是否禁用)
○ data.hrData.idCard (身份证号)
○ data.hrData.bankCard (银行卡号)
○ data.hrData.birthDate (出生日期)
○ data.hrData.hireDate (入职日期)
○ data.hrData.gender (性别)
⚠️ 如果不设置 isActivated = true
→ 员工不会显示在列表中
→ 查询条件会过滤掉该员工
→ 看起来好像保存失败
⚠️ UI状态和数据库字段要正确对应
→ "离职"必须设置 isDisabled = true
→ employmentStatus 必须正确设置
→ 否则显示状态会混乱
✅ 保存成功后查看控制台
→ 新增:"✅ [员工档案] 新员工保存成功:"
→ 编辑:"✅ [员工档案] 员工信息更新成功:"
→ 失败:"❌ [员工档案] XXX失败:"
| 文件 | 修改内容 |
|---|---|
employee-records.scss |
✅ 添加菜单项样式,确保文字颜色清晰 |
employee-records.html |
✅ 为菜单添加 hr-menu-panel 类 |
employee-records.ts |
✅ 新增员工时设置 isActivated 和 isDeleted |
| ↓ | ✅ 添加状态映射逻辑(UI状态 → employmentStatus) |
| ↓ | ✅ 编辑员工时更新 isDisabled 状态 |
| ↓ | ✅ 添加详细的控制台日志 |
✅ 菜单文字颜色清晰可见
✅ 菜单悬停效果正常
✅ 分页器有上一页/下一页按钮
✅ 分页器有首页/尾页按钮
✅ 新增员工时设置 isActivated = true
✅ 新增员工时设置 isDeleted = false
✅ 状态正确映射到 employmentStatus
✅ 状态正确映射到 isDisabled
✅ 身份证号和银行卡号正确保存
✅ 添加详细的控制台日志
✅ 数据保存后自动刷新列表
✅ 显示成功/失败提示
文档版本:v1.0
最后更新:2025-11-20 00:56
维护人:Cascade AI Assistant
状态:✅ 所有问题已修复