全栈: 接收任务写入remark — 后端receive接口+Body参数+前端接收弹窗备注输入

This commit is contained in:
2026-08-05 16:16:35 +08:00
parent 353633f061
commit 62422e7558
3 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,7 @@
"""任务 API 端点 — 核心业务:接收、驳回返工、裂变转交、无限嵌套子任务"""
from __future__ import annotations
import uuid
from fastapi import APIRouter, Depends, Query
from fastapi import APIRouter, Depends, Query, Body
from sqlalchemy.ext.asyncio import AsyncSession
from app.core.database import get_db
@ -110,16 +110,17 @@ async def complete_task_endpoint(
async def receive_task_endpoint(
task_id: str,
operator_id: str | None = Query(None, description="操作人ID"),
remark: str | None = Body(None, description="接收备注", embed=True),
db: AsyncSession = Depends(get_db),
):
"""
**确认接收任务。**
校验:只有状态为 PENDING 的任务可接收。
动作:将状态改为 WIP,记录 received_at 为当前时间。
动作:将状态改为 WIP,记录 received_at 为当前时间,写入 remark。
"""
return await task_service.receive_task(
db, uuid.UUID(task_id), operator_id
db, uuid.UUID(task_id), operator_id, remark
)

View File

@ -227,13 +227,14 @@ async def get_all_tasks(
# ============================================================
async def receive_task(
db: AsyncSession, task_id: uuid.UUID, operator_id: str | None = None
db: AsyncSession, task_id: uuid.UUID, operator_id: str | None = None,
remark: str | None = None,
) -> TaskResponse:
"""
操作员确认接收任务。
校验:只有状态为 PENDING 的任务可接收。
动作:状态改为 WIP,记录 received_at 为当前时间。
动作:状态改为 WIP,记录 received_at,写入 remark。
"""
task = await _get_task_or_404(db, task_id)
@ -247,12 +248,14 @@ async def receive_task(
now = get_beijing_time()
task.status = TASK_STATUS_WIP
task.received_at = now
if remark:
task.remark = remark
await _create_task_log(
db, task_id,
action_type="receive",
operator_id=operator_id,
remark=f"操作员确认接收任务「{task.task_name}」",
remark=remark or f"操作员确认接收任务「{task.task_name}」",
)
await db.commit()