Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5260f05522 | ||
|
|
99583b38ce | ||
|
|
9b6228860f | ||
|
|
8d7b2ada59 | ||
|
|
332711ad36 | ||
|
|
03acf5115a | ||
|
|
12cf373a49 | ||
|
|
0434999603 | ||
|
|
f40d33b07a | ||
|
|
e5f84b4693 |
No files matched your search
@@ -29,6 +29,7 @@ from app.crud import qc_lab_test_item as lab_svc
|
||||
from app.crud import qc_inspection_item_template as iit_svc
|
||||
from app.crud import qc_item_param as param_svc
|
||||
from app.crud import qc_task_result as result_svc
|
||||
from app.crud import qc_task_result_change_log as result_change_log_svc
|
||||
from app.crud import qc_task as task_svc
|
||||
from app.crud import qc_third_party_company as tpc_svc
|
||||
from app.crud import qc_third_party_item as tpi_svc
|
||||
@@ -1349,6 +1350,48 @@ 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,
|
||||
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)
|
||||
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
|
||||
)
|
||||
)
|
||||
except PermissionError as e:
|
||||
return error_response(403, str(e))
|
||||
except Exception as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/qc-tasks/{task_id}/complete-with-result")
|
||||
async def complete_task_with_result(
|
||||
task_id: str,
|
||||
@@ -1364,6 +1407,7 @@ async def complete_task_with_result(
|
||||
if not t:
|
||||
return error_response(404, "任务不存在")
|
||||
was_done = (t.task_status or "").strip() == "ywc"
|
||||
before = result_change_log_svc.snapshot_task_result_state(db, t, tenant_no)
|
||||
if body.results:
|
||||
result_svc.save_results_for_task(
|
||||
db, task_id, body.results, tenant_no, user_id, commit=False,
|
||||
@@ -1384,6 +1428,16 @@ async def complete_task_with_result(
|
||||
task_status=body.task_status,
|
||||
commit=False,
|
||||
)
|
||||
after = result_change_log_svc.snapshot_task_result_state(db, obj, tenant_no)
|
||||
result_change_log_svc.append_task_result_change_log(
|
||||
db,
|
||||
task=obj,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user_id,
|
||||
operator_user_name=str(user.get("nickName") or user.get("nick_name") or ""),
|
||||
before=before,
|
||||
after=after,
|
||||
)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
if (obj.task_status or "").strip() == "ywc":
|
||||
|
||||
@@ -1394,6 +1394,7 @@ def list_collection_protocols(
|
||||
"sampleTypeName": type_name,
|
||||
"sampleCode": code,
|
||||
"sampleStatus": (s.sample_status or "").strip(),
|
||||
"voidDesc": (getattr(s, "void_desc", None) or "").strip(),
|
||||
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
||||
"transport": transport_dict,
|
||||
"freight": freight_by_sample.get(s.id),
|
||||
|
||||
@@ -410,7 +410,8 @@ def list_protocol_sample_collections(
|
||||
item["newbornDeliveryTime"] = _fmt_dt(party.newborn_delivery_time) if party else ""
|
||||
item["protocolRemark"] = (proto.remark or "") if proto else ""
|
||||
item["voidType"] = (proto.void_type or "") if proto else ""
|
||||
item["voidDesc"] = (proto.void_desc or "") if proto else ""
|
||||
# 样本状态问号展示样本作废原因,不用协议作废描述
|
||||
item["voidDesc"] = (getattr(psample, "void_desc", None) or "").strip()
|
||||
item["protocolAttachments"] = (proto.protocol_attachments or "") if proto else ""
|
||||
item["consentFormUrls"] = (proto.consent_form_urls or "") if proto else ""
|
||||
item["healthSurveyFormUrls"] = (proto.health_survey_form_urls or "") if proto else ""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
"""质检任务检测结果操作留痕"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.utils import generate_uuid
|
||||
from app.models.models import BizQcTask, BizQcTaskResultChangeLog, SysUser
|
||||
from app.models.qc_param import BizQcTaskResult
|
||||
|
||||
_TASK_STATUS_LABELS = {"dzx": "待执行", "jxz": "进行中", "ywc": "已完成"}
|
||||
_CONCLUSION_LABELS = {"": "待结论", "tg": "通过", "btg": "不通过"}
|
||||
|
||||
|
||||
def _fmt_dt(v: Optional[datetime]) -> str:
|
||||
if not v:
|
||||
return ""
|
||||
return v.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
def _display_status(code: Optional[str]) -> str:
|
||||
c = (code or "").strip()
|
||||
return _TASK_STATUS_LABELS.get(c, c or "—")
|
||||
|
||||
|
||||
def _display_conclusion(code: Optional[str]) -> str:
|
||||
c = (code or "").strip()
|
||||
return _CONCLUSION_LABELS.get(c, c or "待结论")
|
||||
|
||||
|
||||
def _norm_text(v: Any) -> str:
|
||||
if v is None:
|
||||
return ""
|
||||
return str(v).strip()
|
||||
|
||||
|
||||
def _param_key(param_id: Optional[str], param_code: Optional[str], param_name: Optional[str]) -> str:
|
||||
pid = _norm_text(param_id)
|
||||
if pid:
|
||||
return f"paramId:{pid}"
|
||||
code = _norm_text(param_code)
|
||||
if code:
|
||||
return f"paramCode:{code}"
|
||||
return f"paramName:{_norm_text(param_name)}"
|
||||
|
||||
|
||||
def snapshot_task_result_state(db: Session, task: BizQcTask, tenant_no: str) -> Dict[str, Any]:
|
||||
"""保存前快照:任务结论字段 + 已存参数值。"""
|
||||
rows = (
|
||||
db.query(BizQcTaskResult)
|
||||
.filter(
|
||||
BizQcTaskResult.task_id == task.id,
|
||||
BizQcTaskResult.tenant_no == tenant_no,
|
||||
BizQcTaskResult.del_flag == 0,
|
||||
)
|
||||
.order_by(BizQcTaskResult.create_time.asc())
|
||||
.all()
|
||||
)
|
||||
params: Dict[str, Dict[str, str]] = {}
|
||||
for r in rows:
|
||||
key = _param_key(r.param_id, r.param_code, r.param_name)
|
||||
params[key] = {
|
||||
"label": _norm_text(r.param_name) or key,
|
||||
"value": _norm_text(r.param_value),
|
||||
}
|
||||
return {
|
||||
"taskStatus": _norm_text(task.task_status),
|
||||
"conclusion": _norm_text(task.conclusion),
|
||||
"remark": _norm_text(task.remark),
|
||||
"attachments": _norm_text(task.third_party_attachments),
|
||||
"params": params,
|
||||
}
|
||||
|
||||
|
||||
def build_result_changes(
|
||||
before: Dict[str, Any],
|
||||
after: Dict[str, Any],
|
||||
) -> List[Dict[str, str]]:
|
||||
changes: List[Dict[str, str]] = []
|
||||
|
||||
def add(field_key: str, label: str, old_v: str, new_v: str) -> None:
|
||||
if old_v == new_v:
|
||||
return
|
||||
changes.append(
|
||||
{
|
||||
"fieldKey": field_key,
|
||||
"fieldLabel": label,
|
||||
"oldValue": old_v,
|
||||
"newValue": new_v,
|
||||
}
|
||||
)
|
||||
|
||||
add(
|
||||
"taskStatus",
|
||||
"任务状态",
|
||||
_display_status(before.get("taskStatus")),
|
||||
_display_status(after.get("taskStatus")),
|
||||
)
|
||||
add(
|
||||
"conclusion",
|
||||
"结论",
|
||||
_display_conclusion(before.get("conclusion")),
|
||||
_display_conclusion(after.get("conclusion")),
|
||||
)
|
||||
add("remark", "备注", _norm_text(before.get("remark")), _norm_text(after.get("remark")))
|
||||
add(
|
||||
"attachments",
|
||||
"检测材料",
|
||||
_norm_text(before.get("attachments")),
|
||||
_norm_text(after.get("attachments")),
|
||||
)
|
||||
|
||||
before_params: Dict[str, Dict[str, str]] = before.get("params") or {}
|
||||
after_params: Dict[str, Dict[str, str]] = after.get("params") or {}
|
||||
keys = sorted(set(before_params.keys()) | set(after_params.keys()))
|
||||
for key in keys:
|
||||
b = before_params.get(key) or {"label": key, "value": ""}
|
||||
a = after_params.get(key) or {"label": b.get("label") or key, "value": ""}
|
||||
label = _norm_text(a.get("label")) or _norm_text(b.get("label")) or key
|
||||
add(key, label, _norm_text(b.get("value")), _norm_text(a.get("value")))
|
||||
return changes
|
||||
|
||||
|
||||
def _resolve_operator_name(db: Session, user_id: Optional[str], fallback: str = "") -> str:
|
||||
uid = _norm_text(user_id)
|
||||
if not uid:
|
||||
return _norm_text(fallback)
|
||||
row = db.query(SysUser.nick_name).filter(SysUser.id == uid).first()
|
||||
if row and row[0]:
|
||||
return str(row[0]).strip()
|
||||
return _norm_text(fallback) or uid
|
||||
|
||||
|
||||
def append_task_result_change_log(
|
||||
db: Session,
|
||||
*,
|
||||
task: BizQcTask,
|
||||
tenant_no: str,
|
||||
user_id: Optional[str],
|
||||
operator_user_name: str = "",
|
||||
before: Dict[str, Any],
|
||||
after: Dict[str, Any],
|
||||
operate_time: Optional[datetime] = 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)
|
||||
obj = BizQcTaskResultChangeLog(
|
||||
id=generate_uuid(),
|
||||
task_id=task.id,
|
||||
work_order_id=_norm_text(task.work_order_id) or None,
|
||||
sample_code=_norm_text(task.sample_code) or None,
|
||||
item_name=_norm_text(task.item_name) or None,
|
||||
operate_time=now,
|
||||
operator_user_id=user_id,
|
||||
operator_user_name=name or None,
|
||||
has_field_change=has_change,
|
||||
changes_json=json.dumps(changes, ensure_ascii=False),
|
||||
tenant_no=tenant_no,
|
||||
order_num=0,
|
||||
remark=None,
|
||||
create_by=user_id,
|
||||
create_dept_id="",
|
||||
create_time=now,
|
||||
update_by=user_id,
|
||||
update_time=now,
|
||||
del_flag=0,
|
||||
)
|
||||
db.add(obj)
|
||||
return obj
|
||||
|
||||
|
||||
def _row_to_dict(row: BizQcTaskResultChangeLog) -> Dict[str, Any]:
|
||||
changes: List[Dict[str, Any]] = []
|
||||
raw = row.changes_json or ""
|
||||
if raw.strip():
|
||||
try:
|
||||
parsed = json.loads(raw)
|
||||
if isinstance(parsed, list):
|
||||
changes = parsed
|
||||
except json.JSONDecodeError:
|
||||
changes = []
|
||||
return {
|
||||
"id": row.id,
|
||||
"taskId": row.task_id,
|
||||
"workOrderId": row.work_order_id or "",
|
||||
"sampleCode": row.sample_code or "",
|
||||
"itemName": row.item_name or "",
|
||||
"operateTime": _fmt_dt(row.operate_time),
|
||||
"operatorUserId": row.operator_user_id or "",
|
||||
"operatorUserName": row.operator_user_name or "",
|
||||
"hasFieldChange": row.has_field_change == "1",
|
||||
"changes": changes,
|
||||
"createTime": _fmt_dt(row.create_time),
|
||||
}
|
||||
|
||||
|
||||
def list_task_result_change_logs(
|
||||
db: Session,
|
||||
*,
|
||||
task_id: str,
|
||||
tenant_no: str,
|
||||
) -> List[Dict[str, Any]]:
|
||||
tid = _norm_text(task_id)
|
||||
if not tid:
|
||||
return []
|
||||
rows = (
|
||||
db.query(BizQcTaskResultChangeLog)
|
||||
.filter(
|
||||
BizQcTaskResultChangeLog.task_id == tid,
|
||||
BizQcTaskResultChangeLog.tenant_no == tenant_no,
|
||||
BizQcTaskResultChangeLog.del_flag == 0,
|
||||
)
|
||||
.order_by(
|
||||
BizQcTaskResultChangeLog.operate_time.desc(),
|
||||
BizQcTaskResultChangeLog.create_time.desc(),
|
||||
)
|
||||
.all()
|
||||
)
|
||||
return [_row_to_dict(r) for r in rows]
|
||||
|
||||
|
||||
def list_task_result_change_logs_by_task_ids(
|
||||
db: Session,
|
||||
*,
|
||||
task_ids: List[str],
|
||||
tenant_no: str,
|
||||
) -> List[Dict[str, Any]]:
|
||||
ids = [_norm_text(x) for x in task_ids if _norm_text(x)]
|
||||
if not ids:
|
||||
return []
|
||||
rows = (
|
||||
db.query(BizQcTaskResultChangeLog)
|
||||
.filter(
|
||||
BizQcTaskResultChangeLog.task_id.in_(ids),
|
||||
BizQcTaskResultChangeLog.tenant_no == tenant_no,
|
||||
BizQcTaskResultChangeLog.del_flag == 0,
|
||||
)
|
||||
.order_by(
|
||||
BizQcTaskResultChangeLog.operate_time.desc(),
|
||||
BizQcTaskResultChangeLog.create_time.desc(),
|
||||
)
|
||||
.all()
|
||||
)
|
||||
return [_row_to_dict(r) for r in rows]
|
||||
@@ -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
|
||||
|
||||
@@ -976,6 +976,7 @@ def list_donations(
|
||||
"sampleTypeName": type_name,
|
||||
"sampleCode": code,
|
||||
"sampleStatus": (s.sample_status or "").strip(),
|
||||
"voidDesc": (getattr(s, "void_desc", None) or "").strip(),
|
||||
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
||||
"transport": transport_dict,
|
||||
"freight": freight_by_sample.get(s.id),
|
||||
|
||||
@@ -444,6 +444,7 @@ def _rows_to_sample_list_items(
|
||||
"sampleTypeName": type_map.get(sample.sample_type_id or "", ""),
|
||||
"collectAmount": _dec(sample.collect_amount),
|
||||
"sampleStatus": sample.sample_status or "",
|
||||
"voidDesc": (getattr(sample, "void_desc", None) or "").strip(),
|
||||
"motherName": (party.mother_name if party else "") or "",
|
||||
"newbornName": (party.newborn_name if party else "") or "",
|
||||
"sampleCollectTime": (
|
||||
|
||||
@@ -2394,6 +2394,32 @@ class BizQcTask(Base):
|
||||
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||
|
||||
|
||||
class BizQcTaskResultChangeLog(Base):
|
||||
"""质检任务检测结果操作留痕 biz_qc_task_result_change_log(Issue #148/#149)"""
|
||||
|
||||
__tablename__ = "biz_qc_task_result_change_log"
|
||||
|
||||
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||
task_id = Column(String(64), nullable=False, comment="质检任务ID")
|
||||
work_order_id = Column(String(64), nullable=True, comment="质检工单ID快照")
|
||||
sample_code = Column(String(32), nullable=True, comment="样本编码快照")
|
||||
item_name = Column(String(200), nullable=True, comment="检测项目名称快照")
|
||||
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="操作人姓名快照")
|
||||
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="租户编号")
|
||||
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||
remark = Column(String(512), nullable=True, comment="备注")
|
||||
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||
|
||||
|
||||
class BizQcTaskAssignee(Base):
|
||||
"""质检任务负责人 biz_qc_task_assignee"""
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""市场协议无效态 ↔ 样本接收废弃 / 样本状态作废联动。
|
||||
|
||||
规则(细胞存储 / 科研捐赠):
|
||||
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf)并写 `void_date`;
|
||||
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态与 void_date。
|
||||
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf),
|
||||
写 `void_date`,并将接收备注写入 `void_desc`(备注为空则作废原因为空);
|
||||
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态、void_date 与 void_desc。
|
||||
2. 协议变为已作废(yzf)或属地废弃(sdfq)时:
|
||||
- 协议下全部样本接收结论自动为废弃(bj);
|
||||
- 协议下全部有效样本 `sample_status` 置为已作废(yzf),并写入 `void_date`。
|
||||
@@ -585,13 +586,17 @@ def void_sample_for_discarded_reception(
|
||||
tenant_no: str,
|
||||
user_id: Optional[str] = None,
|
||||
) -> bool:
|
||||
"""单条接收废弃:仅将该样本置为已作废。"""
|
||||
"""单条接收废弃:将该样本置为已作废,作废原因取接收备注。"""
|
||||
_source, sample = _find_sample_for_reception(db, reception=reception, tenant_no=tenant_no)
|
||||
if not sample:
|
||||
return False
|
||||
now = datetime.now()
|
||||
reason = (reception.remark or "").strip()
|
||||
if len(reason) > 512:
|
||||
reason = reason[:512]
|
||||
sample.sample_status = SAMPLE_VOID_STATUS
|
||||
sample.void_date = _void_date_yyyymmdd(void_time=reception.reception_time or now)
|
||||
sample.void_desc = reason or None
|
||||
sample.update_by = user_id
|
||||
sample.update_time = now
|
||||
db.add(sample)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
"""协议/捐赠列表 sampleItems 须返回样本 voidDesc,供审核列表问号展示。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
import re
|
||||
import unittest
|
||||
|
||||
|
||||
_SAMPLE_ITEM_VOID_DESC = re.compile(
|
||||
r'"sampleStatus"\s*:\s*\(s\.sample_status[^)]*\)\.strip\(\),\s*'
|
||||
r'"voidDesc"\s*:\s*\(getattr\(s,\s*"void_desc"',
|
||||
re.S,
|
||||
)
|
||||
|
||||
|
||||
class TestProtocolListSampleVoidDesc(unittest.TestCase):
|
||||
def test_collection_protocol_list_includes_sample_void_desc(self):
|
||||
from app.crud import collection_protocol as cp
|
||||
|
||||
src = inspect.getsource(cp.list_collection_protocols)
|
||||
self.assertRegex(src, _SAMPLE_ITEM_VOID_DESC)
|
||||
|
||||
def test_research_donation_list_includes_sample_void_desc(self):
|
||||
from app.crud import research_donation as rd
|
||||
|
||||
# 捐赠列表函数名
|
||||
fn = None
|
||||
for name, obj in inspect.getmembers(rd, inspect.isfunction):
|
||||
if "list" in name and "donation" in name:
|
||||
src = inspect.getsource(obj)
|
||||
if "sample_items.append" in src and '"sampleStatus"' in src:
|
||||
fn = obj
|
||||
break
|
||||
self.assertIsNotNone(fn, "未找到组装 sampleItems 的捐赠列表函数")
|
||||
self.assertRegex(inspect.getsource(fn), _SAMPLE_ITEM_VOID_DESC)
|
||||
|
||||
def test_sample_collection_list_uses_sample_void_desc(self):
|
||||
from app.crud import protocol_sample_collection as psc
|
||||
|
||||
src = inspect.getsource(psc)
|
||||
self.assertIn('getattr(psample, "void_desc"', src)
|
||||
self.assertNotIn('item["voidDesc"] = (proto.void_desc or "") if proto else ""', src)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -440,6 +440,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
||||
accept_conclusion="bj",
|
||||
reception_source="cell_storage",
|
||||
sample_code="ZKA",
|
||||
remark="母血乙肝阳性",
|
||||
tenant_no="tenant-a",
|
||||
create_dept_id="",
|
||||
create_time=now,
|
||||
@@ -471,6 +472,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
||||
}
|
||||
self.assertEqual(by_id["sa"].sample_status, SAMPLE_VOID_STATUS)
|
||||
self.assertEqual(by_id["sa"].void_date, "20261105")
|
||||
self.assertEqual(by_id["sa"].void_desc, "母血乙肝阳性")
|
||||
self.assertEqual(by_id["sb"].sample_status, "ycj")
|
||||
self.assertEqual(by_id["sc"].sample_status, "ycj")
|
||||
|
||||
@@ -496,6 +498,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
||||
sample_code="ZKCLR",
|
||||
sample_status=SAMPLE_VOID_STATUS,
|
||||
void_date="20261101",
|
||||
void_desc="旧作废原因",
|
||||
tenant_no="tenant-a",
|
||||
create_dept_id="",
|
||||
create_time=now,
|
||||
@@ -535,6 +538,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
||||
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s-clear").one()
|
||||
self.assertFalse((sample.sample_status or "").strip())
|
||||
self.assertFalse((sample.void_date or "").strip())
|
||||
self.assertFalse((sample.void_desc or "").strip())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
"""质检检测结果留痕:字段差异与空保存。"""
|
||||
from app.crud.qc_task_result_change_log import build_result_changes
|
||||
|
||||
|
||||
def test_build_changes_for_status_and_param():
|
||||
before = {
|
||||
"taskStatus": "dzx",
|
||||
"conclusion": "",
|
||||
"remark": "",
|
||||
"attachments": "",
|
||||
"params": {"paramCode:HBsAg": {"label": "HBsAg", "value": "阴性"}},
|
||||
}
|
||||
after = {
|
||||
"taskStatus": "ywc",
|
||||
"conclusion": "tg",
|
||||
"remark": "",
|
||||
"attachments": "",
|
||||
"params": {"paramCode:HBsAg": {"label": "HBsAg", "value": "阳性"}},
|
||||
}
|
||||
changes = build_result_changes(before, after)
|
||||
keys = {c["fieldKey"] for c in changes}
|
||||
assert "taskStatus" in keys
|
||||
assert "conclusion" in keys
|
||||
assert "paramCode:HBsAg" in keys
|
||||
hbs = next(c for c in changes if c["fieldKey"] == "paramCode:HBsAg")
|
||||
assert hbs["oldValue"] == "阴性"
|
||||
assert hbs["newValue"] == "阳性"
|
||||
|
||||
|
||||
def test_build_changes_empty_when_identical():
|
||||
state = {
|
||||
"taskStatus": "ywc",
|
||||
"conclusion": "tg",
|
||||
"remark": "ok",
|
||||
"attachments": "a.png",
|
||||
"params": {"paramCode:X": {"label": "X", "value": "1"}},
|
||||
}
|
||||
assert build_result_changes(state, state) == []
|
||||
@@ -0,0 +1,27 @@
|
||||
-- 质检任务检测结果操作留痕(Issue #148 / #149)
|
||||
-- 每次「填写检测结果」保存追加一条;即使字段无变更也记录操作人与时间。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `biz_qc_task_result_change_log` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键ID',
|
||||
`task_id` varchar(64) NOT NULL COMMENT '质检任务ID',
|
||||
`work_order_id` varchar(64) DEFAULT NULL COMMENT '质检工单ID快照',
|
||||
`sample_code` varchar(32) DEFAULT NULL COMMENT '样本编码快照',
|
||||
`item_name` varchar(200) DEFAULT NULL COMMENT '检测项目名称快照',
|
||||
`operate_time` datetime NOT NULL COMMENT '业务操作时间',
|
||||
`operator_user_id` varchar(64) DEFAULT NULL COMMENT '操作人用户ID',
|
||||
`operator_user_name` varchar(64) DEFAULT NULL COMMENT '操作人姓名快照',
|
||||
`has_field_change` char(1) NOT NULL DEFAULT '0' COMMENT '1有字段变更 0仅保存无变更',
|
||||
`changes_json` mediumtext COMMENT '变更明细JSON:[{fieldKey,fieldLabel,oldValue,newValue}]',
|
||||
`tenant_no` varchar(64) NOT NULL DEFAULT 'zkxw' COMMENT '租户编号',
|
||||
`order_num` int(11) DEFAULT NULL COMMENT '排序号',
|
||||
`remark` varchar(512) DEFAULT NULL COMMENT '备注',
|
||||
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人id',
|
||||
`create_dept_id` varchar(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人id',
|
||||
`update_time` datetime NOT NULL COMMENT '更新时间',
|
||||
`del_flag` smallint(6) NOT NULL DEFAULT '0' COMMENT '删除标记',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_qc_result_chg_task` (`tenant_no`,`task_id`,`del_flag`,`operate_time`),
|
||||
KEY `idx_qc_result_chg_wo` (`tenant_no`,`work_order_id`,`del_flag`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='质检任务检测结果操作留痕';
|
||||
@@ -66,3 +66,38 @@ export function fetchCompleteTaskWithResult(
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type QcTaskResultChangeItem = {
|
||||
fieldKey: string
|
||||
fieldLabel: string
|
||||
oldValue: string
|
||||
newValue: string
|
||||
}
|
||||
|
||||
export type QcTaskResultChangeLog = {
|
||||
id: string
|
||||
taskId: string
|
||||
workOrderId?: string
|
||||
sampleCode?: string
|
||||
itemName?: string
|
||||
operateTime: string
|
||||
operatorUserId?: string
|
||||
operatorUserName?: string
|
||||
hasFieldChange: boolean
|
||||
changes: QcTaskResultChangeItem[]
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
export function fetchQcTaskResultChangeLogs(taskId: string) {
|
||||
return request.get<QcTaskResultChangeLog[]>({
|
||||
url: `/web/admin/qc-tasks/${taskId}/result-change-logs`
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchQcTaskResultChangeLogsBatch(taskIds: string[]) {
|
||||
const ids = taskIds.map((x) => (x || '').trim()).filter(Boolean)
|
||||
return request.get<QcTaskResultChangeLog[]>({
|
||||
url: `/web/admin/qc-tasks/result-change-logs`,
|
||||
params: { taskIds: ids.join(',') }
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/** 填写检测结果弹窗默认值(Issue #148):未落结论时默认已完成 + 通过 */
|
||||
|
||||
export type QcResultFillStatus = 'dzx' | 'jxz' | 'ywc'
|
||||
export type QcResultFillConclusion = '' | 'tg' | 'btg'
|
||||
|
||||
export function normalizeFillConclusion(raw?: string | null): QcResultFillConclusion {
|
||||
const c = (raw || '').trim()
|
||||
return c === 'tg' || c === 'btg' ? c : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开填写弹窗时的任务状态 / 结论默认。
|
||||
* - 已有结论或已是已完成:回显实际值
|
||||
* - 尚未落结论:默认 已完成 + 通过
|
||||
*/
|
||||
export function resolveQcResultFillDefaults(input: {
|
||||
taskStatus?: string | null
|
||||
conclusion?: string | null
|
||||
}): { saveStatus: QcResultFillStatus; conclusion: QcResultFillConclusion } {
|
||||
const status = (input.taskStatus || '').trim()
|
||||
const conclusion = normalizeFillConclusion(input.conclusion)
|
||||
if (conclusion || status === 'ywc') {
|
||||
const saveStatus: QcResultFillStatus =
|
||||
status === 'dzx' || status === 'jxz' || status === 'ywc' ? status : 'ywc'
|
||||
return {
|
||||
saveStatus: saveStatus === 'ywc' ? 'ywc' : saveStatus,
|
||||
conclusion: conclusion || (saveStatus === 'ywc' ? 'tg' : '')
|
||||
}
|
||||
}
|
||||
return { saveStatus: 'ywc', conclusion: 'tg' }
|
||||
}
|
||||
|
||||
/** 第三方弹窗仅展示待执行/已完成 */
|
||||
export function resolveThirdPartyFillDefaults(input: {
|
||||
taskStatus?: string | null
|
||||
conclusion?: string | null
|
||||
}): { saveStatus: 'dzx' | 'ywc'; conclusion: QcResultFillConclusion } {
|
||||
const resolved = resolveQcResultFillDefaults(input)
|
||||
return {
|
||||
saveStatus: resolved.saveStatus === 'ywc' ? 'ywc' : 'dzx',
|
||||
conclusion: resolved.conclusion
|
||||
}
|
||||
}
|
||||
@@ -141,9 +141,10 @@
|
||||
<span class="sample-card__seq">{{ sIdx + 1 }}</span>
|
||||
{{ sampleTypeName(row.sampleTypeId) }}
|
||||
</div>
|
||||
<el-tag :type="sampleStatusTagType(String(row.sampleStatus || ''))" size="small">
|
||||
{{ sampleStatusLabel(String(row.sampleStatus || '')) }}
|
||||
</el-tag>
|
||||
<SampleStatusTag
|
||||
:status="row.sampleStatus"
|
||||
:void-desc="row.voidDesc"
|
||||
/>
|
||||
</div>
|
||||
<div class="sample-card__body">
|
||||
<div class="sample-card__section">
|
||||
@@ -1254,6 +1255,7 @@
|
||||
import SampleQcInfoGroupedPanel from '@/components/business/sample-qc-info-grouped-panel/index.vue'
|
||||
import SampleReceptionDualReadonlyPanel from '@/components/business/sample-reception-dual-readonly-panel/index.vue'
|
||||
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/index.vue'
|
||||
import SampleStatusTag from '@/components/business/sample-status-tag/index.vue'
|
||||
import SampleProductionInfoCards from '@/components/business/sample-production-info-cards/index.vue'
|
||||
import SampleStorageReleaseInfo from '@/components/business/sample-storage-release-info/index.vue'
|
||||
import ProtocolHandlePanel from '@/components/business/protocol-handle-panel/index.vue'
|
||||
@@ -1284,8 +1286,6 @@
|
||||
payModeTagType,
|
||||
newbornSexLabel,
|
||||
deliveryModeLabel,
|
||||
sampleStatusLabel,
|
||||
sampleStatusTagType,
|
||||
transportTypeLabel,
|
||||
payStatusLabel,
|
||||
payStatusTagType
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
type QcTaskResultItem
|
||||
} from '@/api/qc-task-result'
|
||||
import { taskStatusLabel, taskStatusTagType } from '@/utils/qc-labels'
|
||||
import { resolveThirdPartyFillDefaults } from '@/utils/qc-result-fill-defaults'
|
||||
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
||||
import {
|
||||
pickSharedRemarkAndAttachments,
|
||||
@@ -233,16 +234,6 @@
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
/** 第三方弹窗仅展示待执行/已完成;其它状态按待执行回显 */
|
||||
function normalizeThirdPartySaveStatus(status?: string): 'dzx' | 'ywc' {
|
||||
return (status || '').trim() === 'ywc' ? 'ywc' : 'dzx'
|
||||
}
|
||||
|
||||
function normalizeConclusion(raw?: string): '' | 'tg' | 'btg' {
|
||||
const c = (raw || '').trim()
|
||||
return c === 'tg' || c === 'btg' ? c : ''
|
||||
}
|
||||
|
||||
function normalizeResultParams(items: QcTaskResultItem[]): QcTaskResultItem[] {
|
||||
return (items || []).map((p) => ({
|
||||
...p,
|
||||
@@ -319,13 +310,17 @@
|
||||
companyId: detail?.companyId ?? task.companyId,
|
||||
companyName: detail?.companyName ?? task.companyName
|
||||
}
|
||||
const fillDefaults = resolveThirdPartyFillDefaults({
|
||||
taskStatus: merged.taskStatus,
|
||||
conclusion: merged.conclusion
|
||||
})
|
||||
const item: ItemState = {
|
||||
taskId: task.id,
|
||||
itemName: merged.itemName || '—',
|
||||
companyName: thirdPartyCompanyDisplayName(merged),
|
||||
params: normalizeResultParams(results || []),
|
||||
saveStatus: normalizeThirdPartySaveStatus(merged.taskStatus),
|
||||
conclusion: normalizeConclusion(merged.conclusion)
|
||||
saveStatus: fillDefaults.saveStatus,
|
||||
conclusion: fillDefaults.conclusion
|
||||
}
|
||||
return { item, merged }
|
||||
})
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
<!-- 质检任务 · 检测结果修改记录 -->
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
:title="dialogTitle"
|
||||
width="560px"
|
||||
class="dialog-form-layout qc-task-result-change-log-dialog"
|
||||
align-center
|
||||
modal-class="protocol-dialog-mask"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<DialogFormBody :loading="loading">
|
||||
<el-empty
|
||||
v-if="!loading && !entries.length"
|
||||
description="暂无修改记录"
|
||||
:image-size="56"
|
||||
/>
|
||||
<div v-else class="qc-result-chg-tl">
|
||||
<div v-for="(entry, idx) in entries" :key="entry.id" class="qc-result-chg-tl__item">
|
||||
<div class="qc-result-chg-tl__rail">
|
||||
<span class="qc-result-chg-tl__dot" />
|
||||
<span v-if="idx < entries.length - 1" class="qc-result-chg-tl__line" />
|
||||
</div>
|
||||
<div class="qc-result-chg-tl__content">
|
||||
<div class="qc-result-chg-tl__meta">
|
||||
{{ entry.operateTime || '—' }} · {{ entry.operatorUserName || '—' }}
|
||||
<template v-if="showItemName && entry.itemName">
|
||||
· {{ entry.itemName }}
|
||||
</template>
|
||||
</div>
|
||||
<template v-if="entry.hasFieldChange && entry.changes?.length">
|
||||
<div
|
||||
v-for="(chg, cIdx) in entry.changes"
|
||||
:key="`${entry.id}-${cIdx}`"
|
||||
class="qc-result-chg-tl__line-text"
|
||||
>
|
||||
<template v-if="chg.oldValue">
|
||||
{{ chg.fieldLabel }}:{{ chg.oldValue || '—' }} → {{ chg.newValue || '—' }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ chg.fieldLabel }}:{{ chg.newValue || '—' }}
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="qc-result-chg-tl__line-text">保存操作(字段无变更)</div>
|
||||
<div v-if="!entry.hasFieldChange" class="qc-result-chg-tl__note">
|
||||
即使未改值,点击保存也会记一条操作留痕
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogFormBody>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="close">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
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'
|
||||
|
||||
defineOptions({ name: 'QcTaskResultChangeLogDialog' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
taskIds: string[]
|
||||
titleSuffix?: string
|
||||
}>(),
|
||||
{
|
||||
titleSuffix: ''
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
}>()
|
||||
|
||||
const loading = ref(false)
|
||||
const entries = ref<QcTaskResultChangeLog[]>([])
|
||||
let loadSeq = 0
|
||||
|
||||
const showItemName = computed(() => (props.taskIds || []).length > 1)
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
const suffix = (props.titleSuffix || '').trim()
|
||||
return suffix ? `修改记录 · ${suffix}` : '修改记录'
|
||||
})
|
||||
|
||||
function onVisibleChange(v: boolean) {
|
||||
emit('update:visible', v)
|
||||
}
|
||||
|
||||
function close() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
async function loadLogs() {
|
||||
const seq = ++loadSeq
|
||||
const ids = (props.taskIds || []).map((x) => (x || '').trim()).filter(Boolean)
|
||||
loading.value = true
|
||||
entries.value = []
|
||||
try {
|
||||
const list =
|
||||
ids.length > 1
|
||||
? await fetchQcTaskResultChangeLogsBatch(ids)
|
||||
: ids.length === 1
|
||||
? await fetchQcTaskResultChangeLogs(ids[0])
|
||||
: []
|
||||
if (seq !== loadSeq) return
|
||||
entries.value = list || []
|
||||
} catch {
|
||||
if (seq !== loadSeq) return
|
||||
entries.value = []
|
||||
ElMessage.error('加载修改记录失败')
|
||||
} finally {
|
||||
if (seq === loadSeq) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, (props.taskIds || []).join(',')] as const,
|
||||
([vis]) => {
|
||||
if (vis) void loadLogs()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.qc-result-chg-tl {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 4px 0 8px;
|
||||
}
|
||||
|
||||
.qc-result-chg-tl__item {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.qc-result-chg-tl__rail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.qc-result-chg-tl__dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-top: 4px;
|
||||
border-radius: 50%;
|
||||
background: var(--mint-primary, #10b981);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.qc-result-chg-tl__line {
|
||||
width: 2px;
|
||||
flex: 1;
|
||||
min-height: 36px;
|
||||
margin-top: 4px;
|
||||
background: var(--mint-primary-bg, #ecfdf5);
|
||||
}
|
||||
|
||||
.qc-result-chg-tl__content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding-bottom: 14px;
|
||||
}
|
||||
|
||||
.qc-result-chg-tl__meta {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--mint-primary-dark, #059669);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.qc-result-chg-tl__line-text {
|
||||
font-size: 13px;
|
||||
color: var(--mint-text, #1e293b);
|
||||
margin: 2px 0;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.qc-result-chg-tl__note {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #334155);
|
||||
}
|
||||
</style>
|
||||
@@ -33,6 +33,16 @@
|
||||
@click="openAllThirdResult(item)"
|
||||
@dblclick="openAllThirdResult(item)"
|
||||
>
|
||||
<el-button
|
||||
class="qc-task-card__history-icon"
|
||||
link
|
||||
type="primary"
|
||||
title="修改记录"
|
||||
aria-label="修改记录"
|
||||
@click.stop="openChangeLogForTasks(item.tasks, ALL_THIRD_PARTY_CARD_TITLE)"
|
||||
>
|
||||
<el-icon><Clock /></el-icon>
|
||||
</el-button>
|
||||
<div class="qc-task-card__line qc-task-card__line--top">
|
||||
<span class="qc-task-card__name">{{ ALL_THIRD_PARTY_CARD_TITLE }}</span>
|
||||
<div class="qc-task-card__sub">
|
||||
@@ -77,6 +87,16 @@
|
||||
class="qc-task-card qc-task-card--compact"
|
||||
@dblclick="handleView(item.task)"
|
||||
>
|
||||
<el-button
|
||||
class="qc-task-card__history-icon"
|
||||
link
|
||||
type="primary"
|
||||
title="修改记录"
|
||||
aria-label="修改记录"
|
||||
@click.stop="openChangeLogForTask(item.task)"
|
||||
>
|
||||
<el-icon><Clock /></el-icon>
|
||||
</el-button>
|
||||
<div class="qc-task-card__line qc-task-card__line--top">
|
||||
<span class="qc-task-card__name">{{ item.task.itemName || '—' }}</span>
|
||||
<div class="qc-task-card__tags">
|
||||
@@ -414,6 +434,12 @@
|
||||
@saved="handleTaskMutationSuccess"
|
||||
/>
|
||||
|
||||
<QcTaskResultChangeLogDialog
|
||||
v-model:visible="changeLogVisible"
|
||||
:task-ids="changeLogTaskIds"
|
||||
:title-suffix="changeLogTitleSuffix"
|
||||
/>
|
||||
|
||||
<SystemViewDialog
|
||||
v-model:visible="viewVisible"
|
||||
title="任务详情"
|
||||
@@ -575,7 +601,8 @@
|
||||
EditPen,
|
||||
Plus,
|
||||
More,
|
||||
Delete
|
||||
Delete,
|
||||
Clock
|
||||
} from '@element-plus/icons-vue'
|
||||
import ProtocolFinanceConfirmFields from '@/components/business/protocol-finance-confirm-fields/index.vue'
|
||||
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
||||
@@ -612,6 +639,7 @@
|
||||
import { fetchItemUnitList } from '@/api/admin'
|
||||
import { SHOW_QC_TASK_MATERIAL_USAGE } from '@/utils/qc-material-ui'
|
||||
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
||||
import { resolveQcResultFillDefaults } from '@/utils/qc-result-fill-defaults'
|
||||
import {
|
||||
taskTypeLabel,
|
||||
taskTypeTagType,
|
||||
@@ -656,6 +684,7 @@
|
||||
type QcTaskListDisplayItem
|
||||
} from '@/utils/qc-company-task-group'
|
||||
import QcCompanyTaskResultDialog from './QcCompanyTaskResultDialog.vue'
|
||||
import QcTaskResultChangeLogDialog from './QcTaskResultChangeLogDialog.vue'
|
||||
|
||||
/** 根据来源类型返回协议状态标签 */
|
||||
function protocolStatusLabelBySource(status: string, source: string, voidType?: string): string {
|
||||
@@ -739,6 +768,25 @@
|
||||
const companyDialogReadonly = ref(false)
|
||||
const companyDialogTasks = ref<QcTask[]>([])
|
||||
const companyDialogName = ref(ALL_THIRD_PARTY_CARD_TITLE)
|
||||
const changeLogVisible = ref(false)
|
||||
const changeLogTaskIds = ref<string[]>([])
|
||||
const changeLogTitleSuffix = ref('')
|
||||
|
||||
function openChangeLogForTask(task: QcTask) {
|
||||
const id = (task.id || '').trim()
|
||||
if (!id) return
|
||||
changeLogTaskIds.value = [id]
|
||||
changeLogTitleSuffix.value = task.itemName || task.taskNo || ''
|
||||
changeLogVisible.value = true
|
||||
}
|
||||
|
||||
function openChangeLogForTasks(tasks: QcTask[], title: string) {
|
||||
const ids = tasks.map((t) => (t.id || '').trim()).filter(Boolean)
|
||||
if (!ids.length) return
|
||||
changeLogTaskIds.value = ids
|
||||
changeLogTitleSuffix.value = title || ''
|
||||
changeLogVisible.value = true
|
||||
}
|
||||
|
||||
function openAllThirdResult(item: QcTaskListAllThirdItem, forceReadonly?: boolean) {
|
||||
let tasks = item.tasks
|
||||
@@ -864,11 +912,6 @@
|
||||
|
||||
const resultDialogWidth = computed(() => (resultTaskType.value === 'sysz' ? '1200px' : '960px'))
|
||||
|
||||
function normalizeResultSaveStatus(status?: string): 'dzx' | 'jxz' | 'ywc' {
|
||||
if (status === 'dzx' || status === 'jxz' || status === 'ywc') return status
|
||||
return 'jxz'
|
||||
}
|
||||
|
||||
function canFillResult(row: QcTask) {
|
||||
if (row.taskType === 'sysz') {
|
||||
return row.taskStatus === 'jxz' || row.taskStatus === 'ywc'
|
||||
@@ -1391,12 +1434,16 @@
|
||||
}
|
||||
return
|
||||
}
|
||||
const initialDefaults = resolveQcResultFillDefaults({
|
||||
taskStatus: row.taskStatus,
|
||||
conclusion: row.conclusion
|
||||
})
|
||||
resultTaskStatus.value = row.taskStatus
|
||||
resultSaveStatus.value = normalizeResultSaveStatus(row.taskStatus)
|
||||
resultSaveStatus.value = initialDefaults.saveStatus
|
||||
resultTaskId.value = row.id
|
||||
resultTaskType.value = row.taskType
|
||||
resultRemark.value = row.remark || ''
|
||||
resultConclusion.value = ''
|
||||
resultConclusion.value = initialDefaults.conclusion
|
||||
resultAttachments.value = apiFilesToFinanceItems(row.attachmentFiles)
|
||||
materialUsages.value = []
|
||||
requisitionOptions.value = []
|
||||
@@ -1404,10 +1451,13 @@
|
||||
try {
|
||||
const detail = await fetchQcTaskDetail(row.id)
|
||||
resultTaskStatus.value = detail.taskStatus || row.taskStatus
|
||||
resultSaveStatus.value = normalizeResultSaveStatus(detail.taskStatus || row.taskStatus)
|
||||
const fillDefaults = resolveQcResultFillDefaults({
|
||||
taskStatus: detail.taskStatus || row.taskStatus,
|
||||
conclusion: detail.conclusion ?? row.conclusion
|
||||
})
|
||||
resultSaveStatus.value = fillDefaults.saveStatus
|
||||
resultRemark.value = detail.remark || row.remark || ''
|
||||
const c = (detail.conclusion || '').trim()
|
||||
resultConclusion.value = c === 'tg' || c === 'btg' ? c : ''
|
||||
resultConclusion.value = fillDefaults.conclusion
|
||||
resultAttachments.value = apiFilesToFinanceItems(detail.attachmentFiles)
|
||||
const results = await fetchQcTaskResults(row.id)
|
||||
resultParams.value = normalizeResultParams(results || [])
|
||||
@@ -1675,6 +1725,7 @@
|
||||
}
|
||||
|
||||
.qc-task-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
@@ -1702,7 +1753,7 @@
|
||||
width: 100%;
|
||||
max-width: 220px;
|
||||
gap: 4px;
|
||||
padding: 6px 8px;
|
||||
padding: 6px 28px 6px 8px;
|
||||
}
|
||||
|
||||
&--company {
|
||||
@@ -1717,6 +1768,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
.qc-task-card__history-icon {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
z-index: 1;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
color: var(--mint-primary-dark, #059669);
|
||||
|
||||
:deep(.el-icon) {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: var(--mint-primary, #10b981);
|
||||
}
|
||||
}
|
||||
|
||||
.qc-task-card__sub {
|
||||
width: 100%;
|
||||
font-size: 11px;
|
||||
|
||||
Reference in new issue
Block a user