Compare commits
29
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e85645a649 | ||
|
|
5ec997228d | ||
|
|
fb4bceb6b0 | ||
|
|
cc17ac2425 | ||
|
|
70ebd4eff7 | ||
|
|
4d4856d4c2 | ||
|
|
fb67f3dbd7 | ||
|
|
38bad4232a | ||
|
|
e396b1a6eb | ||
|
|
7640052c96 | ||
|
|
99583b38ce | ||
|
|
9b6228860f | ||
|
|
8d7b2ada59 | ||
|
|
332711ad36 | ||
|
|
03acf5115a | ||
|
|
12cf373a49 | ||
|
|
0434999603 | ||
|
|
f40d33b07a | ||
|
|
e5f84b4693 | ||
|
|
71424ff576 | ||
|
|
fbe62c7a9b | ||
|
|
034a4da1ad | ||
|
|
dbc4a24543 | ||
|
|
b59c921b50 | ||
|
|
b57898fabb | ||
|
|
9fd1cc4370 | ||
|
|
af02e2cdd2 | ||
|
|
6ddd07dbb5 | ||
|
|
f9aa16ef31 |
No files matched your search
@@ -86,7 +86,7 @@ SECRET_KEY=
|
|||||||
# WX_MP_TPL_PROGRESS_FIELD_APPROVER=thing6
|
# WX_MP_TPL_PROGRESS_FIELD_APPROVER=thing6
|
||||||
# WX_MP_TPL_PROGRESS_FIELD_RESULT=const4
|
# WX_MP_TPL_PROGRESS_FIELD_RESULT=const4
|
||||||
# WX_MP_TPL_PROGRESS_FIELD_TIME=time11
|
# WX_MP_TPL_PROGRESS_FIELD_TIME=time11
|
||||||
# 基础实验交付日前一天提醒(出库提醒模板)
|
# 临床科研交付日前一天提醒(出库提醒模板)
|
||||||
# WX_MP_TEMPLATE_BASIC_EXPERIMENT_DELIVERY=oQNU3t0Q5kwc4KPJ8Z6yPA-k6qlsH9pikSCIb4eAwgM
|
# WX_MP_TEMPLATE_BASIC_EXPERIMENT_DELIVERY=oQNU3t0Q5kwc4KPJ8Z6yPA-k6qlsH9pikSCIb4eAwgM
|
||||||
# WX_MP_TPL_BE_DELIVERY_FIELD_CUSTOMER=thing6
|
# WX_MP_TPL_BE_DELIVERY_FIELD_CUSTOMER=thing6
|
||||||
# WX_MP_TPL_BE_DELIVERY_FIELD_PRODUCT=thing10
|
# WX_MP_TPL_BE_DELIVERY_FIELD_PRODUCT=thing10
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ from app.crud import user as user_svc
|
|||||||
from app.crud.collection_protocol import _lookup_attachment_by_url
|
from app.crud.collection_protocol import _lookup_attachment_by_url
|
||||||
from app.models.models import BizAttachment, SysDept, SysRole, SysUser, SysMenu, SysPost
|
from app.models.models import BizAttachment, SysDept, SysRole, SysUser, SysMenu, SysPost
|
||||||
from app.services.permission_administration import validate_tenant_references
|
from app.services.permission_administration import validate_tenant_references
|
||||||
|
from app.services.user_select_options import prioritize_caller_dept_options
|
||||||
from app.services.web_auth_roles import (
|
from app.services.web_auth_roles import (
|
||||||
_map_role_name_to_web,
|
_map_role_name_to_web,
|
||||||
list_user_ids_with_effective_role_name,
|
list_user_ids_with_effective_role_name,
|
||||||
@@ -77,12 +78,15 @@ async def list_roles_for_select(
|
|||||||
@router.get("/users/options")
|
@router.get("/users/options")
|
||||||
async def list_users_for_select(
|
async def list_users_for_select(
|
||||||
roleName: Optional[str] = Query(None, alias="roleName"),
|
roleName: Optional[str] = Query(None, alias="roleName"),
|
||||||
|
prioritizeCallerDept: bool = Query(False, alias="prioritizeCallerDept"),
|
||||||
_user: dict = Depends(require_admin_or_super_admin),
|
_user: dict = Depends(require_admin_or_super_admin),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
):
|
):
|
||||||
"""返回用户下拉选项(label=昵称,value=用户ID),供流程设计器审批人选择使用。
|
"""返回用户下拉选项(label=昵称,value=用户ID,deptId=部门ID)。
|
||||||
|
|
||||||
|
供流程设计器审批人选择、OA 评论 @ 人员等使用。
|
||||||
可选 roleName:按有效角色(直接绑定 ∪ 职位继承)精确过滤。
|
可选 roleName:按有效角色(直接绑定 ∪ 职位继承)精确过滤。
|
||||||
|
可选 prioritizeCallerDept:当前登录用户同部门人员排在前面(组内仍按创建时间倒序)。
|
||||||
"""
|
"""
|
||||||
tenant_no = _user.get("tenant_no", "")
|
tenant_no = _user.get("tenant_no", "")
|
||||||
q = db.query(SysUser).filter(SysUser.del_flag == 0, SysUser.status == "1")
|
q = db.query(SysUser).filter(SysUser.del_flag == 0, SysUser.status == "1")
|
||||||
@@ -97,7 +101,16 @@ async def list_users_for_select(
|
|||||||
return success_response([])
|
return success_response([])
|
||||||
q = q.filter(SysUser.id.in_(matched_ids))
|
q = q.filter(SysUser.id.in_(matched_ids))
|
||||||
rows = q.order_by(SysUser.create_time.desc()).distinct().all()
|
rows = q.order_by(SysUser.create_time.desc()).distinct().all()
|
||||||
out = [{"label": (r.nick_name or r.user_no or ""), "value": r.id} for r in rows]
|
out = [
|
||||||
|
{
|
||||||
|
"label": (r.nick_name or r.user_no or ""),
|
||||||
|
"value": r.id,
|
||||||
|
"deptId": (r.dept_id or ""),
|
||||||
|
}
|
||||||
|
for r in rows
|
||||||
|
]
|
||||||
|
if prioritizeCallerDept:
|
||||||
|
out = prioritize_caller_dept_options(out, _user.get("region_id") or "")
|
||||||
return success_response(out)
|
return success_response(out)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+54
-6
@@ -7,7 +7,7 @@ from app.core.response import success_response
|
|||||||
router = APIRouter(prefix="/web/menu", tags=["菜单管理"])
|
router = APIRouter(prefix="/web/menu", tags=["菜单管理"])
|
||||||
|
|
||||||
# 与 web-admin/src/router/modules/sqxp.ts 一致:6 个一级菜单分组
|
# 与 web-admin/src/router/modules/sqxp.ts 一致:6 个一级菜单分组
|
||||||
# 市场二级顺序:存储服务、科研捐赠、市场基础信息、中试服务、基础实验
|
# 市场二级顺序:存储服务、科研捐赠、市场基础信息、中试服务、临床科研、器械销售
|
||||||
STATIC_MENU_TREE = [
|
STATIC_MENU_TREE = [
|
||||||
{
|
{
|
||||||
"id": "TOP00000000000000000000000000006",
|
"id": "TOP00000000000000000000000000006",
|
||||||
@@ -199,7 +199,7 @@ STATIC_MENU_TREE = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
# 市场基础信息(前段:存储/捐赠相关;后段:中试/基础实验相关)
|
# 市场基础信息(前段:存储/捐赠相关;后段:中试/临床科研相关)
|
||||||
{
|
{
|
||||||
"id": "MKT00000000000000000000000000001",
|
"id": "MKT00000000000000000000000000001",
|
||||||
"name": "MarketInfo",
|
"name": "MarketInfo",
|
||||||
@@ -328,14 +328,14 @@ STATIC_MENU_TREE = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
# 基础实验
|
# 临床科研
|
||||||
{
|
{
|
||||||
"id": "BEX00000000000000000000000000001",
|
"id": "BEX00000000000000000000000000001",
|
||||||
"name": "BasicExperiment",
|
"name": "BasicExperiment",
|
||||||
"path": "basic-experiment",
|
"path": "basic-experiment",
|
||||||
"component": "",
|
"component": "",
|
||||||
"meta": {
|
"meta": {
|
||||||
"title": "基础实验",
|
"title": "临床科研",
|
||||||
"icon": "ri:flask-line",
|
"icon": "ri:flask-line",
|
||||||
"keepAlive": False,
|
"keepAlive": False,
|
||||||
"roles": ["admin"],
|
"roles": ["admin"],
|
||||||
@@ -347,7 +347,7 @@ STATIC_MENU_TREE = [
|
|||||||
"path": "application",
|
"path": "application",
|
||||||
"component": "/pilot-service/pilot-application/index",
|
"component": "/pilot-service/pilot-application/index",
|
||||||
"meta": {
|
"meta": {
|
||||||
"title": "基础实验申请单",
|
"title": "临床科研申请单",
|
||||||
"keepAlive": True,
|
"keepAlive": True,
|
||||||
"menuCode": "basic-experiment:application:list",
|
"menuCode": "basic-experiment:application:list",
|
||||||
},
|
},
|
||||||
@@ -375,7 +375,55 @@ STATIC_MENU_TREE = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
},
|
||||||
|
# 器械销售(市场侧栏末位)
|
||||||
|
{
|
||||||
|
"id": "DEV00000000000000000000000000001",
|
||||||
|
"name": "DeviceSales",
|
||||||
|
"path": "device-sales",
|
||||||
|
"component": "",
|
||||||
|
"meta": {
|
||||||
|
"title": "器械销售",
|
||||||
|
"icon": "ri:shopping-bag-3-line",
|
||||||
|
"keepAlive": False,
|
||||||
|
"roles": ["admin"],
|
||||||
|
},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "DEV00000000000000000000000000002",
|
||||||
|
"name": "DeviceSalesClassIii",
|
||||||
|
"path": "class-iii",
|
||||||
|
"component": "/device-sales/under-construction/index",
|
||||||
|
"meta": {
|
||||||
|
"title": "三类医疗器械",
|
||||||
|
"keepAlive": False,
|
||||||
|
"menuCode": "device-sales:class-iii:list",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "DEV00000000000000000000000000003",
|
||||||
|
"name": "DeviceSalesClassIi",
|
||||||
|
"path": "class-ii",
|
||||||
|
"component": "/device-sales/under-construction/index",
|
||||||
|
"meta": {
|
||||||
|
"title": "二类医疗器械",
|
||||||
|
"keepAlive": False,
|
||||||
|
"menuCode": "device-sales:class-ii:list",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "DEV00000000000000000000000000004",
|
||||||
|
"name": "DeviceSalesCosmetics",
|
||||||
|
"path": "cosmetics",
|
||||||
|
"component": "/device-sales/under-construction/index",
|
||||||
|
"meta": {
|
||||||
|
"title": "化妆品产品",
|
||||||
|
"keepAlive": False,
|
||||||
|
"menuCode": "device-sales:cosmetics:list",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -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_inspection_item_template as iit_svc
|
||||||
from app.crud import qc_item_param as param_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 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_task as task_svc
|
||||||
from app.crud import qc_third_party_company as tpc_svc
|
from app.crud import qc_third_party_company as tpc_svc
|
||||||
from app.crud import qc_third_party_item as tpi_svc
|
from app.crud import qc_third_party_item as tpi_svc
|
||||||
@@ -448,6 +449,7 @@ class TaskCompleteWithResultBody(BaseModel):
|
|||||||
third_party_attachments: Optional[str] = Field(None, alias="thirdPartyAttachments")
|
third_party_attachments: Optional[str] = Field(None, alias="thirdPartyAttachments")
|
||||||
material_usages: Optional[List[Dict[str, Any]]] = Field(None, alias="materialUsages")
|
material_usages: Optional[List[Dict[str, Any]]] = Field(None, alias="materialUsages")
|
||||||
task_status: Optional[str] = Field(None, alias="taskStatus")
|
task_status: Optional[str] = Field(None, alias="taskStatus")
|
||||||
|
operate_batch_id: Optional[str] = Field(None, alias="operateBatchId")
|
||||||
|
|
||||||
|
|
||||||
@router.get("/qc-lab-test-items")
|
@router.get("/qc-lab-test-items")
|
||||||
@@ -1234,6 +1236,29 @@ async def list_qc_tasks(
|
|||||||
return error_response(400, str(e))
|
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}")
|
@router.get("/qc-tasks/{task_id}")
|
||||||
async def get_qc_task_detail(
|
async def get_qc_task_detail(
|
||||||
task_id: str,
|
task_id: str,
|
||||||
@@ -1349,6 +1374,26 @@ async def get_task_material_usages(
|
|||||||
return error_response(400, str(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)
|
||||||
|
# 无任务或无留痕均返回空列表,避免前端把“暂无记录”当成错误
|
||||||
|
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")
|
@router.post("/qc-tasks/{task_id}/complete-with-result")
|
||||||
async def complete_task_with_result(
|
async def complete_task_with_result(
|
||||||
task_id: str,
|
task_id: str,
|
||||||
@@ -1364,6 +1409,7 @@ async def complete_task_with_result(
|
|||||||
if not t:
|
if not t:
|
||||||
return error_response(404, "任务不存在")
|
return error_response(404, "任务不存在")
|
||||||
was_done = (t.task_status or "").strip() == "ywc"
|
was_done = (t.task_status or "").strip() == "ywc"
|
||||||
|
before = result_change_log_svc.snapshot_task_result_state(db, t, tenant_no)
|
||||||
if body.results:
|
if body.results:
|
||||||
result_svc.save_results_for_task(
|
result_svc.save_results_for_task(
|
||||||
db, task_id, body.results, tenant_no, user_id, commit=False,
|
db, task_id, body.results, tenant_no, user_id, commit=False,
|
||||||
@@ -1384,6 +1430,17 @@ async def complete_task_with_result(
|
|||||||
task_status=body.task_status,
|
task_status=body.task_status,
|
||||||
commit=False,
|
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,
|
||||||
|
operate_batch_id=body.operate_batch_id,
|
||||||
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(obj)
|
db.refresh(obj)
|
||||||
if (obj.task_status or "").strip() == "ywc":
|
if (obj.task_status or "").strip() == "ywc":
|
||||||
|
|||||||
@@ -136,14 +136,14 @@ class Settings(BaseSettings):
|
|||||||
WX_TEMPLATE_DELIVERY_WARNING: str = "" # 配送时效预警模板ID
|
WX_TEMPLATE_DELIVERY_WARNING: str = "" # 配送时效预警模板ID
|
||||||
|
|
||||||
# 微信服务号(OA 审批/抄送通知)
|
# 微信服务号(OA 审批/抄送通知)
|
||||||
# 总开关:false 时不发送审批/抄送/申请人进度/评论@提到/基础实验交付提醒/样本采集通知模板消息
|
# 总开关:false 时不发送审批/抄送/申请人进度/评论@提到/临床科研交付提醒/样本采集通知模板消息
|
||||||
WX_MP_NOTIFY_ENABLED: bool = False
|
WX_MP_NOTIFY_ENABLED: bool = False
|
||||||
WX_MP_APPID: str = ""
|
WX_MP_APPID: str = ""
|
||||||
WX_MP_SECRET: str = ""
|
WX_MP_SECRET: str = ""
|
||||||
WX_MP_TEMPLATE_APPROVAL: str = ""
|
WX_MP_TEMPLATE_APPROVAL: str = ""
|
||||||
WX_MP_TEMPLATE_CC: str = ""
|
WX_MP_TEMPLATE_CC: str = ""
|
||||||
WX_MP_TEMPLATE_APPLICANT_PROGRESS: str = ""
|
WX_MP_TEMPLATE_APPLICANT_PROGRESS: str = ""
|
||||||
# 基础实验交付日前一天提醒(出库提醒模板)
|
# 临床科研交付日前一天提醒(出库提醒模板)
|
||||||
WX_MP_TEMPLATE_BASIC_EXPERIMENT_DELIVERY: str = (
|
WX_MP_TEMPLATE_BASIC_EXPERIMENT_DELIVERY: str = (
|
||||||
"oQNU3t0Q5kwc4KPJ8Z6yPA-k6qlsH9pikSCIb4eAwgM"
|
"oQNU3t0Q5kwc4KPJ8Z6yPA-k6qlsH9pikSCIb4eAwgM"
|
||||||
)
|
)
|
||||||
@@ -171,7 +171,7 @@ class Settings(BaseSettings):
|
|||||||
WX_MP_TPL_PROGRESS_FIELD_APPROVER: str = "thing6"
|
WX_MP_TPL_PROGRESS_FIELD_APPROVER: str = "thing6"
|
||||||
WX_MP_TPL_PROGRESS_FIELD_RESULT: str = "const4"
|
WX_MP_TPL_PROGRESS_FIELD_RESULT: str = "const4"
|
||||||
WX_MP_TPL_PROGRESS_FIELD_TIME: str = "time11"
|
WX_MP_TPL_PROGRESS_FIELD_TIME: str = "time11"
|
||||||
# 基础实验交付提醒:客户名称/产品名称/件数/收货联系人/出库时间
|
# 临床科研交付提醒:客户名称/产品名称/件数/收货联系人/出库时间
|
||||||
WX_MP_TPL_BE_DELIVERY_FIELD_CUSTOMER: str = "thing6"
|
WX_MP_TPL_BE_DELIVERY_FIELD_CUSTOMER: str = "thing6"
|
||||||
WX_MP_TPL_BE_DELIVERY_FIELD_PRODUCT: str = "thing10"
|
WX_MP_TPL_BE_DELIVERY_FIELD_PRODUCT: str = "thing10"
|
||||||
WX_MP_TPL_BE_DELIVERY_FIELD_QTY: str = "character_string8"
|
WX_MP_TPL_BE_DELIVERY_FIELD_QTY: str = "character_string8"
|
||||||
|
|||||||
@@ -1394,6 +1394,7 @@ def list_collection_protocols(
|
|||||||
"sampleTypeName": type_name,
|
"sampleTypeName": type_name,
|
||||||
"sampleCode": code,
|
"sampleCode": code,
|
||||||
"sampleStatus": (s.sample_status or "").strip(),
|
"sampleStatus": (s.sample_status or "").strip(),
|
||||||
|
"voidDesc": (getattr(s, "void_desc", None) or "").strip(),
|
||||||
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
||||||
"transport": transport_dict,
|
"transport": transport_dict,
|
||||||
"freight": freight_by_sample.get(s.id),
|
"freight": freight_by_sample.get(s.id),
|
||||||
|
|||||||
@@ -269,10 +269,13 @@ def _build_cell_system(
|
|||||||
clear_flag = checked
|
clear_flag = checked
|
||||||
break
|
break
|
||||||
|
|
||||||
|
sample_status = str(getattr(sample, "sample_status", None) or "").strip()
|
||||||
base: Dict[str, Any] = {
|
base: Dict[str, Any] = {
|
||||||
"receptionId": rec.id,
|
"receptionId": rec.id,
|
||||||
"sampleCode": (rec.sample_code or sample.sample_code or "").strip(),
|
"sampleCode": (rec.sample_code or sample.sample_code or "").strip(),
|
||||||
"labStorageCode": (rec.lab_storage_code or "").strip(),
|
"labStorageCode": (rec.lab_storage_code or "").strip(),
|
||||||
|
"sampleStatus": sample_status,
|
||||||
|
"voidDesc": str(getattr(sample, "void_desc", None) or "").strip(),
|
||||||
"motherName": (party.mother_name if party else "") or "",
|
"motherName": (party.mother_name if party else "") or "",
|
||||||
"collectionTime": ledger.format_cn_datetime(coll.sample_collect_time if coll else None),
|
"collectionTime": ledger.format_cn_datetime(coll.sample_collect_time if coll else None),
|
||||||
"collectionTimeRaw": _fmt_raw(coll.sample_collect_time if coll else None),
|
"collectionTimeRaw": _fmt_raw(coll.sample_collect_time if coll else None),
|
||||||
@@ -353,10 +356,13 @@ def _build_donation_system(
|
|||||||
qc_process: Dict[str, str],
|
qc_process: Dict[str, str],
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
prod = prod or {}
|
prod = prod or {}
|
||||||
|
sample_status = str(getattr(sample, "sample_status", None) or "").strip()
|
||||||
base: Dict[str, Any] = {
|
base: Dict[str, Any] = {
|
||||||
"receptionId": rec.id,
|
"receptionId": rec.id,
|
||||||
"sampleCode": (rec.sample_code or sample.sample_code or "").strip(),
|
"sampleCode": (rec.sample_code or sample.sample_code or "").strip(),
|
||||||
"labStorageCode": (rec.lab_storage_code or "").strip(),
|
"labStorageCode": (rec.lab_storage_code or "").strip(),
|
||||||
|
"sampleStatus": sample_status,
|
||||||
|
"voidDesc": str(getattr(sample, "void_desc", None) or "").strip(),
|
||||||
"motherName": (party.mother_name if party else "") or "",
|
"motherName": (party.mother_name if party else "") or "",
|
||||||
"receptionTime": ledger.format_cn_datetime(rec.reception_time),
|
"receptionTime": ledger.format_cn_datetime(rec.reception_time),
|
||||||
"receptionTimeRaw": _fmt_raw(rec.reception_time),
|
"receptionTimeRaw": _fmt_raw(rec.reception_time),
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ _QC_STATUS_LABELS = {
|
|||||||
_BIZ_TYPE_LABELS = {
|
_BIZ_TYPE_LABELS = {
|
||||||
"pilot_service": "中试服务",
|
"pilot_service": "中试服务",
|
||||||
"clinical_application": "临床应用",
|
"clinical_application": "临床应用",
|
||||||
"basic_experiment": "基础实验",
|
"basic_experiment": "临床科研",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1601,7 +1601,7 @@ def _get_or_create_infusion_plan(
|
|||||||
user_id: str,
|
user_id: str,
|
||||||
dept_id: str,
|
dept_id: str,
|
||||||
) -> BizPilotInfusionPlan:
|
) -> BizPilotInfusionPlan:
|
||||||
"""获取或创建申请单下的输注/售卖方案(基础实验批量创建售卖计划用)。"""
|
"""获取或创建申请单下的输注/售卖方案(临床科研批量创建售卖计划用)。"""
|
||||||
plans = list_infusion_plans(db, application_id, tenant_no)
|
plans = list_infusion_plans(db, application_id, tenant_no)
|
||||||
if plans:
|
if plans:
|
||||||
plan_row = (
|
plan_row = (
|
||||||
@@ -1647,7 +1647,7 @@ def create_basic_experiment_sale_schedules(
|
|||||||
user_id: str,
|
user_id: str,
|
||||||
dept_id: str,
|
dept_id: str,
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""基础实验:每个产品行创建一条售卖计划(一产品一计划)。"""
|
"""临床科研:每个产品行创建一条售卖计划(一产品一计划)。"""
|
||||||
app = (
|
app = (
|
||||||
db.query(BizPilotApplication)
|
db.query(BizPilotApplication)
|
||||||
.filter(
|
.filter(
|
||||||
@@ -1660,7 +1660,7 @@ def create_basic_experiment_sale_schedules(
|
|||||||
if not app:
|
if not app:
|
||||||
raise ValueError("申请单不存在")
|
raise ValueError("申请单不存在")
|
||||||
if (app.biz_type or "") != "basic_experiment":
|
if (app.biz_type or "") != "basic_experiment":
|
||||||
raise ValueError("仅基础实验申请单可批量创建售卖计划")
|
raise ValueError("仅临床科研申请单可批量创建售卖计划")
|
||||||
if not product_lines:
|
if not product_lines:
|
||||||
raise ValueError("请至少添加一行售卖产品")
|
raise ValueError("请至少添加一行售卖产品")
|
||||||
|
|
||||||
|
|||||||
@@ -918,7 +918,7 @@ def _deduct_fee_on_complete(db: Session, schedule_id: str, tenant_no: str, user_
|
|||||||
if not application:
|
if not application:
|
||||||
raise ValueError("中试申请单不存在")
|
raise ValueError("中试申请单不存在")
|
||||||
|
|
||||||
# 临床应用/基础实验走缴费模块,不走服务订单扣费
|
# 临床应用/临床科研走缴费模块,不走服务订单扣费
|
||||||
if (application.biz_type or "") in ("clinical_application", "basic_experiment"):
|
if (application.biz_type or "") in ("clinical_application", "basic_experiment"):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ def _wo_to_dict(wo: BizProductionWorkOrder) -> Dict[str, Any]:
|
|||||||
"bizTypeLabel": {
|
"bizTypeLabel": {
|
||||||
"pilot_service": "中试服务",
|
"pilot_service": "中试服务",
|
||||||
"clinical_application": "临床应用",
|
"clinical_application": "临床应用",
|
||||||
"basic_experiment": "基础实验",
|
"basic_experiment": "临床科研",
|
||||||
}.get(getattr(wo, "biz_type", None) or "", ""),
|
}.get(getattr(wo, "biz_type", None) or "", ""),
|
||||||
"workOrderStatus": wo.work_order_status,
|
"workOrderStatus": wo.work_order_status,
|
||||||
"workOrderStatusLabel": _WORK_ORDER_STATUS_LABELS.get(wo.work_order_status, wo.work_order_status),
|
"workOrderStatusLabel": _WORK_ORDER_STATUS_LABELS.get(wo.work_order_status, wo.work_order_status),
|
||||||
@@ -288,7 +288,7 @@ def _enrich_inbound_qc_conclusions(
|
|||||||
_BIZ_TYPE_LABELS = {
|
_BIZ_TYPE_LABELS = {
|
||||||
"pilot_service": "中试服务",
|
"pilot_service": "中试服务",
|
||||||
"clinical_application": "临床应用",
|
"clinical_application": "临床应用",
|
||||||
"basic_experiment": "基础实验",
|
"basic_experiment": "临床科研",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -410,7 +410,8 @@ def list_protocol_sample_collections(
|
|||||||
item["newbornDeliveryTime"] = _fmt_dt(party.newborn_delivery_time) if party else ""
|
item["newbornDeliveryTime"] = _fmt_dt(party.newborn_delivery_time) if party else ""
|
||||||
item["protocolRemark"] = (proto.remark or "") if proto else ""
|
item["protocolRemark"] = (proto.remark or "") if proto else ""
|
||||||
item["voidType"] = (proto.void_type 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["protocolAttachments"] = (proto.protocol_attachments or "") if proto else ""
|
||||||
item["consentFormUrls"] = (proto.consent_form_urls 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 ""
|
item["healthSurveyFormUrls"] = (proto.health_survey_form_urls or "") if proto else ""
|
||||||
|
|||||||
@@ -45,6 +45,14 @@ from app.services.sample_payment_progress import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_SAMPLE_STATUS_LABELS = {
|
||||||
|
"ycj": "已采集",
|
||||||
|
"jcz": "检测中",
|
||||||
|
"yrk": "已入库",
|
||||||
|
"yzf": "已作废",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _fmt_ymd8(v: Any) -> str:
|
def _fmt_ymd8(v: Any) -> str:
|
||||||
s = str(v or "").strip()
|
s = str(v or "").strip()
|
||||||
if len(s) == 8 and s.isdigit():
|
if len(s) == 8 and s.isdigit():
|
||||||
@@ -1882,6 +1890,7 @@ def _build_list_summary_row(
|
|||||||
]
|
]
|
||||||
receivable = float(sum(active_dues, Decimal("0"))) if active_dues else 0.0
|
receivable = float(sum(active_dues, Decimal("0"))) if active_dues else 0.0
|
||||||
discount = meta.get("discountAmount")
|
discount = meta.get("discountAmount")
|
||||||
|
sample_status = str(meta.get("sampleStatus") or "").strip()
|
||||||
row: Dict[str, Any] = {
|
row: Dict[str, Any] = {
|
||||||
"id": sp.id,
|
"id": sp.id,
|
||||||
"collectionProtocolId": sp.collection_protocol_id,
|
"collectionProtocolId": sp.collection_protocol_id,
|
||||||
@@ -1891,6 +1900,10 @@ def _build_list_summary_row(
|
|||||||
"motherName": (party.mother_name if party else "") or "",
|
"motherName": (party.mother_name if party else "") or "",
|
||||||
"motherPhone": (party.mother_phone if party else "") or "",
|
"motherPhone": (party.mother_phone if party else "") or "",
|
||||||
"sampleCode": sp.sample_code or "",
|
"sampleCode": sp.sample_code or "",
|
||||||
|
"sampleStatus": sample_status,
|
||||||
|
"sampleStatusLabel": str(meta.get("sampleStatusLabel") or "").strip()
|
||||||
|
or _SAMPLE_STATUS_LABELS.get(sample_status, ""),
|
||||||
|
"voidDesc": str(meta.get("voidDesc") or "").strip(),
|
||||||
"payMode": sp.pay_mode or "",
|
"payMode": sp.pay_mode or "",
|
||||||
"contractAmount": float(sp.contract_amount)
|
"contractAmount": float(sp.contract_amount)
|
||||||
if sp.contract_amount is not None
|
if sp.contract_amount is not None
|
||||||
@@ -2020,10 +2033,14 @@ def list_sample_payments_page(
|
|||||||
discount = None
|
discount = None
|
||||||
if orig is not None and price is not None and orig > price:
|
if orig is not None and price is not None and orig > price:
|
||||||
discount = round(orig - price, 2)
|
discount = round(orig - price, 2)
|
||||||
|
status = str(s.sample_status or "").strip()
|
||||||
sample_meta_by_key[key] = {
|
sample_meta_by_key[key] = {
|
||||||
"storageYears": s.storage_years,
|
"storageYears": s.storage_years,
|
||||||
"sampleTypeName": type_name_map.get(s.sample_type_id or "", ""),
|
"sampleTypeName": type_name_map.get(s.sample_type_id or "", ""),
|
||||||
"discountAmount": discount,
|
"discountAmount": discount,
|
||||||
|
"sampleStatus": status,
|
||||||
|
"sampleStatusLabel": _SAMPLE_STATUS_LABELS.get(status, ""),
|
||||||
|
"voidDesc": str(getattr(s, "void_desc", None) or "").strip(),
|
||||||
}
|
}
|
||||||
rows: List[Dict[str, Any]] = []
|
rows: List[Dict[str, Any]] = []
|
||||||
for sp, proto, party in candidates:
|
for sp, proto, party in candidates:
|
||||||
@@ -2228,6 +2245,40 @@ def list_payment_chase_page(
|
|||||||
for u in db.query(SysUser.id, SysUser.nick_name).filter(SysUser.id.in_(sales_ids)).all():
|
for u in db.query(SysUser.id, SysUser.nick_name).filter(SysUser.id.in_(sales_ids)).all():
|
||||||
sales_name_map[u.id] = u.nick_name or ""
|
sales_name_map[u.id] = u.nick_name or ""
|
||||||
|
|
||||||
|
sample_codes = list(
|
||||||
|
{
|
||||||
|
(sp.sample_code or sch.sample_code or "").strip()
|
||||||
|
for sch, sp, _, _, _ in candidates
|
||||||
|
if (sp.sample_code or sch.sample_code or "").strip()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
sample_status_by_code: Dict[str, Dict[str, str]] = {}
|
||||||
|
if sample_codes:
|
||||||
|
s_rows = (
|
||||||
|
db.query(BizProtocolSample)
|
||||||
|
.filter(
|
||||||
|
BizProtocolSample.tenant_no == tenant_no,
|
||||||
|
BizProtocolSample.del_flag == 0,
|
||||||
|
BizProtocolSample.sample_code.in_(sample_codes),
|
||||||
|
)
|
||||||
|
.order_by(
|
||||||
|
BizProtocolSample.update_time.desc(),
|
||||||
|
BizProtocolSample.create_time.desc(),
|
||||||
|
BizProtocolSample.id.desc(),
|
||||||
|
)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
for sample in s_rows:
|
||||||
|
code = str(sample.sample_code or "").strip()
|
||||||
|
if not code or code in sample_status_by_code:
|
||||||
|
continue
|
||||||
|
status = str(sample.sample_status or "").strip()
|
||||||
|
sample_status_by_code[code] = {
|
||||||
|
"sampleStatus": status,
|
||||||
|
"sampleStatusLabel": _SAMPLE_STATUS_LABELS.get(status, ""),
|
||||||
|
"voidDesc": str(getattr(sample, "void_desc", None) or "").strip(),
|
||||||
|
}
|
||||||
|
|
||||||
ct = (chase_type or "").strip()
|
ct = (chase_type or "").strip()
|
||||||
rows: List[Dict[str, Any]] = []
|
rows: List[Dict[str, Any]] = []
|
||||||
for sch, sp, proto, party, ci in candidates:
|
for sch, sp, proto, party, ci in candidates:
|
||||||
@@ -2257,6 +2308,8 @@ def list_payment_chase_page(
|
|||||||
continue
|
continue
|
||||||
days_overdue = (today_d - due_d).days if overdue else 0
|
days_overdue = (today_d - due_d).days if overdue else 0
|
||||||
days_until = (due_d - today_d).days if not overdue else 0
|
days_until = (due_d - today_d).days if not overdue else 0
|
||||||
|
sample_code = sp.sample_code or sch.sample_code or ""
|
||||||
|
sample_state = sample_status_by_code.get(str(sample_code).strip(), {})
|
||||||
rows.append(
|
rows.append(
|
||||||
{
|
{
|
||||||
"scheduleId": sch.id,
|
"scheduleId": sch.id,
|
||||||
@@ -2265,7 +2318,10 @@ def list_payment_chase_page(
|
|||||||
"protocolNo": (proto.protocol_no if proto else "") or "",
|
"protocolNo": (proto.protocol_no if proto else "") or "",
|
||||||
"motherName": (party.mother_name if party else "") or "",
|
"motherName": (party.mother_name if party else "") or "",
|
||||||
"motherPhone": (party.mother_phone if party else "") or "",
|
"motherPhone": (party.mother_phone if party else "") or "",
|
||||||
"sampleCode": sp.sample_code or sch.sample_code or "",
|
"sampleCode": sample_code,
|
||||||
|
"sampleStatus": sample_state.get("sampleStatus", ""),
|
||||||
|
"sampleStatusLabel": sample_state.get("sampleStatusLabel", ""),
|
||||||
|
"voidDesc": sample_state.get("voidDesc", ""),
|
||||||
"salesUserId": (ci.sales_user_id if ci else "") or "",
|
"salesUserId": (ci.sales_user_id if ci else "") or "",
|
||||||
"salesUserName": sales_name_map.get(
|
"salesUserName": sales_name_map.get(
|
||||||
(ci.sales_user_id if ci else "") or "", ""
|
(ci.sales_user_id if ci else "") or "", ""
|
||||||
|
|||||||
@@ -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.qc_param import BizQcTaskResult
|
||||||
|
from app.models.models import BizQcTaskResultChangeLog
|
||||||
|
|
||||||
results = db.query(BizQcTaskResult).filter(
|
results = db.query(BizQcTaskResult).filter(
|
||||||
and_(BizQcTaskResult.task_id == task_id, BizQcTaskResult.del_flag == 0)
|
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_by = user_id
|
||||||
r.update_time = now
|
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(
|
_soft_delete_source_line_for_task(
|
||||||
db, task, tenant_no=tenant_no, user_id=user_id, now=now
|
db, task, tenant_no=tenant_no, user_id=user_id, now=now
|
||||||
|
|||||||
@@ -0,0 +1,254 @@
|
|||||||
|
"""质检任务检测结果操作留痕"""
|
||||||
|
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,
|
||||||
|
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,
|
||||||
|
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,
|
||||||
|
operate_batch_id=batch_id,
|
||||||
|
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 "",
|
||||||
|
"operateBatchId": row.operate_batch_id 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]
|
||||||
@@ -108,7 +108,7 @@ _CONCLUSION_LABELS = {"tg": "通过", "btg": "不通过"}
|
|||||||
_OUTBOUND_BIZ_TYPE_LABELS = {
|
_OUTBOUND_BIZ_TYPE_LABELS = {
|
||||||
"pilot_service": "中试服务",
|
"pilot_service": "中试服务",
|
||||||
"clinical_application": "临床应用",
|
"clinical_application": "临床应用",
|
||||||
"basic_experiment": "基础实验",
|
"basic_experiment": "临床科研",
|
||||||
}
|
}
|
||||||
_OUTBOUND_BIZ_TYPES = tuple(_OUTBOUND_BIZ_TYPE_LABELS.keys())
|
_OUTBOUND_BIZ_TYPES = tuple(_OUTBOUND_BIZ_TYPE_LABELS.keys())
|
||||||
|
|
||||||
@@ -2753,6 +2753,16 @@ def _soft_delete_tasks_by_source_line_ids(
|
|||||||
{"del_flag": 1, "update_time": now},
|
{"del_flag": 1, "update_time": now},
|
||||||
synchronize_session="fetch",
|
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:
|
for t in tasks:
|
||||||
t.del_flag = 1
|
t.del_flag = 1
|
||||||
t.update_time = now
|
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()
|
).all()
|
||||||
from app.models.qc_param import BizQcTaskResult
|
from app.models.qc_param import BizQcTaskResult
|
||||||
|
|
||||||
|
from app.models.models import BizQcTaskResultChangeLog
|
||||||
|
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
results = db.query(BizQcTaskResult).filter(
|
results = db.query(BizQcTaskResult).filter(
|
||||||
and_(BizQcTaskResult.task_id == task.id, BizQcTaskResult.del_flag == 0)
|
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.del_flag = 1
|
||||||
r.update_by = user_id
|
r.update_by = user_id
|
||||||
r.update_time = now
|
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.del_flag = 1
|
||||||
task.update_by = user_id
|
task.update_by = user_id
|
||||||
task.update_time = now
|
task.update_time = now
|
||||||
|
|||||||
@@ -976,6 +976,7 @@ def list_donations(
|
|||||||
"sampleTypeName": type_name,
|
"sampleTypeName": type_name,
|
||||||
"sampleCode": code,
|
"sampleCode": code,
|
||||||
"sampleStatus": (s.sample_status or "").strip(),
|
"sampleStatus": (s.sample_status or "").strip(),
|
||||||
|
"voidDesc": (getattr(s, "void_desc", None) or "").strip(),
|
||||||
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
||||||
"transport": transport_dict,
|
"transport": transport_dict,
|
||||||
"freight": freight_by_sample.get(s.id),
|
"freight": freight_by_sample.get(s.id),
|
||||||
|
|||||||
@@ -194,6 +194,14 @@ def _item_to_dict(item: BizSampleFreightItem) -> Dict[str, Any]:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_SAMPLE_STATUS_LABELS = {
|
||||||
|
"ycj": "已采集",
|
||||||
|
"jcz": "检测中",
|
||||||
|
"yrk": "已入库",
|
||||||
|
"yzf": "已作废",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _item_to_dict_enriched(
|
def _item_to_dict_enriched(
|
||||||
item: BizSampleFreightItem,
|
item: BizSampleFreightItem,
|
||||||
*,
|
*,
|
||||||
@@ -201,12 +209,19 @@ def _item_to_dict_enriched(
|
|||||||
sample_type_name: str = "",
|
sample_type_name: str = "",
|
||||||
mother_name: str = "",
|
mother_name: str = "",
|
||||||
newborn_name: str = "",
|
newborn_name: str = "",
|
||||||
|
sample_status: str = "",
|
||||||
|
void_desc: str = "",
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
data = _item_to_dict(item)
|
data = _item_to_dict(item)
|
||||||
data["protocolNo"] = protocol_no or ""
|
data["protocolNo"] = protocol_no or ""
|
||||||
data["sampleTypeName"] = sample_type_name or ""
|
data["sampleTypeName"] = sample_type_name or ""
|
||||||
data["motherName"] = mother_name or ""
|
data["motherName"] = mother_name or ""
|
||||||
data["newbornName"] = newborn_name or ""
|
data["newbornName"] = newborn_name or ""
|
||||||
|
status = str(sample_status or "").strip()
|
||||||
|
if str(item.sample_code or "").strip():
|
||||||
|
data["sampleStatus"] = status
|
||||||
|
data["sampleStatusLabel"] = _SAMPLE_STATUS_LABELS.get(status, "")
|
||||||
|
data["voidDesc"] = str(void_desc or "").strip()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@@ -257,6 +272,8 @@ def _enrich_items_maps(
|
|||||||
BizCellSampleType.type_name,
|
BizCellSampleType.type_name,
|
||||||
BizProtocolPartyCustomer.mother_name,
|
BizProtocolPartyCustomer.mother_name,
|
||||||
BizProtocolPartyCustomer.newborn_name,
|
BizProtocolPartyCustomer.newborn_name,
|
||||||
|
BizProtocolSample.sample_status,
|
||||||
|
BizProtocolSample.void_desc,
|
||||||
)
|
)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
BizCollectionProtocol,
|
BizCollectionProtocol,
|
||||||
@@ -287,12 +304,14 @@ def _enrich_items_maps(
|
|||||||
)
|
)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
for sid, pno, tname, mname, nname in rows:
|
for sid, pno, tname, mname, nname, status, void_desc in rows:
|
||||||
out[f"{SAMPLE_SOURCE_CELL}|{sid}"] = {
|
out[f"{SAMPLE_SOURCE_CELL}|{sid}"] = {
|
||||||
"protocolNo": pno or "",
|
"protocolNo": pno or "",
|
||||||
"sampleTypeName": tname or "",
|
"sampleTypeName": tname or "",
|
||||||
"motherName": mname or "",
|
"motherName": mname or "",
|
||||||
"newbornName": nname or "",
|
"newbornName": nname or "",
|
||||||
|
"sampleStatus": str(status or "").strip(),
|
||||||
|
"voidDesc": str(void_desc or "").strip(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if donation_ids:
|
if donation_ids:
|
||||||
@@ -303,6 +322,8 @@ def _enrich_items_maps(
|
|||||||
BizCellSampleType.type_name,
|
BizCellSampleType.type_name,
|
||||||
BizResearchDonationParty.mother_name,
|
BizResearchDonationParty.mother_name,
|
||||||
BizResearchDonationParty.newborn_name,
|
BizResearchDonationParty.newborn_name,
|
||||||
|
BizResearchDonationSample.sample_status,
|
||||||
|
BizResearchDonationSample.void_desc,
|
||||||
)
|
)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
BizResearchDonation,
|
BizResearchDonation,
|
||||||
@@ -334,12 +355,14 @@ def _enrich_items_maps(
|
|||||||
)
|
)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
for sid, dno, tname, mname, nname in rows:
|
for sid, dno, tname, mname, nname, status, void_desc in rows:
|
||||||
out[f"{SAMPLE_SOURCE_DONATION}|{sid}"] = {
|
out[f"{SAMPLE_SOURCE_DONATION}|{sid}"] = {
|
||||||
"protocolNo": dno or "",
|
"protocolNo": dno or "",
|
||||||
"sampleTypeName": tname or "",
|
"sampleTypeName": tname or "",
|
||||||
"motherName": mname or "",
|
"motherName": mname or "",
|
||||||
"newbornName": nname or "",
|
"newbornName": nname or "",
|
||||||
|
"sampleStatus": str(status or "").strip(),
|
||||||
|
"voidDesc": str(void_desc or "").strip(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return out
|
return out
|
||||||
@@ -541,6 +564,8 @@ def list_freights(
|
|||||||
sample_type_name=info.get("sampleTypeName", ""),
|
sample_type_name=info.get("sampleTypeName", ""),
|
||||||
mother_name=info.get("motherName", ""),
|
mother_name=info.get("motherName", ""),
|
||||||
newborn_name=info.get("newbornName", ""),
|
newborn_name=info.get("newbornName", ""),
|
||||||
|
sample_status=info.get("sampleStatus", ""),
|
||||||
|
void_desc=info.get("voidDesc", ""),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
data["items"] = enriched
|
data["items"] = enriched
|
||||||
@@ -584,6 +609,8 @@ def get_freight_detail(
|
|||||||
sample_type_name=info.get("sampleTypeName", ""),
|
sample_type_name=info.get("sampleTypeName", ""),
|
||||||
mother_name=info.get("motherName", ""),
|
mother_name=info.get("motherName", ""),
|
||||||
newborn_name=info.get("newbornName", ""),
|
newborn_name=info.get("newbornName", ""),
|
||||||
|
sample_status=info.get("sampleStatus", ""),
|
||||||
|
void_desc=info.get("voidDesc", ""),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
data["items"] = enriched
|
data["items"] = enriched
|
||||||
|
|||||||
@@ -444,6 +444,7 @@ def _rows_to_sample_list_items(
|
|||||||
"sampleTypeName": type_map.get(sample.sample_type_id or "", ""),
|
"sampleTypeName": type_map.get(sample.sample_type_id or "", ""),
|
||||||
"collectAmount": _dec(sample.collect_amount),
|
"collectAmount": _dec(sample.collect_amount),
|
||||||
"sampleStatus": sample.sample_status or "",
|
"sampleStatus": sample.sample_status or "",
|
||||||
|
"voidDesc": (getattr(sample, "void_desc", None) or "").strip(),
|
||||||
"motherName": (party.mother_name if party else "") or "",
|
"motherName": (party.mother_name if party else "") or "",
|
||||||
"newbornName": (party.newborn_name if party else "") or "",
|
"newbornName": (party.newborn_name if party else "") or "",
|
||||||
"sampleCollectTime": (
|
"sampleCollectTime": (
|
||||||
|
|||||||
@@ -2394,6 +2394,33 @@ class BizQcTask(Base):
|
|||||||
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
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="操作人姓名快照")
|
||||||
|
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="租户编号")
|
||||||
|
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):
|
class BizQcTaskAssignee(Base):
|
||||||
"""质检任务负责人 biz_qc_task_assignee"""
|
"""质检任务负责人 biz_qc_task_assignee"""
|
||||||
|
|
||||||
@@ -4151,15 +4178,15 @@ class BizPilotApplication(Base):
|
|||||||
project_id = Column(String(64), nullable=True, index=True, comment="所属统计项目ID")
|
project_id = Column(String(64), nullable=True, index=True, comment="所属统计项目ID")
|
||||||
application_no = Column(String(64), nullable=True, comment="申请单号(自动生成,前缀ZSSQ)")
|
application_no = Column(String(64), nullable=True, comment="申请单号(自动生成,前缀ZSSQ)")
|
||||||
application_name = Column(String(200), nullable=True, comment="申请单名称")
|
application_name = Column(String(200), nullable=True, comment="申请单名称")
|
||||||
project_title = Column(String(200), nullable=True, comment="课题名称(基础实验)")
|
project_title = Column(String(200), nullable=True, comment="课题名称(临床科研)")
|
||||||
customer_name = Column(String(200), nullable=True, comment="客户名称(基础实验)")
|
customer_name = Column(String(200), nullable=True, comment="客户名称(临床科研)")
|
||||||
customer_contact = Column(String(100), nullable=True, comment="客户联系人(基础实验)")
|
customer_contact = Column(String(100), nullable=True, comment="客户联系人(临床科研)")
|
||||||
customer_phone = Column(String(32), nullable=True, comment="客户联系方式(基础实验)")
|
customer_phone = Column(String(32), nullable=True, comment="客户联系方式(临床科研)")
|
||||||
application_status = Column(String(16), nullable=False, default="dks", comment="dks待开始 jxz进行中 ywc已完成 yzf已作废")
|
application_status = Column(String(16), nullable=False, default="dks", comment="dks待开始 jxz进行中 ywc已完成 yzf已作废")
|
||||||
channel_service_order_id = Column(String(64), nullable=False, comment="渠道服务购买订单ID")
|
channel_service_order_id = Column(String(64), nullable=False, comment="渠道服务购买订单ID")
|
||||||
channel_id = Column(String(64), nullable=True, comment="渠道ID(缓存自服务订单)")
|
channel_id = Column(String(64), nullable=True, comment="渠道ID(缓存自服务订单)")
|
||||||
channel_name = Column(String(200), nullable=True, comment="渠道名称(缓存)")
|
channel_name = Column(String(200), nullable=True, comment="渠道名称(缓存)")
|
||||||
biz_type = Column(String(20), nullable=False, default="pilot_service", comment="业务类型: pilot_service=中试服务, clinical_application=临床应用, basic_experiment=基础实验")
|
biz_type = Column(String(20), nullable=False, default="pilot_service", comment="业务类型: pilot_service=中试服务, clinical_application=临床应用, basic_experiment=临床科研")
|
||||||
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
order_num = Column(Integer, nullable=True, comment="排序号")
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
remark = Column(String(512), nullable=True, comment="备注")
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""基础实验交付日前一天:服务号模板提醒。"""
|
"""临床科研交付日前一天:服务号模板提醒。"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@@ -137,7 +137,7 @@ def _iter_candidate_schedules(db: Session, *, delivery_day: date) -> List[Any]:
|
|||||||
.order_by(BizPilotInfusionSchedule.infusion_time.asc())
|
.order_by(BizPilotInfusionSchedule.infusion_time.asc())
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
# 一计划多产品时取首条产品行(基础实验通常一行)
|
# 一计划多产品时取首条产品行(临床科研通常一行)
|
||||||
seen: set = set()
|
seen: set = set()
|
||||||
out = []
|
out = []
|
||||||
for sched, app, prod in rows:
|
for sched, app, prod in rows:
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
"""市场协议无效态 ↔ 样本接收废弃 / 样本状态作废联动。
|
"""市场协议无效态 ↔ 样本接收废弃 / 样本状态作废联动。
|
||||||
|
|
||||||
规则(细胞存储 / 科研捐赠):
|
规则(细胞存储 / 科研捐赠):
|
||||||
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf)并写 `void_date`;
|
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf),
|
||||||
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态与 void_date。
|
写 `void_date`,并将接收备注写入 `void_desc`(备注为空则作废原因为空);
|
||||||
|
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态、void_date 与 void_desc。
|
||||||
2. 协议变为已作废(yzf)或属地废弃(sdfq)时:
|
2. 协议变为已作废(yzf)或属地废弃(sdfq)时:
|
||||||
- 协议下全部样本接收结论自动为废弃(bj);
|
- 协议下全部样本接收结论自动为废弃(bj);
|
||||||
- 协议下全部有效样本 `sample_status` 置为已作废(yzf),并写入 `void_date`。
|
- 协议下全部有效样本 `sample_status` 置为已作废(yzf),并写入 `void_date`。
|
||||||
@@ -585,13 +586,17 @@ def void_sample_for_discarded_reception(
|
|||||||
tenant_no: str,
|
tenant_no: str,
|
||||||
user_id: Optional[str] = None,
|
user_id: Optional[str] = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""单条接收废弃:仅将该样本置为已作废。"""
|
"""单条接收废弃:将该样本置为已作废,作废原因取接收备注。"""
|
||||||
_source, sample = _find_sample_for_reception(db, reception=reception, tenant_no=tenant_no)
|
_source, sample = _find_sample_for_reception(db, reception=reception, tenant_no=tenant_no)
|
||||||
if not sample:
|
if not sample:
|
||||||
return False
|
return False
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
reason = (reception.remark or "").strip()
|
||||||
|
if len(reason) > 512:
|
||||||
|
reason = reason[:512]
|
||||||
sample.sample_status = SAMPLE_VOID_STATUS
|
sample.sample_status = SAMPLE_VOID_STATUS
|
||||||
sample.void_date = _void_date_yyyymmdd(void_time=reception.reception_time or now)
|
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_by = user_id
|
||||||
sample.update_time = now
|
sample.update_time = now
|
||||||
db.add(sample)
|
db.add(sample)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""质检工单 · 用户费用摘要(采集协议 / 基础实验)"""
|
"""质检工单 · 用户费用摘要(采集协议 / 临床科研)"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
@@ -27,7 +27,7 @@ _PAY_STATUS_LABELS = {
|
|||||||
"ytf": "已退费",
|
"ytf": "已退费",
|
||||||
}
|
}
|
||||||
|
|
||||||
# 出库工单:输注计划缴费(基础实验 / 临床应用共用 biz_pilot_payment)
|
# 出库工单:输注计划缴费(临床科研 / 临床应用共用 biz_pilot_payment)
|
||||||
_OUTBOUND_FEE_BIZ_TYPES = frozenset({"basic_experiment", "clinical_application"})
|
_OUTBOUND_FEE_BIZ_TYPES = frozenset({"basic_experiment", "clinical_application"})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
"""用户下拉选项:同部门优先排序等轻量辅助。"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any, Dict, List, Sequence
|
||||||
|
|
||||||
|
|
||||||
|
def prioritize_caller_dept_options(
|
||||||
|
options: Sequence[Dict[str, Any]],
|
||||||
|
caller_dept_id: str,
|
||||||
|
) -> List[Dict[str, Any]]:
|
||||||
|
"""稳定排序:当前登录用户同部门在前,其余保持原相对顺序。"""
|
||||||
|
items = list(options)
|
||||||
|
dept = (caller_dept_id or "").strip()
|
||||||
|
if not dept or not items:
|
||||||
|
return items
|
||||||
|
return sorted(
|
||||||
|
items,
|
||||||
|
key=lambda item: 0 if str(item.get("deptId") or "").strip() == dept else 1,
|
||||||
|
)
|
||||||
@@ -246,7 +246,7 @@ def send_basic_experiment_delivery_remind(
|
|||||||
time_text: str,
|
time_text: str,
|
||||||
pagepath: str = "",
|
pagepath: str = "",
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""基础实验:交付日前一天出库提醒。"""
|
"""临床科研:交付日前一天出库提醒。"""
|
||||||
data: Dict[str, Dict[str, str]] = {}
|
data: Dict[str, Dict[str, str]] = {}
|
||||||
customer_key = (settings.WX_MP_TPL_BE_DELIVERY_FIELD_CUSTOMER or "").strip()
|
customer_key = (settings.WX_MP_TPL_BE_DELIVERY_FIELD_CUSTOMER or "").strip()
|
||||||
product_key = (settings.WX_MP_TPL_BE_DELIVERY_FIELD_PRODUCT or "").strip()
|
product_key = (settings.WX_MP_TPL_BE_DELIVERY_FIELD_PRODUCT or "").strip()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""基础实验申请单与售卖计划批量创建"""
|
"""临床科研申请单与售卖计划批量创建"""
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""基础实验交付日前一天服务号提醒单测。"""
|
"""临床科研交付日前一天服务号提醒单测。"""
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
from app.services.lab_sample_process import (
|
from app.services.lab_sample_process import (
|
||||||
format_cn_datetime,
|
format_cn_datetime,
|
||||||
@@ -38,5 +39,65 @@ class LabSampleProcessServiceTests(unittest.TestCase):
|
|||||||
self.assertEqual(merged["motherName"], "张三")
|
self.assertEqual(merged["motherName"], "张三")
|
||||||
|
|
||||||
|
|
||||||
|
class LabSampleProcessRowStatusTests(unittest.TestCase):
|
||||||
|
def test_cell_and_donation_rows_expose_sample_status(self):
|
||||||
|
from app.crud.lab_sample_process import (
|
||||||
|
_build_cell_system,
|
||||||
|
_build_donation_system,
|
||||||
|
)
|
||||||
|
|
||||||
|
rec = SimpleNamespace(
|
||||||
|
id="r1",
|
||||||
|
sample_code="S1",
|
||||||
|
lab_storage_code="B0000108",
|
||||||
|
reception_time=None,
|
||||||
|
receive_temperature="",
|
||||||
|
handler_name="",
|
||||||
|
remark="",
|
||||||
|
create_time=None,
|
||||||
|
)
|
||||||
|
sample = SimpleNamespace(
|
||||||
|
sample_code="S1",
|
||||||
|
sample_status="yrk",
|
||||||
|
void_desc="",
|
||||||
|
)
|
||||||
|
voided = SimpleNamespace(
|
||||||
|
sample_code="S2",
|
||||||
|
sample_status="yzf",
|
||||||
|
void_desc="溶血",
|
||||||
|
)
|
||||||
|
cell = _build_cell_system(
|
||||||
|
tab_key="cell_hsc",
|
||||||
|
rec=rec,
|
||||||
|
sample=sample,
|
||||||
|
party=None,
|
||||||
|
coll=None,
|
||||||
|
protocol=None,
|
||||||
|
prod={},
|
||||||
|
hospital_name="",
|
||||||
|
check_flags={},
|
||||||
|
storage_status="已入库",
|
||||||
|
qc_mother={},
|
||||||
|
qc_process={},
|
||||||
|
)
|
||||||
|
self.assertEqual(cell["sampleStatus"], "yrk")
|
||||||
|
self.assertEqual(cell["voidDesc"], "")
|
||||||
|
self.assertEqual(cell["cellCode"], "B0000108")
|
||||||
|
|
||||||
|
donation = _build_donation_system(
|
||||||
|
tab_key="donation_hsc",
|
||||||
|
rec=rec,
|
||||||
|
sample=voided,
|
||||||
|
party=None,
|
||||||
|
coll=None,
|
||||||
|
prod={},
|
||||||
|
storage_status="",
|
||||||
|
qc_mother={},
|
||||||
|
qc_process={},
|
||||||
|
)
|
||||||
|
self.assertEqual(donation["sampleStatus"], "yzf")
|
||||||
|
self.assertEqual(donation["voidDesc"], "溶血")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
@@ -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",
|
accept_conclusion="bj",
|
||||||
reception_source="cell_storage",
|
reception_source="cell_storage",
|
||||||
sample_code="ZKA",
|
sample_code="ZKA",
|
||||||
|
remark="母血乙肝阳性",
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
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"].sample_status, SAMPLE_VOID_STATUS)
|
||||||
self.assertEqual(by_id["sa"].void_date, "20261105")
|
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["sb"].sample_status, "ycj")
|
||||||
self.assertEqual(by_id["sc"].sample_status, "ycj")
|
self.assertEqual(by_id["sc"].sample_status, "ycj")
|
||||||
|
|
||||||
@@ -496,6 +498,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
sample_code="ZKCLR",
|
sample_code="ZKCLR",
|
||||||
sample_status=SAMPLE_VOID_STATUS,
|
sample_status=SAMPLE_VOID_STATUS,
|
||||||
void_date="20261101",
|
void_date="20261101",
|
||||||
|
void_desc="旧作废原因",
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -535,6 +538,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s-clear").one()
|
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s-clear").one()
|
||||||
self.assertFalse((sample.sample_status or "").strip())
|
self.assertFalse((sample.sample_status or "").strip())
|
||||||
self.assertFalse((sample.void_date or "").strip())
|
self.assertFalse((sample.void_date or "").strip())
|
||||||
|
self.assertFalse((sample.void_desc or "").strip())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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) == []
|
||||||
@@ -79,12 +79,26 @@ class TestFreightListHelpers(unittest.TestCase):
|
|||||||
sample_type_name="脐带血",
|
sample_type_name="脐带血",
|
||||||
mother_name="张三",
|
mother_name="张三",
|
||||||
newborn_name="张小宝",
|
newborn_name="张小宝",
|
||||||
|
sample_status="ycj",
|
||||||
|
void_desc="",
|
||||||
)
|
)
|
||||||
self.assertEqual(d["protocolNo"], "CP001")
|
self.assertEqual(d["protocolNo"], "CP001")
|
||||||
self.assertEqual(d["sampleTypeName"], "脐带血")
|
self.assertEqual(d["sampleTypeName"], "脐带血")
|
||||||
self.assertEqual(d["sampleSource"], "cell_storage")
|
self.assertEqual(d["sampleSource"], "cell_storage")
|
||||||
self.assertEqual(d["motherName"], "张三")
|
self.assertEqual(d["motherName"], "张三")
|
||||||
self.assertEqual(d["newbornName"], "张小宝")
|
self.assertEqual(d["newbornName"], "张小宝")
|
||||||
|
self.assertEqual(d["sampleStatus"], "ycj")
|
||||||
|
self.assertEqual(d["sampleStatusLabel"], "已采集")
|
||||||
|
self.assertEqual(d["voidDesc"], "")
|
||||||
|
|
||||||
|
voided = _item_to_dict_enriched(
|
||||||
|
I(),
|
||||||
|
sample_status="yzf",
|
||||||
|
void_desc="运输破损",
|
||||||
|
)
|
||||||
|
self.assertEqual(voided["sampleStatus"], "yzf")
|
||||||
|
self.assertEqual(voided["sampleStatusLabel"], "已作废")
|
||||||
|
self.assertEqual(voided["voidDesc"], "运输破损")
|
||||||
|
|
||||||
def test_row_dict_includes_create_by(self):
|
def test_row_dict_includes_create_by(self):
|
||||||
from app.crud.sample_freight import _row_to_dict
|
from app.crud.sample_freight import _row_to_dict
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
"""样本缴费列表:进度过滤与分页顺序"""
|
"""样本缴费列表:进度过滤与分页顺序、样本状态汇总字段"""
|
||||||
|
|
||||||
|
from types import SimpleNamespace
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from app.crud.protocol_sample_payment import _filter_and_page_progress
|
from app.crud.protocol_sample_payment import (
|
||||||
|
_build_list_summary_row,
|
||||||
|
_filter_and_page_progress,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestFilterAndPageProgress(unittest.TestCase):
|
class TestFilterAndPageProgress(unittest.TestCase):
|
||||||
@@ -33,5 +37,73 @@ class TestFilterAndPageProgress(unittest.TestCase):
|
|||||||
self.assertEqual([r["id"] for r in page], ["0", "1", "2"])
|
self.assertEqual([r["id"] for r in page], ["0", "1", "2"])
|
||||||
|
|
||||||
|
|
||||||
|
class TestPaymentListSampleStatus(unittest.TestCase):
|
||||||
|
def test_summary_row_exposes_sample_status_and_void_desc(self):
|
||||||
|
sp = SimpleNamespace(
|
||||||
|
id="sp1",
|
||||||
|
collection_protocol_id="p1",
|
||||||
|
sample_code="ZKZX34001028",
|
||||||
|
pay_mode="dj",
|
||||||
|
contract_amount=None,
|
||||||
|
remark="",
|
||||||
|
)
|
||||||
|
proto = SimpleNamespace(
|
||||||
|
protocol_no="CP-1",
|
||||||
|
protocol_status="sxz",
|
||||||
|
void_type="",
|
||||||
|
register_date="20261101",
|
||||||
|
)
|
||||||
|
party = SimpleNamespace(mother_name="张三", mother_phone="13800000000")
|
||||||
|
progress = {
|
||||||
|
"progressStatus": "dfj",
|
||||||
|
"paidAmount": 0,
|
||||||
|
"arrearsAmount": 0,
|
||||||
|
"dueAmount": 0,
|
||||||
|
}
|
||||||
|
row = _build_list_summary_row(
|
||||||
|
sp,
|
||||||
|
proto,
|
||||||
|
party,
|
||||||
|
progress,
|
||||||
|
schedules=[],
|
||||||
|
transfers=[],
|
||||||
|
sample_meta={
|
||||||
|
"storageYears": 20,
|
||||||
|
"sampleTypeName": "脐带血",
|
||||||
|
"discountAmount": None,
|
||||||
|
"sampleStatus": "ycj",
|
||||||
|
"sampleStatusLabel": "已采集",
|
||||||
|
"voidDesc": "",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.assertEqual(row["sampleStatus"], "ycj")
|
||||||
|
self.assertEqual(row["sampleStatusLabel"], "已采集")
|
||||||
|
self.assertEqual(row["voidDesc"], "")
|
||||||
|
|
||||||
|
voided = _build_list_summary_row(
|
||||||
|
sp,
|
||||||
|
proto,
|
||||||
|
party,
|
||||||
|
progress,
|
||||||
|
schedules=[],
|
||||||
|
transfers=[],
|
||||||
|
sample_meta={
|
||||||
|
"sampleStatus": "yzf",
|
||||||
|
"voidDesc": "客户放弃存储",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.assertEqual(voided["sampleStatus"], "yzf")
|
||||||
|
self.assertEqual(voided["sampleStatusLabel"], "已作废")
|
||||||
|
self.assertEqual(voided["voidDesc"], "客户放弃存储")
|
||||||
|
|
||||||
|
|
||||||
|
class TestPaymentChaseSampleStatusLabels(unittest.TestCase):
|
||||||
|
def test_status_label_map_covers_voided(self):
|
||||||
|
from app.crud.protocol_sample_payment import _SAMPLE_STATUS_LABELS
|
||||||
|
|
||||||
|
self.assertEqual(_SAMPLE_STATUS_LABELS.get("ycj"), "已采集")
|
||||||
|
self.assertEqual(_SAMPLE_STATUS_LABELS.get("yzf"), "已作废")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
"""用户下拉选项:同部门优先排序。"""
|
||||||
|
from app.services.user_select_options import prioritize_caller_dept_options
|
||||||
|
|
||||||
|
|
||||||
|
def test_prioritize_caller_dept_keeps_relative_order():
|
||||||
|
options = [
|
||||||
|
{"label": "外1", "value": "a", "deptId": "d2"},
|
||||||
|
{"label": "同1", "value": "b", "deptId": "d1"},
|
||||||
|
{"label": "外2", "value": "c", "deptId": "d3"},
|
||||||
|
{"label": "同2", "value": "d", "deptId": "d1"},
|
||||||
|
{"label": "无部门", "value": "e", "deptId": ""},
|
||||||
|
]
|
||||||
|
out = prioritize_caller_dept_options(options, "d1")
|
||||||
|
assert [x["value"] for x in out] == ["b", "d", "a", "c", "e"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_prioritize_caller_dept_noop_without_caller_dept():
|
||||||
|
options = [
|
||||||
|
{"label": "a", "value": "a", "deptId": "d1"},
|
||||||
|
{"label": "b", "value": "b", "deptId": "d2"},
|
||||||
|
]
|
||||||
|
assert prioritize_caller_dept_options(options, "") == options
|
||||||
|
assert prioritize_caller_dept_options(options, " ") == options
|
||||||
|
|
||||||
|
|
||||||
|
def test_prioritize_caller_dept_empty_list():
|
||||||
|
assert prioritize_caller_dept_options([], "d1") == []
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
-- 市场模块新增「器械销售」及三个子菜单;授权给已有 menu:market 的角色。
|
||||||
|
-- 不新建角色/用户;用户经现有 sys_user_role 自动带上菜单。
|
||||||
|
-- MySQL 5.7,可重复执行。目标库:测试库(如 zkxw-sc)。
|
||||||
|
|
||||||
|
-- 1) 二级目录:器械销售(挂在市场下,order_num=6 末位)
|
||||||
|
INSERT INTO sys_menu (
|
||||||
|
id, menu_name, parent_id, menu_type, path, component, perms,
|
||||||
|
is_frame, visible, status, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
'DEV00000000000000000000000000001',
|
||||||
|
'器械销售',
|
||||||
|
m.id,
|
||||||
|
'M',
|
||||||
|
'device-sales',
|
||||||
|
NULL,
|
||||||
|
'menu:device-sales',
|
||||||
|
1, '1', '1', m.tenant_no, 6,
|
||||||
|
'市场-器械销售',
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM sys_menu m
|
||||||
|
WHERE m.del_flag = 0 AND m.perms = 'menu:market'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_menu e
|
||||||
|
WHERE e.id = 'DEV00000000000000000000000000001' AND e.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 2) 子菜单:三类 / 二类 / 化妆品
|
||||||
|
INSERT INTO sys_menu (
|
||||||
|
id, menu_name, parent_id, menu_type, path, component, perms,
|
||||||
|
is_frame, visible, status, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
x.id, x.menu_name, 'DEV00000000000000000000000000001', 'C', x.path,
|
||||||
|
'device-sales/under-construction/index', x.perms,
|
||||||
|
1, '1', '1', p.tenant_no, x.order_num, x.remark,
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM sys_menu p
|
||||||
|
JOIN (
|
||||||
|
SELECT 'DEV00000000000000000000000000002' AS id, '三类医疗器械' AS menu_name,
|
||||||
|
'class-iii' AS path, 'device-sales:class-iii:list' AS perms, 1 AS order_num,
|
||||||
|
'市场-器械销售-三类医疗器械' AS remark
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'DEV00000000000000000000000000003', '二类医疗器械',
|
||||||
|
'class-ii', 'device-sales:class-ii:list', 2,
|
||||||
|
'市场-器械销售-二类医疗器械'
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'DEV00000000000000000000000000004', '化妆品产品',
|
||||||
|
'cosmetics', 'device-sales:cosmetics:list', 3,
|
||||||
|
'市场-器械销售-化妆品产品'
|
||||||
|
) x ON 1 = 1
|
||||||
|
WHERE p.del_flag = 0 AND p.id = 'DEV00000000000000000000000000001'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_menu e WHERE e.id = x.id AND e.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 3) 给已有「市场」顶级菜单授权的角色,授予器械销售目录+三个子菜单
|
||||||
|
-- (含祖先目录,满足选中子菜单须含祖先)
|
||||||
|
INSERT INTO sys_role_menu (
|
||||||
|
id, role_id, menu_id, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
INSERT(INSERT(MD5(CONCAT('device-sales-rm:', r.tenant_no, ':', r.id, ':', m.id)), 13, 1, '3'), 17, 1, '8'),
|
||||||
|
r.id, m.id, r.tenant_no, NULL,
|
||||||
|
'grant device-sales from menu:market',
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM sys_role r
|
||||||
|
JOIN sys_role_menu src
|
||||||
|
ON src.role_id = r.id AND src.tenant_no = r.tenant_no AND src.del_flag = 0
|
||||||
|
JOIN sys_menu top
|
||||||
|
ON top.id = src.menu_id AND top.tenant_no = src.tenant_no AND top.del_flag = 0
|
||||||
|
AND top.perms = 'menu:market'
|
||||||
|
JOIN sys_menu m
|
||||||
|
ON m.tenant_no = r.tenant_no AND m.del_flag = 0 AND m.status = '1'
|
||||||
|
AND m.id IN (
|
||||||
|
'DEV00000000000000000000000000001',
|
||||||
|
'DEV00000000000000000000000000002',
|
||||||
|
'DEV00000000000000000000000000003',
|
||||||
|
'DEV00000000000000000000000000004'
|
||||||
|
)
|
||||||
|
WHERE r.del_flag = 0
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_role_menu existing
|
||||||
|
WHERE existing.role_id = r.id
|
||||||
|
AND existing.menu_id = m.id
|
||||||
|
AND existing.tenant_no = r.tenant_no
|
||||||
|
AND existing.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 3b) 超级管理员同步授予(角色管理勾选与超管侧栏数据一致)
|
||||||
|
INSERT INTO sys_role_menu (
|
||||||
|
id, role_id, menu_id, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
INSERT(INSERT(MD5(CONCAT('device-sales-sa:', r.tenant_no, ':', r.id, ':', m.id)), 13, 1, '3'), 17, 1, '8'),
|
||||||
|
r.id, m.id, r.tenant_no, NULL,
|
||||||
|
'grant device-sales to super admin',
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM sys_role r
|
||||||
|
JOIN sys_menu m
|
||||||
|
ON m.del_flag = 0 AND m.status = '1'
|
||||||
|
AND m.id IN (
|
||||||
|
'DEV00000000000000000000000000001',
|
||||||
|
'DEV00000000000000000000000000002',
|
||||||
|
'DEV00000000000000000000000000003',
|
||||||
|
'DEV00000000000000000000000000004'
|
||||||
|
)
|
||||||
|
WHERE r.del_flag = 0 AND r.role_name = '超级管理员'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_role_menu existing
|
||||||
|
WHERE existing.role_id = r.id
|
||||||
|
AND existing.menu_id = m.id
|
||||||
|
AND existing.tenant_no = r.tenant_no
|
||||||
|
AND existing.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 3c) 恢复已挂到上述角色、但被软删的用户-角色关联(打通 用户→角色→菜单)
|
||||||
|
UPDATE sys_user_role ur
|
||||||
|
JOIN sys_role r ON r.id = ur.role_id AND r.del_flag = 0
|
||||||
|
JOIN sys_role_menu rm
|
||||||
|
ON rm.role_id = r.id AND rm.del_flag = 0
|
||||||
|
AND rm.menu_id = 'DEV00000000000000000000000000001'
|
||||||
|
JOIN sys_user u ON u.id = ur.user_id AND u.del_flag = 0
|
||||||
|
SET ur.del_flag = 0,
|
||||||
|
ur.update_by = 'migration',
|
||||||
|
ur.update_time = NOW()
|
||||||
|
WHERE ur.del_flag = 1;
|
||||||
|
|
||||||
|
-- 4) 核对
|
||||||
|
SELECT id, menu_name, parent_id, path, perms, order_num, visible, del_flag
|
||||||
|
FROM sys_menu
|
||||||
|
WHERE id LIKE 'DEV0000000000000000000000000000%'
|
||||||
|
ORDER BY order_num, menu_name;
|
||||||
|
|
||||||
|
SELECT COUNT(DISTINCT rm.role_id) AS roles_granted,
|
||||||
|
COUNT(*) AS role_menu_rows
|
||||||
|
FROM sys_role_menu rm
|
||||||
|
WHERE rm.del_flag = 0
|
||||||
|
AND rm.menu_id IN (
|
||||||
|
'DEV00000000000000000000000000001',
|
||||||
|
'DEV00000000000000000000000000002',
|
||||||
|
'DEV00000000000000000000000000003',
|
||||||
|
'DEV00000000000000000000000000004'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 抽样:有市场权限的用户是否能通过角色落到器械销售菜单
|
||||||
|
SELECT u.nick_name, u.phone_no, r.role_name, m.menu_name, m.perms
|
||||||
|
FROM sys_user u
|
||||||
|
JOIN sys_user_role ur ON ur.user_id = u.id AND ur.del_flag = 0
|
||||||
|
JOIN sys_role r ON r.id = ur.role_id AND r.del_flag = 0
|
||||||
|
JOIN sys_role_menu rm ON rm.role_id = r.id AND rm.del_flag = 0
|
||||||
|
JOIN sys_menu m ON m.id = rm.menu_id AND m.del_flag = 0
|
||||||
|
WHERE u.del_flag = 0
|
||||||
|
AND m.id IN (
|
||||||
|
'DEV00000000000000000000000000002',
|
||||||
|
'DEV00000000000000000000000000003',
|
||||||
|
'DEV00000000000000000000000000004'
|
||||||
|
)
|
||||||
|
ORDER BY u.nick_name, m.order_num
|
||||||
|
LIMIT 30;
|
||||||
@@ -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`);
|
||||||
@@ -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='质检任务检测结果操作留痕';
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
-- 展示名:基础实验 → 临床科研(仅中文;不改 perms / path / component / id)
|
||||||
|
-- MySQL 5.7,可重复执行。目标库:测试库(如 zkxw-sc)。
|
||||||
|
|
||||||
|
UPDATE sys_menu
|
||||||
|
SET
|
||||||
|
menu_name = REPLACE(menu_name, '基础实验', '临床科研'),
|
||||||
|
remark = REPLACE(IFNULL(remark, ''), '基础实验', '临床科研'),
|
||||||
|
update_by = 'migration',
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE del_flag = 0
|
||||||
|
AND (
|
||||||
|
menu_name LIKE '%基础实验%'
|
||||||
|
OR IFNULL(remark, '') LIKE '%基础实验%'
|
||||||
|
);
|
||||||
@@ -270,12 +270,12 @@ test('sample-coded list cards show sample status and a void reason affordance',
|
|||||||
}).fields.find((field) => field.label === '样本状态').value,
|
}).fields.find((field) => field.label === '样本状态').value,
|
||||||
'已入库'
|
'已入库'
|
||||||
)
|
)
|
||||||
assert.equal(
|
const detecting = buildMarketCard('payment-chase', 'specialist', {
|
||||||
buildMarketCard('payment-chase', 'specialist', {
|
sampleCode: 'S-1', sampleStatus: 'jcz'
|
||||||
sampleCode: 'S-1', sampleStatus: 'jcz'
|
}).fields.find((field) => field.label === '样本状态')
|
||||||
}).fields.find((field) => field.label === '样本状态').value,
|
assert.equal(detecting.value, '检测中')
|
||||||
'检测中'
|
assert.equal(detecting.helpTitle, undefined)
|
||||||
)
|
assert.equal(detecting.helpText, undefined)
|
||||||
|
|
||||||
const voided = buildMarketCard('payment', 'specialist', {
|
const voided = buildMarketCard('payment', 'specialist', {
|
||||||
motherName: '作废客户',
|
motherName: '作废客户',
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export const receptionSource = createRegistry({
|
|||||||
outbound: { label: '出库', tagType: 'primary' },
|
outbound: { label: '出库', tagType: 'primary' },
|
||||||
pilot_service: { label: '中试服务', tagType: 'primary' },
|
pilot_service: { label: '中试服务', tagType: 'primary' },
|
||||||
clinical_application: { label: '临床应用', tagType: 'warning' },
|
clinical_application: { label: '临床应用', tagType: 'warning' },
|
||||||
basic_experiment: { label: '基础实验', tagType: 'primary' }
|
basic_experiment: { label: '临床科研', tagType: 'primary' }
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 协议/捐赠样本状态;与 Web sampleStatus 保持一致 */
|
/** 协议/捐赠样本状态;与 Web sampleStatus 保持一致 */
|
||||||
|
|||||||
@@ -216,7 +216,8 @@ async function ensureUserCache() {
|
|||||||
if (userCachePromise) return userCachePromise
|
if (userCachePromise) return userCachePromise
|
||||||
userCachePromise = (async () => {
|
userCachePromise = (async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetchUserOptions()
|
// 同部门优先:由后端按当前登录用户部门排序
|
||||||
|
const res = await fetchUserOptions({ prioritizeCallerDept: true })
|
||||||
const list = Array.isArray(res) ? res : res?.list || []
|
const list = Array.isArray(res) ? res : res?.list || []
|
||||||
const next = []
|
const next = []
|
||||||
const seen = new Set()
|
const seen = new Set()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
用户明确采用 [Figma 原型 v2](https://www.figma.com/design/wOQLDAhr1gdlQEXnVaFO9S?node-id=13-23)。范围为 Web 历史归属维护及其后端读取接口,沿用用户先合入 V2.0 再自测的安排。复用 P02 列表和 `pilot-service/pilot-application/index.vue` 的 `panel-pill-tabs`,操作列固定右侧,搜索右对齐。
|
用户明确采用 [Figma 原型 v2](https://www.figma.com/design/wOQLDAhr1gdlQEXnVaFO9S?node-id=13-23)。范围为 Web 历史归属维护及其后端读取接口,沿用用户先合入 V2.0 再自测的安排。复用 P02 列表和 `pilot-service/pilot-application/index.vue` 的 `panel-pill-tabs`,操作列固定右侧,搜索右对齐。
|
||||||
|
|
||||||
`RecordList` 仅在 assignment 模式显示四类正式业务 tab 和业务识别列。细胞存储/科研捐赠展示母亲姓名、电话、采集医院、市场专员及采集/捐赠日期;中试展示申请名称、渠道、服务订单名称、患者姓名/电话;基础实验展示课题、客户名称/联系人/电话。公共列保留序号、主单号、状态、项目组、所属项目、创建时间。多个有效子记录以稳定顺序去重连接展示,缺失值显示破折号,采集日期来自采集信息的样本采集时间。
|
`RecordList` 仅在 assignment 模式显示四类正式业务 tab 和业务识别列。细胞存储/科研捐赠展示母亲姓名、电话、采集医院、市场专员及采集/捐赠日期;中试展示申请名称、渠道、服务订单名称、患者姓名/电话;临床科研展示课题、客户名称/联系人/电话。公共列保留序号、主单号、状态、项目组、所属项目、创建时间。多个有效子记录以稳定顺序去重连接展示,缺失值显示破折号,采集日期来自采集信息的样本采集时间。
|
||||||
|
|
||||||
新增 `GET /web/admin/project-management/assignments/records`,严格要求 `project:assignment:edit`,仅接受四类正式业务。原 `/records` 继续服务统计明细,不扩展联系信息;移动接口不变。专用服务复用主单租户、软删除、数据权限和归属筛选。关键词支持单号、姓名/电话、医院/专员、渠道/服务订单名称、课题/客户信息(日期使用现有创建日期条件);子表使用同租户未删除记录 EXISTS 匹配,不增加主单行数。分页后批量补充项目、医院、人员、患者和服务订单资料,避免逐行查询。
|
新增 `GET /web/admin/project-management/assignments/records`,严格要求 `project:assignment:edit`,仅接受四类正式业务。原 `/records` 继续服务统计明细,不扩展联系信息;移动接口不变。专用服务复用主单租户、软删除、数据权限和归属筛选。关键词支持单号、姓名/电话、医院/专员、渠道/服务订单名称、课题/客户信息(日期使用现有创建日期条件);子表使用同租户未删除记录 EXISTS 匹配,不增加主单行数。分页后批量补充项目、医院、人员、患者和服务订单资料,避免逐行查询。
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
## 模块边界
|
## 模块边界
|
||||||
|
|
||||||
新增 models/project_management.py、services/project_management.py、api/project_management.py。现有四种主表(预签约、采集协议、科研捐赠、中试/基础实验申请)增加可空 project_id,不向下游样本表复制归属。不更改已有课题名称 project_title。
|
新增 models/project_management.py、services/project_management.py、api/project_management.py。现有四种主表(预签约、采集协议、科研捐赠、中试/临床科研申请)增加可空 project_id,不向下游样本表复制归属。不更改已有课题名称 project_title。
|
||||||
|
|
||||||
项目组包含 teamName、leaderUserId、members[{id?,userId}]、regions[{id?,regionId}]、hospitals[{id?,hospitalId}]、enabled、remark。子行按 sync_child_rows 与自然键更新。负责人应计入可选项目成员判断。项目包含 projectNo、projectName、teamId、leaderUserId、bizTypes[]、startDate、endDate、status(pending/active/completed/disabled)、remark。编号服务端生成。项目已有业务后禁止换组;引用中的项目和组只能停用,不能删除。所有引用租户内校验。
|
项目组包含 teamName、leaderUserId、members[{id?,userId}]、regions[{id?,regionId}]、hospitals[{id?,hospitalId}]、enabled、remark。子行按 sync_child_rows 与自然键更新。负责人应计入可选项目成员判断。项目包含 projectNo、projectName、teamId、leaderUserId、bizTypes[]、startDate、endDate、status(pending/active/completed/disabled)、remark。编号服务端生成。项目已有业务后禁止换组;引用中的项目和组只能停用,不能删除。所有引用租户内校验。
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ project_brief(db, tenant_no, project_id) -> dict # projectId/projectName/teamId
|
|||||||
|
|
||||||
预签约转协议继承归属;存储/捐赠互转继承。归属维护将同租户的预签约→协议→捐赠转换记录组成关联集合,循环防重,锁定顺序固定;任一关联记录不可访问则拒绝整个操作,返回信息不暴露无权查看单据。历史软删除记录不参与活跃统计,不复活。
|
预签约转协议继承归属;存储/捐赠互转继承。归属维护将同租户的预签约→协议→捐赠转换记录组成关联集合,循环防重,锁定顺序固定;任一关联记录不可访问则拒绝整个操作,返回信息不暴露无权查看单据。历史软删除记录不参与活跃统计,不复活。
|
||||||
|
|
||||||
正式存储按协议、捐赠按主单、中试和基础实验按对应 biz_type 申请单计数;预签约另列,不把四类数量称为独立客户数。日期按创建日期(起日含、结束日次日不含),状态显示当前状态。查询先按租户、软删除、原有数据权限过滤,再聚合,不联接子行产生重复;金额不在本期。
|
正式存储按协议、捐赠按主单、中试和临床科研按对应 biz_type 申请单计数;预签约另列,不把四类数量称为独立客户数。日期按创建日期(起日含、结束日次日不含),状态显示当前状态。查询先按租户、软删除、原有数据权限过滤,再聚合,不联接子行产生重复;金额不在本期。
|
||||||
|
|
||||||
## 界面与验证
|
## 界面与验证
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
## ADDED Requirements
|
## ADDED Requirements
|
||||||
|
|
||||||
### Requirement: 按业务识别历史归属单据
|
### Requirement: 按业务识别历史归属单据
|
||||||
历史归属维护 SHALL 按细胞存储、科研捐赠、中试服务、基础实验展示四个 tab,并提供对应业务识别字段和关键词搜索;列表保持主单分页,右侧固定归属与审计操作。
|
历史归属维护 SHALL 按细胞存储、科研捐赠、中试服务、临床科研展示四个 tab,并提供对应业务识别字段和关键词搜索;列表保持主单分页,右侧固定归属与审计操作。
|
||||||
#### Scenario: 存储和捐赠以样本编码识别
|
#### Scenario: 存储和捐赠以样本编码识别
|
||||||
- **WHEN** 查看细胞存储或科研捐赠 tab
|
- **WHEN** 查看细胞存储或科研捐赠 tab
|
||||||
- **THEN** 展示样本编码列而非协议单号/捐赠单号列;多个有效编码在同一主单行去重展示,无编码显示破折号,支持按任一编码搜索;跨租户或已删除的样本不用于展示和匹配,分页和归属仍以主单为单位。
|
- **THEN** 展示样本编码列而非协议单号/捐赠单号列;多个有效编码在同一主单行去重展示,无编码显示破折号,支持按任一编码搜索;跨租户或已删除的样本不用于展示和匹配,分页和归属仍以主单为单位。
|
||||||
@@ -54,7 +54,7 @@ Web SHALL 使用“项目 → 项目管理 → 项目组管理 / 项目管理 /
|
|||||||
- **WHEN** 用户打开某项目的某类业务明细
|
- **WHEN** 用户打开某项目的某类业务明细
|
||||||
- **THEN** 明细总数与相同筛选条件汇总一致,不因子行联接重复计数。
|
- **THEN** 明细总数与相同筛选条件汇总一致,不因子行联接重复计数。
|
||||||
#### Scenario: 四类统计明细展示业务字段
|
#### Scenario: 四类统计明细展示业务字段
|
||||||
- **WHEN** 点击细胞存储、科研捐赠、中试服务、基础实验的统计数量
|
- **WHEN** 点击细胞存储、科研捐赠、中试服务、临床科研的统计数量
|
||||||
- **THEN** 原明细弹窗复用历史归属维护对应 tab 的业务列与关键词能力,存储/捐赠显示样本编码,保留汇总传入的筛选条件和只读权限,不显示归属维护操作;预签约仍沿用原行为。
|
- **THEN** 原明细弹窗复用历史归属维护对应 tab 的业务列与关键词能力,存储/捐赠显示样本编码,保留汇总传入的筛选条件和只读权限,不显示归属维护操作;预签约仍沿用原行为。
|
||||||
|
|
||||||
### Requirement: 沿用现有界面样式
|
### Requirement: 沿用现有界面样式
|
||||||
|
|||||||
@@ -22,9 +22,12 @@ export function fetchGetRoleList() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 流程设计器:用户下拉选项(label=昵称,value=用户ID) */
|
/** 用户下拉选项(label=昵称,value=用户ID;可选 deptId / prioritizeCallerDept) */
|
||||||
export function fetchUserOptions(params?: { roleName?: string }) {
|
export function fetchUserOptions(params?: {
|
||||||
return request.get<Array<{ label: string; value: string }>>({
|
roleName?: string
|
||||||
|
prioritizeCallerDept?: boolean
|
||||||
|
}) {
|
||||||
|
return request.get<Array<{ label: string; value: string; deptId?: string }>>({
|
||||||
url: '/web/admin/users/options',
|
url: '/web/admin/users/options',
|
||||||
params
|
params
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ export type SampleVoidTarget = {
|
|||||||
receptionSource: 'cell_storage' | 'research_donation'
|
receptionSource: 'cell_storage' | 'research_donation'
|
||||||
sampleId?: string
|
sampleId?: string
|
||||||
sampleCode?: string
|
sampleCode?: string
|
||||||
|
/** 仅弹窗展示,不参与作废请求 */
|
||||||
|
labStorageCode?: string
|
||||||
protocolId?: string
|
protocolId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ export interface ProductionWorkOrderItem {
|
|||||||
/** 出库工单:输注计划总次数 */
|
/** 出库工单:输注计划总次数 */
|
||||||
totalCourseCount?: number | null
|
totalCourseCount?: number | null
|
||||||
infusionTime?: string
|
infusionTime?: string
|
||||||
/** 基础实验出库:课题名称(列表 enrich) */
|
/** 临床科研出库:课题名称(列表 enrich) */
|
||||||
projectTitle?: string
|
projectTitle?: string
|
||||||
/** 基础实验出库:客户名称(列表 enrich) */
|
/** 临床科研出库:客户名称(列表 enrich) */
|
||||||
customerName?: string
|
customerName?: string
|
||||||
/** 出库工单:输注计划细胞类型(列表 enrich,无产品明细时兜底) */
|
/** 出库工单:输注计划细胞类型(列表 enrich,无产品明细时兜底) */
|
||||||
cellType?: string
|
cellType?: string
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const bizLabels: Record<BizType, string> = {
|
|||||||
cell_storage: '细胞存储',
|
cell_storage: '细胞存储',
|
||||||
research_donation: '科研捐赠',
|
research_donation: '科研捐赠',
|
||||||
pilot_service: '中试服务',
|
pilot_service: '中试服务',
|
||||||
basic_experiment: '基础实验'
|
basic_experiment: '临床科研'
|
||||||
}
|
}
|
||||||
export type ProjectOption = {
|
export type ProjectOption = {
|
||||||
id: string
|
id: string
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export function fetchCompleteTaskWithResult(
|
|||||||
remark?: string
|
remark?: string
|
||||||
thirdPartyAttachments?: string
|
thirdPartyAttachments?: string
|
||||||
taskStatus?: 'dzx' | 'jxz' | 'ywc'
|
taskStatus?: 'dzx' | 'jxz' | 'ywc'
|
||||||
|
operateBatchId?: string
|
||||||
materialUsages?: Array<{
|
materialUsages?: Array<{
|
||||||
requisitionUsageId: string
|
requisitionUsageId: string
|
||||||
qty: number
|
qty: number
|
||||||
@@ -66,3 +67,39 @@ export function fetchCompleteTaskWithResult(
|
|||||||
data
|
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
|
||||||
|
operateBatchId?: 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(',') }
|
||||||
|
})
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
@@ -751,7 +751,7 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 面板级步骤胶囊 Tab(样本信息管理 / 采集协议单 / 中试·基础实验申请单等)
|
// 面板级步骤胶囊 Tab(样本信息管理 / 采集协议单 / 中试·临床科研申请单等)
|
||||||
.pill-tab-nav {
|
.pill-tab-nav {
|
||||||
padding: 16px 20px 0;
|
padding: 16px 20px 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<!-- 样本状态:标签 + 作废原因 -->
|
<!-- 样本状态:标签;仅已作废时展示问号与作废原因 -->
|
||||||
<template>
|
<template>
|
||||||
<span class="sample-status-tag">
|
<span class="sample-status-tag">
|
||||||
<el-tag :type="tagType" size="small">{{ label }}</el-tag>
|
<el-tag :type="tagType" size="small">{{ label }}</el-tag>
|
||||||
<el-popover placement="top" trigger="click" :width="240">
|
<el-popover v-if="voided" placement="top" trigger="click" :width="240">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<button type="button" class="sample-status-tag__q" aria-label="作废原因" @click.stop>
|
<button type="button" class="sample-status-tag__q" aria-label="作废原因" @click.stop>
|
||||||
<el-icon><QuestionFilled /></el-icon>
|
<el-icon><QuestionFilled /></el-icon>
|
||||||
@@ -31,6 +31,8 @@
|
|||||||
const code = computed(() => String(props.status || '').trim())
|
const code = computed(() => String(props.status || '').trim())
|
||||||
const label = computed(() => (code.value ? sampleStatusLabel(code.value) : '—'))
|
const label = computed(() => (code.value ? sampleStatusLabel(code.value) : '—'))
|
||||||
const tagType = computed(() => (code.value ? sampleStatusTagType(code.value) : 'info'))
|
const tagType = computed(() => (code.value ? sampleStatusTagType(code.value) : 'info'))
|
||||||
|
/** 问号仅已作废(yzf)展示 */
|
||||||
|
const voided = computed(() => code.value === 'yzf')
|
||||||
const reasonText = computed(() => String(props.voidDesc || '').trim() || '暂无作废原因')
|
const reasonText = computed(() => String(props.voidDesc || '').trim() || '暂无作废原因')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
class="biz-dialog-form"
|
class="biz-dialog-form"
|
||||||
>
|
>
|
||||||
<div class="form-grid-2">
|
<div class="form-grid-2">
|
||||||
|
<el-form-item label="实验室入库编码" class="form-col-span-2">
|
||||||
|
<span class="sample-void-dialog__code">{{ labStorageCodeDisplay }}</span>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item v-if="sampleCode" label="样本编码" class="form-col-span-2">
|
<el-form-item v-if="sampleCode" label="样本编码" class="form-col-span-2">
|
||||||
<span class="sample-void-dialog__code">{{ sampleCode }}</span>
|
<span class="sample-void-dialog__code">{{ sampleCode }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -84,6 +87,9 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const labStorageCodeDisplay = computed(
|
||||||
|
() => String(props.target?.labStorageCode || '').trim() || '—'
|
||||||
|
)
|
||||||
const sampleCode = computed(() => String(props.target?.sampleCode || '').trim())
|
const sampleCode = computed(() => String(props.target?.sampleCode || '').trim())
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
@@ -255,7 +255,8 @@
|
|||||||
if (userCachePromise) return userCachePromise
|
if (userCachePromise) return userCachePromise
|
||||||
userCachePromise = (async () => {
|
userCachePromise = (async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetchUserOptions()
|
// 同部门优先:由后端按当前登录用户部门排序
|
||||||
|
const res = await fetchUserOptions({ prioritizeCallerDept: true })
|
||||||
const list = Array.isArray(res) ? res : []
|
const list = Array.isArray(res) ? res : []
|
||||||
const next: MentionUser[] = []
|
const next: MentionUser[] = []
|
||||||
const seen = new Set<string>()
|
const seen = new Set<string>()
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export const PILOT_BIZ_TYPE_CONFIG: Record<PilotBizType, PilotBizTypeConfig> = {
|
|||||||
statusLabel: '输注状态'
|
statusLabel: '输注状态'
|
||||||
},
|
},
|
||||||
basic_experiment: {
|
basic_experiment: {
|
||||||
label: '基础实验',
|
label: '临床科研',
|
||||||
applicationNoPrefix: 'JCSY',
|
applicationNoPrefix: 'JCSY',
|
||||||
showChannel: false,
|
showChannel: false,
|
||||||
showPatient: false,
|
showPatient: false,
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
},
|
},
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
// 1. 市场 (menu:market)
|
// 1. 市场 (menu:market)
|
||||||
// 二级菜单:存储服务、科研捐赠、市场基础信息、中试服务、基础实验
|
// 二级菜单:存储服务、科研捐赠、市场基础信息、中试服务、临床科研、器械销售
|
||||||
// (主推存储/捐赠在前;中试/基础实验及关联基础信息后置)
|
// (主推存储/捐赠在前;中试/临床科研及关联基础信息后置;器械销售在末位)
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
{
|
{
|
||||||
id: 'TOP00000000000000000000000000001',
|
id: 'TOP00000000000000000000000000001',
|
||||||
@@ -329,7 +329,7 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 市场基础信息(前段:存储/捐赠相关;后段:中试/基础实验相关)──
|
// ── 市场基础信息(前段:存储/捐赠相关;后段:中试/临床科研相关)──
|
||||||
{
|
{
|
||||||
id: 'MKT00000000000000000000000000001',
|
id: 'MKT00000000000000000000000000001',
|
||||||
name: 'MarketInfo',
|
name: 'MarketInfo',
|
||||||
@@ -619,14 +619,14 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 基础实验 ──────────────────────────────────────────────────────────
|
// ── 临床科研 ──────────────────────────────────────────────────────────
|
||||||
{
|
{
|
||||||
id: 'BEX00000000000000000000000000001',
|
id: 'BEX00000000000000000000000000001',
|
||||||
name: 'BasicExperiment',
|
name: 'BasicExperiment',
|
||||||
path: 'basic-experiment',
|
path: 'basic-experiment',
|
||||||
component: '',
|
component: '',
|
||||||
meta: {
|
meta: {
|
||||||
title: '基础实验',
|
title: '临床科研',
|
||||||
icon: 'ri:flask-line',
|
icon: 'ri:flask-line',
|
||||||
keepAlive: false,
|
keepAlive: false,
|
||||||
roles: ['admin']
|
roles: ['admin']
|
||||||
@@ -638,7 +638,7 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
path: 'application',
|
path: 'application',
|
||||||
component: '/pilot-service/pilot-application/index',
|
component: '/pilot-service/pilot-application/index',
|
||||||
meta: {
|
meta: {
|
||||||
title: '基础实验申请单',
|
title: '临床科研申请单',
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
menuCode: 'basic-experiment:application:list'
|
menuCode: 'basic-experiment:application:list'
|
||||||
},
|
},
|
||||||
@@ -669,6 +669,55 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
props: { bizType: 'basic_experiment' }
|
props: { bizType: 'basic_experiment' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// ── 器械销售(市场侧栏末位;占位页待完善)────────────────────────────
|
||||||
|
{
|
||||||
|
id: 'DEV00000000000000000000000000001',
|
||||||
|
name: 'DeviceSales',
|
||||||
|
path: 'device-sales',
|
||||||
|
component: '',
|
||||||
|
meta: {
|
||||||
|
title: '器械销售',
|
||||||
|
icon: 'ri:shopping-bag-3-line',
|
||||||
|
keepAlive: false,
|
||||||
|
roles: ['admin']
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
id: 'DEV00000000000000000000000000002',
|
||||||
|
name: 'DeviceSalesClassIii',
|
||||||
|
path: 'class-iii',
|
||||||
|
component: '/device-sales/under-construction/index',
|
||||||
|
meta: {
|
||||||
|
title: '三类医疗器械',
|
||||||
|
keepAlive: false,
|
||||||
|
menuCode: 'device-sales:class-iii:list'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'DEV00000000000000000000000000003',
|
||||||
|
name: 'DeviceSalesClassIi',
|
||||||
|
path: 'class-ii',
|
||||||
|
component: '/device-sales/under-construction/index',
|
||||||
|
meta: {
|
||||||
|
title: '二类医疗器械',
|
||||||
|
keepAlive: false,
|
||||||
|
menuCode: 'device-sales:class-ii:list'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'DEV00000000000000000000000000004',
|
||||||
|
name: 'DeviceSalesCosmetics',
|
||||||
|
path: 'cosmetics',
|
||||||
|
component: '/device-sales/under-construction/index',
|
||||||
|
meta: {
|
||||||
|
title: '化妆品产品',
|
||||||
|
keepAlive: false,
|
||||||
|
menuCode: 'device-sales:cosmetics:list'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const SECTION_TITLES: Record<
|
|||||||
schedule: '临床应用输注计划信息'
|
schedule: '临床应用输注计划信息'
|
||||||
},
|
},
|
||||||
basic_experiment: {
|
basic_experiment: {
|
||||||
application: '基础实验申请信息',
|
application: '临床科研申请信息',
|
||||||
schedule: '交付计划信息'
|
schedule: '交付计划信息'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const CATEGORY_LABELS: Record<ProductionWorkOrderCategoryKey, string> = {
|
|||||||
inbound_cell_storage: '细胞存储',
|
inbound_cell_storage: '细胞存储',
|
||||||
inbound_research_donation: '科研捐赠',
|
inbound_research_donation: '科研捐赠',
|
||||||
outbound_pilot_service: '中试服务',
|
outbound_pilot_service: '中试服务',
|
||||||
outbound_basic_experiment: '基础实验',
|
outbound_basic_experiment: '临床科研',
|
||||||
temporary: '临时'
|
temporary: '临时'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const PRODUCTION_WORK_ORDER_TABS: ProductionWorkOrderTabConfig[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'outbound_basic_experiment',
|
key: 'outbound_basic_experiment',
|
||||||
label: '基础实验生产',
|
label: '临床科研生产',
|
||||||
group: 'outbound',
|
group: 'outbound',
|
||||||
workOrderType: 'outbound',
|
workOrderType: 'outbound',
|
||||||
bizType: 'basic_experiment',
|
bizType: 'basic_experiment',
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ const CATEGORY_LABELS: Record<QcWorkOrderCategoryKey, string> = {
|
|||||||
inbound_cell_storage: '细胞存储',
|
inbound_cell_storage: '细胞存储',
|
||||||
inbound_research_donation: '科研捐赠',
|
inbound_research_donation: '科研捐赠',
|
||||||
outbound_pilot_service: '中试服务',
|
outbound_pilot_service: '中试服务',
|
||||||
outbound_basic_experiment: '基础实验',
|
outbound_basic_experiment: '临床科研',
|
||||||
temporary: '临时'
|
temporary: '临时'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const QC_WORK_ORDER_TABS: QcWorkOrderTabConfig[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'outbound_basic_experiment',
|
key: 'outbound_basic_experiment',
|
||||||
label: '基础实验质检',
|
label: '临床科研质检',
|
||||||
group: 'outbound',
|
group: 'outbound',
|
||||||
workOrderType: 'outbound',
|
workOrderType: 'outbound',
|
||||||
bizType: 'basic_experiment',
|
bizType: 'basic_experiment',
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ describe('resolveSampleVoidTarget', () => {
|
|||||||
receptionSource: 'cell_storage',
|
receptionSource: 'cell_storage',
|
||||||
protocolSampleId: 'ps-1',
|
protocolSampleId: 'ps-1',
|
||||||
sampleCode: 'S1',
|
sampleCode: 'S1',
|
||||||
|
labStorageCode: 'B0000108',
|
||||||
collectionProtocolId: 'p-1'
|
collectionProtocolId: 'p-1'
|
||||||
})
|
})
|
||||||
assert.deepEqual(target, {
|
assert.deepEqual(target, {
|
||||||
receptionSource: 'cell_storage',
|
receptionSource: 'cell_storage',
|
||||||
sampleId: 'ps-1',
|
sampleId: 'ps-1',
|
||||||
sampleCode: 'S1',
|
sampleCode: 'S1',
|
||||||
|
labStorageCode: 'B0000108',
|
||||||
protocolId: 'p-1'
|
protocolId: 'p-1'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export function resolveSampleVoidTarget(input: {
|
|||||||
receptionSource?: string | null
|
receptionSource?: string | null
|
||||||
protocolSampleId?: string | null
|
protocolSampleId?: string | null
|
||||||
sampleCode?: string | null
|
sampleCode?: string | null
|
||||||
|
labStorageCode?: string | null
|
||||||
collectionProtocolId?: string | null
|
collectionProtocolId?: string | null
|
||||||
fallbackSource?: string | null
|
fallbackSource?: string | null
|
||||||
}): SampleVoidTarget | null {
|
}): SampleVoidTarget | null {
|
||||||
@@ -18,12 +19,14 @@ export function resolveSampleVoidTarget(input: {
|
|||||||
if (source !== 'cell_storage' && source !== 'research_donation') return null
|
if (source !== 'cell_storage' && source !== 'research_donation') return null
|
||||||
const sampleId = String(input.protocolSampleId || '').trim()
|
const sampleId = String(input.protocolSampleId || '').trim()
|
||||||
const sampleCode = String(input.sampleCode || '').trim()
|
const sampleCode = String(input.sampleCode || '').trim()
|
||||||
|
const labStorageCode = String(input.labStorageCode || '').trim()
|
||||||
const protocolId = String(input.collectionProtocolId || '').trim()
|
const protocolId = String(input.collectionProtocolId || '').trim()
|
||||||
if (!sampleId && !sampleCode) return null
|
if (!sampleId && !sampleCode) return null
|
||||||
return {
|
return {
|
||||||
receptionSource: source,
|
receptionSource: source,
|
||||||
sampleId: sampleId || undefined,
|
sampleId: sampleId || undefined,
|
||||||
sampleCode: sampleCode || undefined,
|
sampleCode: sampleCode || undefined,
|
||||||
|
labStorageCode: labStorageCode || undefined,
|
||||||
protocolId: protocolId || undefined
|
protocolId: protocolId || undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ export const receptionSource: StatusRegistry = {
|
|||||||
outbound: { label: '出库', tagType: 'primary' },
|
outbound: { label: '出库', tagType: 'primary' },
|
||||||
pilot_service: { label: '中试服务', tagType: 'primary' },
|
pilot_service: { label: '中试服务', tagType: 'primary' },
|
||||||
clinical_application: { label: '临床应用', tagType: 'warning' },
|
clinical_application: { label: '临床应用', tagType: 'warning' },
|
||||||
basic_experiment: { label: '基础实验', tagType: 'primary' }
|
basic_experiment: { label: '临床科研', tagType: 'primary' }
|
||||||
}
|
}
|
||||||
export const receptionSourceLabel = createLabelGetter(receptionSource)
|
export const receptionSourceLabel = createLabelGetter(receptionSource)
|
||||||
export const receptionSourceTagType = createTagTypeGetter(receptionSource)
|
export const receptionSourceTagType = createTagTypeGetter(receptionSource)
|
||||||
@@ -386,7 +386,7 @@ export const agreementType: StatusRegistry = {
|
|||||||
kyxy: { label: '框架协议', tagType: 'primary' },
|
kyxy: { label: '框架协议', tagType: 'primary' },
|
||||||
zsxy: { label: '中试协议', tagType: 'success' },
|
zsxy: { label: '中试协议', tagType: 'success' },
|
||||||
lcxy: { label: '临床协议', tagType: 'warning' },
|
lcxy: { label: '临床协议', tagType: 'warning' },
|
||||||
jcsy: { label: '基础实验', tagType: 'primary' }
|
jcsy: { label: '临床科研', tagType: 'primary' }
|
||||||
}
|
}
|
||||||
export const agreementTypeLabel = createLabelGetter(agreementType)
|
export const agreementTypeLabel = createLabelGetter(agreementType)
|
||||||
export const agreementTypeTagType = createTagTypeGetter(agreementType)
|
export const agreementTypeTagType = createTagTypeGetter(agreementType)
|
||||||
@@ -761,7 +761,7 @@ export function bizTypeLabel(type: string): string {
|
|||||||
const map: Record<string, string> = {
|
const map: Record<string, string> = {
|
||||||
pilot_service: '中试服务',
|
pilot_service: '中试服务',
|
||||||
clinical_application: '临床应用',
|
clinical_application: '临床应用',
|
||||||
basic_experiment: '基础实验'
|
basic_experiment: '临床科研'
|
||||||
}
|
}
|
||||||
return map[type] || type || '-'
|
return map[type] || type || '-'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,9 +141,10 @@
|
|||||||
<span class="sample-card__seq">{{ sIdx + 1 }}</span>
|
<span class="sample-card__seq">{{ sIdx + 1 }}</span>
|
||||||
{{ sampleTypeName(row.sampleTypeId) }}
|
{{ sampleTypeName(row.sampleTypeId) }}
|
||||||
</div>
|
</div>
|
||||||
<el-tag :type="sampleStatusTagType(String(row.sampleStatus || ''))" size="small">
|
<SampleStatusTag
|
||||||
{{ sampleStatusLabel(String(row.sampleStatus || '')) }}
|
:status="row.sampleStatus"
|
||||||
</el-tag>
|
:void-desc="row.voidDesc"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="sample-card__body">
|
<div class="sample-card__body">
|
||||||
<div class="sample-card__section">
|
<div class="sample-card__section">
|
||||||
@@ -1254,6 +1255,7 @@
|
|||||||
import SampleQcInfoGroupedPanel from '@/components/business/sample-qc-info-grouped-panel/index.vue'
|
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 SampleReceptionDualReadonlyPanel from '@/components/business/sample-reception-dual-readonly-panel/index.vue'
|
||||||
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/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 SampleProductionInfoCards from '@/components/business/sample-production-info-cards/index.vue'
|
||||||
import SampleStorageReleaseInfo from '@/components/business/sample-storage-release-info/index.vue'
|
import SampleStorageReleaseInfo from '@/components/business/sample-storage-release-info/index.vue'
|
||||||
import ProtocolHandlePanel from '@/components/business/protocol-handle-panel/index.vue'
|
import ProtocolHandlePanel from '@/components/business/protocol-handle-panel/index.vue'
|
||||||
@@ -1284,8 +1286,6 @@
|
|||||||
payModeTagType,
|
payModeTagType,
|
||||||
newbornSexLabel,
|
newbornSexLabel,
|
||||||
deliveryModeLabel,
|
deliveryModeLabel,
|
||||||
sampleStatusLabel,
|
|
||||||
sampleStatusTagType,
|
|
||||||
transportTypeLabel,
|
transportTypeLabel,
|
||||||
payStatusLabel,
|
payStatusLabel,
|
||||||
payStatusTagType
|
payStatusTagType
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<!-- 器械销售占位页:施工中 -->
|
||||||
|
<template>
|
||||||
|
<div class="page-container under-construction-page">
|
||||||
|
<section class="panel under-construction-panel">
|
||||||
|
<img
|
||||||
|
class="under-construction-img"
|
||||||
|
src="@/assets/images/common/under-construction.jpg"
|
||||||
|
alt="正在施工"
|
||||||
|
/>
|
||||||
|
<p class="under-construction-title">{{ pageTitle }}</p>
|
||||||
|
<p class="under-construction-hint">待完善</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
defineOptions({ name: 'DeviceSalesUnderConstruction' })
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const pageTitle = computed(() => String(route.meta?.title || '器械销售'))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.under-construction-page {
|
||||||
|
min-height: calc(100vh - 140px);
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.under-construction-panel {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 48px 24px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.under-construction-img {
|
||||||
|
width: min(420px, 70vw);
|
||||||
|
max-height: 280px;
|
||||||
|
object-fit: contain;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.under-construction-title {
|
||||||
|
margin: 8px 0 0;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.under-construction-hint {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #10b981;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+1
-1
@@ -288,7 +288,7 @@
|
|||||||
const contextSections: ViewSection[] = basic
|
const contextSections: ViewSection[] = basic
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
title: '基础实验申请信息',
|
title: '临床科研申请信息',
|
||||||
fields: [
|
fields: [
|
||||||
{ label: '申请单号', value: app.applicationNo || d.applicationNo || '—' },
|
{ label: '申请单号', value: app.applicationNo || d.applicationNo || '—' },
|
||||||
{ label: '课题名称', value: app.projectTitle || d.projectTitle || '—' },
|
{ label: '课题名称', value: app.projectTitle || d.projectTitle || '—' },
|
||||||
|
|||||||
+1
-1
@@ -256,7 +256,7 @@
|
|||||||
total: number
|
total: number
|
||||||
selectedIds: string[]
|
selectedIds: string[]
|
||||||
pickupTimeLabel: string
|
pickupTimeLabel: string
|
||||||
/** 中试/临床展示患者;基础实验展示课题与客户 */
|
/** 中试/临床展示患者;临床科研展示课题与客户 */
|
||||||
showPatient?: boolean
|
showPatient?: boolean
|
||||||
bizType?: string
|
bizType?: string
|
||||||
}>()
|
}>()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<!-- 中试/临床/基础实验申请单页:Tab 由 bizType 策略配置驱动 -->
|
<!-- 中试/临床/临床科研申请单页:Tab 由 bizType 策略配置驱动 -->
|
||||||
<template>
|
<template>
|
||||||
<div class="page-container">
|
<div class="page-container">
|
||||||
<section class="panel">
|
<section class="panel">
|
||||||
|
|||||||
@@ -499,6 +499,7 @@
|
|||||||
receptionSource: row.receptionSource,
|
receptionSource: row.receptionSource,
|
||||||
protocolSampleId: row.protocolSampleId,
|
protocolSampleId: row.protocolSampleId,
|
||||||
sampleCode: row.sampleCode,
|
sampleCode: row.sampleCode,
|
||||||
|
labStorageCode: row.labStorageCode,
|
||||||
collectionProtocolId: row.collectionProtocolId,
|
collectionProtocolId: row.collectionProtocolId,
|
||||||
fallbackSource: productionVoidFallbackSource(row)
|
fallbackSource: productionVoidFallbackSource(row)
|
||||||
})
|
})
|
||||||
@@ -509,6 +510,7 @@
|
|||||||
receptionSource: row.receptionSource,
|
receptionSource: row.receptionSource,
|
||||||
protocolSampleId: row.protocolSampleId,
|
protocolSampleId: row.protocolSampleId,
|
||||||
sampleCode: row.sampleCode,
|
sampleCode: row.sampleCode,
|
||||||
|
labStorageCode: row.labStorageCode,
|
||||||
collectionProtocolId: row.collectionProtocolId,
|
collectionProtocolId: row.collectionProtocolId,
|
||||||
fallbackSource: productionVoidFallbackSource(row)
|
fallbackSource: productionVoidFallbackSource(row)
|
||||||
})
|
})
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
<!-- 基础实验生产工单 — 查看详情 -->
|
<!-- 临床科研生产工单 — 查看详情 -->
|
||||||
<!-- eslint-disable vue/no-v-model-argument -->
|
<!-- eslint-disable vue/no-v-model-argument -->
|
||||||
<template>
|
<template>
|
||||||
<ProductionWorkOrderViewDialogFrame
|
<ProductionWorkOrderViewDialogFrame
|
||||||
v-model:visible="dialogVisible"
|
v-model:visible="dialogVisible"
|
||||||
title="基础实验生产工单详情"
|
title="临床科研生产工单详情"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:detail="detail"
|
:detail="detail"
|
||||||
:sections="sections"
|
:sections="sections"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const assignmentTabs: { key: AssignmentBizType; title: string }[] = [
|
|||||||
{ key: 'cell_storage', title: '细胞存储' },
|
{ key: 'cell_storage', title: '细胞存储' },
|
||||||
{ key: 'research_donation', title: '科研捐赠' },
|
{ key: 'research_donation', title: '科研捐赠' },
|
||||||
{ key: 'pilot_service', title: '中试服务' },
|
{ key: 'pilot_service', title: '中试服务' },
|
||||||
{ key: 'basic_experiment', title: '基础实验' }
|
{ key: 'basic_experiment', title: '临床科研' }
|
||||||
]
|
]
|
||||||
|
|
||||||
const collectionColumns: AssignmentColumn[] = [
|
const collectionColumns: AssignmentColumn[] = [
|
||||||
|
|||||||
+14
-13
@@ -154,6 +154,7 @@
|
|||||||
type QcTaskResultItem
|
type QcTaskResultItem
|
||||||
} from '@/api/qc-task-result'
|
} from '@/api/qc-task-result'
|
||||||
import { taskStatusLabel, taskStatusTagType } from '@/utils/qc-labels'
|
import { taskStatusLabel, taskStatusTagType } from '@/utils/qc-labels'
|
||||||
|
import { resolveThirdPartyFillDefaults } from '@/utils/qc-result-fill-defaults'
|
||||||
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
||||||
import {
|
import {
|
||||||
pickSharedRemarkAndAttachments,
|
pickSharedRemarkAndAttachments,
|
||||||
@@ -233,16 +234,6 @@
|
|||||||
emit('update:visible', false)
|
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[] {
|
function normalizeResultParams(items: QcTaskResultItem[]): QcTaskResultItem[] {
|
||||||
return (items || []).map((p) => ({
|
return (items || []).map((p) => ({
|
||||||
...p,
|
...p,
|
||||||
@@ -319,13 +310,17 @@
|
|||||||
companyId: detail?.companyId ?? task.companyId,
|
companyId: detail?.companyId ?? task.companyId,
|
||||||
companyName: detail?.companyName ?? task.companyName
|
companyName: detail?.companyName ?? task.companyName
|
||||||
}
|
}
|
||||||
|
const fillDefaults = resolveThirdPartyFillDefaults({
|
||||||
|
taskStatus: merged.taskStatus,
|
||||||
|
conclusion: merged.conclusion
|
||||||
|
})
|
||||||
const item: ItemState = {
|
const item: ItemState = {
|
||||||
taskId: task.id,
|
taskId: task.id,
|
||||||
itemName: merged.itemName || '—',
|
itemName: merged.itemName || '—',
|
||||||
companyName: thirdPartyCompanyDisplayName(merged),
|
companyName: thirdPartyCompanyDisplayName(merged),
|
||||||
params: normalizeResultParams(results || []),
|
params: normalizeResultParams(results || []),
|
||||||
saveStatus: normalizeThirdPartySaveStatus(merged.taskStatus),
|
saveStatus: fillDefaults.saveStatus,
|
||||||
conclusion: normalizeConclusion(merged.conclusion)
|
conclusion: fillDefaults.conclusion
|
||||||
}
|
}
|
||||||
return { item, merged }
|
return { item, merged }
|
||||||
})
|
})
|
||||||
@@ -385,6 +380,11 @@
|
|||||||
|
|
||||||
const thirdPartyAttachments = financeAttachmentsToUrlString(attachments.value)
|
const thirdPartyAttachments = financeAttachmentsToUrlString(attachments.value)
|
||||||
const remarkVal = remark.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
|
saving.value = true
|
||||||
const failures: string[] = []
|
const failures: string[] = []
|
||||||
let successCount = 0
|
let successCount = 0
|
||||||
@@ -404,7 +404,8 @@
|
|||||||
})),
|
})),
|
||||||
remark: remarkVal,
|
remark: remarkVal,
|
||||||
thirdPartyAttachments,
|
thirdPartyAttachments,
|
||||||
taskStatus: item.saveStatus
|
taskStatus: item.saveStatus,
|
||||||
|
operateBatchId
|
||||||
},
|
},
|
||||||
props.operateScope
|
props.operateScope
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,445 @@
|
|||||||
|
<!-- 质检任务 · 检测结果修改记录 -->
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
:model-value="visible"
|
||||||
|
:title="dialogTitle"
|
||||||
|
width="800px"
|
||||||
|
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" body-class="qc-result-chg-body">
|
||||||
|
<el-empty
|
||||||
|
v-if="!loading && !timelineNodes.length"
|
||||||
|
description="暂无修改记录"
|
||||||
|
:image-size="72"
|
||||||
|
/>
|
||||||
|
<div v-else class="qc-result-chg-tl">
|
||||||
|
<div
|
||||||
|
v-for="(node, idx) in timelineNodes"
|
||||||
|
:key="node.key"
|
||||||
|
class="qc-result-chg-tl__item"
|
||||||
|
>
|
||||||
|
<div class="qc-result-chg-tl__rail">
|
||||||
|
<span class="qc-result-chg-tl__dot" />
|
||||||
|
<span v-if="idx < timelineNodes.length - 1" class="qc-result-chg-tl__line" />
|
||||||
|
</div>
|
||||||
|
<div class="qc-result-chg-tl__content">
|
||||||
|
<div class="qc-result-chg-tl__meta">
|
||||||
|
{{ node.operateTime || '—' }} · {{ node.operatorUserName || '—' }}
|
||||||
|
<template v-if="node.entries.length > 1">
|
||||||
|
· 共 {{ node.entries.length }} 项
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="node.sharedAttachment" class="qc-result-chg-tl__change">
|
||||||
|
<div class="qc-result-chg-tl__line-text">
|
||||||
|
{{ node.sharedAttachment.fieldLabel }}:
|
||||||
|
<template
|
||||||
|
v-if="
|
||||||
|
node.sharedAttachment.oldValue &&
|
||||||
|
node.sharedAttachment.oldValue !== node.sharedAttachment.newValue
|
||||||
|
"
|
||||||
|
>
|
||||||
|
已更新
|
||||||
|
</template>
|
||||||
|
<template v-else-if="!node.sharedAttachment.newValue">已清空</template>
|
||||||
|
</div>
|
||||||
|
<ProtocolAttachmentReadonly
|
||||||
|
v-if="attachmentFilesFromValue(node.sharedAttachment.newValue).length"
|
||||||
|
size="compact"
|
||||||
|
:files="attachmentFilesFromValue(node.sharedAttachment.newValue)"
|
||||||
|
@preview="onAttachmentPreview"
|
||||||
|
@download="onAttachmentDownload"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
v-else-if="!node.sharedAttachment.newValue"
|
||||||
|
class="qc-result-chg-tl__line-text"
|
||||||
|
>—</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-for="entry in node.entries"
|
||||||
|
:key="entry.id"
|
||||||
|
class="qc-result-chg-tl__entry"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="showItemName && entry.itemName"
|
||||||
|
class="qc-result-chg-tl__item-name"
|
||||||
|
>
|
||||||
|
{{ entry.itemName }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-if="visibleChanges(entry, node).length">
|
||||||
|
<div
|
||||||
|
v-for="(chg, cIdx) in visibleChanges(entry, node)"
|
||||||
|
:key="`${entry.id}-${cIdx}`"
|
||||||
|
class="qc-result-chg-tl__change"
|
||||||
|
>
|
||||||
|
<template v-if="isAttachmentChange(chg)">
|
||||||
|
<div class="qc-result-chg-tl__line-text">
|
||||||
|
{{ chg.fieldLabel }}:
|
||||||
|
<template v-if="chg.oldValue && chg.oldValue !== chg.newValue">
|
||||||
|
已更新
|
||||||
|
</template>
|
||||||
|
<template v-else-if="!chg.newValue">已清空</template>
|
||||||
|
</div>
|
||||||
|
<ProtocolAttachmentReadonly
|
||||||
|
v-if="attachmentFilesFromValue(chg.newValue).length"
|
||||||
|
size="compact"
|
||||||
|
:files="attachmentFilesFromValue(chg.newValue)"
|
||||||
|
@preview="onAttachmentPreview"
|
||||||
|
@download="onAttachmentDownload"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
v-else-if="!chg.newValue"
|
||||||
|
class="qc-result-chg-tl__line-text"
|
||||||
|
>—</span>
|
||||||
|
</template>
|
||||||
|
<div v-else 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>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div
|
||||||
|
v-else-if="!entry.hasFieldChange || !entry.changes?.length"
|
||||||
|
class="qc-result-chg-tl__line-text"
|
||||||
|
>
|
||||||
|
保存操作(字段无变更)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="node.allNoFieldChange" 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 ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
||||||
|
import { downloadAttachmentFile } from '@/utils/download-attachment'
|
||||||
|
import {
|
||||||
|
qcAttachmentFullUrl,
|
||||||
|
qcPreviewAttachment
|
||||||
|
} from './composables/useQcViewAttachmentHelpers'
|
||||||
|
import {
|
||||||
|
fetchQcTaskResultChangeLogsBatch,
|
||||||
|
type QcTaskResultChangeItem,
|
||||||
|
type QcTaskResultChangeLog
|
||||||
|
} from '@/api/qc-task-result'
|
||||||
|
|
||||||
|
defineOptions({ name: 'QcTaskResultChangeLogDialog' })
|
||||||
|
|
||||||
|
type TimelineNode = {
|
||||||
|
key: string
|
||||||
|
operateTime: string
|
||||||
|
operatorUserName: string
|
||||||
|
entries: QcTaskResultChangeLog[]
|
||||||
|
allNoFieldChange: boolean
|
||||||
|
/** 多任务同次提交且检测材料一致时,提到节点级只展示一次 */
|
||||||
|
sharedAttachment: QcTaskResultChangeItem | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 无批次号的旧数据:同操作人且时间差 ≤15s 合并为一次提交 */
|
||||||
|
const LEGACY_GROUP_WINDOW_MS = 15_000
|
||||||
|
|
||||||
|
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}` : '修改记录'
|
||||||
|
})
|
||||||
|
|
||||||
|
const timelineNodes = computed(() => groupChangeLogs(entries.value))
|
||||||
|
|
||||||
|
function onVisibleChange(v: boolean) {
|
||||||
|
emit('update:visible', v)
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
emit('update:visible', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
function isAttachmentChange(chg: QcTaskResultChangeItem) {
|
||||||
|
return (chg.fieldKey || '') === 'attachments'
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickSharedAttachment(rows: QcTaskResultChangeLog[]) {
|
||||||
|
if (rows.length < 2) return null
|
||||||
|
const attChanges = rows
|
||||||
|
.map((r) => (r.changes || []).find((c) => isAttachmentChange(c)))
|
||||||
|
.filter(Boolean) as QcTaskResultChangeItem[]
|
||||||
|
if (!attChanges.length || attChanges.length !== rows.length) return null
|
||||||
|
const first = attChanges[0]
|
||||||
|
const same = attChanges.every(
|
||||||
|
(c) => c.newValue === first.newValue && c.oldValue === first.oldValue
|
||||||
|
)
|
||||||
|
return same ? first : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function visibleChanges(entry: QcTaskResultChangeLog, node: TimelineNode) {
|
||||||
|
const list = entry.changes || []
|
||||||
|
if (!node.sharedAttachment) return list
|
||||||
|
return list.filter((c) => !isAttachmentChange(c))
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachmentFilesFromValue(raw: string | undefined) {
|
||||||
|
const text = String(raw || '').trim()
|
||||||
|
if (!text) return [] as Array<Record<string, unknown>>
|
||||||
|
return text
|
||||||
|
.split(',')
|
||||||
|
.map((u, i) => {
|
||||||
|
const url = u.trim()
|
||||||
|
if (!url) return null
|
||||||
|
const name = url.includes('/') ? url.split('/').pop() || `附件${i + 1}` : url
|
||||||
|
return {
|
||||||
|
id: `chg_att_${i}_${name}`,
|
||||||
|
fileUrl: url,
|
||||||
|
fileName: name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Boolean) as Array<Record<string, unknown>>
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAttachmentPreview(file: Record<string, unknown>) {
|
||||||
|
qcPreviewAttachment(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAttachmentDownload(file: Record<string, unknown>) {
|
||||||
|
downloadAttachmentFile(file, { fullFileUrl: qcAttachmentFullUrl })
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseOperateTimeMs(text: string | undefined) {
|
||||||
|
const s = String(text || '').trim()
|
||||||
|
if (!s) return NaN
|
||||||
|
const t = Date.parse(s.replace(/-/g, '/'))
|
||||||
|
return Number.isFinite(t) ? t : NaN
|
||||||
|
}
|
||||||
|
|
||||||
|
function groupChangeLogs(list: QcTaskResultChangeLog[]): TimelineNode[] {
|
||||||
|
const sorted = [...(list || [])].sort((a, b) => {
|
||||||
|
const tb = parseOperateTimeMs(b.operateTime)
|
||||||
|
const ta = parseOperateTimeMs(a.operateTime)
|
||||||
|
if (Number.isFinite(tb) && Number.isFinite(ta) && tb !== ta) return tb - ta
|
||||||
|
return String(b.id || '').localeCompare(String(a.id || ''))
|
||||||
|
})
|
||||||
|
|
||||||
|
const batchBuckets = new Map<string, QcTaskResultChangeLog[]>()
|
||||||
|
const orphans: QcTaskResultChangeLog[] = []
|
||||||
|
for (const row of sorted) {
|
||||||
|
const batch = String(row.operateBatchId || '').trim()
|
||||||
|
if (batch) {
|
||||||
|
const arr = batchBuckets.get(batch) || []
|
||||||
|
arr.push(row)
|
||||||
|
batchBuckets.set(batch, arr)
|
||||||
|
} else {
|
||||||
|
orphans.push(row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const nodes: TimelineNode[] = []
|
||||||
|
for (const [batch, rows] of batchBuckets) {
|
||||||
|
nodes.push(toNode(`batch:${batch}`, rows))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 旧数据兜底:按时间序贪心合并同操作人短窗口
|
||||||
|
const used = new Set<string>()
|
||||||
|
for (let i = 0; i < orphans.length; i++) {
|
||||||
|
const head = orphans[i]
|
||||||
|
if (used.has(head.id)) continue
|
||||||
|
const group = [head]
|
||||||
|
used.add(head.id)
|
||||||
|
const headTs = parseOperateTimeMs(head.operateTime)
|
||||||
|
const headOp = String(head.operatorUserId || head.operatorUserName || '')
|
||||||
|
for (let j = i + 1; j < orphans.length; j++) {
|
||||||
|
const cur = orphans[j]
|
||||||
|
if (used.has(cur.id)) continue
|
||||||
|
const curOp = String(cur.operatorUserId || cur.operatorUserName || '')
|
||||||
|
if (curOp !== headOp) continue
|
||||||
|
const curTs = parseOperateTimeMs(cur.operateTime)
|
||||||
|
if (!Number.isFinite(headTs) || !Number.isFinite(curTs)) continue
|
||||||
|
if (Math.abs(curTs - headTs) > LEGACY_GROUP_WINDOW_MS) continue
|
||||||
|
group.push(cur)
|
||||||
|
used.add(cur.id)
|
||||||
|
}
|
||||||
|
nodes.push(toNode(`legacy:${head.id}`, group))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodes.sort((a, b) => {
|
||||||
|
const tb = parseOperateTimeMs(b.operateTime)
|
||||||
|
const ta = parseOperateTimeMs(a.operateTime)
|
||||||
|
if (Number.isFinite(tb) && Number.isFinite(ta) && tb !== ta) return tb - ta
|
||||||
|
return a.key.localeCompare(b.key)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function toNode(key: string, rows: QcTaskResultChangeLog[]): TimelineNode {
|
||||||
|
const first = rows[0]
|
||||||
|
return {
|
||||||
|
key,
|
||||||
|
operateTime: first?.operateTime || '',
|
||||||
|
operatorUserName: first?.operatorUserName || '',
|
||||||
|
entries: rows,
|
||||||
|
allNoFieldChange: rows.every((r) => !r.hasFieldChange),
|
||||||
|
sharedAttachment: pickSharedAttachment(rows)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ? await fetchQcTaskResultChangeLogsBatch(ids) : []
|
||||||
|
if (seq !== loadSeq) return
|
||||||
|
entries.value = Array.isArray(list) ? 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">
|
||||||
|
:deep(.qc-result-chg-body) {
|
||||||
|
min-height: 480px;
|
||||||
|
max-height: min(70vh, 640px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qc-result-chg-tl {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px 0 8px;
|
||||||
|
min-height: 420px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qc-result-chg-tl__entry {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.qc-result-chg-tl__item-name {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--mint-text, #1e293b);
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qc-result-chg-tl__change {
|
||||||
|
margin: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--mint-text-muted, #334155);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<!-- 质检工单 · 用户费用摘要条(采集协议 / 基础实验) -->
|
<!-- 质检工单 · 用户费用摘要条(采集协议 / 临床科研) -->
|
||||||
<template>
|
<template>
|
||||||
<div v-if="visible" class="qc-fee-summary">
|
<div v-if="visible" class="qc-fee-summary">
|
||||||
<span class="qc-fee-summary__label">{{ label }}</span>
|
<span class="qc-fee-summary__label">{{ label }}</span>
|
||||||
|
|||||||
@@ -419,6 +419,7 @@
|
|||||||
receptionSource: props.row.receptionSource,
|
receptionSource: props.row.receptionSource,
|
||||||
protocolSampleId: props.row.protocolSampleId,
|
protocolSampleId: props.row.protocolSampleId,
|
||||||
sampleCode: props.row.sampleCode,
|
sampleCode: props.row.sampleCode,
|
||||||
|
labStorageCode: props.row.labStorageCode,
|
||||||
collectionProtocolId: props.row.collectionProtocolId,
|
collectionProtocolId: props.row.collectionProtocolId,
|
||||||
fallbackSource: inboundVoidFallbackSource()
|
fallbackSource: inboundVoidFallbackSource()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,6 +33,16 @@
|
|||||||
@click="openAllThirdResult(item)"
|
@click="openAllThirdResult(item)"
|
||||||
@dblclick="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">
|
<div class="qc-task-card__line qc-task-card__line--top">
|
||||||
<span class="qc-task-card__name">{{ ALL_THIRD_PARTY_CARD_TITLE }}</span>
|
<span class="qc-task-card__name">{{ ALL_THIRD_PARTY_CARD_TITLE }}</span>
|
||||||
<div class="qc-task-card__sub">
|
<div class="qc-task-card__sub">
|
||||||
@@ -77,6 +87,16 @@
|
|||||||
class="qc-task-card qc-task-card--compact"
|
class="qc-task-card qc-task-card--compact"
|
||||||
@dblclick="handleView(item.task)"
|
@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">
|
<div class="qc-task-card__line qc-task-card__line--top">
|
||||||
<span class="qc-task-card__name">{{ item.task.itemName || '—' }}</span>
|
<span class="qc-task-card__name">{{ item.task.itemName || '—' }}</span>
|
||||||
<div class="qc-task-card__tags">
|
<div class="qc-task-card__tags">
|
||||||
@@ -414,6 +434,12 @@
|
|||||||
@saved="handleTaskMutationSuccess"
|
@saved="handleTaskMutationSuccess"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<QcTaskResultChangeLogDialog
|
||||||
|
v-model:visible="changeLogVisible"
|
||||||
|
:task-ids="changeLogTaskIds"
|
||||||
|
:title-suffix="changeLogTitleSuffix"
|
||||||
|
/>
|
||||||
|
|
||||||
<SystemViewDialog
|
<SystemViewDialog
|
||||||
v-model:visible="viewVisible"
|
v-model:visible="viewVisible"
|
||||||
title="任务详情"
|
title="任务详情"
|
||||||
@@ -575,7 +601,8 @@
|
|||||||
EditPen,
|
EditPen,
|
||||||
Plus,
|
Plus,
|
||||||
More,
|
More,
|
||||||
Delete
|
Delete,
|
||||||
|
Clock
|
||||||
} from '@element-plus/icons-vue'
|
} from '@element-plus/icons-vue'
|
||||||
import ProtocolFinanceConfirmFields from '@/components/business/protocol-finance-confirm-fields/index.vue'
|
import ProtocolFinanceConfirmFields from '@/components/business/protocol-finance-confirm-fields/index.vue'
|
||||||
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
||||||
@@ -612,6 +639,7 @@
|
|||||||
import { fetchItemUnitList } from '@/api/admin'
|
import { fetchItemUnitList } from '@/api/admin'
|
||||||
import { SHOW_QC_TASK_MATERIAL_USAGE } from '@/utils/qc-material-ui'
|
import { SHOW_QC_TASK_MATERIAL_USAGE } from '@/utils/qc-material-ui'
|
||||||
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
||||||
|
import { resolveQcResultFillDefaults } from '@/utils/qc-result-fill-defaults'
|
||||||
import {
|
import {
|
||||||
taskTypeLabel,
|
taskTypeLabel,
|
||||||
taskTypeTagType,
|
taskTypeTagType,
|
||||||
@@ -656,6 +684,7 @@
|
|||||||
type QcTaskListDisplayItem
|
type QcTaskListDisplayItem
|
||||||
} from '@/utils/qc-company-task-group'
|
} from '@/utils/qc-company-task-group'
|
||||||
import QcCompanyTaskResultDialog from './QcCompanyTaskResultDialog.vue'
|
import QcCompanyTaskResultDialog from './QcCompanyTaskResultDialog.vue'
|
||||||
|
import QcTaskResultChangeLogDialog from './QcTaskResultChangeLogDialog.vue'
|
||||||
|
|
||||||
/** 根据来源类型返回协议状态标签 */
|
/** 根据来源类型返回协议状态标签 */
|
||||||
function protocolStatusLabelBySource(status: string, source: string, voidType?: string): string {
|
function protocolStatusLabelBySource(status: string, source: string, voidType?: string): string {
|
||||||
@@ -739,6 +768,25 @@
|
|||||||
const companyDialogReadonly = ref(false)
|
const companyDialogReadonly = ref(false)
|
||||||
const companyDialogTasks = ref<QcTask[]>([])
|
const companyDialogTasks = ref<QcTask[]>([])
|
||||||
const companyDialogName = ref(ALL_THIRD_PARTY_CARD_TITLE)
|
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) {
|
function openAllThirdResult(item: QcTaskListAllThirdItem, forceReadonly?: boolean) {
|
||||||
let tasks = item.tasks
|
let tasks = item.tasks
|
||||||
@@ -864,11 +912,6 @@
|
|||||||
|
|
||||||
const resultDialogWidth = computed(() => (resultTaskType.value === 'sysz' ? '1200px' : '960px'))
|
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) {
|
function canFillResult(row: QcTask) {
|
||||||
if (row.taskType === 'sysz') {
|
if (row.taskType === 'sysz') {
|
||||||
return row.taskStatus === 'jxz' || row.taskStatus === 'ywc'
|
return row.taskStatus === 'jxz' || row.taskStatus === 'ywc'
|
||||||
@@ -1391,12 +1434,16 @@
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const initialDefaults = resolveQcResultFillDefaults({
|
||||||
|
taskStatus: row.taskStatus,
|
||||||
|
conclusion: row.conclusion
|
||||||
|
})
|
||||||
resultTaskStatus.value = row.taskStatus
|
resultTaskStatus.value = row.taskStatus
|
||||||
resultSaveStatus.value = normalizeResultSaveStatus(row.taskStatus)
|
resultSaveStatus.value = initialDefaults.saveStatus
|
||||||
resultTaskId.value = row.id
|
resultTaskId.value = row.id
|
||||||
resultTaskType.value = row.taskType
|
resultTaskType.value = row.taskType
|
||||||
resultRemark.value = row.remark || ''
|
resultRemark.value = row.remark || ''
|
||||||
resultConclusion.value = ''
|
resultConclusion.value = initialDefaults.conclusion
|
||||||
resultAttachments.value = apiFilesToFinanceItems(row.attachmentFiles)
|
resultAttachments.value = apiFilesToFinanceItems(row.attachmentFiles)
|
||||||
materialUsages.value = []
|
materialUsages.value = []
|
||||||
requisitionOptions.value = []
|
requisitionOptions.value = []
|
||||||
@@ -1404,10 +1451,13 @@
|
|||||||
try {
|
try {
|
||||||
const detail = await fetchQcTaskDetail(row.id)
|
const detail = await fetchQcTaskDetail(row.id)
|
||||||
resultTaskStatus.value = detail.taskStatus || row.taskStatus
|
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 || ''
|
resultRemark.value = detail.remark || row.remark || ''
|
||||||
const c = (detail.conclusion || '').trim()
|
resultConclusion.value = fillDefaults.conclusion
|
||||||
resultConclusion.value = c === 'tg' || c === 'btg' ? c : ''
|
|
||||||
resultAttachments.value = apiFilesToFinanceItems(detail.attachmentFiles)
|
resultAttachments.value = apiFilesToFinanceItems(detail.attachmentFiles)
|
||||||
const results = await fetchQcTaskResults(row.id)
|
const results = await fetchQcTaskResults(row.id)
|
||||||
resultParams.value = normalizeResultParams(results || [])
|
resultParams.value = normalizeResultParams(results || [])
|
||||||
@@ -1675,6 +1725,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.qc-task-card {
|
.qc-task-card {
|
||||||
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
@@ -1702,7 +1753,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 220px;
|
max-width: 220px;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 6px 8px;
|
padding: 6px 28px 6px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--company {
|
&--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 {
|
.qc-task-card__sub {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
<!-- 基础实验出库质检工单 — 查看详情 -->
|
<!-- 临床科研出库质检工单 — 查看详情 -->
|
||||||
<!-- eslint-disable vue/no-v-model-argument -->
|
<!-- eslint-disable vue/no-v-model-argument -->
|
||||||
<template>
|
<template>
|
||||||
<QcWorkOrderSystemViewDialog
|
<QcWorkOrderSystemViewDialog
|
||||||
v-model:visible="dialogVisible"
|
v-model:visible="dialogVisible"
|
||||||
title="基础实验出库质检工单详情"
|
title="临床科研出库质检工单详情"
|
||||||
width="1200px"
|
width="1200px"
|
||||||
:grid-columns="4"
|
:grid-columns="4"
|
||||||
compact
|
compact
|
||||||
|
|||||||
+1
-1
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
products?: OutboundQcDetail['products']
|
products?: OutboundQcDetail['products']
|
||||||
/** 基础实验时产品状态 dtz 展示为「待交付」 */
|
/** 临床科研时产品状态 dtz 展示为「待交付」 */
|
||||||
bizType?: string
|
bizType?: string
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in new issue
Block a user