From 99583b38ce72c9fe6fdf244b1a67d0f7c94d480a Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Fri, 20 Nov 2026 11:39:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(qc):=20=E4=BB=BB=E5=8A=A1=E8=BD=AF=E5=88=A0?= =?UTF-8?q?=E7=BA=A7=E8=81=94=E6=B8=85=E7=90=86=E6=A3=80=E6=B5=8B=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E7=95=99=E7=97=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除质检任务/工单时同步软删修改记录,避免批量查询仍返回已删任务历史; 实验室填写结论回显优先沿用列表行结论。 Co-authored-by: Cursor --- backend/app/crud/qc_task.py | 13 +++++++++++ backend/app/crud/qc_work_order.py | 23 +++++++++++++++++++ .../qc-work-order/QcWorkOrderTaskSubList.vue | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/backend/app/crud/qc_task.py b/backend/app/crud/qc_task.py index 1369e23d..7bc279cc 100644 --- a/backend/app/crud/qc_task.py +++ b/backend/app/crud/qc_task.py @@ -1095,6 +1095,7 @@ def delete_qc_task(db: Session, task_id: str, tenant_no: str, user_id: Optional[ # 软删除任务结果 from app.models.qc_param import BizQcTaskResult + from app.models.models import BizQcTaskResultChangeLog results = db.query(BizQcTaskResult).filter( and_(BizQcTaskResult.task_id == task_id, BizQcTaskResult.del_flag == 0) @@ -1104,6 +1105,18 @@ def delete_qc_task(db: Session, task_id: str, tenant_no: str, user_id: Optional[ r.update_by = user_id r.update_time = now + change_logs = db.query(BizQcTaskResultChangeLog).filter( + and_( + BizQcTaskResultChangeLog.task_id == task_id, + BizQcTaskResultChangeLog.tenant_no == tenant_no, + BizQcTaskResultChangeLog.del_flag == 0, + ) + ).all() + for log in change_logs: + log.del_flag = 1 + log.update_by = user_id + log.update_time = now + # 同步软删批次明细行(配置弹窗勾选来源) _soft_delete_source_line_for_task( db, task, tenant_no=tenant_no, user_id=user_id, now=now diff --git a/backend/app/crud/qc_work_order.py b/backend/app/crud/qc_work_order.py index d5a69711..b9b72fa7 100644 --- a/backend/app/crud/qc_work_order.py +++ b/backend/app/crud/qc_work_order.py @@ -2753,6 +2753,16 @@ def _soft_delete_tasks_by_source_line_ids( {"del_flag": 1, "update_time": now}, synchronize_session="fetch", ) + from app.models.models import BizQcTaskResultChangeLog + + db.query(BizQcTaskResultChangeLog).filter( + BizQcTaskResultChangeLog.task_id.in_(task_ids), + BizQcTaskResultChangeLog.tenant_no == tenant_no, + BizQcTaskResultChangeLog.del_flag == 0, + ).update( + {"del_flag": 1, "update_time": now}, + synchronize_session="fetch", + ) for t in tasks: t.del_flag = 1 t.update_time = now @@ -3884,6 +3894,8 @@ def delete_qc_work_order(db: Session, work_order_id: str, tenant_no: str, user_i ).all() from app.models.qc_param import BizQcTaskResult + from app.models.models import BizQcTaskResultChangeLog + for task in tasks: results = db.query(BizQcTaskResult).filter( and_(BizQcTaskResult.task_id == task.id, BizQcTaskResult.del_flag == 0) @@ -3892,6 +3904,17 @@ def delete_qc_work_order(db: Session, work_order_id: str, tenant_no: str, user_i r.del_flag = 1 r.update_by = user_id r.update_time = now + change_logs = db.query(BizQcTaskResultChangeLog).filter( + and_( + BizQcTaskResultChangeLog.task_id == task.id, + BizQcTaskResultChangeLog.tenant_no == tenant_no, + BizQcTaskResultChangeLog.del_flag == 0, + ) + ).all() + for log in change_logs: + log.del_flag = 1 + log.update_by = user_id + log.update_time = now task.del_flag = 1 task.update_by = user_id task.update_time = now diff --git a/web-admin/src/views/quality-inspection/qc-work-order/QcWorkOrderTaskSubList.vue b/web-admin/src/views/quality-inspection/qc-work-order/QcWorkOrderTaskSubList.vue index b59b1da0..0b584f32 100644 --- a/web-admin/src/views/quality-inspection/qc-work-order/QcWorkOrderTaskSubList.vue +++ b/web-admin/src/views/quality-inspection/qc-work-order/QcWorkOrderTaskSubList.vue @@ -1447,7 +1447,7 @@ resultTaskStatus.value = detail.taskStatus || row.taskStatus const fillDefaults = resolveQcResultFillDefaults({ taskStatus: detail.taskStatus || row.taskStatus, - conclusion: detail.conclusion + conclusion: detail.conclusion ?? row.conclusion }) resultSaveStatus.value = fillDefaults.saveStatus resultRemark.value = detail.remark || row.remark || ''