feat: 完善任务中心全部功能
All checks were successful
continuous-integration/drone/push Build is passing

1. 动态加载选项数据
   - 从API获取团队、成员、课程列表
   - 替换硬编码选项为动态渲染

2. 编辑任务功能
   - 复用创建对话框,添加编辑模式
   - 填充表单数据并调用updateTask API

3. 查看详情弹窗
   - 展示任务基本信息、进度、课程、要求
   - 调用getTaskDetail API获取详情

4. 结束任务功能
   - 确认后调用updateTask API更新状态为completed
   - 刷新列表和统计数据

5. 复制任务功能
   - 复制任务内容到表单(标题添加"副本"后缀)
   - 打开创建对话框

6. 发送提醒功能
   - 后端新增 /tasks/{id}/remind API
   - 前端调用API并显示结果
This commit is contained in:
yuliang_guo
2026-01-31 14:05:55 +08:00
parent 9bd9e58439
commit d2e6abfc80
3 changed files with 410 additions and 63 deletions

View File

@@ -226,3 +226,44 @@ async def delete_task(
return ResponseModel(message="任务已删除")
@router.post("/{task_id}/remind", response_model=ResponseModel, summary="发送任务提醒")
async def send_task_reminder(
task_id: int,
request: Request,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(require_admin_or_manager)
):
"""向未完成任务的成员发送提醒"""
task = await task_service.get_task_detail(db, task_id)
if not task:
raise HTTPException(status_code=404, detail="任务不存在")
# 获取未完成的成员数量
incomplete_count = sum(1 for a in task.assignments if a.status.value != "completed")
if incomplete_count == 0:
return ResponseModel(message="所有成员已完成任务,无需发送提醒")
# 记录提醒日志
await system_log_service.create_log(
db,
SystemLogCreate(
level="INFO",
type="notification",
message=f"发送任务提醒: {task.title},提醒 {incomplete_count}",
user_id=current_user.id,
user=current_user.username,
ip=request.client.host if request.client else None,
path=f"/api/v1/manager/tasks/{task_id}/remind",
method="POST",
user_agent=request.headers.get("user-agent")
)
)
# TODO: 实际发送通知逻辑(通过通知服务)
# 可以调用 notification_service.send_task_reminder(task, incomplete_assignments)
return ResponseModel(message=f"已向 {incomplete_count} 位未完成成员发送提醒")