From 9b5e68f4aeb0f1587b0f49d591cde6ae901351d9 Mon Sep 17 00:00:00 2001 From: cykj Date: Mon, 23 Nov 2026 11:47:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(market):=20=E6=96=B0=E5=A2=9E=E5=A7=94?= =?UTF-8?q?=E6=89=98=E5=8A=A0=E5=B7=A5=E4=B8=9A=E5=8A=A1=E5=B9=B6=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E4=B8=B4=E5=BA=8A=E7=A7=91=E7=A0=94=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 独立 biz_type=contract_processing,申请/缴费/出库与临床科研共用逻辑; 业务子类型支持胎盘冻干粉/脂肪外泌体/NK/MSC/其他自定义,并补充菜单与生产质检 Tab。 Co-authored-by: Cursor --- backend/app/api/pilot_application.py | 4 +- backend/app/api/project_management.py | 6 +- backend/app/constants/pilot_biz.py | 33 +++++ backend/app/constants/research_category.py | 47 ++++++- backend/app/crud/clinical_payment.py | 4 +- backend/app/crud/outbound_handover.py | 4 +- backend/app/crud/outbound_release_review.py | 1 + backend/app/crud/pilot_application.py | 39 +++--- .../app/crud/pilot_infusion_schedule_mgmt.py | 4 +- .../app/crud/pilot_outbound_status_sync.py | 2 +- backend/app/crud/production_task.py | 5 + backend/app/crud/production_work_order.py | 4 +- backend/app/crud/qc_work_order.py | 6 +- backend/app/models/models.py | 11 +- .../basic_experiment_delivery_remind.py | 2 +- backend/app/services/project_management.py | 1 + .../app/services/qc_work_order_fee_summary.py | 4 +- .../test_contract_processing_application.py | 81 ++++++++++++ ...processing-menus-and-research-category.sql | 97 ++++++++++++++ web-admin/src/api/project-management.ts | 4 +- .../index.vue | 3 +- .../index.vue | 3 +- web-admin/src/config/pilot-biz-type.ts | 55 +++++--- .../constants/clinical-research-category.ts | 33 ++++- web-admin/src/router/modules/sqxp.ts | 52 ++++++++ .../utils/outbound-qc-pilot-view-sections.ts | 25 ++-- .../src/utils/production-mine-task-groups.ts | 2 +- .../utils/production-work-order-card-meta.ts | 13 ++ .../utils/production-work-order-category.ts | 2 + .../utils/production-work-order-tabs.test.ts | 7 + .../src/utils/production-work-order-tabs.ts | 14 +- web-admin/src/utils/qc-mine-task-groups.ts | 2 +- .../src/utils/qc-work-order-card-meta.ts | 14 ++ web-admin/src/utils/qc-work-order-category.ts | 2 + .../src/utils/qc-work-order-tabs.test.ts | 7 + web-admin/src/utils/qc-work-order-tabs.ts | 18 ++- web-admin/src/utils/research-like-biz.ts | 12 ++ web-admin/src/utils/status-tag-registry.ts | 12 +- .../RefundConfirmTab.vue | 3 +- .../clinical-payment-confirm/index.vue | 3 +- .../InfusionScheduleHandoverDialog.vue | 3 +- .../ScheduleEditDialog.vue | 3 +- .../ScheduleViewDialog.vue | 4 +- .../OutboundReleaseReviewDialog.vue | 8 +- .../outbound-release-review/index.vue | 3 +- .../ApplicationFormDialog.vue | 121 ++++++++++++++++-- .../ApplicationViewDialog.vue | 3 +- .../pilot-application/ClinicalPaymentTab.vue | 3 +- .../pilot-application/InfusionScheduleTab.vue | 3 +- .../pilot-application/PilotApplicationTab.vue | 7 +- .../ProductionWorkOrderCardList.vue | 3 +- .../composables/production-view-sections.ts | 11 +- .../tabs/tab-registry.ts | 1 + .../view-dialogs/view-dialog-registry.ts | 1 + .../project-management/assignment-columns.ts | 13 +- .../project-management/statistics/index.vue | 3 +- .../qc-work-order/tabs/tab-registry.ts | 1 + .../view-dialogs/view-dialog-registry.ts | 1 + 58 files changed, 717 insertions(+), 116 deletions(-) create mode 100644 backend/app/constants/pilot_biz.py create mode 100644 backend/tests/test_contract_processing_application.py create mode 100644 docs/sql/migrations/2026-11-23-contract-processing-menus-and-research-category.sql create mode 100644 web-admin/src/utils/research-like-biz.ts diff --git a/backend/app/api/pilot_application.py b/backend/app/api/pilot_application.py index beec2552..0adcf520 100644 --- a/backend/app/api/pilot_application.py +++ b/backend/app/api/pilot_application.py @@ -383,14 +383,14 @@ async def api_save_application( if ( not is_edit - and biz_type not in ("clinical_application", "basic_experiment") + and biz_type not in ("clinical_application", "basic_experiment", "contract_processing") and not app_data["channelServiceOrderId"] ): return error_response(400, "请选择渠道服务订单") if ( not is_edit - and biz_type in ("clinical_application", "basic_experiment") + and biz_type in ("clinical_application", "basic_experiment", "contract_processing") and not app_data["channelId"] ): return error_response(400, "请选择渠道") diff --git a/backend/app/api/project_management.py b/backend/app/api/project_management.py index 8b4e7845..38d0d5eb 100644 --- a/backend/app/api/project_management.py +++ b/backend/app/api/project_management.py @@ -56,7 +56,7 @@ class ProjectBody(Body): class PreviewBody(Body): - bizType: Literal['presign', 'cell_storage', 'research_donation', 'pilot_service', 'basic_experiment'] + bizType: Literal['presign', 'cell_storage', 'research_donation', 'pilot_service', 'basic_experiment', 'contract_processing'] id: str projectId: str @@ -162,7 +162,7 @@ def records(bizType: str, page: int=Query(1, ge=1), pageSize: int=Query(20, ge=1 @router.get(PREFIX + '/statistics/records') def statistics_records( - bizType: Literal['cell_storage', 'research_donation', 'pilot_service', 'basic_experiment'], + bizType: Literal['cell_storage', 'research_donation', 'pilot_service', 'basic_experiment', 'contract_processing'], page: int = Query(1, ge=1), pageSize: int = Query(20, ge=1, le=200), teamId: Optional[str] = None, projectId: Optional[str] = None, unassigned: bool = False, status: Optional[str] = None, keyword: Optional[str] = None, @@ -182,7 +182,7 @@ def preview(body: PreviewBody, ctx=Depends(guard('project:assignment:edit')), db @router.get(PREFIX + '/assignments/records') def assignment_records( - bizType: Literal['cell_storage', 'research_donation', 'pilot_service', 'basic_experiment'], + bizType: Literal['cell_storage', 'research_donation', 'pilot_service', 'basic_experiment', 'contract_processing'], page: int = Query(1, ge=1), pageSize: int = Query(20, ge=1, le=200), teamId: Optional[str] = None, projectId: Optional[str] = None, unassigned: bool = False, status: Optional[str] = None, keyword: Optional[str] = None, diff --git a/backend/app/constants/pilot_biz.py b/backend/app/constants/pilot_biz.py new file mode 100644 index 00000000..3e175025 --- /dev/null +++ b/backend/app/constants/pilot_biz.py @@ -0,0 +1,33 @@ +"""中试/临床/科研类申请单业务类型辅助。""" +from typing import Optional + +# 临床科研与委托加工共用申请/交付/缴费/出库流程 +RESEARCH_LIKE_BIZ_TYPES = ("basic_experiment", "contract_processing") + +BIZ_TYPE_LABELS = { + "pilot_service": "中试服务", + "clinical_application": "临床应用", + "basic_experiment": "临床科研", + "contract_processing": "委托加工", +} + +APPLICATION_NO_PREFIX = { + "clinical_application": "LCSQ", + "basic_experiment": "JCSY", + "contract_processing": "WTJG", + "pilot_service": "ZSSQ", +} + + +def is_research_like_biz(biz_type: Optional[str]) -> bool: + return (biz_type or "") in RESEARCH_LIKE_BIZ_TYPES + + +def biz_type_label(biz_type: Optional[str]) -> str: + key = biz_type or "" + return BIZ_TYPE_LABELS.get(key, key or "") + + +def application_no_prefix(biz_type: Optional[str]) -> str: + key = biz_type or "pilot_service" + return APPLICATION_NO_PREFIX.get(key, APPLICATION_NO_PREFIX["pilot_service"]) diff --git a/backend/app/constants/research_category.py b/backend/app/constants/research_category.py index 6e2004b0..d1b609b5 100644 --- a/backend/app/constants/research_category.py +++ b/backend/app/constants/research_category.py @@ -1,14 +1,33 @@ -"""临床科研申请单 · 业务子类型(research_category)""" +"""申请单业务子类型(research_category)。 + +临床科研保留历史三项;委托加工使用产品四项,并支持「其他」自定义文本。 +""" from typing import Optional -RESEARCH_CATEGORY_LABELS = { +from app.constants.pilot_biz import is_research_like_biz + +CLINICAL_RESEARCH_CATEGORY_LABELS = { "bio_tech_clinical": "生物新技术临床科研", "joint_topic_declare": "临床课题联合申报", "bio_pharma_rd": "生物制药研发", } +CONTRACT_PROCESSING_CATEGORY_LABELS = { + "placenta_freeze_dried": "胎盘冻干粉", + "adipose_exosome": "脂肪外泌体", + "nk": "NK", + "msc": "MSC", +} + +# 兼容旧导入名 +RESEARCH_CATEGORY_LABELS = { + **CLINICAL_RESEARCH_CATEGORY_LABELS, + **CONTRACT_PROCESSING_CATEGORY_LABELS, +} RESEARCH_CATEGORY_CODES = tuple(RESEARCH_CATEGORY_LABELS.keys()) +CUSTOM_CATEGORY_MAX_LEN = 64 + def research_category_label(code: Optional[str]) -> str: if not code: @@ -16,12 +35,34 @@ def research_category_label(code: Optional[str]) -> str: return RESEARCH_CATEGORY_LABELS.get(code, code) -def validate_research_category(code: Optional[str], required: bool = False) -> str: +def validate_research_category( + code: Optional[str], + required: bool = False, + *, + biz_type: Optional[str] = "basic_experiment", +) -> str: value = (code or "").strip() if not value: if required: raise ValueError("请选择业务类型") return "" + + bt = biz_type or "basic_experiment" + if bt == "contract_processing": + if value in CONTRACT_PROCESSING_CATEGORY_LABELS: + return value + if len(value) > CUSTOM_CATEGORY_MAX_LEN: + raise ValueError(f"业务类型不能超过{CUSTOM_CATEGORY_MAX_LEN}个字符") + # 「其他」:存自定义原文;禁止仅用保留码占位 + if value in CLINICAL_RESEARCH_CATEGORY_LABELS: + raise ValueError("业务类型无效") + return value + + if is_research_like_biz(bt) or bt == "basic_experiment": + if value not in CLINICAL_RESEARCH_CATEGORY_LABELS: + raise ValueError("业务类型无效") + return value + if value not in RESEARCH_CATEGORY_LABELS: raise ValueError("业务类型无效") return value diff --git a/backend/app/crud/clinical_payment.py b/backend/app/crud/clinical_payment.py index cef17fa2..94d9c435 100644 --- a/backend/app/crud/clinical_payment.py +++ b/backend/app/crud/clinical_payment.py @@ -100,14 +100,14 @@ def _enrich_payment(db: Session, row: BizPilotPayment) -> Dict[str, Any]: "applicationNo": app_row.application_no if app_row else "", "applicationName": app_row.application_name if app_row else "", "channelName": app_row.channel_name if app_row else "", - "patientName": "" if app_biz == "basic_experiment" else (patient_row.patient_name if patient_row else ""), + "patientName": "" if app_biz in ("basic_experiment", "contract_processing") else (patient_row.patient_name if patient_row else ""), "cellType": cell_type, "specText": spec_text, "cellTypeSpec": cell_type_spec, "paymentAmount": float(row.amount) if row.amount else 0, "infusionTime": schedule_row.infusion_time.strftime("%Y-%m-%d %H:%M:%S") if schedule_row and schedule_row.infusion_time else "", } - if app_biz == "basic_experiment" and app_row: + if app_biz in ("basic_experiment", "contract_processing") and app_row: extra["projectTitle"] = app_row.project_title or "" extra["customerName"] = app_row.customer_name or "" extra["customerContact"] = app_row.customer_contact or "" diff --git a/backend/app/crud/outbound_handover.py b/backend/app/crud/outbound_handover.py index dbce866c..51726cd3 100644 --- a/backend/app/crud/outbound_handover.py +++ b/backend/app/crud/outbound_handover.py @@ -187,7 +187,7 @@ def save_outbound_handover( if not biz_type: biz_type = ((detail.get("application") or {}).get("bizType") or "").strip() # 临床科研:细胞出库由生产工单确认,市场交接只维护物料/交接信息 - cells_owned_by_production = biz_type == "basic_experiment" + cells_owned_by_production = biz_type in ("basic_experiment", "contract_processing") # 读取保存前台账,用于回滚上次出库交接的库存/状态变更 previous_material = orm_material_svc.get_outbound_material(db, schedule_id, tenant_no) @@ -278,7 +278,7 @@ def _assert_basic_experiment_outbound_wo(wo: Any) -> str: raise HTTPException(status_code=404, detail="工单不存在") if (getattr(wo, "work_order_type", None) or "") != "outbound": raise HTTPException(status_code=400, detail="仅出库工单可确认出库细胞") - if (getattr(wo, "biz_type", None) or "") != "basic_experiment": + if (getattr(wo, "biz_type", None) or "") not in ("basic_experiment", "contract_processing"): raise HTTPException(status_code=400, detail="仅临床科研出库工单可确认出库细胞") if (getattr(wo, "work_order_status", None) or "") == "yzf": raise HTTPException(status_code=400, detail="已作废工单不可确认出库细胞") diff --git a/backend/app/crud/outbound_release_review.py b/backend/app/crud/outbound_release_review.py index 2c304e33..681e07b8 100644 --- a/backend/app/crud/outbound_release_review.py +++ b/backend/app/crud/outbound_release_review.py @@ -42,6 +42,7 @@ _BIZ_TYPE_LABELS = { "pilot_service": "中试服务", "clinical_application": "临床应用", "basic_experiment": "临床科研", + "contract_processing": "委托加工", } diff --git a/backend/app/crud/pilot_application.py b/backend/app/crud/pilot_application.py index 498ad1ef..0730d9ce 100644 --- a/backend/app/crud/pilot_application.py +++ b/backend/app/crud/pilot_application.py @@ -25,6 +25,7 @@ from app.models.models import ( ) from app.crud import pilot_checkup from app.crud.collection_protocol import attachments_to_urls, urls_to_attachment_list +from app.constants.pilot_biz import application_no_prefix, is_research_like_biz from app.constants.research_category import validate_research_category @@ -77,12 +78,7 @@ def _release_application_no_for_soft_delete(application_no: str, row_id: str) -> def _generate_application_no(db: Session, tenant_no: str, biz_type: str = "pilot_service") -> str: today_str = datetime.now().strftime("%Y%m%d") - if biz_type == "clinical_application": - prefix = f"LCSQ{today_str}" - elif biz_type == "basic_experiment": - prefix = f"JCSY{today_str}" - else: - prefix = f"ZSSQ{today_str}" + prefix = f"{application_no_prefix(biz_type)}{today_str}" existing = ( db.query(BizPilotApplication.application_no) .filter( @@ -425,7 +421,10 @@ def get_application(db: Session, app_id: str, tenant_no: str) -> Optional[Dict[s plan_id = plan.get("id") if plan_id: result["infusionSchedules"] = list_schedules_by_plan(db, plan_id, tenant_no) - if row.biz_type in ("clinical_application", "basic_experiment") and result["infusionSchedules"]: + if ( + row.biz_type in ("clinical_application", "basic_experiment", "contract_processing") + and result["infusionSchedules"] + ): from app.crud import clinical_payment payment_map = clinical_payment.map_payments_by_schedule_id( @@ -460,7 +459,7 @@ def create_application( research_category = "" consent_form_urls = data.get("consentFormUrls") or None - if biz_type == "basic_experiment": + if is_research_like_biz(biz_type): if not (data.get("projectTitle") or "").strip(): raise ValueError("请填写课题名称") if not (data.get("customerName") or "").strip(): @@ -470,7 +469,7 @@ def create_application( if not (data.get("customerPhone") or "").strip(): raise ValueError("请填写客户联系方式") research_category = validate_research_category( - data.get("researchCategory"), required=True + data.get("researchCategory"), required=True, biz_type=biz_type ) project_title = (data.get("projectTitle") or "").strip() customer_name = (data.get("customerName") or "").strip() @@ -607,16 +606,21 @@ def update_application(db: Session, app_id: str, data: dict, tenant_no: str) -> if "customerPhone" in data and data["customerPhone"] is not None: row.customer_phone = (data["customerPhone"] or "").strip() or None if "researchCategory" in data and data["researchCategory"] is not None: - if (row.biz_type or "") == "basic_experiment": + row_biz = row.biz_type or "" + if is_research_like_biz(row_biz): row.research_category = validate_research_category( - data.get("researchCategory"), required=True + data.get("researchCategory"), required=True, biz_type=row_biz ) or None else: row.research_category = validate_research_category( - data.get("researchCategory"), required=False + data.get("researchCategory"), required=False, biz_type=row_biz ) or None if "channelId" in data and data["channelId"] is not None: - if (row.biz_type or "") in ("basic_experiment", "clinical_application"): + if (row.biz_type or "") in ( + "basic_experiment", + "contract_processing", + "clinical_application", + ): new_channel_id = (data.get("channelId") or "").strip() if not new_channel_id: raise ValueError("请选择渠道") @@ -633,7 +637,7 @@ def update_application(db: Session, app_id: str, data: dict, tenant_no: str) -> raise ValueError("渠道不存在") row.channel_id = new_channel_id row.channel_name = ch.channel_name or "" - if (row.biz_type or "") == "basic_experiment": + if is_research_like_biz(row.biz_type): row.channel_service_order_id = "" if "consentFormUrls" in data: row.consent_form_urls = data.get("consentFormUrls") or None @@ -1391,7 +1395,8 @@ def create_schedule( application = _app if ( application - and application.biz_type in ("clinical_application", "basic_experiment") + and application.biz_type + in ("clinical_application", "basic_experiment", "contract_processing") and data.get("amount") ): from app.crud.clinical_payment import auto_create_payment @@ -1708,8 +1713,8 @@ def create_basic_experiment_sale_schedules( ) if not app: raise ValueError("申请单不存在") - if (app.biz_type or "") != "basic_experiment": - raise ValueError("仅临床科研申请单可批量创建售卖计划") + if not is_research_like_biz(app.biz_type): + raise ValueError("仅临床科研/委托加工申请单可批量创建售卖计划") if not product_lines: raise ValueError("请至少添加一行售卖产品") diff --git a/backend/app/crud/pilot_infusion_schedule_mgmt.py b/backend/app/crud/pilot_infusion_schedule_mgmt.py index c860d4b0..3386a591 100644 --- a/backend/app/crud/pilot_infusion_schedule_mgmt.py +++ b/backend/app/crud/pilot_infusion_schedule_mgmt.py @@ -560,7 +560,7 @@ def get_infusion_schedule_detail( "outboundHandover": handover_svc.get_outbound_handover_view(db, schedule_id, tenant_no), "infusionConfirm": confirm_svc.get_confirm_by_schedule(db, schedule_id, tenant_no) or {}, } - if application and (application.biz_type or "") in ("clinical_application", "basic_experiment"): + if application and (application.biz_type or "") in ("clinical_application", "basic_experiment", "contract_processing"): from app.crud import clinical_payment payment = clinical_payment.get_payment_by_schedule( @@ -919,7 +919,7 @@ def _deduct_fee_on_complete(db: Session, schedule_id: str, tenant_no: str, user_ raise ValueError("中试申请单不存在") # 临床应用/临床科研走缴费模块,不走服务订单扣费 - if (application.biz_type or "") in ("clinical_application", "basic_experiment"): + if (application.biz_type or "") in ("clinical_application", "basic_experiment", "contract_processing"): return if not application.channel_service_order_id: diff --git a/backend/app/crud/pilot_outbound_status_sync.py b/backend/app/crud/pilot_outbound_status_sync.py index fa1fa235..e50ca3a9 100644 --- a/backend/app/crud/pilot_outbound_status_sync.py +++ b/backend/app/crud/pilot_outbound_status_sync.py @@ -13,7 +13,7 @@ from app.models.models import ( ) -_OUTBOUND_BIZ_TYPES = ("pilot_service", "clinical_application", "basic_experiment") +_OUTBOUND_BIZ_TYPES = ("pilot_service", "clinical_application", "basic_experiment", "contract_processing") def _is_pilot_outbound_production(wo: BizProductionWorkOrder) -> bool: diff --git a/backend/app/crud/production_task.py b/backend/app/crud/production_task.py index 5fedfd84..0ddd9e29 100644 --- a/backend/app/crud/production_task.py +++ b/backend/app/crud/production_task.py @@ -91,6 +91,8 @@ _RECEPTION_SOURCE_LABELS = { _OUTBOUND_BIZ_TYPE_LABELS = { "pilot_service": "中试服务", "clinical_application": "临床应用", + "basic_experiment": "临床科研", + "contract_processing": "委托加工", } _APPLICATION_STATUS_LABELS = { "dks": "待开始", @@ -3328,6 +3330,7 @@ _PRODUCTION_TAB_STEP_COUNT_KEYS = ( "inbound_research_donation", "outbound_pilot_service", "outbound_basic_experiment", + "outbound_contract_processing", "temporary", ) @@ -3351,6 +3354,8 @@ def _resolve_production_tab_key( bt = (biz_type or "pilot_service").strip() or "pilot_service" if bt == "basic_experiment": return "outbound_basic_experiment" + if bt == "contract_processing": + return "outbound_contract_processing" if bt == "clinical_application": return None return "outbound_pilot_service" diff --git a/backend/app/crud/production_work_order.py b/backend/app/crud/production_work_order.py index 617cc755..df04242e 100644 --- a/backend/app/crud/production_work_order.py +++ b/backend/app/crud/production_work_order.py @@ -199,6 +199,7 @@ def _wo_to_dict(wo: BizProductionWorkOrder) -> Dict[str, Any]: "pilot_service": "中试服务", "clinical_application": "临床应用", "basic_experiment": "临床科研", + "contract_processing": "委托加工", }.get(getattr(wo, "biz_type", None) or "", ""), "workOrderStatus": wo.work_order_status, "workOrderStatusLabel": _WORK_ORDER_STATUS_LABELS.get(wo.work_order_status, wo.work_order_status), @@ -289,6 +290,7 @@ _BIZ_TYPE_LABELS = { "pilot_service": "中试服务", "clinical_application": "临床应用", "basic_experiment": "临床科研", + "contract_processing": "委托加工", } @@ -545,7 +547,7 @@ def _attach_outbound_detail( schedule_id = getattr(wo, "infusion_schedule_id", None) or "" biz_type = getattr(wo, "biz_type", None) or "" - if schedule_id and biz_type in ("pilot_service", "clinical_application", "basic_experiment"): + if schedule_id and biz_type in ("pilot_service", "clinical_application", "basic_experiment", "contract_processing"): pilot_ctx = build_outbound_pilot_context_by_schedule( db, schedule_id, wo.tenant_no or "" ) diff --git a/backend/app/crud/qc_work_order.py b/backend/app/crud/qc_work_order.py index 83d4596d..da8b74d7 100644 --- a/backend/app/crud/qc_work_order.py +++ b/backend/app/crud/qc_work_order.py @@ -109,6 +109,7 @@ _OUTBOUND_BIZ_TYPE_LABELS = { "pilot_service": "中试服务", "clinical_application": "临床应用", "basic_experiment": "临床科研", + "contract_processing": "委托加工", } _OUTBOUND_BIZ_TYPES = tuple(_OUTBOUND_BIZ_TYPE_LABELS.keys()) @@ -2003,6 +2004,7 @@ _QC_TAB_COUNT_KEYS = ( "inbound_research_donation", "outbound_pilot_service", "outbound_basic_experiment", + "outbound_contract_processing", "temporary", ) @@ -2023,6 +2025,8 @@ def _resolve_wo_tab_key( bt = (biz_type or "pilot_service").strip() or "pilot_service" if bt == "basic_experiment": return "outbound_basic_experiment" + if bt == "contract_processing": + return "outbound_contract_processing" if bt == "clinical_application": return "outbound_clinical_application" return "outbound_pilot_service" @@ -3713,7 +3717,7 @@ def build_outbound_pilot_context_by_schedule( "bizType": app_biz, "bizTypeLabel": _OUTBOUND_BIZ_TYPE_LABELS.get(app_biz, app_biz), } - if app_biz == "basic_experiment": + if app_biz in ("basic_experiment", "contract_processing"): out["application"]["projectTitle"] = app.project_title or "" out["application"]["customerName"] = app.customer_name or "" out["application"]["customerContact"] = app.customer_contact or "" diff --git a/backend/app/models/models.py b/backend/app/models/models.py index f25aea40..41b0bccc 100644 --- a/backend/app/models/models.py +++ b/backend/app/models/models.py @@ -4183,15 +4183,20 @@ class BizPilotApplication(Base): customer_contact = Column(String(100), nullable=True, comment="客户联系人(临床科研)") customer_phone = Column(String(32), nullable=True, comment="客户联系方式(临床科研)") research_category = Column( - String(32), + String(64), nullable=True, - comment="临床科研业务子类型: bio_tech_clinical/joint_topic_declare/bio_pharma_rd", + comment="业务子类型;临床科研三项码/委托加工产品码或自定义其他", ) 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_id = Column(String(64), nullable=True, comment="渠道ID(缓存自服务订单)") 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/contract_processing", + ) tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号") order_num = Column(Integer, nullable=True, comment="排序号") remark = Column(String(512), nullable=True, comment="备注") diff --git a/backend/app/services/basic_experiment_delivery_remind.py b/backend/app/services/basic_experiment_delivery_remind.py index 7825fb3d..52ba174d 100644 --- a/backend/app/services/basic_experiment_delivery_remind.py +++ b/backend/app/services/basic_experiment_delivery_remind.py @@ -126,7 +126,7 @@ def _iter_candidate_schedules(db: Session, *, delivery_day: date) -> List[Any]: & (BizPilotInfusionScheduleProduct.del_flag == 0), ) .filter( - BizPilotApplication.biz_type == "basic_experiment", + BizPilotApplication.biz_type in ("basic_experiment", "contract_processing"), BizPilotApplication.del_flag == 0, BizPilotInfusionPlan.del_flag == 0, BizPilotInfusionSchedule.del_flag == 0, diff --git a/backend/app/services/project_management.py b/backend/app/services/project_management.py index e7db34b4..99cbebf2 100644 --- a/backend/app/services/project_management.py +++ b/backend/app/services/project_management.py @@ -19,6 +19,7 @@ BUSINESS = { 'research_donation': (BizResearchDonation, 'donation_no', 'donation_status'), 'pilot_service': (BizPilotApplication, 'application_no', 'application_status'), 'basic_experiment': (BizPilotApplication, 'application_no', 'application_status'), + 'contract_processing': (BizPilotApplication, 'application_no', 'application_status'), } COUNT_TYPES = tuple(k for k in BUSINESS if k != 'presign') ALL_PROJECTS_PERMISSION = 'project:project:all' diff --git a/backend/app/services/qc_work_order_fee_summary.py b/backend/app/services/qc_work_order_fee_summary.py index 7bb1abf0..98853d8e 100644 --- a/backend/app/services/qc_work_order_fee_summary.py +++ b/backend/app/services/qc_work_order_fee_summary.py @@ -28,7 +28,9 @@ _PAY_STATUS_LABELS = { } # 出库工单:输注计划缴费(临床科研 / 临床应用共用 biz_pilot_payment) -_OUTBOUND_FEE_BIZ_TYPES = frozenset({"basic_experiment", "clinical_application"}) +_OUTBOUND_FEE_BIZ_TYPES = frozenset( + {"basic_experiment", "contract_processing", "clinical_application"} +) def _is_outbound_fee_biz_type(biz_type: Optional[str]) -> bool: diff --git a/backend/tests/test_contract_processing_application.py b/backend/tests/test_contract_processing_application.py new file mode 100644 index 00000000..e8e97ea7 --- /dev/null +++ b/backend/tests/test_contract_processing_application.py @@ -0,0 +1,81 @@ +"""委托加工申请单:编号前缀、业务子类型校验、复用临床科研创建校验。""" +import unittest +from unittest.mock import MagicMock, patch + +from app.constants.research_category import validate_research_category +from app.crud import pilot_application as crud + + +class TestContractProcessingApplicationNo(unittest.TestCase): + @patch("app.crud.pilot_application.datetime") + def test_generate_application_no_contract_processing_prefix(self, mock_dt): + mock_dt.now.return_value.strftime.return_value = "20261123" + db = MagicMock() + mock_query = MagicMock() + db.query.return_value = mock_query + mock_query.filter.return_value = mock_query + mock_query.order_by.return_value = mock_query + mock_query.first.return_value = None + + result = crud._generate_application_no(db, "zkxw", biz_type="contract_processing") + + self.assertEqual(result, "WTJG202611230001") + + +class TestContractProcessingResearchCategory(unittest.TestCase): + def test_fixed_categories(self): + self.assertEqual( + validate_research_category("placenta_freeze_dried", required=True, biz_type="contract_processing"), + "placenta_freeze_dried", + ) + self.assertEqual( + validate_research_category("nk", required=True, biz_type="contract_processing"), + "nk", + ) + + def test_custom_other_text(self): + self.assertEqual( + validate_research_category("自定义产品A", required=True, biz_type="contract_processing"), + "自定义产品A", + ) + + def test_clinical_codes_rejected_for_contract_processing(self): + with self.assertRaises(ValueError): + validate_research_category( + "bio_tech_clinical", required=True, biz_type="contract_processing" + ) + + def test_clinical_still_uses_legacy_codes(self): + self.assertEqual( + validate_research_category("bio_tech_clinical", required=True, biz_type="basic_experiment"), + "bio_tech_clinical", + ) + with self.assertRaises(ValueError): + validate_research_category("nk", required=True, biz_type="basic_experiment") + + +class TestContractProcessingCreateValidation(unittest.TestCase): + def test_create_requires_customer_fields(self): + db = MagicMock() + data = { + "bizType": "contract_processing", + "researchCategory": "msc", + "channelId": "ch-1", + "projectTitle": "课题A", + "customerName": "", + "customerContact": "张三", + "customerPhone": "13800000000", + } + with self.assertRaises(ValueError) as ctx: + crud.create_application( + db, + data=data, + tenant_no="zkxw", + user_id="user-1", + dept_id="dept-1", + ) + self.assertIn("客户名称", str(ctx.exception)) + + +if __name__ == "__main__": + unittest.main() diff --git a/docs/sql/migrations/2026-11-23-contract-processing-menus-and-research-category.sql b/docs/sql/migrations/2026-11-23-contract-processing-menus-and-research-category.sql new file mode 100644 index 00000000..e9c296b5 --- /dev/null +++ b/docs/sql/migrations/2026-11-23-contract-processing-menus-and-research-category.sql @@ -0,0 +1,97 @@ +-- 委托加工:市场菜单(复用临床科研页面组件)+ research_category 加长以支持「其他」自定义。 +-- MySQL 5.7,可重复执行。目标库:测试库(如 zkxw-sc)。 + +-- 1) research_category 加长(自定义「其他」文本) +ALTER TABLE biz_pilot_application + MODIFY COLUMN research_category VARCHAR(64) NULL + COMMENT '业务子类型;临床科研三项码/委托加工产品码或自定义其他'; + +-- 2) 二级目录:委托加工(挂在市场下,order_num=5,器械销售前) +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 + 'CPG00000000000000000000000000001', + '委托加工', + m.id, + 'M', + 'contract-processing', + NULL, + 'menu:contract-processing', + 1, '1', '1', m.tenant_no, 5, + '市场-委托加工', + '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 = 'CPG00000000000000000000000000001' AND e.del_flag = 0 + ); + +-- 3) 子菜单:申请单 / 缴退费财务确认 / 出库放行审核 +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, 'CPG00000000000000000000000000001', 'C', x.path, + x.component, x.perms, + 1, '1', '1', p.tenant_no, x.order_num, x.remark, + 'migration', '', NOW(), 'migration', NOW(), 0 +FROM sys_menu p +JOIN ( + SELECT 'CPG00000000000000000000000000002' AS id, '委托加工申请单' AS menu_name, + 'application' AS path, + 'pilot-service/pilot-application/index' AS component, + 'contract-processing:application:list' AS perms, 1 AS order_num, + '市场-委托加工-申请单' AS remark + UNION ALL + SELECT 'CPG00000000000000000000000000003', '缴退费财务确认', + 'payment-confirm', + 'pilot-service/clinical-payment-confirm/index', + 'contract-processing:payment-confirm:list', 2, + '市场-委托加工-缴退费财务确认' + UNION ALL + SELECT 'CPG00000000000000000000000000004', '出库放行审核', + 'outbound-release-review', + 'pilot-service/outbound-release-review/index', + 'contract-processing:outbound-release-review:list', 3, + '市场-委托加工-出库放行审核' +) x ON 1 = 1 +WHERE p.del_flag = 0 AND p.id = 'CPG00000000000000000000000000001' + AND NOT EXISTS ( + SELECT 1 FROM sys_menu e WHERE e.id = x.id AND e.del_flag = 0 + ); + +-- 4) 给已有「市场」顶级菜单授权的角色,授予委托加工目录+子菜单 +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('contract-processing-rm:', r.tenant_no, ':', r.id, ':', m.id)), 13, 1, '3'), 17, 1, '8'), + r.id, m.id, r.tenant_no, NULL, + 'grant contract-processing 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 ( + 'CPG00000000000000000000000000001', + 'CPG00000000000000000000000000002', + 'CPG00000000000000000000000000003', + 'CPG00000000000000000000000000004' + ) +WHERE r.del_flag = 0 + AND NOT EXISTS ( + SELECT 1 FROM sys_role_menu e + WHERE e.role_id = r.id AND e.menu_id = m.id AND e.tenant_no = r.tenant_no AND e.del_flag = 0 + ); diff --git a/web-admin/src/api/project-management.ts b/web-admin/src/api/project-management.ts index 4542265f..746fc771 100644 --- a/web-admin/src/api/project-management.ts +++ b/web-admin/src/api/project-management.ts @@ -5,12 +5,14 @@ export type BizType = | 'research_donation' | 'pilot_service' | 'basic_experiment' + | 'contract_processing' export const bizLabels: Record = { presign: '预签约', cell_storage: '细胞存储', research_donation: '科研捐赠', pilot_service: '中试服务', - basic_experiment: '临床科研' + basic_experiment: '临床科研', + contract_processing: '委托加工' } export type ProjectOption = { id: string diff --git a/web-admin/src/components/business/clinical-payment-confirm-timeline/index.vue b/web-admin/src/components/business/clinical-payment-confirm-timeline/index.vue index 37f9909e..f8d18019 100644 --- a/web-admin/src/components/business/clinical-payment-confirm-timeline/index.vue +++ b/web-admin/src/components/business/clinical-payment-confirm-timeline/index.vue @@ -284,6 +284,7 @@ protocolStatusTagType } from '@/utils/protocol-payment-labels' import { formatMoneyDisplay } from '@/utils/money-format' + import { isResearchLikeBiz } from '@/utils/research-like-biz' const props = withDefaults( defineProps<{ @@ -393,7 +394,7 @@ ) const isBasicExperiment = computed( - () => String(props.detail?.bizType || '') === 'basic_experiment' + () => isResearchLikeBiz(props.bizType || detail?.bizType) ) const pickupTimeLabel = computed(() => diff --git a/web-admin/src/components/business/clinical-payment-submit-readonly/index.vue b/web-admin/src/components/business/clinical-payment-submit-readonly/index.vue index 1a9cc649..9aaa1569 100644 --- a/web-admin/src/components/business/clinical-payment-submit-readonly/index.vue +++ b/web-admin/src/components/business/clinical-payment-submit-readonly/index.vue @@ -103,6 +103,7 @@ import { formatMoneyDisplay } from '@/utils/money-format' import { payStatusLabel, payStatusTagType } from '@/utils/status-tag-registry' import { getPilotBizConfig } from '@/config/pilot-biz-type' + import { isResearchLikeBiz } from '@/utils/research-like-biz' const props = withDefaults( defineProps<{ @@ -143,7 +144,7 @@ } const isBasicExperiment = computed( - () => String(props.detail?.bizType || '') === 'basic_experiment' + () => isResearchLikeBiz(props.bizType || detail?.bizType) ) const pickupTimeLabel = computed(() => diff --git a/web-admin/src/config/pilot-biz-type.ts b/web-admin/src/config/pilot-biz-type.ts index c4670e1c..26baa118 100644 --- a/web-admin/src/config/pilot-biz-type.ts +++ b/web-admin/src/config/pilot-biz-type.ts @@ -1,4 +1,8 @@ -export type PilotBizType = 'pilot_service' | 'clinical_application' | 'basic_experiment' +export type PilotBizType = + | 'pilot_service' + | 'clinical_application' + | 'basic_experiment' + | 'contract_processing' export interface PilotBizTypeConfig { label: string @@ -20,6 +24,26 @@ export interface PilotBizTypeConfig { statusLabel: string } +const RESEARCH_LIKE_CONFIG: PilotBizTypeConfig = { + label: '临床科研', + applicationNoPrefix: 'JCSY', + showChannel: true, + showPatient: false, + showConsent: false, + showOtherAttachments: false, + showStandardAttachments: true, + showCheckup: false, + showInfusionConfirm: false, + showDelivery: true, + showPayment: true, + planLabel: '交付计划', + scheduleLabel: '交付计划', + pickupTimeLabel: '交付时间', + locationLabel: '交付地点', + methodLabel: '交付方式', + statusLabel: '交付状态' +} + export const PILOT_BIZ_TYPE_CONFIG: Record = { pilot_service: { label: '中试服务', @@ -60,23 +84,14 @@ export const PILOT_BIZ_TYPE_CONFIG: Record = { statusLabel: '输注状态' }, basic_experiment: { + ...RESEARCH_LIKE_CONFIG, label: '临床科研', - applicationNoPrefix: 'JCSY', - showChannel: true, - showPatient: false, - showConsent: false, - showOtherAttachments: false, - showStandardAttachments: true, - showCheckup: false, - showInfusionConfirm: false, - showDelivery: true, - showPayment: true, - planLabel: '交付计划', - scheduleLabel: '交付计划', - pickupTimeLabel: '交付时间', - locationLabel: '交付地点', - methodLabel: '交付方式', - statusLabel: '交付状态' + applicationNoPrefix: 'JCSY' + }, + contract_processing: { + ...RESEARCH_LIKE_CONFIG, + label: '委托加工', + applicationNoPrefix: 'WTJG' } } @@ -86,7 +101,11 @@ export function getPilotBizConfig(bizType?: string): PilotBizTypeConfig { } export function resolvePilotBizType(bizType?: string): PilotBizType { - if (bizType === 'clinical_application' || bizType === 'basic_experiment') { + if ( + bizType === 'clinical_application' || + bizType === 'basic_experiment' || + bizType === 'contract_processing' + ) { return bizType } return 'pilot_service' diff --git a/web-admin/src/constants/clinical-research-category.ts b/web-admin/src/constants/clinical-research-category.ts index 3fda1dce..34dacf51 100644 --- a/web-admin/src/constants/clinical-research-category.ts +++ b/web-admin/src/constants/clinical-research-category.ts @@ -8,11 +8,42 @@ export const CLINICAL_RESEARCH_CATEGORY_OPTIONS = [ export type ClinicalResearchCategory = (typeof CLINICAL_RESEARCH_CATEGORY_OPTIONS)[number]['value'] +/** 委托加工 · 产品业务类型 */ +export const CONTRACT_PROCESSING_CATEGORY_OPTIONS = [ + { value: 'placenta_freeze_dried', label: '胎盘冻干粉' }, + { value: 'adipose_exosome', label: '脂肪外泌体' }, + { value: 'nk', label: 'NK' }, + { value: 'msc', label: 'MSC' } +] as const + +export type ContractProcessingCategory = + (typeof CONTRACT_PROCESSING_CATEGORY_OPTIONS)[number]['value'] + +/** 前端「其他」占位,提交时改为自定义文本 */ +export const RESEARCH_CATEGORY_OTHER_VALUE = '__other__' + const LABEL_MAP = Object.fromEntries( - CLINICAL_RESEARCH_CATEGORY_OPTIONS.map((o) => [o.value, o.label]) + [ + ...CLINICAL_RESEARCH_CATEGORY_OPTIONS, + ...CONTRACT_PROCESSING_CATEGORY_OPTIONS + ].map((o) => [o.value, o.label]) ) as Record export function clinicalResearchCategoryLabel(code?: string | null): string { if (!code) return '' return LABEL_MAP[code] || code } + +export function researchCategoryOptionsForBiz(bizType?: string | null) { + if (bizType === 'contract_processing') { + return [ + ...CONTRACT_PROCESSING_CATEGORY_OPTIONS, + { value: RESEARCH_CATEGORY_OTHER_VALUE, label: '其他' } + ] + } + return [...CLINICAL_RESEARCH_CATEGORY_OPTIONS] +} + +export function isFixedContractProcessingCategory(code?: string | null): boolean { + return CONTRACT_PROCESSING_CATEGORY_OPTIONS.some((o) => o.value === code) +} diff --git a/web-admin/src/router/modules/sqxp.ts b/web-admin/src/router/modules/sqxp.ts index 2df87f1f..7cf515b4 100644 --- a/web-admin/src/router/modules/sqxp.ts +++ b/web-admin/src/router/modules/sqxp.ts @@ -605,6 +605,58 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [ ] }, + // ── 委托加工(复用临床科研页面,bizType=contract_processing)────────── + { + id: 'CPG00000000000000000000000000001', + name: 'ContractProcessing', + path: 'contract-processing', + component: '', + meta: { + title: '委托加工', + icon: 'ri:tools-line', + keepAlive: false, + roles: ['admin'] + }, + children: [ + { + id: 'CPG00000000000000000000000000002', + name: 'ContractProcessingApplication', + path: 'application', + component: '/pilot-service/pilot-application/index', + meta: { + title: '委托加工申请单', + keepAlive: true, + menuCode: 'contract-processing:application:list' + }, + props: { bizType: 'contract_processing' } + }, + { + id: 'CPG00000000000000000000000000003', + name: 'ContractProcessingPaymentConfirm', + path: 'payment-confirm', + component: '/pilot-service/clinical-payment-confirm/index', + meta: { + title: '缴退费财务确认', + keepAlive: true, + menuCode: 'contract-processing:payment-confirm:list' + }, + props: { bizType: 'contract_processing' } + }, + { + id: 'CPG00000000000000000000000000004', + name: 'ContractProcessingOutboundRelease', + path: 'outbound-release-review', + component: '/pilot-service/outbound-release-review/index', + meta: { + title: '出库放行审核', + keepAlive: true, + menuCode: 'contract-processing:outbound-release-review:list' + }, + props: { bizType: 'contract_processing' } + } + ] + }, + // ── 器械销售(市场侧栏末位;占位页待完善)──────────────────────────── { id: 'DEV00000000000000000000000000001', diff --git a/web-admin/src/utils/outbound-qc-pilot-view-sections.ts b/web-admin/src/utils/outbound-qc-pilot-view-sections.ts index 56a74fa3..4d55d723 100644 --- a/web-admin/src/utils/outbound-qc-pilot-view-sections.ts +++ b/web-admin/src/utils/outbound-qc-pilot-view-sections.ts @@ -1,6 +1,7 @@ import type { OutboundQcDetail } from '@/api/qc-work-order' import type { ViewField, ViewSection } from '@/components/business/system-view-dialog/index.vue' import { maskIdCard } from '@/utils/mask-sensitive' +import { isResearchLikeBiz } from '@/utils/research-like-biz' import { applicationStatusLabel, applicationStatusTagType, @@ -18,6 +19,7 @@ export type OutboundViewContextVariant = | 'pilot_service' | 'clinical_application' | 'basic_experiment' + | 'contract_processing' const SECTION_TITLES: Record< OutboundViewContextVariant, @@ -34,6 +36,10 @@ const SECTION_TITLES: Record< basic_experiment: { application: '临床科研申请信息', schedule: '交付计划信息' + }, + contract_processing: { + application: '委托加工申请信息', + schedule: '交付计划信息' } } @@ -56,7 +62,7 @@ function buildDefaultApplicationFields( app: NonNullable, variant: OutboundViewContextVariant ) { - if (variant === 'basic_experiment') { + if (isResearchLikeBiz(variant)) { return buildBasicExperimentApplicationFields(app) } return [ @@ -82,6 +88,7 @@ export function buildOutboundPilotContextSections( const schedule = detail.infusionSchedule const products = detail.products || [] const titles = SECTION_TITLES[variant] + const researchLike = isResearchLikeBiz(variant) const result: ViewSection[] = [] if (app) { @@ -91,7 +98,7 @@ export function buildOutboundPilotContextSections( }) } - if (patient && variant !== 'basic_experiment') { + if (patient && !researchLike) { result.push({ title: '患者信息', fields: [ @@ -113,7 +120,7 @@ export function buildOutboundPilotContextSections( }) } - if (plan && variant !== 'basic_experiment') { + if (plan && !researchLike) { result.push({ title: '输注方案信息', fields: [ @@ -128,12 +135,12 @@ export function buildOutboundPilotContextSections( } if (schedule) { - const pickupLabel = variant === 'basic_experiment' ? '交付时间' : '输注时间' + const pickupLabel = researchLike ? '交付时间' : '输注时间' const scheduleFields: ViewField[] = [ { label: pickupLabel, value: schedule.infusionTime || '—' } ] - if (variant === 'basic_experiment') { + if (researchLike) { scheduleFields.push({ label: '售卖金额', value: @@ -154,7 +161,7 @@ export function buildOutboundPilotContextSections( tagType: scheduleStatusTagType(schedule.scheduleStatus || '') as ViewField['tagType'] }) - if (variant !== 'basic_experiment') { + if (!researchLike) { scheduleFields.push({ label: '输注状态', value: infusionStatusLabel(schedule.infusionStatus || ''), @@ -186,9 +193,9 @@ export function buildOutboundPilotContextSections( } export function resolveOutboundViewVariant(bizType?: string | null): OutboundViewContextVariant { - if (bizType === 'clinical_application' || bizType === 'basic_experiment') { - return bizType - } + if (bizType === 'clinical_application') return 'clinical_application' + if (bizType === 'contract_processing') return 'contract_processing' + if (bizType === 'basic_experiment') return 'basic_experiment' return 'pilot_service' } diff --git a/web-admin/src/utils/production-mine-task-groups.ts b/web-admin/src/utils/production-mine-task-groups.ts index c4acfd84..fa8741a1 100644 --- a/web-admin/src/utils/production-mine-task-groups.ts +++ b/web-admin/src/utils/production-mine-task-groups.ts @@ -53,7 +53,7 @@ function keywordMatchesWorkOrder( const fields = tabKey === 'temporary' ? [row.remark] - : tabKey === 'outbound_basic_experiment' + : tabKey === 'outbound_basic_experiment' || tabKey === 'outbound_contract_processing' ? [ row.workOrderNo, row.applicationNo, diff --git a/web-admin/src/utils/production-work-order-card-meta.ts b/web-admin/src/utils/production-work-order-card-meta.ts index 9a090083..02145bf2 100644 --- a/web-admin/src/utils/production-work-order-card-meta.ts +++ b/web-admin/src/utils/production-work-order-card-meta.ts @@ -251,6 +251,19 @@ const CARD_META_BY_TAB: Record = { inbound_research_donation: '科研捐赠', outbound_pilot_service: '中试服务', outbound_basic_experiment: '临床科研', + outbound_contract_processing: '委托加工', temporary: '临时' } @@ -34,6 +35,7 @@ const CATEGORY_TAG_TYPES: Record = { inbound_research_donation: 'primary', outbound_pilot_service: 'info', outbound_basic_experiment: 'info', + outbound_contract_processing: 'info', temporary: 'warning' } diff --git a/web-admin/src/utils/production-work-order-tabs.test.ts b/web-admin/src/utils/production-work-order-tabs.test.ts index c2846a51..be3647d1 100644 --- a/web-admin/src/utils/production-work-order-tabs.test.ts +++ b/web-admin/src/utils/production-work-order-tabs.test.ts @@ -23,10 +23,17 @@ describe('production work order tabs — hide pilot service', () => { const pilot = { workOrderType: 'outbound', bizType: 'pilot_service' } const defaultPilot = { workOrderType: 'outbound' } const basic = { workOrderType: 'outbound', bizType: 'basic_experiment' } + const contract = { workOrderType: 'outbound', bizType: 'contract_processing' } assert.equal(isPilotServiceOutboundWorkOrder(pilot), true) assert.equal(isPilotServiceOutboundWorkOrder(defaultPilot), true) assert.equal(workOrderMatchesTab(pilot as any, 'all'), false) assert.equal(workOrderMatchesTab(defaultPilot as any, 'all'), false) assert.equal(workOrderMatchesTab(basic as any, 'all'), true) + assert.equal(workOrderMatchesTab(contract as any, 'all'), true) + assert.equal(workOrderMatchesTab(contract as any, 'outbound_contract_processing'), true) + }) + + it('visible tabs include contract processing', () => { + assert.ok(PRODUCTION_WORK_ORDER_VISIBLE_TABS.some((t) => t.key === 'outbound_contract_processing')) }) }) diff --git a/web-admin/src/utils/production-work-order-tabs.ts b/web-admin/src/utils/production-work-order-tabs.ts index c233794c..1d5f614b 100644 --- a/web-admin/src/utils/production-work-order-tabs.ts +++ b/web-admin/src/utils/production-work-order-tabs.ts @@ -6,6 +6,7 @@ export type ProductionWorkOrderTabKey = | 'inbound_research_donation' | 'outbound_pilot_service' | 'outbound_basic_experiment' + | 'outbound_contract_processing' | 'outbound_clinical_application' | 'temporary' @@ -17,7 +18,7 @@ export type ProductionWorkOrderTabConfig = { group: ProductionWorkOrderTabGroup workOrderType: 'inbound' | 'outbound' | 'temporary' receptionSource?: 'cell_storage' | 'research_donation' - bizType?: 'pilot_service' | 'basic_experiment' | 'clinical_application' + bizType?: 'pilot_service' | 'basic_experiment' | 'contract_processing' | 'clinical_application' listLayout: 'inbound-grouped' | 'standalone' /** 侧栏 Tab 不展示(保留 key 供路由/数据解析) */ hidden?: boolean @@ -65,6 +66,14 @@ export const PRODUCTION_WORK_ORDER_TABS: ProductionWorkOrderTabConfig[] = [ bizType: 'basic_experiment', listLayout: 'standalone' }, + { + key: 'outbound_contract_processing', + label: '委托加工生产', + group: 'outbound', + workOrderType: 'outbound', + bizType: 'contract_processing', + listLayout: 'standalone' + }, { key: 'outbound_clinical_application', label: '临床应用生产', @@ -129,6 +138,7 @@ export function resolveTabKeyFromWorkOrder(row: { if (wt === 'outbound') { const bt = row.bizType || 'pilot_service' if (bt === 'basic_experiment') return 'outbound_basic_experiment' + if (bt === 'contract_processing') return 'outbound_contract_processing' if (bt === 'clinical_application') return 'outbound_clinical_application' return 'outbound_pilot_service' } @@ -140,7 +150,7 @@ export function resolveTabKeyFromWorkOrder(row: { export function keywordPlaceholderForTab(tab: ProductionWorkOrderTabConfig): string { if (tab.key === 'all') return '工单号 / 样本编码 / 申请单号 / 产品名称等' if (tab.key === 'temporary') return '备注' - if (tab.key === 'outbound_basic_experiment') { + if (tab.key === 'outbound_basic_experiment' || tab.key === 'outbound_contract_processing') { return '工单号/申请单号/课题名称/客户' } if (tab.group === 'outbound') return '工单号/申请单号/申请单名称/患者' diff --git a/web-admin/src/utils/qc-mine-task-groups.ts b/web-admin/src/utils/qc-mine-task-groups.ts index 8cc471da..ca8e14c6 100644 --- a/web-admin/src/utils/qc-mine-task-groups.ts +++ b/web-admin/src/utils/qc-mine-task-groups.ts @@ -75,7 +75,7 @@ function keywordMatchesWorkOrder( const fields = tabKey === 'temporary' ? [row.workOrderNo, row.productionWorkOrderNo] - : tabKey === 'outbound_basic_experiment' + : tabKey === 'outbound_basic_experiment' || tabKey === 'outbound_contract_processing' ? [ row.workOrderNo, row.applicationNo, diff --git a/web-admin/src/utils/qc-work-order-card-meta.ts b/web-admin/src/utils/qc-work-order-card-meta.ts index a7b09643..bb7bd463 100644 --- a/web-admin/src/utils/qc-work-order-card-meta.ts +++ b/web-admin/src/utils/qc-work-order-card-meta.ts @@ -356,6 +356,20 @@ const CARD_META_BY_TAB: Record = { allowEditRemark: true, allowDelete: false }, + outbound_contract_processing: { + tabKey: 'outbound_contract_processing', + listLayout: 'outbound-grouped', + showCategoryTag: false, + showTriggerTag: true, + showProtocolFeeSummary: false, + showOutboundFeeSummary: true, + showCellProducts: true, + metaFields: outboundGroupedFields, + buildGroupContextParts: buildOutboundBasicExperimentGroupContext, + allowEditTemporary: false, + allowEditRemark: true, + allowDelete: false + }, outbound_clinical_application: { tabKey: 'outbound_clinical_application', listLayout: 'standalone', diff --git a/web-admin/src/utils/qc-work-order-category.ts b/web-admin/src/utils/qc-work-order-category.ts index a38c324c..cd32c558 100644 --- a/web-admin/src/utils/qc-work-order-category.ts +++ b/web-admin/src/utils/qc-work-order-category.ts @@ -25,6 +25,7 @@ const CATEGORY_LABELS: Record = { inbound_research_donation: '科研捐赠', outbound_pilot_service: '中试服务', outbound_basic_experiment: '临床科研', + outbound_contract_processing: '委托加工', temporary: '临时' } @@ -33,6 +34,7 @@ const CATEGORY_TAG_TYPES: Record = { inbound_research_donation: 'primary', outbound_pilot_service: 'info', outbound_basic_experiment: 'info', + outbound_contract_processing: 'info', temporary: 'warning' } diff --git a/web-admin/src/utils/qc-work-order-tabs.test.ts b/web-admin/src/utils/qc-work-order-tabs.test.ts index 00d1bbe9..1b2e6100 100644 --- a/web-admin/src/utils/qc-work-order-tabs.test.ts +++ b/web-admin/src/utils/qc-work-order-tabs.test.ts @@ -24,10 +24,17 @@ describe('qc work order tabs — hide pilot service', () => { const pilot = { workOrderType: 'outbound', bizType: 'pilot_service' } const defaultPilot = { workOrderType: 'outbound' } const basic = { workOrderType: 'outbound', bizType: 'basic_experiment' } + const contract = { workOrderType: 'outbound', bizType: 'contract_processing' } assert.equal(isPilotServiceOutboundWorkOrder(pilot), true) assert.equal(isPilotServiceOutboundWorkOrder(defaultPilot), true) assert.equal(workOrderMatchesTab(pilot as any, 'all'), false) assert.equal(workOrderMatchesTab(defaultPilot as any, 'all'), false) assert.equal(workOrderMatchesTab(basic as any, 'all'), true) + assert.equal(workOrderMatchesTab(contract as any, 'all'), true) + assert.equal(workOrderMatchesTab(contract as any, 'outbound_contract_processing'), true) + }) + + it('visible tabs include contract processing', () => { + assert.ok(QC_WORK_ORDER_VISIBLE_TABS.some((t) => t.key === 'outbound_contract_processing')) }) }) diff --git a/web-admin/src/utils/qc-work-order-tabs.ts b/web-admin/src/utils/qc-work-order-tabs.ts index 211af8ef..258ec71c 100644 --- a/web-admin/src/utils/qc-work-order-tabs.ts +++ b/web-admin/src/utils/qc-work-order-tabs.ts @@ -6,6 +6,7 @@ export type QcWorkOrderTabKey = | 'inbound_research_donation' | 'outbound_pilot_service' | 'outbound_basic_experiment' + | 'outbound_contract_processing' | 'outbound_clinical_application' | 'temporary' @@ -17,7 +18,7 @@ export type QcWorkOrderTabConfig = { group: QcWorkOrderTabGroup workOrderType?: 'inbound' | 'outbound' | 'temporary' receptionSource?: 'cell_storage' | 'research_donation' - bizType?: 'pilot_service' | 'basic_experiment' | 'clinical_application' + bizType?: 'pilot_service' | 'basic_experiment' | 'contract_processing' | 'clinical_application' listLayout: 'inbound-grouped' | 'outbound-grouped' | 'standalone' /** 侧栏 Tab 不展示(保留 key 供路由/数据解析) */ hidden?: boolean @@ -65,6 +66,14 @@ export const QC_WORK_ORDER_TABS: QcWorkOrderTabConfig[] = [ bizType: 'basic_experiment', listLayout: 'outbound-grouped' }, + { + key: 'outbound_contract_processing', + label: '委托加工质检', + group: 'outbound', + workOrderType: 'outbound', + bizType: 'contract_processing', + listLayout: 'outbound-grouped' + }, { key: 'outbound_clinical_application', label: '临床应用质检', @@ -127,6 +136,7 @@ export function resolveTabKeyFromWorkOrder(row: { if (wt === 'outbound') { const bt = row.bizType || 'pilot_service' if (bt === 'basic_experiment') return 'outbound_basic_experiment' + if (bt === 'contract_processing') return 'outbound_contract_processing' if (bt === 'clinical_application') return 'outbound_clinical_application' return 'outbound_pilot_service' } @@ -142,7 +152,7 @@ export function tabUsesInfusionTimeFilter(tab: QcWorkOrderTabConfig): boolean { export function keywordPlaceholderForTab(tab: QcWorkOrderTabConfig): string { if (tab.key === 'all') return '工单号 / 样本编码 / 母亲姓名 / 申请单号 / 产品名称等' if (tab.key === 'temporary') return '工单号 / 外部编号' - if (tab.key === 'outbound_basic_experiment') { + if (tab.key === 'outbound_basic_experiment' || tab.key === 'outbound_contract_processing') { return '工单号/申请单号/课题名称/客户' } if (tab.group === 'outbound') return '工单号/申请单号/申请单名称/患者' @@ -157,7 +167,9 @@ export function keywordPlaceholderForTab(tab: QcWorkOrderTabConfig): string { export function filterTimeLabelForTab(tab: QcWorkOrderTabConfig): string { if (tab.key === 'all') return '创建时间' - if (tab.key === 'outbound_basic_experiment') return '交付时间' + if (tab.key === 'outbound_basic_experiment' || tab.key === 'outbound_contract_processing') { + return '交付时间' + } if (tab.group === 'outbound') return '输注时间' return '创建时间' } diff --git a/web-admin/src/utils/research-like-biz.ts b/web-admin/src/utils/research-like-biz.ts new file mode 100644 index 00000000..3e2b1670 --- /dev/null +++ b/web-admin/src/utils/research-like-biz.ts @@ -0,0 +1,12 @@ +/** 临床科研 / 委托加工:共用申请、交付、缴费、出库流程 */ +export const RESEARCH_LIKE_BIZ_TYPES = ['basic_experiment', 'contract_processing'] as const + +export type ResearchLikeBizType = (typeof RESEARCH_LIKE_BIZ_TYPES)[number] + +export function isResearchLikeBiz(bizType?: string | null): boolean { + return RESEARCH_LIKE_BIZ_TYPES.includes((bizType || '') as ResearchLikeBizType) +} + +export function isContractProcessing(bizType?: string | null): boolean { + return (bizType || '') === 'contract_processing' +} diff --git a/web-admin/src/utils/status-tag-registry.ts b/web-admin/src/utils/status-tag-registry.ts index 539faa66..556bdf87 100644 --- a/web-admin/src/utils/status-tag-registry.ts +++ b/web-admin/src/utils/status-tag-registry.ts @@ -3,6 +3,7 @@ */ import { resolveVoidTypeLabel } from '@/utils/void-type-dict' +import { isResearchLikeBiz } from '@/utils/research-like-biz' // ── 类型定义 ────────────────────────────────────────────────────────────────── @@ -228,7 +229,8 @@ export const receptionSource: StatusRegistry = { outbound: { label: '出库', tagType: 'primary' }, pilot_service: { label: '中试服务', tagType: 'primary' }, clinical_application: { label: '临床应用', tagType: 'warning' }, - basic_experiment: { label: '临床科研', tagType: 'primary' } + basic_experiment: { label: '临床科研', tagType: 'primary' }, + contract_processing: { label: '委托加工', tagType: 'primary' } } export const receptionSourceLabel = createLabelGetter(receptionSource) export const receptionSourceTagType = createTagTypeGetter(receptionSource) @@ -761,7 +763,8 @@ export function bizTypeLabel(type: string): string { const map: Record = { pilot_service: '中试服务', clinical_application: '临床应用', - basic_experiment: '临床科研' + basic_experiment: '临床科研', + contract_processing: '委托加工' } return map[type] || type || '-' } @@ -769,14 +772,15 @@ export function bizTypeTagType(type: string): string { const map: Record = { pilot_service: 'primary', clinical_application: 'warning', - basic_experiment: 'primary' + basic_experiment: 'primary', + contract_processing: 'primary' } return map[type] || 'info' } // ========== 中试服务 - 产品状态 ========== export function productStatusLabel(status: string, bizType?: string): string { - const isBasicExperiment = bizType === 'basic_experiment' + const isBasicExperiment = isResearchLikeBiz(bizType) const map: Record = { dtz: isBasicExperiment ? '待交付' : '待输注', yrqr: '已用户确认', diff --git a/web-admin/src/views/pilot-service/clinical-payment-confirm/RefundConfirmTab.vue b/web-admin/src/views/pilot-service/clinical-payment-confirm/RefundConfirmTab.vue index 88b5b9f1..f111e271 100644 --- a/web-admin/src/views/pilot-service/clinical-payment-confirm/RefundConfirmTab.vue +++ b/web-admin/src/views/pilot-service/clinical-payment-confirm/RefundConfirmTab.vue @@ -594,6 +594,7 @@ import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue' import { formatMoneyDisplay } from '@/utils/money-format' import { getPilotBizConfig, resolvePilotBizType } from '@/config/pilot-biz-type' + import { isResearchLikeBiz } from '@/utils/research-like-biz' defineOptions({ name: 'ClinicalRefundConfirmTab' }) @@ -602,7 +603,7 @@ const props = defineProps<{ bizType?: string }>() const bizConfig = computed(() => getPilotBizConfig(props.bizType)) const isBasicExperiment = computed( - () => resolvePilotBizType(props.bizType) === 'basic_experiment' + () => isResearchLikeBiz(props.bizType) ) const pickupTimeLabel = computed(() => bizConfig.value.pickupTimeLabel) const keywordPlaceholder = computed(() => diff --git a/web-admin/src/views/pilot-service/clinical-payment-confirm/index.vue b/web-admin/src/views/pilot-service/clinical-payment-confirm/index.vue index 57dc7516..5fbb4731 100644 --- a/web-admin/src/views/pilot-service/clinical-payment-confirm/index.vue +++ b/web-admin/src/views/pilot-service/clinical-payment-confirm/index.vue @@ -636,13 +636,14 @@ import { useAttachmentDropZone } from '@/composables/useAttachmentDropZone' import { formatMoneyDisplay } from '@/utils/money-format' import { getPilotBizConfig, resolvePilotBizType } from '@/config/pilot-biz-type' + import { isResearchLikeBiz } from '@/utils/research-like-biz' defineOptions({ name: 'ClinicalPaymentConfirm' }) const props = defineProps<{ bizType?: string }>() const bizConfig = computed(() => getPilotBizConfig(props.bizType)) const effectiveBizType = computed(() => resolvePilotBizType(props.bizType)) - const isBasicExperiment = computed(() => effectiveBizType.value === 'basic_experiment') + const isBasicExperiment = computed(() => isResearchLikeBiz(effectiveBizType.value)) const pickupTimeLabel = computed(() => bizConfig.value.pickupTimeLabel) const route = useRoute() const mainTab = ref<'payment' | 'refund'>('payment') diff --git a/web-admin/src/views/pilot-service/infusion-schedule-management/InfusionScheduleHandoverDialog.vue b/web-admin/src/views/pilot-service/infusion-schedule-management/InfusionScheduleHandoverDialog.vue index 82657c1e..a082ce14 100644 --- a/web-admin/src/views/pilot-service/infusion-schedule-management/InfusionScheduleHandoverDialog.vue +++ b/web-admin/src/views/pilot-service/infusion-schedule-management/InfusionScheduleHandoverDialog.vue @@ -247,6 +247,7 @@ import { useUserStore } from '@/store/modules/user' import { downloadAttachmentFile } from '@/utils/download-attachment' import { getPilotBizConfig, resolvePilotBizType } from '@/config/pilot-biz-type' + import { isResearchLikeBiz } from '@/utils/research-like-biz' type AttachmentItem = { id: string @@ -269,7 +270,7 @@ () => getPilotBizConfig(resolvePilotBizType(props.bizType)).pickupTimeLabel ) const isBasicExperiment = computed( - () => resolvePilotBizType(props.bizType) === 'basic_experiment' + () => isResearchLikeBiz(props.bizType) ) const emit = defineEmits<{ diff --git a/web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleEditDialog.vue b/web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleEditDialog.vue index e83c4908..e5185665 100644 --- a/web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleEditDialog.vue +++ b/web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleEditDialog.vue @@ -480,6 +480,7 @@ import { formatMoneyDisplay } from '@/utils/money-format' import { fetchAllPagedRecords } from '@/utils/fetch-paged-list' import { getPilotBizConfig } from '@/config/pilot-biz-type' + import { isResearchLikeBiz } from '@/utils/research-like-biz' const props = defineProps<{ modelValue: boolean @@ -529,7 +530,7 @@ const optionsLoadIssue = ref('') const bizConfig = computed(() => getPilotBizConfig(scheduleContext.bizType)) - const isBasicExperiment = computed(() => scheduleContext.bizType === 'basic_experiment') + const isBasicExperiment = computed(() => isResearchLikeBiz(scheduleContext.bizType)) const applicationContextLabel = computed(() => { const no = scheduleContext.applicationNo?.trim() diff --git a/web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleViewDialog.vue b/web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleViewDialog.vue index afeea479..57dc6eb7 100644 --- a/web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleViewDialog.vue +++ b/web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleViewDialog.vue @@ -133,6 +133,7 @@ import { downloadAttachmentFile } from '@/utils/download-attachment' import { getPilotBizConfig } from '@/config/pilot-biz-type' import { resolveOutboundViewVariant } from '@/utils/outbound-qc-pilot-view-sections' + import { isResearchLikeBiz } from '@/utils/research-like-biz' defineOptions({ name: 'ScheduleViewDialog' }) @@ -179,8 +180,7 @@ const isBasicExperiment = computed( () => - detail.value?.application?.bizType === 'basic_experiment' || - detail.value?.bizType === 'basic_experiment' + isResearchLikeBiz(detail.value?.application?.bizType || detail.value?.bizType) ) const scheduleBizType = computed(() => diff --git a/web-admin/src/views/pilot-service/outbound-release-review/OutboundReleaseReviewDialog.vue b/web-admin/src/views/pilot-service/outbound-release-review/OutboundReleaseReviewDialog.vue index adb405a7..dc2abd07 100644 --- a/web-admin/src/views/pilot-service/outbound-release-review/OutboundReleaseReviewDialog.vue +++ b/web-admin/src/views/pilot-service/outbound-release-review/OutboundReleaseReviewDialog.vue @@ -49,7 +49,7 @@
resolvePilotBizType(singleDetail.value?.application?.bizType) ) + const isResearchLikeReview = computed(() => isResearchLikeBiz(reviewBizType.value)) const reviewBizConfig = computed(() => getPilotBizConfig(reviewBizType.value)) const reviewBizTypeLabel = computed(() => { const fromApi = singleDetail.value?.application?.bizTypeLabel @@ -371,9 +373,7 @@ const d = singleDetail.value if (!d) return [] as Array<{ label: string; value: string; span?: boolean }> const pickupLabel = reviewBizConfig.value.pickupTimeLabel - const isBasicExperiment = reviewBizType.value === 'basic_experiment' - - if (isBasicExperiment) { + if (isResearchLikeReview.value) { return [ { label: '课题名称', value: d.application?.projectTitle || '—' }, { label: '客户名称', value: d.application?.customerName || '—' }, diff --git a/web-admin/src/views/pilot-service/outbound-release-review/index.vue b/web-admin/src/views/pilot-service/outbound-release-review/index.vue index c5414c54..a4679667 100644 --- a/web-admin/src/views/pilot-service/outbound-release-review/index.vue +++ b/web-admin/src/views/pilot-service/outbound-release-review/index.vue @@ -150,6 +150,7 @@ type OutboundReleaseReview } from '@/api/outbound-release-review' import { getPilotBizConfig, resolvePilotBizType } from '@/config/pilot-biz-type' + import { isResearchLikeBiz } from '@/utils/research-like-biz' defineOptions({ name: 'PilotServiceOutboundReleaseReview' }) @@ -170,7 +171,7 @@ const effectiveBizType = computed(() => resolvePilotBizType(props.bizType)) const bizConfig = computed(() => getPilotBizConfig(effectiveBizType.value)) const pickupTimeLabel = computed(() => bizConfig.value.pickupTimeLabel) - const isBasicExperiment = computed(() => effectiveBizType.value === 'basic_experiment') + const isBasicExperiment = computed(() => isResearchLikeBiz(effectiveBizType.value)) const keywordPlaceholder = computed(() => isBasicExperiment.value ? '申请单号/课题名称/客户名称' : '申请单号/患者姓名' ) diff --git a/web-admin/src/views/pilot-service/pilot-application/ApplicationFormDialog.vue b/web-admin/src/views/pilot-service/pilot-application/ApplicationFormDialog.vue index d0ca2e5a..aa75e377 100644 --- a/web-admin/src/views/pilot-service/pilot-application/ApplicationFormDialog.vue +++ b/web-admin/src/views/pilot-service/pilot-application/ApplicationFormDialog.vue @@ -54,7 +54,7 @@ :required="!isEdit && projectRequired" >