为组长端的设计师详情面板中的负载详细日历添加上月/下月切换按钮,允许组长查看设计师在不同月份的工作负载情况。
2025年11月3日
src/app/pages/team-leader/dashboard/dashboard.html修改位置:第441-462行(日历月份标题部分)
修改内容:
changeEmployeeCalendarMonth() 方法代码片段:
<div class="calendar-month-header">
<button class="btn-prev-month"
(click)="changeEmployeeCalendarMonth(-1)"
title="上月">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="15 18 9 12 15 6"></polyline>
</svg>
</button>
<span class="month-title">
{{ selectedEmployeeDetail.calendarData.currentMonth | date:'yyyy年M月' }}
</span>
<button class="btn-next-month"
(click)="changeEmployeeCalendarMonth(1)"
title="下月">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</button>
</div>
src/app/pages/team-leader/dashboard/dashboard.ts目的:保存当前员工信息和项目数据,用于月份切换时重新生成日历
// 当前员工日历相关数据(用于切换月份)
private currentEmployeeName: string = '';
private currentEmployeeProjects: any[] = [];
generateEmployeeDetail 方法(第2694-2699行)目的:在生成员工详情时保存员工信息和项目数据
// 保存当前员工信息和项目数据(用于切换月份)
this.currentEmployeeName = employeeName;
this.currentEmployeeProjects = employeeProjects;
// 生成日历数据
const calendarData = this.generateEmployeeCalendar(employeeName, employeeProjects);
generateEmployeeCalendar 方法签名(第2771行)目的:支持传入指定月份参数
修改前:
private generateEmployeeCalendar(employeeName: string, employeeProjects: any[]): EmployeeCalendarData {
const currentMonth = new Date();
修改后:
private generateEmployeeCalendar(employeeName: string, employeeProjects: any[], targetMonth?: Date): EmployeeCalendarData {
const currentMonth = targetMonth || new Date();
changeEmployeeCalendarMonth 方法(第2920-2945行)目的:实现月份切换逻辑
/**
* 切换员工日历月份
* @param direction -1=上月, 1=下月
*/
changeEmployeeCalendarMonth(direction: number): void {
if (!this.selectedEmployeeDetail?.calendarData) {
return;
}
const currentMonth = this.selectedEmployeeDetail.calendarData.currentMonth;
const newMonth = new Date(currentMonth);
newMonth.setMonth(newMonth.getMonth() + direction);
// 重新生成日历数据
const newCalendarData = this.generateEmployeeCalendar(
this.currentEmployeeName,
this.currentEmployeeProjects,
newMonth
);
// 更新员工详情中的日历数据
this.selectedEmployeeDetail = {
...this.selectedEmployeeDetail,
calendarData: newCalendarData
};
}
src/app/pages/team-leader/dashboard/dashboard-calendar.scss修改位置:第9-60行(日历月份标题样式)
修改内容:
calendar-month-header 改为 flex 布局,支持左右布局.btn-prev-month 和 .btn-next-month 按钮样式关键样式:
.calendar-month-header {
display: flex;
align-items: center;
justify-content: space-between;
.month-title {
flex: 1;
text-align: center;
}
.btn-prev-month,
.btn-next-month {
background: transparent;
border: 1px solid #e2e8f0;
border-radius: 8px;
width: 32px;
height: 32px;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-color: #667eea;
transform: scale(1.05);
svg {
stroke: white;
}
}
&:active {
transform: scale(0.95);
}
}
}
组长想要查看设计师上个月的工作负载情况:
组长想要查看设计师下个月的工作安排:
组长想要对比不同月份的负载情况:
generateEmployeeCalendar 方法使用可选的 targetMonth 参数:
使用 currentEmployeeName 和 currentEmployeeProjects 缓存当前员工数据:
使用对象展开运算符更新 selectedEmployeeDetail:
this.selectedEmployeeDetail = {
...this.selectedEmployeeDetail,
calendarData: newCalendarData
};
在 changeEmployeeCalendarMonth 中进行空值检查:
if (!this.selectedEmployeeDetail?.calendarData) {
return;
}
可以添加月份选择器,允许直接跳转到指定月份:
<select (change)="jumpToMonth($event)">
<option>2024年10月</option>
<option selected>2024年11月</option>
<option>2024年12月</option>
</select>
当前只能切换月份,可以添加年份切换按钮:
<button (click)="changeYear(-1)">上一年</button>
<button (click)="changeYear(1)">下一年</button>
支持键盘快捷键:
切换月份时显示加载动画,提升用户体验:
isLoadingCalendar: boolean = false;
changeEmployeeCalendarMonth(direction: number): void {
this.isLoadingCalendar = true;
// ... 生成日历 ...
this.isLoadingCalendar = false;
}
预加载前后一个月的数据,实现无缝切换:
// 缓存前后3个月的日历数据
private calendarCache: Map<string, EmployeeCalendarData> = new Map();
此功能为组长端的设计师负载管理增加了重要的时间维度导航能力,使组长能够:
通过简洁的UI设计和流畅的交互动画,提升了用户体验,使负载管理更加高效便捷。