From cc17ac2425caed285e0a0207217e700f8290793c Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Fri, 20 Nov 2026 13:23:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(qc):=20=E4=BF=AE=E6=94=B9=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=90=8C=E6=AC=A1=E6=8F=90=E4=BA=A4=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=B9=B6=E9=99=84=E4=BB=B6=E5=8C=96=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 批量保存写入 operateBatchId;弹窗按批次合并时间线,检测材料复用附件只读组件。 Co-authored-by: Cursor --- backend/app/api/qc.py | 2 + backend/app/crud/qc_task_result_change_log.py | 4 + backend/app/models/models.py | 1 + ...-20-qc-task-result-change-log-batch-id.sql | 8 + web-admin/src/api/qc-task-result.ts | 2 + .../QcCompanyTaskResultDialog.vue | 8 +- .../QcTaskResultChangeLogDialog.vue | 284 ++++++++++++++++-- 7 files changed, 284 insertions(+), 25 deletions(-) create mode 100644 docs/sql/migrations/2026-11-20-qc-task-result-change-log-batch-id.sql diff --git a/backend/app/api/qc.py b/backend/app/api/qc.py index cffd592c..b3edf5b7 100644 --- a/backend/app/api/qc.py +++ b/backend/app/api/qc.py @@ -449,6 +449,7 @@ class TaskCompleteWithResultBody(BaseModel): third_party_attachments: Optional[str] = Field(None, alias="thirdPartyAttachments") material_usages: Optional[List[Dict[str, Any]]] = Field(None, alias="materialUsages") task_status: Optional[str] = Field(None, alias="taskStatus") + operate_batch_id: Optional[str] = Field(None, alias="operateBatchId") @router.get("/qc-lab-test-items") @@ -1438,6 +1439,7 @@ async def complete_task_with_result( operator_user_name=str(user.get("nickName") or user.get("nick_name") or ""), before=before, after=after, + operate_batch_id=body.operate_batch_id, ) db.commit() db.refresh(obj) diff --git a/backend/app/crud/qc_task_result_change_log.py b/backend/app/crud/qc_task_result_change_log.py index d932e5ef..27b72f8d 100644 --- a/backend/app/crud/qc_task_result_change_log.py +++ b/backend/app/crud/qc_task_result_change_log.py @@ -144,12 +144,14 @@ def append_task_result_change_log( before: Dict[str, Any], after: Dict[str, Any], operate_time: Optional[datetime] = None, + operate_batch_id: Optional[str] = None, ) -> BizQcTaskResultChangeLog: """追加一条检测结果保存留痕(不 commit)。无字段差异也写入。""" now = operate_time or datetime.now() changes = build_result_changes(before, after) has_change = "1" if changes else "0" name = _resolve_operator_name(db, user_id, operator_user_name) + batch_id = _norm_text(operate_batch_id) or None obj = BizQcTaskResultChangeLog( id=generate_uuid(), task_id=task.id, @@ -159,6 +161,7 @@ def append_task_result_change_log( operate_time=now, operator_user_id=user_id, operator_user_name=name or None, + operate_batch_id=batch_id, has_field_change=has_change, changes_json=json.dumps(changes, ensure_ascii=False), tenant_no=tenant_no, @@ -194,6 +197,7 @@ def _row_to_dict(row: BizQcTaskResultChangeLog) -> Dict[str, Any]: "operateTime": _fmt_dt(row.operate_time), "operatorUserId": row.operator_user_id or "", "operatorUserName": row.operator_user_name or "", + "operateBatchId": row.operate_batch_id or "", "hasFieldChange": row.has_field_change == "1", "changes": changes, "createTime": _fmt_dt(row.create_time), diff --git a/backend/app/models/models.py b/backend/app/models/models.py index 7fb1eaf9..ea32bd44 100644 --- a/backend/app/models/models.py +++ b/backend/app/models/models.py @@ -2407,6 +2407,7 @@ class BizQcTaskResultChangeLog(Base): operate_time = Column(DateTime, nullable=False, comment="业务操作时间") operator_user_id = Column(String(64), nullable=True, comment="操作人用户ID") operator_user_name = Column(String(64), nullable=True, comment="操作人姓名快照") + operate_batch_id = Column(String(64), nullable=True, comment="同一次保存批次ID(多任务共用)") has_field_change = Column(CHAR(1), nullable=False, default="0", comment="1有字段变更 0仅保存无变更") changes_json = Column(Text, nullable=True, comment="变更明细JSON") tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号") diff --git a/docs/sql/migrations/2026-11-20-qc-task-result-change-log-batch-id.sql b/docs/sql/migrations/2026-11-20-qc-task-result-change-log-batch-id.sql new file mode 100644 index 00000000..265bd3db --- /dev/null +++ b/docs/sql/migrations/2026-11-20-qc-task-result-change-log-batch-id.sql @@ -0,0 +1,8 @@ +-- 质检检测结果留痕:同一次批量保存共用 operate_batch_id(Issue #153) +-- 历史行可为空;前端对无批次号的旧数据做短时窗口合并兜底。 + +ALTER TABLE `biz_qc_task_result_change_log` + ADD COLUMN `operate_batch_id` varchar(64) DEFAULT NULL COMMENT '同一次保存批次ID(多任务共用)' AFTER `operator_user_name`; + +ALTER TABLE `biz_qc_task_result_change_log` + ADD KEY `idx_qc_result_chg_batch` (`tenant_no`, `operate_batch_id`, `del_flag`); diff --git a/web-admin/src/api/qc-task-result.ts b/web-admin/src/api/qc-task-result.ts index 5ac3f3d7..58d31fa8 100644 --- a/web-admin/src/api/qc-task-result.ts +++ b/web-admin/src/api/qc-task-result.ts @@ -51,6 +51,7 @@ export function fetchCompleteTaskWithResult( remark?: string thirdPartyAttachments?: string taskStatus?: 'dzx' | 'jxz' | 'ywc' + operateBatchId?: string materialUsages?: Array<{ requisitionUsageId: string qty: number @@ -83,6 +84,7 @@ export type QcTaskResultChangeLog = { operateTime: string operatorUserId?: string operatorUserName?: string + operateBatchId?: string hasFieldChange: boolean changes: QcTaskResultChangeItem[] createTime?: string diff --git a/web-admin/src/views/quality-inspection/qc-work-order/QcCompanyTaskResultDialog.vue b/web-admin/src/views/quality-inspection/qc-work-order/QcCompanyTaskResultDialog.vue index 6cdeea6a..4a822096 100644 --- a/web-admin/src/views/quality-inspection/qc-work-order/QcCompanyTaskResultDialog.vue +++ b/web-admin/src/views/quality-inspection/qc-work-order/QcCompanyTaskResultDialog.vue @@ -380,6 +380,11 @@ const thirdPartyAttachments = financeAttachmentsToUrlString(attachments.value) const remarkVal = remark.value + // 同一次批量保存共用批次号,修改记录弹窗合并为一个时间线节点 + const operateBatchId = + typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function' + ? crypto.randomUUID().replace(/-/g, '').toUpperCase() + : `BATCH${Date.now()}${Math.random().toString(16).slice(2, 10)}`.toUpperCase() saving.value = true const failures: string[] = [] let successCount = 0 @@ -399,7 +404,8 @@ })), remark: remarkVal, thirdPartyAttachments, - taskStatus: item.saveStatus + taskStatus: item.saveStatus, + operateBatchId }, props.operateScope ) 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 4039b08c..15e7da32 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 @@ -14,39 +14,112 @@ >
-
+
- +
- {{ entry.operateTime || '—' }} · {{ entry.operatorUserName || '—' }} -