日期: 2025-10-22 13:00 需求: 优化工作负载甘特图,使组长能一眼看清楚多个设计师的真实负载情况
HTML变更 (dashboard.html 第68-69行)
<h3>项目负载时间图</h3>
<p class="gantt-subtitle">设计师按负载由高到低排列,颜色深度代表负载强度</p>
说明:
从模糊到精确的4级渐进色:
| 项目数 | 状态 | 颜色 | 色值 | 说明 |
|---|---|---|---|---|
| 0 | idle | 最浅绿色 | #f0fdf4 | 完全空闲 |
| 1 | light-busy | 浅绿色 | #86efac | 轻度负载 |
| 2 | busy | 中绿色 | #22c55e | 中度负载 |
| 3+ | overload | 深绿色 | #16a34a | 高负载 |
| 请假 | leave | 灰色 | #e5e7eb | 请假状态 |
TypeScript实现 (dashboard.ts 第1698-1716行)
const projectCount = dayProjects.length;
if (projectCount === 0) {
status = 'idle';
color = '#f0fdf4'; // 0项目-最浅绿色
} else if (projectCount === 1) {
status = 'light-busy';
color = '#86efac'; // 1项目-浅绿色
} else if (projectCount === 2) {
status = 'busy';
color = '#22c55e'; // 2项目-中绿色
} else {
status = 'overload';
color = '#16a34a'; // 3+项目-深绿色
}
HTML更新 (dashboard.html 第75-81行)
<div class="legend">
<span class="legend-item"><span class="dot idle"></span>0项目</span>
<span class="legend-item"><span class="dot light-busy"></span>1项目</span>
<span class="legend-item"><span class="dot busy"></span>2项目</span>
<span class="legend-item"><span class="dot overload"></span>3+项目</span>
<span class="legend-item"><span class="dot leave"></span>请假</span>
</div>
样式更新 (dashboard-new-styles.scss 第544-569行)
.dot {
width: 20px;
height: 16px;
border-radius: 4px;
border: 1px solid rgba(0, 0, 0, 0.1);
&.idle { background: #f0fdf4; }
&.light-busy { background: #86efac; }
&.busy { background: #22c55e; }
&.overload { background: #16a34a; }
&.leave { background: #e5e7eb; }
}
TypeScript实现 (dashboard.ts 第1664-1674行)
// 计算每个设计师的总负载(用于排序)
const designerTotalLoad: Record<string, number> = {};
designers.forEach(name => {
const projects = assigned.filter(p => p.designerName === name);
designerTotalLoad[name] = projects.length;
});
// 按总负载从高到低排序设计师
const sortedDesigners = designers.sort((a, b) => {
return designerTotalLoad[b] - designerTotalLoad[a];
});
效果:
TypeScript实现 (dashboard.ts 第1834-1843行)
axisLabel: {
color: '#374151',
margin: 8,
fontSize: 13,
fontWeight: 500,
formatter: (value: string) => {
const totalProjects = designerTotalLoad[value] || 0;
const icon = totalProjects >= 3 ? '🔥' :
totalProjects >= 2 ? '⚡' :
totalProjects >= 1 ? '✓' : '○';
return `${icon} ${value} (${totalProjects})`;
}
}
显示效果:
🔥 张三 (4) ← 高负载,4个项目
⚡ 李四 (2) ← 中负载,2个项目
✓ 王五 (1) ← 轻负载,1个项目
○ 赵六 (0) ← 空闲,0个项目
TypeScript实现 (dashboard.ts 第1752-1806行)
新增功能:
10月23日 周三Tooltip显示示例:
┌─────────────────────────────────────┐
│ 张三 [3 项目] │
├─────────────────────────────────────┤
│ 📅 10月23日 周三 │
│ 📊 负载状态: 高负载 │
│ ─────────────────────────────────── │
│ 项目列表: │
│ 1. 现代简约客厅设计 │
│ 2. 轻奢卧室方案 │
│ 3. 北欧风格书房 │
│ ─────────────────────────────────── │
│ 💡 点击查看设计师详细信息 │
└─────────────────────────────────────┘
value数组扩展 (dashboard.ts 第1720行)
value: [
yIndex, // 0: Y轴索引
dayStart, // 1: 开始时间
dayEnd, // 2: 结束时间
designerName, // 3: 设计师名称
status, // 4: 状态
projectCount, // 5: 项目数量
dayProjects.map(p => p.name) // 6: 项目名称列表(新增)
]
TypeScript实现 (dashboard.ts 第1745-1751行)
title: {
text: this.workloadGanttScale === 'week'
? '未来7天项目负载分布'
: '未来30天项目负载分布',
subtext: '颜色越深表示负载越高',
left: 'center',
textStyle: { fontSize: 14, color: '#374151', fontWeight: 600 },
subtextStyle: { fontSize: 12, color: '#6b7280' }
}
TypeScript实现 (dashboard.ts 第1658-1670行)
if (designers.length === 0) {
// 没有设计师数据,显示空状态
const emptyOption = {
title: {
text: '暂无项目数据',
left: 'center',
top: 'center',
textStyle: { fontSize: 16, color: '#9ca3af' }
}
};
this.workloadGanttChart.setOption(emptyOption, true);
return;
}
🔥 张三 (4) 一目了然操作: 打开页面 效果:
🔥 张三 (4) 排在第一位操作: 鼠标悬浮在时间条上 效果:
操作: 查看图表底部 效果:
○ 赵六 (0)操作: 点击任意时间条 效果:
设计师负载情况(从上到下):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔥 张三 (4) ██████████████████ 深绿色
⚡ 李四 (2) ████████░░░░░░░░░░ 中绿色
✓ 王五 (1) ██░░░░░░░░░░░░░░░░ 浅绿色
○ 赵六 (0) ░░░░░░░░░░░░░░░░░░ 最浅绿色
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
周一 周二 周三 周四 周五 周六 周日
颜色梯度:
| 文件 | 变更内容 | 行数 |
|---|---|---|
dashboard.html |
标题、副标题、图例更新 | 65-85 |
dashboard.ts |
颜色系统、排序、Tooltip、Y轴标签 | 1658-1843 |
dashboard-new-styles.scss |
图例颜色样式、副标题样式 | 491-569 |
1. 获取所有已分配项目
↓
2. 提取设计师列表
↓
3. 计算每个设计师的总项目数
↓
4. 按项目数从高到低排序
↓
5. 为每个设计师生成每日数据
├─ 统计该日项目数
├─ 根据项目数确定颜色
└─ 保存项目名称列表
↓
6. 渲染甘特图
├─ Y轴:设计师名称(项目数)
├─ X轴:时间轴
└─ 条形:颜色编码负载
(N)颜色主题切换
更多交互
数据对比
导出功能
实施完成时间: 2025-10-22 13:00 状态: ✅ 已完成并优化 测试状态: ✅ 无Lint错误