refactor(dev-task): 移除工时记录,改为由开始/完成日期自动计算实际工时

- 状态流转到"开发中"时自动记录 startDate
- 实际工时 = startDate → completedAt 的工作日 × 8h
- 详情抽屉移除工时记录面板,增加"开发开始日期"展示
- 列表行工时展示同步改为日期计算

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Script Generator
2026-06-12 09:31:30 +08:00
parent 7322b115c4
commit 75b0d12fa0
4 changed files with 33 additions and 13 deletions

View File

@@ -85,6 +85,22 @@ export function formatHours(hours: number): string {
return `${hours}h${days}人天)`;
}
export function calcActualHoursByDates(startDate?: string, completedAt?: string): number {
if (!startDate) return 0;
const end = completedAt || new Date().toISOString().slice(0, 10);
const start = new Date(startDate);
const endDate = new Date(end);
if (isNaN(start.getTime()) || isNaN(endDate.getTime()) || endDate < start) return 0;
let workDays = 0;
const current = new Date(start);
while (current <= endDate) {
const day = current.getDay();
if (day !== 0 && day !== 6) workDays++;
current.setDate(current.getDate() + 1);
}
return workDays * 8;
}
export function generateTaskNo(existingTasks: DevTask[]): string {
const maxNum = existingTasks.reduce((max, t) => {
const num = parseInt(t.taskNo.replace('DEV-', ''), 10);