全栈: 接收任务写入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 端点 — 核心业务:接收、驳回返工、裂变转交、无限嵌套子任务""" """任务 API 端点 — 核心业务:接收、驳回返工、裂变转交、无限嵌套子任务"""
from __future__ import annotations from __future__ import annotations
import uuid import uuid
from fastapi import APIRouter, Depends, Query from fastapi import APIRouter, Depends, Query, Body
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from app.core.database import get_db from app.core.database import get_db
@ -110,16 +110,17 @@ async def complete_task_endpoint(
async def receive_task_endpoint( async def receive_task_endpoint(
task_id: str, task_id: str,
operator_id: str | None = Query(None, description="操作人ID"), operator_id: str | None = Query(None, description="操作人ID"),
remark: str | None = Body(None, description="接收备注", embed=True),
db: AsyncSession = Depends(get_db), db: AsyncSession = Depends(get_db),
): ):
""" """
**确认接收任务。** **确认接收任务。**
校验:只有状态为 PENDING 的任务可接收。 校验:只有状态为 PENDING 的任务可接收。
动作:将状态改为 WIP记录 received_at 为当前时间。 动作:将状态改为 WIP记录 received_at 为当前时间,写入 remark
""" """
return await task_service.receive_task( 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( 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: ) -> TaskResponse:
""" """
操作员确认接收任务。 操作员确认接收任务。
校验:只有状态为 PENDING 的任务可接收。 校验:只有状态为 PENDING 的任务可接收。
动作:状态改为 WIP记录 received_at 为当前时间 动作:状态改为 WIP记录 received_at,写入 remark
""" """
task = await _get_task_or_404(db, task_id) task = await _get_task_or_404(db, task_id)
@ -247,12 +248,14 @@ async def receive_task(
now = get_beijing_time() now = get_beijing_time()
task.status = TASK_STATUS_WIP task.status = TASK_STATUS_WIP
task.received_at = now task.received_at = now
if remark:
task.remark = remark
await _create_task_log( await _create_task_log(
db, task_id, db, task_id,
action_type="receive", action_type="receive",
operator_id=operator_id, operator_id=operator_id,
remark=f"操作员确认接收任务「{task.task_name}", remark=remark or f"操作员确认接收任务「{task.task_name}",
) )
await db.commit() await db.commit()

View File

@ -224,6 +224,7 @@
<text class="popup-title">确认接收任务</text> <text class="popup-title">确认接收任务</text>
<view class="popup-task">{{ actionPopup.task && actionPopup.task.task_name }}</view> <view class="popup-task">{{ actionPopup.task && actionPopup.task.task_name }}</view>
<text class="popup-hint">状态: {{ statusLabel(actionPopup.task && actionPopup.task.status) }} 进行中</text> <text class="popup-hint">状态: {{ statusLabel(actionPopup.task && actionPopup.task.status) }} 进行中</text>
<textarea v-model="receiveRemark" class="popup-textarea" placeholder="接收备注(选填)" :maxlength="500" />
<view class="popup-btns"> <view class="popup-btns">
<button class="btn-cancel" @tap="closeActionPopup">取消</button> <button class="btn-cancel" @tap="closeActionPopup">取消</button>
<button class="btn-primary" :disabled="actionLoading" @tap="doReceive">确认接收</button> <button class="btn-primary" :disabled="actionLoading" @tap="doReceive">确认接收</button>
@ -357,6 +358,7 @@ export default {
actionPopup: { visible: false, type: "", task: null }, actionPopup: { visible: false, type: "", task: null },
actionLoading: false, actionLoading: false,
rejectReason: "", rejectReason: "",
receiveRemark: "",
transferForm: { branches: [{ task_name: "", assignee_id: "" }], note: "" }, transferForm: { branches: [{ task_name: "", assignee_id: "" }], note: "" },
}; };
}, },
@ -682,6 +684,7 @@ export default {
this.actionPopup = { visible: true, type, task }; this.actionPopup = { visible: true, type, task };
this.rejectReason = ""; this.rejectReason = "";
this.receiveRemark = "";
this.transferForm = { branches: [{ task_name: "", assignee_id: "" }], note: "" }; this.transferForm = { branches: [{ task_name: "", assignee_id: "" }], note: "" };
}, },
handleViewRecords(task) { handleViewRecords(task) {
@ -692,7 +695,8 @@ export default {
async doReceive() { async doReceive() {
this.actionLoading = true; this.actionLoading = true;
try { try {
await post(`/tasks/${this.actionPopup.task.id}/receive`); const remark = this.receiveRemark.trim() || undefined;
await post(`/tasks/${this.actionPopup.task.id}/receive`, { remark });
uni.showToast({ title: "已接收", icon: "success" }); uni.showToast({ title: "已接收", icon: "success" });
this.closeActionPopup(); this.closeActionPopup();
this.doQuery(this.product.serial_number); this.doQuery(this.product.serial_number);