feat: 开发任务时间字段重构 + 双口径耗时 + 搜索 + 性能优化
核心变更: - DevTask 字段重构:startDate/dueDate/estimateHours/actualHours 替换为 expectedStartAt/expectedEndAt/actualStartAt/actualEndAt(含时分),预计/实际工时按工作时段(9:00-12:00 + 13:00-18:00)派生计算 - 状态机自动化:到点自动切开发中、未到可手动开干、超期需填延后原因 - 新建 lib/work-hours.ts:calcWorkHours(工作时段过滤)、formatWorkHours(X h(Y 天))、calcTwoMetrics(日历/人力双口径) - 新建 lib/dev-task-transitions.ts:状态切换守卫 - 三个 Tab 顶部统计:开发任务(预/日历/人力)、测试用例 / Bug(日历 / 人力);版本概览总人天投入改双行(日历总耗时 / 人力总投入) - 三个 Tab 加搜索框:300ms debounce + 标题/编号模糊匹配 - 性能优化:requirementIds/categories/requirements/testCases 转 Map/Set 索引、Row 组件 React.memo - 全局耗时显示统一带天数换算:8h(1天)、11h(1.4天) 新增文件: SearchInput.tsx, useDebouncedValue.ts, work-hours.ts, dev-task-transitions.ts, 设计文档 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
import { useState } from 'react';
|
||||
import { Plus, Trash2 } from 'lucide-react';
|
||||
import { useTaskWorklogStore } from '@/stores/useTaskWorklogStore';
|
||||
import { useDevTaskStore } from '@/stores/useDevTaskStore';
|
||||
import { useAuthStore } from '@/stores/useAuthStore';
|
||||
import { getTaskWorklogs } from '@/lib/task-worklog';
|
||||
|
||||
@@ -13,7 +12,6 @@ interface Props {
|
||||
|
||||
export function WorklogPanel({ taskId }: Props) {
|
||||
const { worklogs, addWorklog, deleteWorklog } = useTaskWorklogStore();
|
||||
const { syncActualHours } = useDevTaskStore();
|
||||
const user = useAuthStore((s) => s.user);
|
||||
|
||||
const taskLogs = getTaskWorklogs(worklogs, taskId);
|
||||
@@ -28,16 +26,13 @@ export function WorklogPanel({ taskId }: Props) {
|
||||
const handleAdd = () => {
|
||||
if (!workContent.trim() || hours <= 0) return;
|
||||
addWorklog({ taskId, userId: user?.name || '', date, hours, workContent: workContent.trim() });
|
||||
const newTotal = totalHours + hours;
|
||||
syncActualHours(taskId, newTotal);
|
||||
setWorkContent('');
|
||||
setHours(1);
|
||||
setAdding(false);
|
||||
};
|
||||
|
||||
const handleDelete = (id: string, logHours: number) => {
|
||||
const handleDelete = (id: string) => {
|
||||
deleteWorklog(id);
|
||||
syncActualHours(taskId, Math.max(0, totalHours - logHours));
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -75,7 +70,7 @@ export function WorklogPanel({ taskId }: Props) {
|
||||
<p className="text-[12px] text-[var(--ink)]">{log.workContent}</p>
|
||||
<p className="text-[10px] text-[var(--ink-muted)]">{log.date} · {log.hours}h · {log.userId}</p>
|
||||
</div>
|
||||
<button onClick={() => handleDelete(log.id, log.hours)} className="p-1 rounded hover:bg-red-50">
|
||||
<button onClick={() => handleDelete(log.id)} className="p-1 rounded hover:bg-red-50">
|
||||
<Trash2 className="h-3 w-3 text-[var(--ink-muted)] hover:text-red-500" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user