From 38bad4232a89facefa1298006542d14a622298de Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Fri, 20 Nov 2026 11:53:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(qc):=20=E4=BF=AE=E6=94=B9=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E9=81=BF=E5=85=8D=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E8=AF=AF=E5=8C=B9=E9=85=8D=E5=B9=B6=E7=A9=BA=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /qc-tasks/result-change-logs 须先于 /qc-tasks/{task_id} 注册; 无留痕时返回 [],不再因路径被当成任务 ID 报「任务不存在」。 Co-authored-by: Cursor --- backend/app/api/qc.py | 47 ++++++++++--------- .../QcTaskResultChangeLogDialog.vue | 13 ++--- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/backend/app/api/qc.py b/backend/app/api/qc.py index 3c5635ea..cffd592c 100644 --- a/backend/app/api/qc.py +++ b/backend/app/api/qc.py @@ -1235,6 +1235,29 @@ async def list_qc_tasks( return error_response(400, str(e)) +@router.get("/qc-tasks/result-change-logs") +async def list_qc_task_result_change_logs_batch( + taskIds: str = Query("", description="逗号分隔的任务ID"), + db: Session = Depends(get_db), + user: dict = Depends(require_any_menu_code(*QC_TASK_READONLY_MENU_CODES)), +): + """批量查询检测结果修改记录。须注册在 /qc-tasks/{task_id} 之前,避免被当成任务 ID。""" + try: + tenant_no = _get_tenant_no(db, user) + ids = [x.strip() for x in (taskIds or "").split(",") if x.strip()] + if not ids: + return success_response([]) + return success_response( + result_change_log_svc.list_task_result_change_logs_by_task_ids( + db, task_ids=ids, tenant_no=tenant_no + ) + ) + except PermissionError as e: + return error_response(403, str(e)) + except Exception as e: + return error_response(400, str(e)) + + @router.get("/qc-tasks/{task_id}") async def get_qc_task_detail( task_id: str, @@ -1350,26 +1373,6 @@ async def get_task_material_usages( return error_response(400, str(e)) -@router.get("/qc-tasks/result-change-logs") -async def list_qc_task_result_change_logs_batch( - taskIds: str = Query(..., description="逗号分隔的任务ID"), - db: Session = Depends(get_db), - user: dict = Depends(require_any_menu_code(*QC_TASK_READONLY_MENU_CODES)), -): - try: - tenant_no = _get_tenant_no(db, user) - ids = [x.strip() for x in (taskIds or "").split(",") if x.strip()] - return success_response( - result_change_log_svc.list_task_result_change_logs_by_task_ids( - db, task_ids=ids, tenant_no=tenant_no - ) - ) - except PermissionError as e: - return error_response(403, str(e)) - except Exception as e: - return error_response(400, str(e)) - - @router.get("/qc-tasks/{task_id}/result-change-logs") async def list_qc_task_result_change_logs( task_id: str, @@ -1378,9 +1381,7 @@ async def list_qc_task_result_change_logs( ): try: tenant_no = _get_tenant_no(db, user) - t = task_svc.get_task(db, task_id, tenant_no=tenant_no) - if not t: - return error_response(404, "任务不存在") + # 无任务或无留痕均返回空列表,避免前端把“暂无记录”当成错误 return success_response( result_change_log_svc.list_task_result_change_logs( db, task_id=task_id, tenant_no=tenant_no diff --git a/web-admin/src/views/quality-inspection/qc-work-order/QcTaskResultChangeLogDialog.vue b/web-admin/src/views/quality-inspection/qc-work-order/QcTaskResultChangeLogDialog.vue index 34e75305..bb71abdf 100644 --- a/web-admin/src/views/quality-inspection/qc-work-order/QcTaskResultChangeLogDialog.vue +++ b/web-admin/src/views/quality-inspection/qc-work-order/QcTaskResultChangeLogDialog.vue @@ -67,7 +67,6 @@ import { Close } from '@element-plus/icons-vue' import DialogFormBody from '@/components/business/dialog-form-body/index.vue' import { - fetchQcTaskResultChangeLogs, fetchQcTaskResultChangeLogsBatch, type QcTaskResultChangeLog } from '@/api/qc-task-result' @@ -114,14 +113,12 @@ loading.value = true entries.value = [] try { - const list = - ids.length > 1 - ? await fetchQcTaskResultChangeLogsBatch(ids) - : ids.length === 1 - ? await fetchQcTaskResultChangeLogs(ids[0]) - : [] + // 多任务统一走批量接口,避免路径被 /qc-tasks/{id} 误匹配 + const list = ids.length + ? await fetchQcTaskResultChangeLogsBatch(ids) + : [] if (seq !== loadSeq) return - entries.value = list || [] + entries.value = Array.isArray(list) ? list : [] } catch { if (seq !== loadSeq) return entries.value = []