全栈: 接收任务写入remark — 后端receive接口+Body参数+前端接收弹窗备注输入
This commit is contained in:
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -224,6 +224,7 @@
|
||||
<text class="popup-title">确认接收任务</text>
|
||||
<view class="popup-task">{{ actionPopup.task && actionPopup.task.task_name }}</view>
|
||||
<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">
|
||||
<button class="btn-cancel" @tap="closeActionPopup">取消</button>
|
||||
<button class="btn-primary" :disabled="actionLoading" @tap="doReceive">确认接收</button>
|
||||
@ -357,6 +358,7 @@ export default {
|
||||
actionPopup: { visible: false, type: "", task: null },
|
||||
actionLoading: false,
|
||||
rejectReason: "",
|
||||
receiveRemark: "",
|
||||
transferForm: { branches: [{ task_name: "", assignee_id: "" }], note: "" },
|
||||
};
|
||||
},
|
||||
@ -682,6 +684,7 @@ export default {
|
||||
|
||||
this.actionPopup = { visible: true, type, task };
|
||||
this.rejectReason = "";
|
||||
this.receiveRemark = "";
|
||||
this.transferForm = { branches: [{ task_name: "", assignee_id: "" }], note: "" };
|
||||
},
|
||||
handleViewRecords(task) {
|
||||
@ -692,7 +695,8 @@ export default {
|
||||
async doReceive() {
|
||||
this.actionLoading = true;
|
||||
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" });
|
||||
this.closeActionPopup();
|
||||
this.doQuery(this.product.serial_number);
|
||||
|
||||
Reference in New Issue
Block a user