Compare commits
54
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b1bf8a1d2 | ||
|
|
ef3e015ff9 | ||
|
|
a598b17ab9 | ||
|
|
f7890f5560 | ||
|
|
6ea3aed8db | ||
|
|
8349b0ce73 | ||
|
|
85fe63fa9f | ||
|
|
77cdeede15 | ||
|
|
4dc352e4f4 | ||
|
|
c5f26912bd | ||
|
|
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 | ||
|
|
0b4c8dfda8 | ||
|
|
6ddd07dbb5 | ||
|
|
f9aa16ef31 | ||
|
|
7751cc0f4a | ||
|
|
0346bc0b1d | ||
|
|
76ddb81818 | ||
|
|
3f16a8ab3e | ||
|
|
14e733faf0 | ||
|
|
aac72e1fd9 | ||
|
|
f0a6abe538 | ||
|
|
a69dcc5bca | ||
|
|
0929164bf5 | ||
|
|
5ecde0c80d | ||
|
|
4024aad174 | ||
|
|
02811197c6 | ||
|
|
7b6a0523dd | ||
|
|
99562ee584 |
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
|
||||||
|
|||||||
@@ -47,10 +47,12 @@ from app.api.sample_cert_insurance import router as sample_cert_insurance_router
|
|||||||
from app.api.sample_code_correction import router as sample_code_correction_router
|
from app.api.sample_code_correction import router as sample_code_correction_router
|
||||||
from app.api.lab_sample_process import router as lab_sample_process_router
|
from app.api.lab_sample_process import router as lab_sample_process_router
|
||||||
from app.api.lab_sample_processing import router as lab_sample_processing_router
|
from app.api.lab_sample_processing import router as lab_sample_processing_router
|
||||||
|
from app.api.business_sample import router as business_sample_router
|
||||||
|
|
||||||
from app.api.project_management import router as project_management_router
|
from app.api.project_management import router as project_management_router
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
"business_sample_router",
|
||||||
"project_management_router",
|
"project_management_router",
|
||||||
"lab_sample_process_router",
|
"lab_sample_process_router",
|
||||||
"public_router",
|
"public_router",
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
"""业务样本:人工作废等跨模块入口。"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Depends
|
||||||
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from app.core.database import get_db
|
||||||
|
from app.core.menu_guard import require_admin_or_super_admin
|
||||||
|
from app.core.response import error_response, success_response
|
||||||
|
from app.models.models import SysUser
|
||||||
|
from app.services.protocol_reception_discard_sync import SAMPLE_VOID_STATUS, void_sample_manually
|
||||||
|
|
||||||
|
router = APIRouter(prefix="/web/admin", tags=["业务样本"])
|
||||||
|
|
||||||
|
|
||||||
|
class VoidSampleBody(BaseModel):
|
||||||
|
model_config = ConfigDict(populate_by_name=True)
|
||||||
|
|
||||||
|
reception_source: str = Field(..., alias="receptionSource")
|
||||||
|
void_desc: str = Field(..., alias="voidDesc")
|
||||||
|
sample_id: Optional[str] = Field(None, alias="sampleId")
|
||||||
|
sample_code: Optional[str] = Field(None, alias="sampleCode")
|
||||||
|
protocol_id: Optional[str] = Field(None, alias="protocolId")
|
||||||
|
|
||||||
|
|
||||||
|
def _get_tenant_no(db: Session, user: dict) -> str:
|
||||||
|
user_id = user.get("user_id")
|
||||||
|
if not user_id:
|
||||||
|
raise PermissionError("用户身份信息缺失,无法确定租户")
|
||||||
|
sys_user = db.query(SysUser).filter(SysUser.id == user_id).first()
|
||||||
|
if not sys_user or not sys_user.tenant_no:
|
||||||
|
raise PermissionError("用户租户信息缺失")
|
||||||
|
return sys_user.tenant_no
|
||||||
|
|
||||||
|
|
||||||
|
def _get_current_user_id(user: dict) -> str:
|
||||||
|
user_id = user.get("user_id")
|
||||||
|
if not user_id:
|
||||||
|
raise PermissionError("用户身份信息缺失")
|
||||||
|
return str(user_id)
|
||||||
|
|
||||||
|
|
||||||
|
@router.put("/business-samples/void")
|
||||||
|
async def void_business_sample(
|
||||||
|
body: VoidSampleBody,
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
user: dict = Depends(require_admin_or_super_admin),
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
tenant_no = _get_tenant_no(db, user)
|
||||||
|
user_id = _get_current_user_id(user)
|
||||||
|
sample = void_sample_manually(
|
||||||
|
db,
|
||||||
|
source=body.reception_source,
|
||||||
|
tenant_no=tenant_no,
|
||||||
|
void_desc=body.void_desc,
|
||||||
|
user_id=user_id,
|
||||||
|
sample_id=body.sample_id,
|
||||||
|
sample_code=body.sample_code,
|
||||||
|
protocol_id=body.protocol_id,
|
||||||
|
commit=True,
|
||||||
|
)
|
||||||
|
return success_response(
|
||||||
|
{
|
||||||
|
"id": sample.id,
|
||||||
|
"sampleCode": getattr(sample, "sample_code", None) or "",
|
||||||
|
"sampleStatus": SAMPLE_VOID_STATUS,
|
||||||
|
"voidDate": getattr(sample, "void_date", None) or "",
|
||||||
|
"voidDesc": getattr(sample, "void_desc", None) or "",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
except PermissionError as e:
|
||||||
|
return error_response(403, str(e))
|
||||||
|
except ValueError as e:
|
||||||
|
return error_response(400, str(e))
|
||||||
|
except Exception as e:
|
||||||
|
return error_response(400, str(e))
|
||||||
+54
-36
@@ -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",
|
||||||
@@ -298,44 +298,14 @@ STATIC_MENU_TREE = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
# 中试服务
|
# 临床科研
|
||||||
{
|
|
||||||
"id": "PIL00000000000000000000000000001",
|
|
||||||
"name": "PilotService",
|
|
||||||
"path": "pilot-service",
|
|
||||||
"component": "",
|
|
||||||
"meta": {
|
|
||||||
"title": "中试服务",
|
|
||||||
"icon": "ri:flask-line",
|
|
||||||
"keepAlive": False,
|
|
||||||
"roles": ["admin"],
|
|
||||||
},
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"id": "80000000000000000000000000000010",
|
|
||||||
"name": "PilotApplication",
|
|
||||||
"path": "pilot-application",
|
|
||||||
"component": "/pilot-service/pilot-application/index",
|
|
||||||
"meta": {"title": "中试服务申请单", "keepAlive": True, "menuCode": "pilot-service:pilot-application:list"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "PIL00000000000000000000000000004",
|
|
||||||
"name": "PilotOutboundRelease",
|
|
||||||
"path": "outbound-release-review",
|
|
||||||
"component": "/pilot-service/outbound-release-review/index",
|
|
||||||
"meta": {"title": "出库放行审核", "keepAlive": True, "menuCode": "pilot-service:outbound-release-review:list"},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
# 基础实验
|
|
||||||
{
|
{
|
||||||
"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 +317,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 +345,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",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class ApplicationCreateBody(BaseModel):
|
|||||||
customer_name: Optional[str] = Field(None, alias="customerName")
|
customer_name: Optional[str] = Field(None, alias="customerName")
|
||||||
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
||||||
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
||||||
|
research_category: Optional[str] = Field(None, alias="researchCategory")
|
||||||
|
|
||||||
|
|
||||||
class ApplicationUpdateBody(BaseModel):
|
class ApplicationUpdateBody(BaseModel):
|
||||||
@@ -65,6 +66,7 @@ class ApplicationUpdateBody(BaseModel):
|
|||||||
customer_name: Optional[str] = Field(None, alias="customerName")
|
customer_name: Optional[str] = Field(None, alias="customerName")
|
||||||
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
||||||
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
||||||
|
research_category: Optional[str] = Field(None, alias="researchCategory")
|
||||||
|
|
||||||
|
|
||||||
class PatientSaveBody(BaseModel):
|
class PatientSaveBody(BaseModel):
|
||||||
@@ -206,6 +208,7 @@ class ApplicationSaveBody(BaseModel):
|
|||||||
customer_name: Optional[str] = Field(None, alias="customerName")
|
customer_name: Optional[str] = Field(None, alias="customerName")
|
||||||
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
||||||
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
||||||
|
research_category: Optional[str] = Field(None, alias="researchCategory")
|
||||||
remark: Optional[str] = None
|
remark: Optional[str] = None
|
||||||
consent_form_urls: Optional[str] = Field(None, alias="consentFormUrls")
|
consent_form_urls: Optional[str] = Field(None, alias="consentFormUrls")
|
||||||
consent_attachments: Optional[list] = Field(None, alias="consentAttachments")
|
consent_attachments: Optional[list] = Field(None, alias="consentAttachments")
|
||||||
@@ -287,6 +290,7 @@ async def api_create_application(
|
|||||||
"customerName": body.customer_name,
|
"customerName": body.customer_name,
|
||||||
"customerContact": body.customer_contact,
|
"customerContact": body.customer_contact,
|
||||||
"customerPhone": body.customer_phone,
|
"customerPhone": body.customer_phone,
|
||||||
|
"researchCategory": body.research_category,
|
||||||
}
|
}
|
||||||
result = pilot_application.create_application(
|
result = pilot_application.create_application(
|
||||||
db,
|
db,
|
||||||
@@ -322,6 +326,8 @@ async def api_update_application(
|
|||||||
data["customerContact"] = body.customer_contact
|
data["customerContact"] = body.customer_contact
|
||||||
if body.customer_phone is not None:
|
if body.customer_phone is not None:
|
||||||
data["customerPhone"] = body.customer_phone
|
data["customerPhone"] = body.customer_phone
|
||||||
|
if body.research_category is not None:
|
||||||
|
data["researchCategory"] = body.research_category
|
||||||
result = pilot_application.update_application(
|
result = pilot_application.update_application(
|
||||||
db, app_id=body.id, data=data, tenant_no=tenant_no
|
db, app_id=body.id, data=data, tenant_no=tenant_no
|
||||||
)
|
)
|
||||||
@@ -364,6 +370,8 @@ async def api_save_application(
|
|||||||
app_data["customerContact"] = body.customer_contact
|
app_data["customerContact"] = body.customer_contact
|
||||||
if body.customer_phone is not None:
|
if body.customer_phone is not None:
|
||||||
app_data["customerPhone"] = body.customer_phone
|
app_data["customerPhone"] = body.customer_phone
|
||||||
|
if body.research_category is not None:
|
||||||
|
app_data["researchCategory"] = body.research_category
|
||||||
if body.consent_attachments is not None:
|
if body.consent_attachments is not None:
|
||||||
app_data["consentAttachments"] = body.consent_attachments
|
app_data["consentAttachments"] = body.consent_attachments
|
||||||
elif body.consent_form_urls is not None:
|
elif body.consent_form_urls is not None:
|
||||||
|
|||||||
@@ -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":
|
||||||
|
|||||||
Whitespace-only changes.
@@ -0,0 +1,27 @@
|
|||||||
|
"""临床科研申请单 · 业务子类型(research_category)"""
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
RESEARCH_CATEGORY_LABELS = {
|
||||||
|
"bio_tech_clinical": "生物新技术临床科研",
|
||||||
|
"joint_topic_declare": "临床课题联合申报",
|
||||||
|
"bio_pharma_rd": "生物制药研发",
|
||||||
|
}
|
||||||
|
|
||||||
|
RESEARCH_CATEGORY_CODES = tuple(RESEARCH_CATEGORY_LABELS.keys())
|
||||||
|
|
||||||
|
|
||||||
|
def research_category_label(code: Optional[str]) -> str:
|
||||||
|
if not code:
|
||||||
|
return ""
|
||||||
|
return RESEARCH_CATEGORY_LABELS.get(code, code)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_research_category(code: Optional[str], required: bool = False) -> str:
|
||||||
|
value = (code or "").strip()
|
||||||
|
if not value:
|
||||||
|
if required:
|
||||||
|
raise ValueError("请选择业务类型")
|
||||||
|
return ""
|
||||||
|
if value not in RESEARCH_CATEGORY_LABELS:
|
||||||
|
raise ValueError("业务类型无效")
|
||||||
|
return value
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -739,6 +739,7 @@ def _sample_to_dict(s: BizProtocolSample) -> Dict[str, Any]:
|
|||||||
"storageInDate": (s.storage_in_date or "").strip() if s.storage_in_date else "",
|
"storageInDate": (s.storage_in_date or "").strip() if s.storage_in_date else "",
|
||||||
"detectStartDate": (s.detect_start_date or "").strip() if s.detect_start_date else "",
|
"detectStartDate": (s.detect_start_date or "").strip() if s.detect_start_date else "",
|
||||||
"voidDate": (s.void_date or "").strip() if s.void_date else "",
|
"voidDate": (s.void_date or "").strip() if s.void_date else "",
|
||||||
|
"voidDesc": (getattr(s, "void_desc", None) or "").strip() if (getattr(s, "void_desc", None) or "").strip() else "",
|
||||||
"storageExpireDate": (s.storage_expire_date or "").strip() if s.storage_expire_date else "",
|
"storageExpireDate": (s.storage_expire_date or "").strip() if s.storage_expire_date else "",
|
||||||
**sample_special_to_dict(s),
|
**sample_special_to_dict(s),
|
||||||
"tenantNo": s.tenant_no,
|
"tenantNo": s.tenant_no,
|
||||||
@@ -1393,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),
|
||||||
@@ -2677,7 +2679,7 @@ def update_collection_protocol(
|
|||||||
next_status = protocol_status.strip()
|
next_status = protocol_status.strip()
|
||||||
assert_protocol_status_transition(obj.protocol_status or "", next_status, kind="protocol")
|
assert_protocol_status_transition(obj.protocol_status or "", next_status, kind="protocol")
|
||||||
obj.protocol_status = next_status
|
obj.protocol_status = next_status
|
||||||
if next_status == "yzf" and from_status != "yzf":
|
if next_status in ("yzf", "sdfq") and from_status not in ("yzf", "sdfq"):
|
||||||
voided_now = True
|
voided_now = True
|
||||||
if next_status == "yzf" and void_time is not None:
|
if next_status == "yzf" and void_time is not None:
|
||||||
if void_type is None or not str(void_type).strip():
|
if void_type is None or not str(void_type).strip():
|
||||||
|
|||||||
@@ -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": "临床科研",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from app.models.models import (
|
|||||||
)
|
)
|
||||||
from app.crud import pilot_checkup
|
from app.crud import pilot_checkup
|
||||||
from app.crud.collection_protocol import attachments_to_urls, urls_to_attachment_list
|
from app.crud.collection_protocol import attachments_to_urls, urls_to_attachment_list
|
||||||
|
from app.constants.research_category import validate_research_category
|
||||||
|
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
@@ -125,6 +126,7 @@ def _row_to_dict_application(row, db=None, tenant_no=None) -> Dict[str, Any]:
|
|||||||
"customerName": row.customer_name or "",
|
"customerName": row.customer_name or "",
|
||||||
"customerContact": row.customer_contact or "",
|
"customerContact": row.customer_contact or "",
|
||||||
"customerPhone": row.customer_phone or "",
|
"customerPhone": row.customer_phone or "",
|
||||||
|
"researchCategory": getattr(row, "research_category", None) or "",
|
||||||
"applicationStatus": row.application_status or "",
|
"applicationStatus": row.application_status or "",
|
||||||
"bizType": row.biz_type or "pilot_service",
|
"bizType": row.biz_type or "pilot_service",
|
||||||
"channelServiceOrderId": row.channel_service_order_id or "",
|
"channelServiceOrderId": row.channel_service_order_id or "",
|
||||||
@@ -455,6 +457,7 @@ def create_application(
|
|||||||
customer_name = ""
|
customer_name = ""
|
||||||
customer_contact = ""
|
customer_contact = ""
|
||||||
customer_phone = ""
|
customer_phone = ""
|
||||||
|
research_category = ""
|
||||||
consent_form_urls = data.get("consentFormUrls") or None
|
consent_form_urls = data.get("consentFormUrls") or None
|
||||||
|
|
||||||
if biz_type == "basic_experiment":
|
if biz_type == "basic_experiment":
|
||||||
@@ -466,6 +469,9 @@ def create_application(
|
|||||||
raise ValueError("请填写客户联系人")
|
raise ValueError("请填写客户联系人")
|
||||||
if not (data.get("customerPhone") or "").strip():
|
if not (data.get("customerPhone") or "").strip():
|
||||||
raise ValueError("请填写客户联系方式")
|
raise ValueError("请填写客户联系方式")
|
||||||
|
research_category = validate_research_category(
|
||||||
|
data.get("researchCategory"), required=True
|
||||||
|
)
|
||||||
project_title = (data.get("projectTitle") or "").strip()
|
project_title = (data.get("projectTitle") or "").strip()
|
||||||
customer_name = (data.get("customerName") or "").strip()
|
customer_name = (data.get("customerName") or "").strip()
|
||||||
customer_contact = (data.get("customerContact") or "").strip()
|
customer_contact = (data.get("customerContact") or "").strip()
|
||||||
@@ -527,6 +533,7 @@ def create_application(
|
|||||||
customer_name=customer_name or None,
|
customer_name=customer_name or None,
|
||||||
customer_contact=customer_contact or None,
|
customer_contact=customer_contact or None,
|
||||||
customer_phone=customer_phone or None,
|
customer_phone=customer_phone or None,
|
||||||
|
research_category=research_category or None,
|
||||||
application_status="dks",
|
application_status="dks",
|
||||||
channel_service_order_id=channel_service_order_id or "",
|
channel_service_order_id=channel_service_order_id or "",
|
||||||
channel_id=(
|
channel_id=(
|
||||||
@@ -586,6 +593,15 @@ def update_application(db: Session, app_id: str, data: dict, tenant_no: str) ->
|
|||||||
row.customer_contact = (data["customerContact"] or "").strip() or None
|
row.customer_contact = (data["customerContact"] or "").strip() or None
|
||||||
if "customerPhone" in data and data["customerPhone"] is not None:
|
if "customerPhone" in data and data["customerPhone"] is not None:
|
||||||
row.customer_phone = (data["customerPhone"] or "").strip() or 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.research_category = validate_research_category(
|
||||||
|
data.get("researchCategory"), required=True
|
||||||
|
) or None
|
||||||
|
else:
|
||||||
|
row.research_category = validate_research_category(
|
||||||
|
data.get("researchCategory"), required=False
|
||||||
|
) or None
|
||||||
if "consentFormUrls" in data:
|
if "consentFormUrls" in data:
|
||||||
row.consent_form_urls = data.get("consentFormUrls") or None
|
row.consent_form_urls = data.get("consentFormUrls") or None
|
||||||
if "attachmentUrls" in data:
|
if "attachmentUrls" in data:
|
||||||
@@ -1601,7 +1617,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 +1663,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 +1676,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]
|
||||||
@@ -49,6 +49,7 @@ from app.models.models import (
|
|||||||
BizPilotInfusionSchedule,
|
BizPilotInfusionSchedule,
|
||||||
BizPilotInfusionScheduleProduct,
|
BizPilotInfusionScheduleProduct,
|
||||||
BizPilotPatient,
|
BizPilotPatient,
|
||||||
|
BizProtocolCollectionInfo,
|
||||||
BizProtocolPartyCustomer,
|
BizProtocolPartyCustomer,
|
||||||
BizProtocolSample,
|
BizProtocolSample,
|
||||||
BizProductionTask,
|
BizProductionTask,
|
||||||
@@ -69,6 +70,7 @@ from app.models.models import (
|
|||||||
from app.models.qc_param import BizQcTaskResult
|
from app.models.qc_param import BizQcTaskResult
|
||||||
from app.models.research_donation import (
|
from app.models.research_donation import (
|
||||||
BizResearchDonation,
|
BizResearchDonation,
|
||||||
|
BizResearchDonationCollection,
|
||||||
BizResearchDonationParty,
|
BizResearchDonationParty,
|
||||||
BizResearchDonationSample,
|
BizResearchDonationSample,
|
||||||
)
|
)
|
||||||
@@ -106,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())
|
||||||
|
|
||||||
@@ -677,9 +679,6 @@ def _enrich_work_order_list_items(
|
|||||||
code = (r.sample_code or "").strip()
|
code = (r.sample_code or "").strip()
|
||||||
if code and code not in sample_code_rec_map:
|
if code and code not in sample_code_rec_map:
|
||||||
sample_code_rec_map[code] = r
|
sample_code_rec_map[code] = r
|
||||||
if not rec_map and not sample_code_rec_map:
|
|
||||||
return items
|
|
||||||
|
|
||||||
def _resolve_reception(item: Dict[str, Any]) -> Optional[BizSampleReception]:
|
def _resolve_reception(item: Dict[str, Any]) -> Optional[BizSampleReception]:
|
||||||
rec = rec_map.get(item.get("receptionId") or "")
|
rec = rec_map.get(item.get("receptionId") or "")
|
||||||
if rec:
|
if rec:
|
||||||
@@ -695,7 +694,9 @@ def _enrich_work_order_list_items(
|
|||||||
rec = _resolve_reception(item)
|
rec = _resolve_reception(item)
|
||||||
source = _effective_reception_source(item, rec)
|
source = _effective_reception_source(item, rec)
|
||||||
if source == "research_donation":
|
if source == "research_donation":
|
||||||
dsid = _effective_donation_sample_id(item, rec)
|
dsid = _effective_donation_sample_id(item, rec) or (
|
||||||
|
item.get("protocolSampleId") or ""
|
||||||
|
).strip()
|
||||||
if dsid:
|
if dsid:
|
||||||
donation_sample_ids.append(dsid)
|
donation_sample_ids.append(dsid)
|
||||||
did = (
|
did = (
|
||||||
@@ -704,7 +705,9 @@ def _enrich_work_order_list_items(
|
|||||||
if did:
|
if did:
|
||||||
donation_ids.append(did)
|
donation_ids.append(did)
|
||||||
else:
|
else:
|
||||||
psid = _effective_protocol_sample_id(item, rec)
|
psid = _effective_protocol_sample_id(item, rec) or (
|
||||||
|
item.get("protocolSampleId") or ""
|
||||||
|
).strip()
|
||||||
if psid:
|
if psid:
|
||||||
cell_sample_ids.append(psid)
|
cell_sample_ids.append(psid)
|
||||||
pid = (
|
pid = (
|
||||||
@@ -808,12 +811,39 @@ def _enrich_work_order_list_items(
|
|||||||
party.mother_name or "",
|
party.mother_name or "",
|
||||||
party.newborn_name or "",
|
party.newborn_name or "",
|
||||||
)
|
)
|
||||||
|
cell_maternal_map: Dict[str, str] = {}
|
||||||
|
if cell_proto_ids:
|
||||||
|
for coll in (
|
||||||
|
db.query(BizProtocolCollectionInfo)
|
||||||
|
.filter(
|
||||||
|
BizProtocolCollectionInfo.collection_protocol_id.in_(cell_proto_ids),
|
||||||
|
BizProtocolCollectionInfo.del_flag == 0,
|
||||||
|
)
|
||||||
|
.all()
|
||||||
|
):
|
||||||
|
cell_maternal_map[coll.collection_protocol_id] = _fmt_dt(
|
||||||
|
coll.maternal_blood_collect_time
|
||||||
|
)
|
||||||
|
donation_maternal_map: Dict[str, str] = {}
|
||||||
|
if donation_ids:
|
||||||
|
for coll in (
|
||||||
|
db.query(BizResearchDonationCollection)
|
||||||
|
.filter(
|
||||||
|
BizResearchDonationCollection.research_donation_id.in_(donation_ids),
|
||||||
|
BizResearchDonationCollection.del_flag == 0,
|
||||||
|
)
|
||||||
|
.all()
|
||||||
|
):
|
||||||
|
donation_maternal_map[coll.research_donation_id] = _fmt_dt(
|
||||||
|
coll.maternal_blood_collect_time
|
||||||
|
)
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.get("workOrderType") == "temporary":
|
if item.get("workOrderType") == "temporary":
|
||||||
item["receptionSource"] = ""
|
item["receptionSource"] = ""
|
||||||
item["receptionSourceLabel"] = ""
|
item["receptionSourceLabel"] = ""
|
||||||
item["motherName"] = ""
|
item["motherName"] = ""
|
||||||
item["newbornName"] = ""
|
item["newbornName"] = ""
|
||||||
|
item["maternalBloodCollectTime"] = ""
|
||||||
continue
|
continue
|
||||||
rec = _resolve_reception(item)
|
rec = _resolve_reception(item)
|
||||||
source = _effective_reception_source(item, rec)
|
source = _effective_reception_source(item, rec)
|
||||||
@@ -826,6 +856,7 @@ def _enrich_work_order_list_items(
|
|||||||
_mother, _newborn = donation_party_map.get(_did or "", ("", ""))
|
_mother, _newborn = donation_party_map.get(_did or "", ("", ""))
|
||||||
item["motherName"] = _mother
|
item["motherName"] = _mother
|
||||||
item["newbornName"] = _newborn
|
item["newbornName"] = _newborn
|
||||||
|
item["maternalBloodCollectTime"] = donation_maternal_map.get(_did or "", "") or ""
|
||||||
else:
|
else:
|
||||||
_pid = (
|
_pid = (
|
||||||
(getattr(rec, "collection_protocol_id", None) if rec else None) or ""
|
(getattr(rec, "collection_protocol_id", None) if rec else None) or ""
|
||||||
@@ -833,11 +864,35 @@ def _enrich_work_order_list_items(
|
|||||||
_mother, _newborn = cell_party_map.get(_pid or "", ("", ""))
|
_mother, _newborn = cell_party_map.get(_pid or "", ("", ""))
|
||||||
item["motherName"] = _mother
|
item["motherName"] = _mother
|
||||||
item["newbornName"] = _newborn
|
item["newbornName"] = _newborn
|
||||||
|
item["maternalBloodCollectTime"] = cell_maternal_map.get(_pid or "", "") or ""
|
||||||
|
def _apply_sample_status_fields() -> None:
|
||||||
|
sample_obj = None
|
||||||
|
if source == "research_donation":
|
||||||
|
dsid = _effective_donation_sample_id(item, rec) or (
|
||||||
|
item.get("protocolSampleId") or ""
|
||||||
|
).strip()
|
||||||
|
sample_obj = donation_samples.get(dsid) if dsid else None
|
||||||
|
else:
|
||||||
|
psid = _effective_protocol_sample_id(item, rec) or (
|
||||||
|
item.get("protocolSampleId") or ""
|
||||||
|
).strip()
|
||||||
|
sample_obj = protocol_samples.get(psid) if psid else None
|
||||||
|
item["sampleStatus"] = (
|
||||||
|
(sample_obj.sample_status or "").strip() if sample_obj else ""
|
||||||
|
)
|
||||||
|
item["voidDesc"] = (
|
||||||
|
(getattr(sample_obj, "void_desc", None) or "").strip() if sample_obj else ""
|
||||||
|
)
|
||||||
|
item["voidDate"] = (
|
||||||
|
(sample_obj.void_date or "").strip() if sample_obj else ""
|
||||||
|
)
|
||||||
|
|
||||||
if not rec:
|
if not rec:
|
||||||
item.setdefault("receptionTime", "")
|
item.setdefault("receptionTime", "")
|
||||||
item.setdefault("handlerName", "")
|
item.setdefault("handlerName", "")
|
||||||
item.setdefault("sampleTypeName", "")
|
item.setdefault("sampleTypeName", "")
|
||||||
item.setdefault("labStorageCode", "")
|
item.setdefault("labStorageCode", "")
|
||||||
|
_apply_sample_status_fields()
|
||||||
continue
|
continue
|
||||||
item["receptionTime"] = _fmt_dt(rec.reception_time)
|
item["receptionTime"] = _fmt_dt(rec.reception_time)
|
||||||
item["handlerName"] = rec.handler_name or ""
|
item["handlerName"] = rec.handler_name or ""
|
||||||
@@ -858,6 +913,7 @@ def _enrich_work_order_list_items(
|
|||||||
protocol_samples=protocol_samples,
|
protocol_samples=protocol_samples,
|
||||||
donation_samples=donation_samples,
|
donation_samples=donation_samples,
|
||||||
)
|
)
|
||||||
|
_apply_sample_status_fields()
|
||||||
if source == "research_donation":
|
if source == "research_donation":
|
||||||
_did = (
|
_did = (
|
||||||
(getattr(rec, "research_donation_id", None) or "").strip()
|
(getattr(rec, "research_donation_id", None) or "").strip()
|
||||||
@@ -1140,6 +1196,7 @@ def _wo_to_dict(
|
|||||||
"receptionTime": "",
|
"receptionTime": "",
|
||||||
"handlerName": "",
|
"handlerName": "",
|
||||||
"sampleTypeName": "",
|
"sampleTypeName": "",
|
||||||
|
"maternalBloodCollectTime": "",
|
||||||
"workOrderStatus": wo.work_order_status,
|
"workOrderStatus": wo.work_order_status,
|
||||||
"workOrderStatusLabel": _WORK_ORDER_STATUS_LABELS.get(
|
"workOrderStatusLabel": _WORK_ORDER_STATUS_LABELS.get(
|
||||||
wo.work_order_status or "", wo.work_order_status or ""
|
wo.work_order_status or "", wo.work_order_status or ""
|
||||||
@@ -2601,6 +2658,7 @@ def get_work_order_detail(
|
|||||||
"receptionSourceLabel": enriched.get("receptionSourceLabel", ""),
|
"receptionSourceLabel": enriched.get("receptionSourceLabel", ""),
|
||||||
"motherName": enriched.get("motherName", ""),
|
"motherName": enriched.get("motherName", ""),
|
||||||
"newbornName": enriched.get("newbornName", ""),
|
"newbornName": enriched.get("newbornName", ""),
|
||||||
|
"maternalBloodCollectTime": enriched.get("maternalBloodCollectTime", ""),
|
||||||
"protocolStatus": enriched.get("protocolStatus", ""),
|
"protocolStatus": enriched.get("protocolStatus", ""),
|
||||||
"protocolStatusLabel": enriched.get("protocolStatusLabel", ""),
|
"protocolStatusLabel": enriched.get("protocolStatusLabel", ""),
|
||||||
"cellProductCode": enriched.get("cellProductCode", ""),
|
"cellProductCode": enriched.get("cellProductCode", ""),
|
||||||
@@ -2695,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
|
||||||
@@ -3826,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)
|
||||||
@@ -3834,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
|
||||||
|
|||||||
@@ -535,6 +535,7 @@ def _sample_to_dict(s: BizResearchDonationSample) -> Dict[str, Any]:
|
|||||||
"storageInDate": (s.storage_in_date or "").strip() if s.storage_in_date else "",
|
"storageInDate": (s.storage_in_date or "").strip() if s.storage_in_date else "",
|
||||||
"detectStartDate": (s.detect_start_date or "").strip() if s.detect_start_date else "",
|
"detectStartDate": (s.detect_start_date or "").strip() if s.detect_start_date else "",
|
||||||
"voidDate": (s.void_date or "").strip() if s.void_date else "",
|
"voidDate": (s.void_date or "").strip() if s.void_date else "",
|
||||||
|
"voidDesc": (getattr(s, "void_desc", None) or "").strip() if (getattr(s, "void_desc", None) or "").strip() else "",
|
||||||
"storageExpireDate": (s.storage_expire_date or "").strip() if s.storage_expire_date else "",
|
"storageExpireDate": (s.storage_expire_date or "").strip() if s.storage_expire_date else "",
|
||||||
**sample_special_to_dict(s),
|
**sample_special_to_dict(s),
|
||||||
"tenantNo": s.tenant_no,
|
"tenantNo": s.tenant_no,
|
||||||
@@ -975,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),
|
||||||
@@ -1702,7 +1704,8 @@ def change_status(
|
|||||||
)
|
)
|
||||||
|
|
||||||
db.add(obj)
|
db.add(obj)
|
||||||
if ns == "yzf" and (current or "").strip() != "yzf":
|
from_status = (current or "").strip()
|
||||||
|
if ns in ("yzf", "sdfq") and from_status not in ("yzf", "sdfq"):
|
||||||
from app.services.protocol_reception_discard_sync import after_protocol_voided
|
from app.services.protocol_reception_discard_sync import after_protocol_voided
|
||||||
|
|
||||||
after_protocol_voided(
|
after_protocol_voided(
|
||||||
|
|||||||
@@ -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": (
|
||||||
@@ -1045,12 +1046,11 @@ def create_sample_reception(
|
|||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
create_dept_id=create_dept_id or "",
|
create_dept_id=create_dept_id or "",
|
||||||
)
|
)
|
||||||
if conclusion == "bj":
|
from app.services.protocol_reception_discard_sync import after_sample_reception_saved
|
||||||
from app.services.protocol_reception_discard_sync import after_sample_reception_saved
|
|
||||||
|
|
||||||
after_sample_reception_saved(
|
after_sample_reception_saved(
|
||||||
db, reception=obj, tenant_no=tenant_no, user_id=user_id
|
db, reception=obj, tenant_no=tenant_no, user_id=user_id
|
||||||
)
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(obj)
|
db.refresh(obj)
|
||||||
return obj
|
return obj
|
||||||
@@ -1169,12 +1169,11 @@ def update_sample_reception(
|
|||||||
)
|
)
|
||||||
check_result_svc.sync_legacy_columns_from_results(db, rec, saved_rows)
|
check_result_svc.sync_legacy_columns_from_results(db, rec, saved_rows)
|
||||||
db.add(rec)
|
db.add(rec)
|
||||||
if conclusion == "bj":
|
from app.services.protocol_reception_discard_sync import after_sample_reception_saved
|
||||||
from app.services.protocol_reception_discard_sync import after_sample_reception_saved
|
|
||||||
|
|
||||||
after_sample_reception_saved(
|
after_sample_reception_saved(
|
||||||
db, reception=rec, tenant_no=tenant_no, user_id=user_id
|
db, reception=rec, tenant_no=tenant_no, user_id=user_id
|
||||||
)
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(rec)
|
db.refresh(rec)
|
||||||
return rec
|
return rec
|
||||||
|
|||||||
+2
-1
@@ -13,7 +13,7 @@ from app.core.database import SessionLocal
|
|||||||
from app.core.api_request_log_middleware import ApiRequestLogMiddleware
|
from app.core.api_request_log_middleware import ApiRequestLogMiddleware
|
||||||
from app.core.api_crypto_middleware import ApiCryptoMiddleware
|
from app.core.api_crypto_middleware import ApiCryptoMiddleware
|
||||||
from app.models import models # noqa: F401
|
from app.models import models # noqa: F401
|
||||||
from app.api import public_router, menu_router, admin_router, workflow_router, basic_info_router, collection_protocol_router, protocol_sample_payment_router, protocol_refund_record_router, presign_order_router, sample_freight_router, leave_router, operations_router, ethnic_router, sample_reception_router, sample_production_reception_router, qc_router, research_donation_router, production_router, pilot_service_router, insurance_company_router, material_router, storage_release_review_router, sample_sms_notification_router, storage_entry_sms_notification_router, qc_sms_notification_router, protocol_sample_collection_router, research_donation_sample_collection_router, pilot_application_router, pilot_checkup_router, pilot_delivery_router, pilot_infusion_confirm_router, pilot_infusion_schedule_mgmt_router, outbound_release_review_router, clinical_payment_router, env_detect_router, cleanroom_garment_router, market_router, pre_transit_sample_router, oa_approval_router, mini_auth_router, mini_menu_router, market_mobile_router, sample_storage_cert_qc_router, customer_service_dict_router, sample_cert_insurance_router, sample_code_correction_router, lab_sample_process_router, lab_sample_processing_router, project_management_router
|
from app.api import public_router, menu_router, admin_router, workflow_router, basic_info_router, collection_protocol_router, protocol_sample_payment_router, protocol_refund_record_router, presign_order_router, sample_freight_router, leave_router, operations_router, ethnic_router, sample_reception_router, sample_production_reception_router, qc_router, research_donation_router, production_router, pilot_service_router, insurance_company_router, material_router, storage_release_review_router, sample_sms_notification_router, storage_entry_sms_notification_router, qc_sms_notification_router, protocol_sample_collection_router, research_donation_sample_collection_router, pilot_application_router, pilot_checkup_router, pilot_delivery_router, pilot_infusion_confirm_router, pilot_infusion_schedule_mgmt_router, outbound_release_review_router, clinical_payment_router, env_detect_router, cleanroom_garment_router, market_router, pre_transit_sample_router, oa_approval_router, mini_auth_router, mini_menu_router, market_mobile_router, sample_storage_cert_qc_router, customer_service_dict_router, sample_cert_insurance_router, sample_code_correction_router, lab_sample_process_router, lab_sample_processing_router, project_management_router, business_sample_router
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
@@ -125,6 +125,7 @@ app.include_router(leave_router, prefix=settings.API_V1_PREFIX)
|
|||||||
app.include_router(operations_router, prefix=settings.API_V1_PREFIX)
|
app.include_router(operations_router, prefix=settings.API_V1_PREFIX)
|
||||||
app.include_router(ethnic_router, prefix=settings.API_V1_PREFIX)
|
app.include_router(ethnic_router, prefix=settings.API_V1_PREFIX)
|
||||||
app.include_router(sample_reception_router, prefix=settings.API_V1_PREFIX)
|
app.include_router(sample_reception_router, prefix=settings.API_V1_PREFIX)
|
||||||
|
app.include_router(business_sample_router, prefix=settings.API_V1_PREFIX)
|
||||||
app.include_router(sample_production_reception_router, prefix=settings.API_V1_PREFIX)
|
app.include_router(sample_production_reception_router, prefix=settings.API_V1_PREFIX)
|
||||||
app.include_router(qc_router, prefix=settings.API_V1_PREFIX)
|
app.include_router(qc_router, prefix=settings.API_V1_PREFIX)
|
||||||
app.include_router(research_donation_router, prefix=settings.API_V1_PREFIX)
|
app.include_router(research_donation_router, prefix=settings.API_V1_PREFIX)
|
||||||
|
|||||||
@@ -1597,6 +1597,7 @@ class BizProtocolSample(Base):
|
|||||||
storage_in_date = Column(CHAR(8), nullable=True, comment="入库日期YYYYMMDD")
|
storage_in_date = Column(CHAR(8), nullable=True, comment="入库日期YYYYMMDD")
|
||||||
detect_start_date = Column(CHAR(8), nullable=True, comment="检测开始日期YYYYMMDD")
|
detect_start_date = Column(CHAR(8), nullable=True, comment="检测开始日期YYYYMMDD")
|
||||||
void_date = Column(CHAR(8), nullable=True, comment="作废日期YYYYMMDD")
|
void_date = Column(CHAR(8), nullable=True, comment="作废日期YYYYMMDD")
|
||||||
|
void_desc = Column(String(512), nullable=True, comment="样本作废原因")
|
||||||
storage_expire_date = Column(CHAR(8), nullable=True, comment="存储到期日期YYYYMMDD")
|
storage_expire_date = Column(CHAR(8), nullable=True, comment="存储到期日期YYYYMMDD")
|
||||||
is_special = Column(SmallInteger, nullable=False, default=0, comment="是否特殊样本:0否 1是")
|
is_special = Column(SmallInteger, nullable=False, default=0, comment="是否特殊样本:0否 1是")
|
||||||
special_remark = Column(String(256), nullable=True, comment="特殊说明")
|
special_remark = Column(String(256), nullable=True, comment="特殊说明")
|
||||||
@@ -2393,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"""
|
||||||
|
|
||||||
@@ -4150,15 +4178,20 @@ 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="客户联系方式(临床科研)")
|
||||||
|
research_category = Column(
|
||||||
|
String(32),
|
||||||
|
nullable=True,
|
||||||
|
comment="临床科研业务子类型: bio_tech_clinical/joint_topic_declare/bio_pharma_rd",
|
||||||
|
)
|
||||||
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="备注")
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ class BizResearchDonationSample(Base):
|
|||||||
storage_in_date = Column(String(8), nullable=True, comment="入库日期YYYYMMDD")
|
storage_in_date = Column(String(8), nullable=True, comment="入库日期YYYYMMDD")
|
||||||
detect_start_date = Column(String(8), nullable=True, comment="检测开始日期YYYYMMDD")
|
detect_start_date = Column(String(8), nullable=True, comment="检测开始日期YYYYMMDD")
|
||||||
void_date = Column(String(8), nullable=True, comment="作废日期YYYYMMDD")
|
void_date = Column(String(8), nullable=True, comment="作废日期YYYYMMDD")
|
||||||
|
void_desc = Column(String(512), nullable=True, comment="样本作废原因")
|
||||||
storage_expire_date = Column(String(8), nullable=True, comment="存储到期日期YYYYMMDD")
|
storage_expire_date = Column(String(8), nullable=True, comment="存储到期日期YYYYMMDD")
|
||||||
is_special = Column(SmallInteger, nullable=False, default=0, comment="是否特殊样本:0否 1是")
|
is_special = Column(SmallInteger, nullable=False, default=0, comment="是否特殊样本:0否 1是")
|
||||||
special_remark = Column(String(256), nullable=True, comment="特殊说明")
|
special_remark = Column(String(256), 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:
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ from app.services.web_auth_roles import (
|
|||||||
CELL = 'cell_storage'
|
CELL = 'cell_storage'
|
||||||
DONATION = 'research_donation'
|
DONATION = 'research_donation'
|
||||||
SOURCES = (CELL, DONATION)
|
SOURCES = (CELL, DONATION)
|
||||||
|
_SAMPLE_STATUS_LABELS = {
|
||||||
|
'ycj': '已采集',
|
||||||
|
'jcz': '检测中',
|
||||||
|
'yrk': '已入库',
|
||||||
|
'yzf': '已作废',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _current_tenant_user_info(
|
def _current_tenant_user_info(
|
||||||
@@ -265,18 +271,25 @@ def _visible_rows(db: Session, freight_ids: List[str], ctx: MarketFieldContext,
|
|||||||
def _item_dict(row) -> Dict[str, Any]:
|
def _item_dict(row) -> Dict[str, Any]:
|
||||||
item, sample, parent, party, sample_type = row
|
item, sample, parent, party, sample_type = row
|
||||||
source = item.sample_source
|
source = item.sample_source
|
||||||
return {
|
sample_code = sample.sample_code or ''
|
||||||
|
payload = {
|
||||||
'id': item.id,
|
'id': item.id,
|
||||||
'freightId': item.freight_id,
|
'freightId': item.freight_id,
|
||||||
'sampleSource': source,
|
'sampleSource': source,
|
||||||
'sampleId': sample.id,
|
'sampleId': sample.id,
|
||||||
'sampleCode': sample.sample_code or '',
|
'sampleCode': sample_code,
|
||||||
'protocolId': parent.id,
|
'protocolId': parent.id,
|
||||||
'protocolNo': (parent.protocol_no if source == CELL else parent.donation_no) or '',
|
'protocolNo': (parent.protocol_no if source == CELL else parent.donation_no) or '',
|
||||||
'sampleTypeName': sample_type.type_name if sample_type else '',
|
'sampleTypeName': sample_type.type_name if sample_type else '',
|
||||||
'motherName': party.mother_name if party else '',
|
'motherName': party.mother_name if party else '',
|
||||||
'newbornName': party.newborn_name if party else '',
|
'newbornName': party.newborn_name if party else '',
|
||||||
}
|
}
|
||||||
|
if sample_code:
|
||||||
|
status = str(getattr(sample, 'sample_status', None) or '').strip()
|
||||||
|
payload['sampleStatus'] = status
|
||||||
|
payload['sampleStatusLabel'] = _SAMPLE_STATUS_LABELS.get(status, '')
|
||||||
|
payload['voidDesc'] = str(getattr(sample, 'void_desc', None) or '')
|
||||||
|
return payload
|
||||||
|
|
||||||
|
|
||||||
def _label_map(db: Session, tenant_no: str, values: List[str]) -> Dict[str, str]:
|
def _label_map(db: Session, tenant_no: str, values: List[str]) -> Dict[str, str]:
|
||||||
|
|||||||
@@ -40,6 +40,51 @@ from app.services.market_support import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_SAMPLE_STATUS_LABELS = {
|
||||||
|
'ycj': '已采集',
|
||||||
|
'jcz': '检测中',
|
||||||
|
'yrk': '已入库',
|
||||||
|
'yzf': '已作废',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _sample_status_by_code(
|
||||||
|
db: Session,
|
||||||
|
tenant_no: str,
|
||||||
|
sample_codes: List[str],
|
||||||
|
) -> Dict[str, Dict[str, str]]:
|
||||||
|
"""按租户 + 样本编码取样本状态;同一编码多行时保留最近更新的一条。"""
|
||||||
|
wanted = [code for code in {str(code or '').strip() for code in sample_codes} if code]
|
||||||
|
if not wanted:
|
||||||
|
return {}
|
||||||
|
rows = (
|
||||||
|
db.query(BizProtocolSample)
|
||||||
|
.filter(
|
||||||
|
BizProtocolSample.tenant_no == tenant_no,
|
||||||
|
BizProtocolSample.del_flag == 0,
|
||||||
|
BizProtocolSample.sample_code.in_(wanted),
|
||||||
|
)
|
||||||
|
.order_by(
|
||||||
|
BizProtocolSample.update_time.desc(),
|
||||||
|
BizProtocolSample.create_time.desc(),
|
||||||
|
BizProtocolSample.id.desc(),
|
||||||
|
)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
result: Dict[str, Dict[str, str]] = {}
|
||||||
|
for sample in rows:
|
||||||
|
code = str(sample.sample_code or '').strip()
|
||||||
|
if not code or code in result:
|
||||||
|
continue
|
||||||
|
status = str(sample.sample_status or '').strip()
|
||||||
|
result[code] = {
|
||||||
|
'sampleStatus': status,
|
||||||
|
'sampleStatusLabel': _SAMPLE_STATUS_LABELS.get(status, ''),
|
||||||
|
'voidDesc': sample.void_desc or '',
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _current_dept_id(user_info: dict) -> str:
|
def _current_dept_id(user_info: dict) -> str:
|
||||||
return str(
|
return str(
|
||||||
user_info.get('dept_id')
|
user_info.get('dept_id')
|
||||||
@@ -104,12 +149,16 @@ def _load_sample_meta(
|
|||||||
discount = None
|
discount = None
|
||||||
if original is not None and current is not None and original > current:
|
if original is not None and current is not None and original > current:
|
||||||
discount = original - current
|
discount = original - current
|
||||||
|
status = str(sample.sample_status or '').strip()
|
||||||
result.setdefault(
|
result.setdefault(
|
||||||
sample.sample_code or '',
|
sample.sample_code or '',
|
||||||
{
|
{
|
||||||
'storageYears': sample.storage_years,
|
'storageYears': sample.storage_years,
|
||||||
'sampleTypeName': sample_type.type_name if sample_type else '',
|
'sampleTypeName': sample_type.type_name if sample_type else '',
|
||||||
'discountAmount': _money(discount),
|
'discountAmount': _money(discount),
|
||||||
|
'sampleStatus': status,
|
||||||
|
'sampleStatusLabel': _SAMPLE_STATUS_LABELS.get(status, ''),
|
||||||
|
'voidDesc': sample.void_desc or '',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
@@ -235,7 +284,8 @@ def _payment_dict(
|
|||||||
'bfyj': '部分已缴',
|
'bfyj': '部分已缴',
|
||||||
'dfj': '待缴费',
|
'dfj': '待缴费',
|
||||||
}[progress_code]
|
}[progress_code]
|
||||||
return {
|
sample_code = payment.sample_code or ''
|
||||||
|
payload = {
|
||||||
'id': payment.id,
|
'id': payment.id,
|
||||||
'collectionProtocolId': protocol.id,
|
'collectionProtocolId': protocol.id,
|
||||||
'protocolNo': protocol.protocol_no or '',
|
'protocolNo': protocol.protocol_no or '',
|
||||||
@@ -243,7 +293,7 @@ def _payment_dict(
|
|||||||
'paymentModelVersion': int(getattr(protocol, 'payment_model_version', None) or 1),
|
'paymentModelVersion': int(getattr(protocol, 'payment_model_version', None) or 1),
|
||||||
'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': payment.sample_code or '',
|
'sampleCode': sample_code,
|
||||||
'payMode': payment.pay_mode or '',
|
'payMode': payment.pay_mode or '',
|
||||||
'contractAmount': _money(payment.contract_amount),
|
'contractAmount': _money(payment.contract_amount),
|
||||||
'signDate': _display_ymd(getattr(protocol, 'register_date', None)),
|
'signDate': _display_ymd(getattr(protocol, 'register_date', None)),
|
||||||
@@ -262,6 +312,11 @@ def _payment_dict(
|
|||||||
'periods': periods,
|
'periods': periods,
|
||||||
'schedules': schedule_rows,
|
'schedules': schedule_rows,
|
||||||
}
|
}
|
||||||
|
if sample_code:
|
||||||
|
payload['sampleStatus'] = meta.get('sampleStatus') or ''
|
||||||
|
payload['sampleStatusLabel'] = meta.get('sampleStatusLabel') or ''
|
||||||
|
payload['voidDesc'] = meta.get('voidDesc') or ''
|
||||||
|
return payload
|
||||||
|
|
||||||
|
|
||||||
def _scoped_payment_query(
|
def _scoped_payment_query(
|
||||||
@@ -733,6 +788,14 @@ def list_payment_chase(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
rows: List[Dict[str, Any]] = []
|
rows: List[Dict[str, Any]] = []
|
||||||
|
status_by_code = _sample_status_by_code(
|
||||||
|
db,
|
||||||
|
ctx.tenant_no,
|
||||||
|
[
|
||||||
|
payment.sample_code or schedule.sample_code or ''
|
||||||
|
for schedule, payment, _, _, _, _ in candidates
|
||||||
|
],
|
||||||
|
)
|
||||||
for schedule, payment, protocol, party, collection, paid in candidates:
|
for schedule, payment, protocol, party, collection, paid in candidates:
|
||||||
due_date = parse_due_date_ymd(schedule.due_date)
|
due_date = parse_due_date_ymd(schedule.due_date)
|
||||||
if due_date is None:
|
if due_date is None:
|
||||||
@@ -741,6 +804,8 @@ def list_payment_chase(
|
|||||||
due_value = Decimal(str(schedule.due_amount or 0))
|
due_value = Decimal(str(schedule.due_amount or 0))
|
||||||
arrears = max(due_value - paid_value, Decimal('0'))
|
arrears = max(due_value - paid_value, Decimal('0'))
|
||||||
is_overdue = due_date < today_value
|
is_overdue = due_date < today_value
|
||||||
|
sample_code = payment.sample_code or schedule.sample_code or ''
|
||||||
|
sample_state = status_by_code.get(sample_code, {}) if sample_code else {}
|
||||||
rows.append(
|
rows.append(
|
||||||
{
|
{
|
||||||
'scheduleId': schedule.id,
|
'scheduleId': schedule.id,
|
||||||
@@ -750,7 +815,16 @@ def list_payment_chase(
|
|||||||
'protocolStatus': protocol.protocol_status or '',
|
'protocolStatus': protocol.protocol_status 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': payment.sample_code or schedule.sample_code or '',
|
'sampleCode': sample_code,
|
||||||
|
**(
|
||||||
|
{
|
||||||
|
'sampleStatus': sample_state.get('sampleStatus', ''),
|
||||||
|
'sampleStatusLabel': sample_state.get('sampleStatusLabel', ''),
|
||||||
|
'voidDesc': sample_state.get('voidDesc', ''),
|
||||||
|
}
|
||||||
|
if sample_code
|
||||||
|
else {}
|
||||||
|
),
|
||||||
'salesUserId': collection.sales_user_id or '',
|
'salesUserId': collection.sales_user_id or '',
|
||||||
'salesUserName': sales_user_names.get(
|
'salesUserName': sales_user_names.get(
|
||||||
collection.sales_user_id or '', ''
|
collection.sales_user_id or '', ''
|
||||||
|
|||||||
@@ -641,6 +641,14 @@ def _party_name_donation(db: Session, ids: List[str], tenant_no: str) -> dict:
|
|||||||
return {row.research_donation_id: row.mother_name or '' for row in rows}
|
return {row.research_donation_id: row.mother_name or '' for row in rows}
|
||||||
|
|
||||||
|
|
||||||
|
_SAMPLE_STATUS_LABELS = {
|
||||||
|
'ycj': '已采集',
|
||||||
|
'jcz': '检测中',
|
||||||
|
'yrk': '已入库',
|
||||||
|
'yzf': '已作废',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _enrich_protocol_cards(
|
def _enrich_protocol_cards(
|
||||||
db: Session, items: List[dict], tenant_no: str
|
db: Session, items: List[dict], tenant_no: str
|
||||||
) -> None:
|
) -> None:
|
||||||
@@ -795,6 +803,11 @@ def _enrich_protocol_cards(
|
|||||||
payment_summary = payment_summaries.get(item['id']) or {}
|
payment_summary = payment_summaries.get(item['id']) or {}
|
||||||
transport = transport_by_sample.get(getattr(sample, 'id', ''))
|
transport = transport_by_sample.get(getattr(sample, 'id', ''))
|
||||||
sample_code = getattr(sample, 'sample_code', '') or ''
|
sample_code = getattr(sample, 'sample_code', '') or ''
|
||||||
|
sample_status = ''
|
||||||
|
sample_void_desc = ''
|
||||||
|
if sample_code:
|
||||||
|
sample_status = str(getattr(sample, 'sample_status', None) or '').strip()
|
||||||
|
sample_void_desc = str(getattr(sample, 'void_desc', None) or '')
|
||||||
region_manager_name = user_names.get(
|
region_manager_name = user_names.get(
|
||||||
getattr(collection, 'region_manager_user_id', ''), ''
|
getattr(collection, 'region_manager_user_id', ''), ''
|
||||||
)
|
)
|
||||||
@@ -844,6 +857,11 @@ def _enrich_protocol_cards(
|
|||||||
str(item.get('voidType') or ''), ''
|
str(item.get('voidType') or ''), ''
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
if sample_code:
|
||||||
|
# 样本作废原因与协议级 voidDesc 分开,捐赠列表「废弃原因」仍读协议描述。
|
||||||
|
item['sampleStatus'] = sample_status
|
||||||
|
item['sampleStatusLabel'] = _SAMPLE_STATUS_LABELS.get(sample_status, '')
|
||||||
|
item['sampleVoidDesc'] = sample_void_desc
|
||||||
|
|
||||||
|
|
||||||
def list_protocols(
|
def list_protocols(
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
"""市场协议作废 ↔ 质检样本接收废弃双向联动。
|
"""市场协议无效态 ↔ 样本接收废弃 / 样本状态作废联动。
|
||||||
|
|
||||||
规则(细胞存储 / 科研捐赠):
|
规则(细胞存储 / 科研捐赠):
|
||||||
1. 协议变为已作废(yzf)时,协议下全部样本接收结论自动为废弃(bj)。
|
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf),
|
||||||
2. 协议下全部有效样本均已废弃/拒收(bj)时,协议自动已作废,作废类型为「实验室废弃」。
|
写 `void_date`,并将接收备注写入 `void_desc`(备注为空则作废原因为空);
|
||||||
|
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态、void_date 与 void_desc。
|
||||||
|
2. 协议变为已作废(yzf)或属地废弃(sdfq)时:
|
||||||
|
- 协议下全部样本接收结论自动为废弃(bj);
|
||||||
|
- 协议下全部有效样本 `sample_status` 置为已作废(yzf),并写入 `void_date`。
|
||||||
|
3. 协议下全部有效样本均已废弃/拒收(bj)时,协议自动已作废,作废类型为「实验室废弃」。
|
||||||
|
4. 人工【样本废弃】:仅将该样本置 yzf 并写 void_date/void_desc,不改接收结论;
|
||||||
|
若协议下有效样本全部为 yzf,则自动作废协议(不联动接收结论)。
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List, Optional
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from app.core.protocol_status_display import INACTIVE_PROTOCOL_STATUSES
|
||||||
from app.core.utils import generate_uuid
|
from app.core.utils import generate_uuid
|
||||||
from app.models.models import (
|
from app.models.models import (
|
||||||
BizCollectionProtocol,
|
BizCollectionProtocol,
|
||||||
@@ -23,9 +31,23 @@ from app.models.research_donation import BizResearchDonation, BizResearchDonatio
|
|||||||
LAB_VOID_TYPE_CODE = "sysfq"
|
LAB_VOID_TYPE_CODE = "sysfq"
|
||||||
LAB_VOID_TYPE_LABEL = "实验室废弃"
|
LAB_VOID_TYPE_LABEL = "实验室废弃"
|
||||||
VOID_TYPE_DICT = "xyzflx"
|
VOID_TYPE_DICT = "xyzflx"
|
||||||
|
SAMPLE_VOID_STATUS = "yzf"
|
||||||
|
|
||||||
_AUTO_DISCARD_REMARK = "协议作废自动废弃"
|
_AUTO_DISCARD_REMARK = "协议作废自动废弃"
|
||||||
_AUTO_VOID_DESC = "全部样本接收废弃/拒收,系统自动作废"
|
_AUTO_VOID_DESC = "全部样本接收废弃/拒收,系统自动作废"
|
||||||
|
_AUTO_VOID_BY_SAMPLE_STATUS_DESC = "全部样本已作废,系统自动作废协议"
|
||||||
|
|
||||||
|
|
||||||
|
def _void_date_yyyymmdd(
|
||||||
|
*,
|
||||||
|
void_time: Optional[datetime] = None,
|
||||||
|
void_date: Optional[str] = None,
|
||||||
|
) -> str:
|
||||||
|
raw = (void_date or "").strip()
|
||||||
|
if len(raw) == 8 and raw.isdigit():
|
||||||
|
return raw
|
||||||
|
ts = void_time or datetime.now()
|
||||||
|
return ts.strftime("%Y%m%d")
|
||||||
|
|
||||||
|
|
||||||
def ensure_lab_void_type(db: Session, *, tenant_no: str) -> str:
|
def ensure_lab_void_type(db: Session, *, tenant_no: str) -> str:
|
||||||
@@ -204,7 +226,7 @@ def discard_receptions_for_voided_protocol(
|
|||||||
tenant_no: str,
|
tenant_no: str,
|
||||||
user_id: Optional[str] = None,
|
user_id: Optional[str] = None,
|
||||||
) -> int:
|
) -> int:
|
||||||
"""协议已作废后,将其下样本接收全部置为废弃。返回处理样本数。"""
|
"""协议无效后,将其下样本接收全部置为废弃。返回处理样本数。"""
|
||||||
src = (source or "").strip()
|
src = (source or "").strip()
|
||||||
pid = (protocol_id or "").strip()
|
pid = (protocol_id or "").strip()
|
||||||
tenant = (tenant_no or "").strip()
|
tenant = (tenant_no or "").strip()
|
||||||
@@ -242,6 +264,75 @@ def discard_receptions_for_voided_protocol(
|
|||||||
return len(samples)
|
return len(samples)
|
||||||
|
|
||||||
|
|
||||||
|
def void_samples_for_inactive_protocol(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
source: str,
|
||||||
|
protocol_id: str,
|
||||||
|
tenant_no: str,
|
||||||
|
user_id: Optional[str] = None,
|
||||||
|
void_time: Optional[datetime] = None,
|
||||||
|
void_date: Optional[str] = None,
|
||||||
|
) -> int:
|
||||||
|
"""协议无效后,将其下有效样本状态一律置为已作废并写入 void_date。返回处理样本数。"""
|
||||||
|
src = (source or "").strip()
|
||||||
|
pid = (protocol_id or "").strip()
|
||||||
|
tenant = (tenant_no or "").strip()
|
||||||
|
if src not in ("cell_storage", "research_donation") or not pid or not tenant:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
date_s = _void_date_yyyymmdd(void_time=void_time, void_date=void_date)
|
||||||
|
now = datetime.now()
|
||||||
|
if src == "cell_storage":
|
||||||
|
samples: List[Union[BizProtocolSample, BizResearchDonationSample]] = list(
|
||||||
|
_list_cell_samples(db, protocol_id=pid, tenant_no=tenant)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
samples = list(_list_donation_samples(db, donation_id=pid, tenant_no=tenant))
|
||||||
|
|
||||||
|
for sample in samples:
|
||||||
|
sample.sample_status = SAMPLE_VOID_STATUS
|
||||||
|
sample.void_date = date_s
|
||||||
|
sample.update_by = user_id
|
||||||
|
sample.update_time = now
|
||||||
|
db.add(sample)
|
||||||
|
db.flush()
|
||||||
|
return len(samples)
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_protocol_void_time(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
source: str,
|
||||||
|
protocol_id: str,
|
||||||
|
tenant_no: str,
|
||||||
|
) -> Optional[datetime]:
|
||||||
|
src = (source or "").strip()
|
||||||
|
pid = (protocol_id or "").strip()
|
||||||
|
tenant = (tenant_no or "").strip()
|
||||||
|
if src == "cell_storage":
|
||||||
|
obj = (
|
||||||
|
db.query(BizCollectionProtocol)
|
||||||
|
.filter(
|
||||||
|
BizCollectionProtocol.id == pid,
|
||||||
|
BizCollectionProtocol.tenant_no == tenant,
|
||||||
|
BizCollectionProtocol.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
return obj.void_time if obj else None
|
||||||
|
obj = (
|
||||||
|
db.query(BizResearchDonation)
|
||||||
|
.filter(
|
||||||
|
BizResearchDonation.id == pid,
|
||||||
|
BizResearchDonation.tenant_no == tenant,
|
||||||
|
BizResearchDonation.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
return obj.void_time if obj else None
|
||||||
|
|
||||||
|
|
||||||
def _all_samples_discarded(
|
def _all_samples_discarded(
|
||||||
db: Session,
|
db: Session,
|
||||||
*,
|
*,
|
||||||
@@ -299,7 +390,7 @@ def maybe_void_protocol_when_all_samples_discarded(
|
|||||||
if not obj:
|
if not obj:
|
||||||
return False
|
return False
|
||||||
status = (obj.protocol_status or "").strip()
|
status = (obj.protocol_status or "").strip()
|
||||||
if status in ("yzf", "sdfq"):
|
if status in INACTIVE_PROTOCOL_STATUSES:
|
||||||
return False
|
return False
|
||||||
from app.core.protocol_status_display import assert_protocol_status_transition
|
from app.core.protocol_status_display import assert_protocol_status_transition
|
||||||
from app.crud.collection_protocol import update_collection_protocol
|
from app.crud.collection_protocol import update_collection_protocol
|
||||||
@@ -319,7 +410,8 @@ def maybe_void_protocol_when_all_samples_discarded(
|
|||||||
void_desc=_AUTO_VOID_DESC,
|
void_desc=_AUTO_VOID_DESC,
|
||||||
void_type=void_type,
|
void_type=void_type,
|
||||||
commit=False,
|
commit=False,
|
||||||
sync_reception_discard=False,
|
# 接收已全部废弃;仍需同步样本状态为已作废
|
||||||
|
sync_reception_discard=True,
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -335,7 +427,7 @@ def maybe_void_protocol_when_all_samples_discarded(
|
|||||||
if not obj:
|
if not obj:
|
||||||
return False
|
return False
|
||||||
status = (obj.donation_status or "").strip()
|
status = (obj.donation_status or "").strip()
|
||||||
if status in ("yzf", "sdfq"):
|
if status in INACTIVE_PROTOCOL_STATUSES:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# 捐赠 change_status 默认 commit;此处内联等价逻辑避免提前提交。
|
# 捐赠 change_status 默认 commit;此处内联等价逻辑避免提前提交。
|
||||||
@@ -374,6 +466,173 @@ def maybe_void_protocol_when_all_samples_discarded(
|
|||||||
)
|
)
|
||||||
db.add(obj)
|
db.add(obj)
|
||||||
db.flush()
|
db.flush()
|
||||||
|
# 接收已全部废弃;仍需同步样本状态为已作废
|
||||||
|
after_protocol_voided(
|
||||||
|
db,
|
||||||
|
source="research_donation",
|
||||||
|
protocol_id=pid,
|
||||||
|
tenant_no=tenant,
|
||||||
|
user_id=user_id,
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def _find_sample_for_reception(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
reception: BizSampleReception,
|
||||||
|
tenant_no: str,
|
||||||
|
) -> tuple[str, Optional[Union[BizProtocolSample, BizResearchDonationSample]]]:
|
||||||
|
source = (reception.reception_source or "cell_storage").strip() or "cell_storage"
|
||||||
|
tenant = (tenant_no or "").strip()
|
||||||
|
code = (reception.sample_code or "").strip()
|
||||||
|
if source == "cell_storage":
|
||||||
|
sid = (reception.protocol_sample_id or "").strip()
|
||||||
|
if sid:
|
||||||
|
obj = (
|
||||||
|
db.query(BizProtocolSample)
|
||||||
|
.filter(
|
||||||
|
BizProtocolSample.id == sid,
|
||||||
|
BizProtocolSample.tenant_no == tenant,
|
||||||
|
BizProtocolSample.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if obj:
|
||||||
|
return source, obj
|
||||||
|
pid = (reception.collection_protocol_id or "").strip()
|
||||||
|
if code and pid:
|
||||||
|
return source, (
|
||||||
|
db.query(BizProtocolSample)
|
||||||
|
.filter(
|
||||||
|
BizProtocolSample.collection_protocol_id == pid,
|
||||||
|
BizProtocolSample.sample_code == code,
|
||||||
|
BizProtocolSample.tenant_no == tenant,
|
||||||
|
BizProtocolSample.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
return source, None
|
||||||
|
|
||||||
|
sid = (reception.donation_sample_id or "").strip()
|
||||||
|
if sid:
|
||||||
|
obj = (
|
||||||
|
db.query(BizResearchDonationSample)
|
||||||
|
.filter(
|
||||||
|
BizResearchDonationSample.id == sid,
|
||||||
|
BizResearchDonationSample.tenant_no == tenant,
|
||||||
|
BizResearchDonationSample.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if obj:
|
||||||
|
return source, obj
|
||||||
|
pid = (reception.research_donation_id or "").strip()
|
||||||
|
if code and pid:
|
||||||
|
return source, (
|
||||||
|
db.query(BizResearchDonationSample)
|
||||||
|
.filter(
|
||||||
|
BizResearchDonationSample.research_donation_id == pid,
|
||||||
|
BizResearchDonationSample.sample_code == code,
|
||||||
|
BizResearchDonationSample.tenant_no == tenant,
|
||||||
|
BizResearchDonationSample.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
return source, None
|
||||||
|
|
||||||
|
|
||||||
|
def _protocol_is_inactive(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
source: str,
|
||||||
|
protocol_id: str,
|
||||||
|
tenant_no: str,
|
||||||
|
) -> bool:
|
||||||
|
src = (source or "").strip()
|
||||||
|
pid = (protocol_id or "").strip()
|
||||||
|
tenant = (tenant_no or "").strip()
|
||||||
|
if not pid or not tenant:
|
||||||
|
return False
|
||||||
|
if src == "cell_storage":
|
||||||
|
obj = (
|
||||||
|
db.query(BizCollectionProtocol)
|
||||||
|
.filter(
|
||||||
|
BizCollectionProtocol.id == pid,
|
||||||
|
BizCollectionProtocol.tenant_no == tenant,
|
||||||
|
BizCollectionProtocol.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
status = (obj.protocol_status or "").strip() if obj else ""
|
||||||
|
else:
|
||||||
|
obj = (
|
||||||
|
db.query(BizResearchDonation)
|
||||||
|
.filter(
|
||||||
|
BizResearchDonation.id == pid,
|
||||||
|
BizResearchDonation.tenant_no == tenant,
|
||||||
|
BizResearchDonation.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
status = (obj.donation_status or "").strip() if obj else ""
|
||||||
|
return status in INACTIVE_PROTOCOL_STATUSES
|
||||||
|
|
||||||
|
|
||||||
|
def void_sample_for_discarded_reception(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
reception: BizSampleReception,
|
||||||
|
tenant_no: str,
|
||||||
|
user_id: Optional[str] = None,
|
||||||
|
) -> bool:
|
||||||
|
"""单条接收废弃:将该样本置为已作废,作废原因取接收备注。"""
|
||||||
|
_source, sample = _find_sample_for_reception(db, reception=reception, tenant_no=tenant_no)
|
||||||
|
if not sample:
|
||||||
|
return False
|
||||||
|
now = datetime.now()
|
||||||
|
reason = (reception.remark or "").strip()
|
||||||
|
if len(reason) > 512:
|
||||||
|
reason = reason[:512]
|
||||||
|
sample.sample_status = SAMPLE_VOID_STATUS
|
||||||
|
sample.void_date = _void_date_yyyymmdd(void_time=reception.reception_time or now)
|
||||||
|
sample.void_desc = reason or None
|
||||||
|
sample.update_by = user_id
|
||||||
|
sample.update_time = now
|
||||||
|
db.add(sample)
|
||||||
|
db.flush()
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def clear_sample_void_for_accepted_reception(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
reception: BizSampleReception,
|
||||||
|
tenant_no: str,
|
||||||
|
user_id: Optional[str] = None,
|
||||||
|
) -> bool:
|
||||||
|
"""接收改回接收:协议仍有效且样本为 yzf 时,清空样本作废状态。"""
|
||||||
|
source, sample = _find_sample_for_reception(db, reception=reception, tenant_no=tenant_no)
|
||||||
|
if not sample:
|
||||||
|
return False
|
||||||
|
if (sample.sample_status or "").strip() != SAMPLE_VOID_STATUS:
|
||||||
|
return False
|
||||||
|
if source == "cell_storage":
|
||||||
|
protocol_id = (reception.collection_protocol_id or "").strip()
|
||||||
|
else:
|
||||||
|
protocol_id = (reception.research_donation_id or "").strip()
|
||||||
|
if _protocol_is_inactive(
|
||||||
|
db, source=source, protocol_id=protocol_id, tenant_no=tenant_no
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
now = datetime.now()
|
||||||
|
sample.sample_status = None
|
||||||
|
sample.void_date = None
|
||||||
|
sample.void_desc = None
|
||||||
|
sample.update_by = user_id
|
||||||
|
sample.update_time = now
|
||||||
|
db.add(sample)
|
||||||
|
db.flush()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@@ -384,23 +643,32 @@ def after_sample_reception_saved(
|
|||||||
tenant_no: str,
|
tenant_no: str,
|
||||||
user_id: Optional[str] = None,
|
user_id: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""样本接收保存后:若结论为废弃,尝试自动作废所属协议。"""
|
"""样本接收保存后:同步该样本状态;若全部废弃则尝试自动作废协议。"""
|
||||||
if (reception.accept_conclusion or "").strip() != "bj":
|
conclusion = (reception.accept_conclusion or "").strip()
|
||||||
return
|
|
||||||
source = (reception.reception_source or "cell_storage").strip() or "cell_storage"
|
source = (reception.reception_source or "cell_storage").strip() or "cell_storage"
|
||||||
if source == "cell_storage":
|
if source == "cell_storage":
|
||||||
protocol_id = (reception.collection_protocol_id or "").strip()
|
protocol_id = (reception.collection_protocol_id or "").strip()
|
||||||
else:
|
else:
|
||||||
protocol_id = (reception.research_donation_id or "").strip()
|
protocol_id = (reception.research_donation_id or "").strip()
|
||||||
if not protocol_id:
|
|
||||||
|
if conclusion == "bj":
|
||||||
|
void_sample_for_discarded_reception(
|
||||||
|
db, reception=reception, tenant_no=tenant_no, user_id=user_id
|
||||||
|
)
|
||||||
|
if protocol_id:
|
||||||
|
maybe_void_protocol_when_all_samples_discarded(
|
||||||
|
db,
|
||||||
|
source=source,
|
||||||
|
protocol_id=protocol_id,
|
||||||
|
tenant_no=tenant_no,
|
||||||
|
user_id=user_id,
|
||||||
|
)
|
||||||
return
|
return
|
||||||
maybe_void_protocol_when_all_samples_discarded(
|
|
||||||
db,
|
if conclusion == "js":
|
||||||
source=source,
|
clear_sample_void_for_accepted_reception(
|
||||||
protocol_id=protocol_id,
|
db, reception=reception, tenant_no=tenant_no, user_id=user_id
|
||||||
tenant_no=tenant_no,
|
)
|
||||||
user_id=user_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def after_protocol_voided(
|
def after_protocol_voided(
|
||||||
@@ -411,7 +679,7 @@ def after_protocol_voided(
|
|||||||
tenant_no: str,
|
tenant_no: str,
|
||||||
user_id: Optional[str] = None,
|
user_id: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""协议作废后:同步废弃其下全部样本接收。"""
|
"""协议作废/属地废弃后:同步废弃样本接收,并将样本状态置为已作废。"""
|
||||||
discard_receptions_for_voided_protocol(
|
discard_receptions_for_voided_protocol(
|
||||||
db,
|
db,
|
||||||
source=source,
|
source=source,
|
||||||
@@ -419,3 +687,234 @@ def after_protocol_voided(
|
|||||||
tenant_no=tenant_no,
|
tenant_no=tenant_no,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
)
|
)
|
||||||
|
void_samples_for_inactive_protocol(
|
||||||
|
db,
|
||||||
|
source=source,
|
||||||
|
protocol_id=protocol_id,
|
||||||
|
tenant_no=tenant_no,
|
||||||
|
user_id=user_id,
|
||||||
|
void_time=_resolve_protocol_void_time(
|
||||||
|
db, source=source, protocol_id=protocol_id, tenant_no=tenant_no
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _all_samples_status_voided(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
source: str,
|
||||||
|
protocol_id: str,
|
||||||
|
tenant_no: str,
|
||||||
|
) -> bool:
|
||||||
|
src = (source or "").strip()
|
||||||
|
if src == "cell_storage":
|
||||||
|
samples = _list_cell_samples(db, protocol_id=protocol_id, tenant_no=tenant_no)
|
||||||
|
else:
|
||||||
|
samples = _list_donation_samples(db, donation_id=protocol_id, tenant_no=tenant_no)
|
||||||
|
if not samples:
|
||||||
|
return False
|
||||||
|
for sample in samples:
|
||||||
|
if (sample.sample_status or "").strip() != SAMPLE_VOID_STATUS:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def maybe_void_protocol_when_all_samples_status_voided(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
source: str,
|
||||||
|
protocol_id: str,
|
||||||
|
tenant_no: str,
|
||||||
|
user_id: Optional[str] = None,
|
||||||
|
) -> bool:
|
||||||
|
"""若协议下有效样本全部已作废,则自动作废协议;不联动接收结论。"""
|
||||||
|
src = (source or "").strip()
|
||||||
|
pid = (protocol_id or "").strip()
|
||||||
|
tenant = (tenant_no or "").strip()
|
||||||
|
if src not in ("cell_storage", "research_donation") or not pid or not tenant:
|
||||||
|
return False
|
||||||
|
if not _all_samples_status_voided(db, source=src, protocol_id=pid, tenant_no=tenant):
|
||||||
|
return False
|
||||||
|
|
||||||
|
void_type = ensure_lab_void_type(db, tenant_no=tenant)
|
||||||
|
now = datetime.now()
|
||||||
|
|
||||||
|
if src == "cell_storage":
|
||||||
|
obj = (
|
||||||
|
db.query(BizCollectionProtocol)
|
||||||
|
.filter(
|
||||||
|
BizCollectionProtocol.id == pid,
|
||||||
|
BizCollectionProtocol.tenant_no == tenant,
|
||||||
|
BizCollectionProtocol.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if not obj:
|
||||||
|
return False
|
||||||
|
status = (obj.protocol_status or "").strip()
|
||||||
|
if status in INACTIVE_PROTOCOL_STATUSES:
|
||||||
|
return False
|
||||||
|
from app.core.protocol_status_display import assert_protocol_status_transition
|
||||||
|
from app.crud.collection_protocol import update_collection_protocol
|
||||||
|
|
||||||
|
try:
|
||||||
|
assert_protocol_status_transition(status, "yzf", kind="protocol")
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
update_collection_protocol(
|
||||||
|
db,
|
||||||
|
pid,
|
||||||
|
tenant_no=tenant,
|
||||||
|
user_id=user_id,
|
||||||
|
protocol_status="yzf",
|
||||||
|
void_time=now,
|
||||||
|
void_desc=_AUTO_VOID_BY_SAMPLE_STATUS_DESC,
|
||||||
|
void_type=void_type,
|
||||||
|
commit=False,
|
||||||
|
sync_reception_discard=False,
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
|
obj = (
|
||||||
|
db.query(BizResearchDonation)
|
||||||
|
.filter(
|
||||||
|
BizResearchDonation.id == pid,
|
||||||
|
BizResearchDonation.tenant_no == tenant,
|
||||||
|
BizResearchDonation.del_flag == 0,
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if not obj:
|
||||||
|
return False
|
||||||
|
status = (obj.donation_status or "").strip()
|
||||||
|
if status in INACTIVE_PROTOCOL_STATUSES:
|
||||||
|
return False
|
||||||
|
|
||||||
|
from app.core.protocol_status_display import assert_protocol_status_transition
|
||||||
|
from app.crud.dict_data import normalize_void_type
|
||||||
|
from app.crud.research_donation import (
|
||||||
|
_DONATION_STATUS_CHANGE_TYPE,
|
||||||
|
append_donation_status_change,
|
||||||
|
)
|
||||||
|
|
||||||
|
current = obj.donation_status or ""
|
||||||
|
try:
|
||||||
|
assert_protocol_status_transition(current, "yzf", kind="donation")
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
normalized = normalize_void_type(db, value=void_type, tenant_no=tenant)
|
||||||
|
obj.donation_status = "yzf"
|
||||||
|
obj.void_time = now
|
||||||
|
obj.void_desc = _AUTO_VOID_BY_SAMPLE_STATUS_DESC
|
||||||
|
obj.void_type = normalized
|
||||||
|
obj.update_by = user_id
|
||||||
|
obj.update_time = now
|
||||||
|
change_type = _DONATION_STATUS_CHANGE_TYPE.get("yzf")
|
||||||
|
if change_type:
|
||||||
|
append_donation_status_change(
|
||||||
|
db,
|
||||||
|
research_donation_id=obj.id,
|
||||||
|
change_type=change_type,
|
||||||
|
from_status=current,
|
||||||
|
to_status="yzf",
|
||||||
|
change_time=now,
|
||||||
|
change_desc=_AUTO_VOID_BY_SAMPLE_STATUS_DESC,
|
||||||
|
void_type=normalized,
|
||||||
|
tenant_no=tenant,
|
||||||
|
user_id=user_id,
|
||||||
|
)
|
||||||
|
db.add(obj)
|
||||||
|
db.flush()
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def void_sample_manually(
|
||||||
|
db: Session,
|
||||||
|
*,
|
||||||
|
source: str,
|
||||||
|
tenant_no: str,
|
||||||
|
void_desc: str,
|
||||||
|
user_id: Optional[str] = None,
|
||||||
|
sample_id: Optional[str] = None,
|
||||||
|
sample_code: Optional[str] = None,
|
||||||
|
protocol_id: Optional[str] = None,
|
||||||
|
commit: bool = True,
|
||||||
|
) -> Union[BizProtocolSample, BizResearchDonationSample]:
|
||||||
|
"""人工样本废弃:写 yzf/void_date/void_desc;不改接收;全作废则自动作废协议。"""
|
||||||
|
src = (source or "").strip()
|
||||||
|
tenant = (tenant_no or "").strip()
|
||||||
|
reason = (void_desc or "").strip()
|
||||||
|
sid = (sample_id or "").strip()
|
||||||
|
code = (sample_code or "").strip()
|
||||||
|
pid = (protocol_id or "").strip()
|
||||||
|
if src not in ("cell_storage", "research_donation"):
|
||||||
|
raise ValueError("来源类型无效")
|
||||||
|
if not tenant:
|
||||||
|
raise ValueError("租户编号不能为空")
|
||||||
|
if not reason:
|
||||||
|
raise ValueError("请填写作废原因")
|
||||||
|
if not sid and not code:
|
||||||
|
raise ValueError("样本标识不能为空")
|
||||||
|
|
||||||
|
now = datetime.now()
|
||||||
|
sample: Optional[Union[BizProtocolSample, BizResearchDonationSample]] = None
|
||||||
|
parent_id = ""
|
||||||
|
|
||||||
|
if src == "cell_storage":
|
||||||
|
q = db.query(BizProtocolSample).filter(
|
||||||
|
BizProtocolSample.tenant_no == tenant,
|
||||||
|
BizProtocolSample.del_flag == 0,
|
||||||
|
)
|
||||||
|
if sid:
|
||||||
|
q = q.filter(BizProtocolSample.id == sid)
|
||||||
|
else:
|
||||||
|
q = q.filter(BizProtocolSample.sample_code == code)
|
||||||
|
if pid:
|
||||||
|
q = q.filter(BizProtocolSample.collection_protocol_id == pid)
|
||||||
|
sample = q.first()
|
||||||
|
if not sample:
|
||||||
|
raise ValueError("样本不存在")
|
||||||
|
parent_id = (sample.collection_protocol_id or "").strip()
|
||||||
|
else:
|
||||||
|
q = db.query(BizResearchDonationSample).filter(
|
||||||
|
BizResearchDonationSample.tenant_no == tenant,
|
||||||
|
BizResearchDonationSample.del_flag == 0,
|
||||||
|
)
|
||||||
|
if sid:
|
||||||
|
q = q.filter(BizResearchDonationSample.id == sid)
|
||||||
|
else:
|
||||||
|
q = q.filter(BizResearchDonationSample.sample_code == code)
|
||||||
|
if pid:
|
||||||
|
q = q.filter(BizResearchDonationSample.research_donation_id == pid)
|
||||||
|
sample = q.first()
|
||||||
|
if not sample:
|
||||||
|
raise ValueError("样本不存在")
|
||||||
|
parent_id = (sample.research_donation_id or "").strip()
|
||||||
|
|
||||||
|
if _protocol_is_inactive(db, source=src, protocol_id=parent_id, tenant_no=tenant):
|
||||||
|
raise ValueError("所属协议已作废或属地废弃,无法操作")
|
||||||
|
|
||||||
|
sample.sample_status = SAMPLE_VOID_STATUS
|
||||||
|
sample.void_date = _void_date_yyyymmdd(void_time=now)
|
||||||
|
sample.void_desc = reason
|
||||||
|
sample.update_by = user_id
|
||||||
|
sample.update_time = now
|
||||||
|
db.add(sample)
|
||||||
|
db.flush()
|
||||||
|
|
||||||
|
if parent_id:
|
||||||
|
maybe_void_protocol_when_all_samples_status_voided(
|
||||||
|
db,
|
||||||
|
source=src,
|
||||||
|
protocol_id=parent_id,
|
||||||
|
tenant_no=tenant,
|
||||||
|
user_id=user_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
if commit:
|
||||||
|
db.commit()
|
||||||
|
db.refresh(sample)
|
||||||
|
else:
|
||||||
|
db.flush()
|
||||||
|
return 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
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
|
|||||||
db = MagicMock()
|
db = MagicMock()
|
||||||
data = {
|
data = {
|
||||||
"bizType": "basic_experiment",
|
"bizType": "basic_experiment",
|
||||||
|
"researchCategory": "bio_tech_clinical",
|
||||||
"projectTitle": "课题A",
|
"projectTitle": "课题A",
|
||||||
"customerName": "",
|
"customerName": "",
|
||||||
"customerContact": "张三",
|
"customerContact": "张三",
|
||||||
@@ -43,6 +44,25 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertIn("客户名称", str(ctx.exception))
|
self.assertIn("客户名称", str(ctx.exception))
|
||||||
|
|
||||||
|
def test_create_basic_experiment_requires_research_category(self):
|
||||||
|
db = MagicMock()
|
||||||
|
data = {
|
||||||
|
"bizType": "basic_experiment",
|
||||||
|
"projectTitle": "课题A",
|
||||||
|
"customerName": "客户A",
|
||||||
|
"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))
|
||||||
|
|
||||||
|
|
||||||
class TestBasicExperimentSaleSchedules(unittest.TestCase):
|
class TestBasicExperimentSaleSchedules(unittest.TestCase):
|
||||||
@patch("app.crud.pilot_application.create_schedule")
|
@patch("app.crud.pilot_application.create_schedule")
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,211 @@
|
|||||||
|
"""人工样本废弃:写状态/原因,全作废则协议作废,不联动接收。"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
from app.core.database import Base
|
||||||
|
from app.models.models import (
|
||||||
|
BizCollectionProtocol,
|
||||||
|
BizProtocolSample,
|
||||||
|
BizProtocolStatusChange,
|
||||||
|
BizSampleReception,
|
||||||
|
SysDictData,
|
||||||
|
)
|
||||||
|
from app.services.protocol_reception_discard_sync import (
|
||||||
|
LAB_VOID_TYPE_CODE,
|
||||||
|
SAMPLE_VOID_STATUS,
|
||||||
|
void_sample_manually,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _session():
|
||||||
|
engine = create_engine("sqlite://")
|
||||||
|
Base.metadata.create_all(
|
||||||
|
bind=engine,
|
||||||
|
tables=[
|
||||||
|
SysDictData.__table__,
|
||||||
|
BizCollectionProtocol.__table__,
|
||||||
|
BizProtocolSample.__table__,
|
||||||
|
BizProtocolStatusChange.__table__,
|
||||||
|
BizSampleReception.__table__,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
return sessionmaker(bind=engine)()
|
||||||
|
|
||||||
|
|
||||||
|
def _now():
|
||||||
|
return datetime(2026, 11, 19, 12, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class TestBusinessSampleVoid(unittest.TestCase):
|
||||||
|
def test_void_one_sample_keeps_protocol_and_skips_reception(self):
|
||||||
|
db = _session()
|
||||||
|
now = _now()
|
||||||
|
db.add(
|
||||||
|
BizCollectionProtocol(
|
||||||
|
id="p1",
|
||||||
|
protocol_no="CP-1",
|
||||||
|
protocol_status="sxz",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.add(
|
||||||
|
BizProtocolSample(
|
||||||
|
id="sa",
|
||||||
|
collection_protocol_id="p1",
|
||||||
|
sample_code="A001",
|
||||||
|
sample_status="ycj",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.add(
|
||||||
|
BizProtocolSample(
|
||||||
|
id="sb",
|
||||||
|
collection_protocol_id="p1",
|
||||||
|
sample_code="B001",
|
||||||
|
sample_status="ycj",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.add(
|
||||||
|
BizSampleReception(
|
||||||
|
id="ra",
|
||||||
|
protocol_sample_id="sa",
|
||||||
|
collection_protocol_id="p1",
|
||||||
|
reception_time=now,
|
||||||
|
accept_conclusion="js",
|
||||||
|
reception_source="cell_storage",
|
||||||
|
sample_code="A001",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
check_packaging=0,
|
||||||
|
check_sealing=0,
|
||||||
|
check_no_damage=0,
|
||||||
|
check_no_leakage=0,
|
||||||
|
check_color=0,
|
||||||
|
check_tying_rope=0,
|
||||||
|
check_no_stratification=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
void_sample_manually(
|
||||||
|
db,
|
||||||
|
source="cell_storage",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
void_desc="质检发现污染",
|
||||||
|
user_id="u1",
|
||||||
|
sample_id="sa",
|
||||||
|
)
|
||||||
|
|
||||||
|
a = db.query(BizProtocolSample).filter(BizProtocolSample.id == "sa").one()
|
||||||
|
b = db.query(BizProtocolSample).filter(BizProtocolSample.id == "sb").one()
|
||||||
|
proto = db.query(BizCollectionProtocol).filter(BizCollectionProtocol.id == "p1").one()
|
||||||
|
rec = db.query(BizSampleReception).filter(BizSampleReception.id == "ra").one()
|
||||||
|
self.assertEqual(a.sample_status, SAMPLE_VOID_STATUS)
|
||||||
|
self.assertEqual(a.void_desc, "质检发现污染")
|
||||||
|
self.assertTrue((a.void_date or "").strip())
|
||||||
|
self.assertEqual(b.sample_status, "ycj")
|
||||||
|
self.assertEqual(proto.protocol_status, "sxz")
|
||||||
|
self.assertEqual(rec.accept_conclusion, "js")
|
||||||
|
|
||||||
|
def test_void_all_samples_auto_voids_protocol_without_reception_change(self):
|
||||||
|
db = _session()
|
||||||
|
now = _now()
|
||||||
|
db.add(
|
||||||
|
BizCollectionProtocol(
|
||||||
|
id="p2",
|
||||||
|
protocol_no="CP-2",
|
||||||
|
protocol_status="sxz",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
for sid, code in (("s1", "C001"), ("s2", "C002")):
|
||||||
|
db.add(
|
||||||
|
BizProtocolSample(
|
||||||
|
id=sid,
|
||||||
|
collection_protocol_id="p2",
|
||||||
|
sample_code=code,
|
||||||
|
sample_status="ycj",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.add(
|
||||||
|
BizSampleReception(
|
||||||
|
id="r1",
|
||||||
|
protocol_sample_id="s1",
|
||||||
|
collection_protocol_id="p2",
|
||||||
|
reception_time=now,
|
||||||
|
accept_conclusion="js",
|
||||||
|
reception_source="cell_storage",
|
||||||
|
sample_code="C001",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
check_packaging=0,
|
||||||
|
check_sealing=0,
|
||||||
|
check_no_damage=0,
|
||||||
|
check_no_leakage=0,
|
||||||
|
check_color=0,
|
||||||
|
check_tying_rope=0,
|
||||||
|
check_no_stratification=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
void_sample_manually(
|
||||||
|
db,
|
||||||
|
source="cell_storage",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
void_desc="原因1",
|
||||||
|
sample_id="s1",
|
||||||
|
commit=True,
|
||||||
|
)
|
||||||
|
void_sample_manually(
|
||||||
|
db,
|
||||||
|
source="cell_storage",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
void_desc="原因2",
|
||||||
|
sample_id="s2",
|
||||||
|
commit=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
proto = db.query(BizCollectionProtocol).filter(BizCollectionProtocol.id == "p2").one()
|
||||||
|
rec = db.query(BizSampleReception).filter(BizSampleReception.id == "r1").one()
|
||||||
|
self.assertEqual(proto.protocol_status, "yzf")
|
||||||
|
self.assertEqual(proto.void_type, LAB_VOID_TYPE_CODE)
|
||||||
|
self.assertEqual(rec.accept_conclusion, "js")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
"""市场下「中试服务」已从静态菜单树下线(Issue #158)。"""
|
||||||
|
import ast
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
MENU_PY = ROOT / "backend/app/api/menu.py"
|
||||||
|
SQXP_TS = ROOT / "web-admin/src/router/modules/sqxp.ts"
|
||||||
|
HIDE_SQL = ROOT / "docs/sql/migrations/2026-11-20-hide-market-pilot-service-menus.sql"
|
||||||
|
|
||||||
|
|
||||||
|
def _market_children_titles_from_menu_py() -> list[str]:
|
||||||
|
source = MENU_PY.read_text(encoding="utf-8")
|
||||||
|
tree_match = re.search(r"STATIC_MENU_TREE\s*=\s*(\[[\s\S]*?\n\])\s*\n", source)
|
||||||
|
assert tree_match, "STATIC_MENU_TREE not found"
|
||||||
|
tree = ast.literal_eval(tree_match.group(1))
|
||||||
|
market = next(
|
||||||
|
node
|
||||||
|
for node in tree
|
||||||
|
if isinstance(node, dict) and (node.get("meta") or {}).get("menuCode") == "menu:market"
|
||||||
|
)
|
||||||
|
titles = []
|
||||||
|
for child in market.get("children") or []:
|
||||||
|
meta = child.get("meta") or {}
|
||||||
|
titles.append(str(meta.get("title") or ""))
|
||||||
|
return titles
|
||||||
|
|
||||||
|
|
||||||
|
def test_backend_static_menu_has_no_market_pilot_service():
|
||||||
|
titles = _market_children_titles_from_menu_py()
|
||||||
|
assert "中试服务" not in titles
|
||||||
|
assert "中试服务申请单" not in titles
|
||||||
|
|
||||||
|
|
||||||
|
def test_frontend_sqxp_has_no_market_pilot_service_block():
|
||||||
|
text = SQXP_TS.read_text(encoding="utf-8")
|
||||||
|
assert "name: 'PilotService'" not in text
|
||||||
|
assert "id: 'PIL00000000000000000000000000001'" not in text
|
||||||
|
assert "pilot-service:pilot-application:list" not in text
|
||||||
|
# 基础实验 / 临床仍可复用出库放行组件与权限码前缀
|
||||||
|
assert "basic-experiment:outbound-release-review:list" in text
|
||||||
|
assert "clinical-application:outbound-release-review:list" in text
|
||||||
|
|
||||||
|
|
||||||
|
def test_hide_sql_soft_deletes_sys_menu_only_under_market_pilot():
|
||||||
|
sql = HIDE_SQL.read_text(encoding="utf-8")
|
||||||
|
compact = re.sub(r"\s+", " ", re.sub(r"--[^\n]*", "", sql))
|
||||||
|
assert re.search(r"UPDATE\s+sys_menu", compact, re.IGNORECASE)
|
||||||
|
assert re.search(r"SET\s+m\.del_flag\s*=\s*1", compact, re.IGNORECASE)
|
||||||
|
assert "menu:market" in compact
|
||||||
|
assert "中试服务" in compact
|
||||||
|
assert not re.search(r"DELETE\s+FROM\s+sys_menu", compact, re.IGNORECASE)
|
||||||
@@ -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()
|
||||||
@@ -99,12 +99,20 @@ def test_specialist_sees_shared_batch_but_only_own_items_and_count():
|
|||||||
from app.services.market_freight import get_freight_detail, list_freights
|
from app.services.market_freight import get_freight_detail, list_freights
|
||||||
db = _session()
|
db = _session()
|
||||||
own, own_parent = _sample(db, 'own')
|
own, own_parent = _sample(db, 'own')
|
||||||
|
own.sample_status = 'yzf'
|
||||||
|
own.void_desc = '冷链中断'
|
||||||
|
db.commit()
|
||||||
other, other_parent = _sample(db, 'other', sales='u2')
|
other, other_parent = _sample(db, 'other', sales='u2')
|
||||||
freight = _freight(db, 'mixed', [('cell_storage', own, own_parent), ('cell_storage', other, other_parent)])
|
freight = _freight(db, 'mixed', [('cell_storage', own, own_parent), ('cell_storage', other, other_parent)])
|
||||||
rows, total = list_freights(db, ctx=_ctx(), user_info=_user(), include_items=True)
|
rows, total = list_freights(db, ctx=_ctx(), user_info=_user(), include_items=True)
|
||||||
detail = get_freight_detail(db, freight.id, ctx=_ctx(), user_info=_user())
|
detail = get_freight_detail(db, freight.id, ctx=_ctx(), user_info=_user())
|
||||||
assert total == 1 and rows[0]['visibleItemCount'] == 1
|
assert total == 1 and rows[0]['visibleItemCount'] == 1
|
||||||
assert [item['sampleCode'] for item in rows[0]['items']] == ['C-own']
|
assert [item['sampleCode'] for item in rows[0]['items']] == ['C-own']
|
||||||
|
assert rows[0]['items'][0]['sampleStatus'] == 'yzf'
|
||||||
|
assert rows[0]['items'][0]['sampleStatusLabel'] == '已作废'
|
||||||
|
assert rows[0]['items'][0]['voidDesc'] == '冷链中断'
|
||||||
|
assert detail['items'][0]['sampleStatus'] == 'yzf'
|
||||||
|
assert detail['items'][0]['voidDesc'] == '冷链中断'
|
||||||
assert [item['sampleCode'] for item in detail['items']] == ['C-own']
|
assert [item['sampleCode'] for item in detail['items']] == ['C-own']
|
||||||
assert rows[0]['createBy'] == detail['createBy'] == 'u1'
|
assert rows[0]['createBy'] == detail['createBy'] == 'u1'
|
||||||
assert rows[0]['createByName'] == detail['createByName'] == '专员'
|
assert rows[0]['createByName'] == detail['createByName'] == '专员'
|
||||||
|
|||||||
@@ -674,6 +674,33 @@ def test_chase_filters_counts_orders_and_pages_in_sql_before_materialization():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_payment_and_chase_lists_include_sample_status_when_coded():
|
||||||
|
from app.services.market_payment import list_payment_chase, list_payments
|
||||||
|
|
||||||
|
db = _session()
|
||||||
|
today = date(2026, 10, 11)
|
||||||
|
_payment_tree(db, 'void-sample', due_date=today.strftime('%Y%m%d'))
|
||||||
|
sample = db.get(BizProtocolSample, 'sample-void-sample')
|
||||||
|
sample.sample_status = 'yzf'
|
||||||
|
sample.void_desc = '客户放弃'
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
payments, payment_total = list_payments(db, ctx=_ctx(), user_info=_user())
|
||||||
|
chase, chase_total = list_payment_chase(
|
||||||
|
db, ctx=_ctx(), user_info=_user(), today=today
|
||||||
|
)
|
||||||
|
|
||||||
|
assert payment_total == 1
|
||||||
|
assert payments[0]['sampleCode'] == 'S-void-sample'
|
||||||
|
assert payments[0]['sampleStatus'] == 'yzf'
|
||||||
|
assert payments[0]['sampleStatusLabel'] == '已作废'
|
||||||
|
assert payments[0]['voidDesc'] == '客户放弃'
|
||||||
|
assert chase_total == 1
|
||||||
|
assert chase[0]['sampleStatus'] == 'yzf'
|
||||||
|
assert chase[0]['sampleStatusLabel'] == '已作废'
|
||||||
|
assert chase[0]['voidDesc'] == '客户放弃'
|
||||||
|
|
||||||
|
|
||||||
def test_payment_list_includes_legacy_models_and_uses_parent_scope_not_transfer_department():
|
def test_payment_list_includes_legacy_models_and_uses_parent_scope_not_transfer_department():
|
||||||
from app.services.market_payment import list_payments
|
from app.services.market_payment import list_payments
|
||||||
|
|
||||||
|
|||||||
@@ -3604,6 +3604,10 @@ def test_protocol_list_contains_mobile_card_fields():
|
|||||||
assert items[0]['deliveryMode'] == 'sc'
|
assert items[0]['deliveryMode'] == 'sc'
|
||||||
assert items[0]['newbornWeightGram'] == 3200
|
assert items[0]['newbornWeightGram'] == 3200
|
||||||
assert items[0]['salesUserName'] == '当前用户'
|
assert items[0]['salesUserName'] == '当前用户'
|
||||||
|
assert items[0]['sampleStatus'] == ''
|
||||||
|
assert items[0]['sampleStatusLabel'] == ''
|
||||||
|
assert items[0]['sampleVoidDesc'] == ''
|
||||||
|
assert items[0]['voidDesc'] == ''
|
||||||
|
|
||||||
by_customer, customer_total = list_protocols(
|
by_customer, customer_total = list_protocols(
|
||||||
db, ctx=_ctx('specialist'), user_info=_user(), keyword='李安然'
|
db, ctx=_ctx('specialist'), user_info=_user(), keyword='李安然'
|
||||||
@@ -3626,6 +3630,54 @@ def test_protocol_list_contains_mobile_card_fields():
|
|||||||
} == {row.id}
|
} == {row.id}
|
||||||
|
|
||||||
|
|
||||||
|
def test_protocol_list_returns_sample_status_without_replacing_donation_void_desc():
|
||||||
|
from app.services.market_protocol import list_protocols
|
||||||
|
|
||||||
|
db = _session()
|
||||||
|
cell = _cell(db, 'status-cell')
|
||||||
|
db.add(
|
||||||
|
BizProtocolSample(
|
||||||
|
id='sample-status-cell',
|
||||||
|
collection_protocol_id=cell.id,
|
||||||
|
sample_code='S-CELL',
|
||||||
|
sample_status='yzf',
|
||||||
|
void_desc='试管破裂',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
create_dept_id='',
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
donation = _donation(db, 'status-don')
|
||||||
|
donation.void_desc = '协议作废说明'
|
||||||
|
db.add(
|
||||||
|
BizResearchDonationSample(
|
||||||
|
id='sample-status-don',
|
||||||
|
research_donation_id=donation.id,
|
||||||
|
sample_code='S-DON',
|
||||||
|
sample_status='yrk',
|
||||||
|
void_desc='样本溶血',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
create_dept_id='',
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
items, total = list_protocols(db, ctx=_ctx('specialist'), user_info=_user())
|
||||||
|
|
||||||
|
assert total == 2
|
||||||
|
by_id = {item['id']: item for item in items}
|
||||||
|
assert by_id['status-cell']['sampleCode'] == 'S-CELL'
|
||||||
|
assert by_id['status-cell']['sampleStatus'] == 'yzf'
|
||||||
|
assert by_id['status-cell']['sampleStatusLabel'] == '已作废'
|
||||||
|
assert by_id['status-cell']['voidDesc'] == '试管破裂'
|
||||||
|
assert by_id['status-cell']['sampleVoidDesc'] == '试管破裂'
|
||||||
|
assert by_id['status-don']['sampleStatus'] == 'yrk'
|
||||||
|
assert by_id['status-don']['sampleStatusLabel'] == '已入库'
|
||||||
|
assert by_id['status-don']['voidDesc'] == '协议作废说明'
|
||||||
|
assert by_id['status-don']['sampleVoidDesc'] == '样本溶血'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('source', ['cell_storage', 'research_donation'])
|
@pytest.mark.parametrize('source', ['cell_storage', 'research_donation'])
|
||||||
def test_protocol_list_and_detail_resolve_tenant_void_type_label(source):
|
def test_protocol_list_and_detail_resolve_tenant_void_type_label(source):
|
||||||
from app.services.market_protocol import get_protocol, list_protocols
|
from app.services.market_protocol import get_protocol, list_protocols
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -23,6 +23,7 @@ from app.models.research_donation import (
|
|||||||
)
|
)
|
||||||
from app.services.protocol_reception_discard_sync import (
|
from app.services.protocol_reception_discard_sync import (
|
||||||
LAB_VOID_TYPE_CODE,
|
LAB_VOID_TYPE_CODE,
|
||||||
|
SAMPLE_VOID_STATUS,
|
||||||
after_protocol_voided,
|
after_protocol_voided,
|
||||||
after_sample_reception_saved,
|
after_sample_reception_saved,
|
||||||
ensure_lab_void_type,
|
ensure_lab_void_type,
|
||||||
@@ -77,6 +78,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
id="p1",
|
id="p1",
|
||||||
protocol_no="CP-1",
|
protocol_no="CP-1",
|
||||||
protocol_status="sxz",
|
protocol_status="sxz",
|
||||||
|
void_time=now,
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -89,6 +91,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
id="s1",
|
id="s1",
|
||||||
collection_protocol_id="p1",
|
collection_protocol_id="p1",
|
||||||
sample_code="ZK001",
|
sample_code="ZK001",
|
||||||
|
sample_status="yrk",
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -101,6 +104,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
id="s2",
|
id="s2",
|
||||||
collection_protocol_id="p1",
|
collection_protocol_id="p1",
|
||||||
sample_code="ZK002",
|
sample_code="ZK002",
|
||||||
|
sample_status="jcz",
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -152,6 +156,16 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
self.assertEqual(by_code["ZK001"], "bj")
|
self.assertEqual(by_code["ZK001"], "bj")
|
||||||
self.assertEqual(by_code["ZK002"], "bj")
|
self.assertEqual(by_code["ZK002"], "bj")
|
||||||
|
|
||||||
|
samples = (
|
||||||
|
db.query(BizProtocolSample)
|
||||||
|
.filter(BizProtocolSample.collection_protocol_id == "p1")
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
self.assertEqual(len(samples), 2)
|
||||||
|
for s in samples:
|
||||||
|
self.assertEqual(s.sample_status, SAMPLE_VOID_STATUS)
|
||||||
|
self.assertEqual(s.void_date, "20261105")
|
||||||
|
|
||||||
def test_all_samples_discarded_auto_voids_protocol_with_lab_type(self):
|
def test_all_samples_discarded_auto_voids_protocol_with_lab_type(self):
|
||||||
db = _session()
|
db = _session()
|
||||||
now = _now()
|
now = _now()
|
||||||
@@ -172,6 +186,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
id="s3",
|
id="s3",
|
||||||
collection_protocol_id="p2",
|
collection_protocol_id="p2",
|
||||||
sample_code="ZK003",
|
sample_code="ZK003",
|
||||||
|
sample_status="ycj",
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -212,6 +227,9 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
self.assertEqual(proto.protocol_status, "yzf")
|
self.assertEqual(proto.protocol_status, "yzf")
|
||||||
self.assertEqual(proto.void_type, LAB_VOID_TYPE_CODE)
|
self.assertEqual(proto.void_type, LAB_VOID_TYPE_CODE)
|
||||||
self.assertIn("全部样本接收", proto.void_desc or "")
|
self.assertIn("全部样本接收", proto.void_desc or "")
|
||||||
|
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s3").one()
|
||||||
|
self.assertEqual(sample.sample_status, SAMPLE_VOID_STATUS)
|
||||||
|
self.assertTrue((sample.void_date or "").strip())
|
||||||
|
|
||||||
def test_partial_discard_does_not_void_protocol(self):
|
def test_partial_discard_does_not_void_protocol(self):
|
||||||
db = _session()
|
db = _session()
|
||||||
@@ -282,6 +300,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
id="d1",
|
id="d1",
|
||||||
donation_no="RD-1",
|
donation_no="RD-1",
|
||||||
donation_status="sxz",
|
donation_status="sxz",
|
||||||
|
void_time=now,
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -294,6 +313,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
id="ds1",
|
id="ds1",
|
||||||
research_donation_id="d1",
|
research_donation_id="d1",
|
||||||
sample_code="RD001",
|
sample_code="RD001",
|
||||||
|
sample_status="yrk",
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -322,6 +342,203 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(rec.accept_conclusion, "bj")
|
self.assertEqual(rec.accept_conclusion, "bj")
|
||||||
self.assertEqual(rec.research_donation_id, "d1")
|
self.assertEqual(rec.research_donation_id, "d1")
|
||||||
|
sample = (
|
||||||
|
db.query(BizResearchDonationSample)
|
||||||
|
.filter(BizResearchDonationSample.id == "ds1")
|
||||||
|
.one()
|
||||||
|
)
|
||||||
|
self.assertEqual(sample.sample_status, SAMPLE_VOID_STATUS)
|
||||||
|
self.assertEqual(sample.void_date, "20261105")
|
||||||
|
|
||||||
|
def test_sdfq_also_voids_sample_status(self):
|
||||||
|
db = _session()
|
||||||
|
now = _now()
|
||||||
|
db.add(
|
||||||
|
BizCollectionProtocol(
|
||||||
|
id="p-sdfq",
|
||||||
|
protocol_no="CP-SDFQ",
|
||||||
|
protocol_status="sdfq",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.add(
|
||||||
|
BizProtocolSample(
|
||||||
|
id="s-sdfq",
|
||||||
|
collection_protocol_id="p-sdfq",
|
||||||
|
sample_code="ZKSDFQ",
|
||||||
|
sample_status="ycj",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
after_protocol_voided(
|
||||||
|
db,
|
||||||
|
source="cell_storage",
|
||||||
|
protocol_id="p-sdfq",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
user_id="u1",
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s-sdfq").one()
|
||||||
|
self.assertEqual(sample.sample_status, SAMPLE_VOID_STATUS)
|
||||||
|
self.assertTrue((sample.void_date or "").strip())
|
||||||
|
rec = (
|
||||||
|
db.query(BizSampleReception)
|
||||||
|
.filter(BizSampleReception.sample_code == "ZKSDFQ")
|
||||||
|
.one()
|
||||||
|
)
|
||||||
|
self.assertEqual(rec.accept_conclusion, "bj")
|
||||||
|
|
||||||
|
def test_single_reception_discard_voids_only_that_sample(self):
|
||||||
|
db = _session()
|
||||||
|
now = _now()
|
||||||
|
db.add(
|
||||||
|
BizCollectionProtocol(
|
||||||
|
id="p-multi",
|
||||||
|
protocol_no="CP-MULTI",
|
||||||
|
protocol_status="sxz",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
for sid, code, status in (
|
||||||
|
("sa", "ZKA", "ycj"),
|
||||||
|
("sb", "ZKB", "ycj"),
|
||||||
|
("sc", "ZKC", "ycj"),
|
||||||
|
):
|
||||||
|
db.add(
|
||||||
|
BizProtocolSample(
|
||||||
|
id=sid,
|
||||||
|
collection_protocol_id="p-multi",
|
||||||
|
sample_code=code,
|
||||||
|
sample_status=status,
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
rec_a = BizSampleReception(
|
||||||
|
id="ra",
|
||||||
|
protocol_sample_id="sa",
|
||||||
|
collection_protocol_id="p-multi",
|
||||||
|
reception_time=now,
|
||||||
|
accept_conclusion="bj",
|
||||||
|
reception_source="cell_storage",
|
||||||
|
sample_code="ZKA",
|
||||||
|
remark="母血乙肝阳性",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
check_packaging=0,
|
||||||
|
check_sealing=0,
|
||||||
|
check_no_damage=0,
|
||||||
|
check_no_leakage=0,
|
||||||
|
check_color=0,
|
||||||
|
check_tying_rope=0,
|
||||||
|
check_no_stratification=0,
|
||||||
|
)
|
||||||
|
db.add(rec_a)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
after_sample_reception_saved(
|
||||||
|
db, reception=rec_a, tenant_no="tenant-a", user_id="u1"
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
proto = db.query(BizCollectionProtocol).filter(BizCollectionProtocol.id == "p-multi").one()
|
||||||
|
self.assertEqual(proto.protocol_status, "sxz")
|
||||||
|
by_id = {
|
||||||
|
s.id: s
|
||||||
|
for s in db.query(BizProtocolSample)
|
||||||
|
.filter(BizProtocolSample.collection_protocol_id == "p-multi")
|
||||||
|
.all()
|
||||||
|
}
|
||||||
|
self.assertEqual(by_id["sa"].sample_status, SAMPLE_VOID_STATUS)
|
||||||
|
self.assertEqual(by_id["sa"].void_date, "20261105")
|
||||||
|
self.assertEqual(by_id["sa"].void_desc, "母血乙肝阳性")
|
||||||
|
self.assertEqual(by_id["sb"].sample_status, "ycj")
|
||||||
|
self.assertEqual(by_id["sc"].sample_status, "ycj")
|
||||||
|
|
||||||
|
def test_reception_accept_clears_sample_void_when_protocol_active(self):
|
||||||
|
db = _session()
|
||||||
|
now = _now()
|
||||||
|
db.add(
|
||||||
|
BizCollectionProtocol(
|
||||||
|
id="p-clear",
|
||||||
|
protocol_no="CP-CLEAR",
|
||||||
|
protocol_status="sxz",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.add(
|
||||||
|
BizProtocolSample(
|
||||||
|
id="s-clear",
|
||||||
|
collection_protocol_id="p-clear",
|
||||||
|
sample_code="ZKCLR",
|
||||||
|
sample_status=SAMPLE_VOID_STATUS,
|
||||||
|
void_date="20261101",
|
||||||
|
void_desc="旧作废原因",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
rec = BizSampleReception(
|
||||||
|
id="r-clear",
|
||||||
|
protocol_sample_id="s-clear",
|
||||||
|
collection_protocol_id="p-clear",
|
||||||
|
reception_time=now,
|
||||||
|
accept_conclusion="js",
|
||||||
|
reception_source="cell_storage",
|
||||||
|
sample_code="ZKCLR",
|
||||||
|
tenant_no="tenant-a",
|
||||||
|
create_dept_id="",
|
||||||
|
create_time=now,
|
||||||
|
update_time=now,
|
||||||
|
del_flag=0,
|
||||||
|
check_packaging=0,
|
||||||
|
check_sealing=0,
|
||||||
|
check_no_damage=0,
|
||||||
|
check_no_leakage=0,
|
||||||
|
check_color=0,
|
||||||
|
check_tying_rope=0,
|
||||||
|
check_no_stratification=0,
|
||||||
|
)
|
||||||
|
db.add(rec)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
after_sample_reception_saved(
|
||||||
|
db, reception=rec, tenant_no="tenant-a", user_id="u1"
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s-clear").one()
|
||||||
|
self.assertFalse((sample.sample_status or "").strip())
|
||||||
|
self.assertFalse((sample.void_date or "").strip())
|
||||||
|
self.assertFalse((sample.void_desc or "").strip())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
"""质检检测结果留痕:字段差异与空保存。"""
|
||||||
|
from app.crud.qc_task_result_change_log import build_result_changes
|
||||||
|
|
||||||
|
|
||||||
|
def test_build_changes_for_status_and_param():
|
||||||
|
before = {
|
||||||
|
"taskStatus": "dzx",
|
||||||
|
"conclusion": "",
|
||||||
|
"remark": "",
|
||||||
|
"attachments": "",
|
||||||
|
"params": {"paramCode:HBsAg": {"label": "HBsAg", "value": "阴性"}},
|
||||||
|
}
|
||||||
|
after = {
|
||||||
|
"taskStatus": "ywc",
|
||||||
|
"conclusion": "tg",
|
||||||
|
"remark": "",
|
||||||
|
"attachments": "",
|
||||||
|
"params": {"paramCode:HBsAg": {"label": "HBsAg", "value": "阳性"}},
|
||||||
|
}
|
||||||
|
changes = build_result_changes(before, after)
|
||||||
|
keys = {c["fieldKey"] for c in changes}
|
||||||
|
assert "taskStatus" in keys
|
||||||
|
assert "conclusion" in keys
|
||||||
|
assert "paramCode:HBsAg" in keys
|
||||||
|
hbs = next(c for c in changes if c["fieldKey"] == "paramCode:HBsAg")
|
||||||
|
assert hbs["oldValue"] == "阴性"
|
||||||
|
assert hbs["newValue"] == "阳性"
|
||||||
|
|
||||||
|
|
||||||
|
def test_build_changes_empty_when_identical():
|
||||||
|
state = {
|
||||||
|
"taskStatus": "ywc",
|
||||||
|
"conclusion": "tg",
|
||||||
|
"remark": "ok",
|
||||||
|
"attachments": "a.png",
|
||||||
|
"params": {"paramCode:X": {"label": "X", "value": "1"}},
|
||||||
|
}
|
||||||
|
assert build_result_changes(state, state) == []
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
"""入库质检工单列表:从协议/捐赠采集信息补齐母血采集时间。"""
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from datetime import datetime
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
import app.crud.qc_task # noqa: F401 先加载任务模块,避免与工单模块循环导入
|
||||||
|
from app.crud import qc_work_order as qc_wo
|
||||||
|
from app.crud.qc_work_order import _enrich_work_order_list_items
|
||||||
|
from app.models.models import (
|
||||||
|
BizCollectionProtocol,
|
||||||
|
BizProtocolCollectionInfo,
|
||||||
|
BizProtocolPartyCustomer,
|
||||||
|
BizSampleReception,
|
||||||
|
)
|
||||||
|
from app.models.research_donation import (
|
||||||
|
BizResearchDonation,
|
||||||
|
BizResearchDonationCollection,
|
||||||
|
BizResearchDonationParty,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _item(**kwargs):
|
||||||
|
data = {
|
||||||
|
"id": "wo-1",
|
||||||
|
"workOrderType": "inbound",
|
||||||
|
"receptionId": "rec-1",
|
||||||
|
"sampleCode": "S001",
|
||||||
|
"collectionProtocolId": "proto-1",
|
||||||
|
"receptionSource": "cell_storage",
|
||||||
|
"protocolSampleId": "",
|
||||||
|
"maternalBloodCollectTime": "",
|
||||||
|
}
|
||||||
|
data.update(kwargs)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def _query_router(mapping):
|
||||||
|
def _query(*entities):
|
||||||
|
q = mock.Mock()
|
||||||
|
q.filter.return_value = q
|
||||||
|
q.order_by.return_value = q
|
||||||
|
model = entities[0]
|
||||||
|
# db.query(Model.col, ...) → first entity is InstrumentedAttribute
|
||||||
|
cls = getattr(model, "class_", model)
|
||||||
|
key = getattr(cls, "__name__", str(cls))
|
||||||
|
rows = mapping.get(key, [])
|
||||||
|
q.all.return_value = rows
|
||||||
|
return q
|
||||||
|
|
||||||
|
return _query
|
||||||
|
|
||||||
|
|
||||||
|
class TestEnrichWorkOrderMaternalBlood(unittest.TestCase):
|
||||||
|
def test_cell_storage_fills_maternal_blood_collect_time(self):
|
||||||
|
rec = mock.Mock(
|
||||||
|
id="rec-1",
|
||||||
|
sample_code="S001",
|
||||||
|
reception_source="cell_storage",
|
||||||
|
collection_protocol_id="proto-1",
|
||||||
|
research_donation_id="",
|
||||||
|
protocol_sample_id="",
|
||||||
|
donation_sample_id="",
|
||||||
|
reception_time=datetime(2026, 11, 8, 13, 30, 41),
|
||||||
|
handler_name="质检员",
|
||||||
|
lab_storage_code="",
|
||||||
|
)
|
||||||
|
coll = mock.Mock(
|
||||||
|
collection_protocol_id="proto-1",
|
||||||
|
maternal_blood_collect_time=datetime(2026, 11, 7, 9, 15, 0),
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
db = mock.Mock()
|
||||||
|
db.query.side_effect = _query_router(
|
||||||
|
{
|
||||||
|
BizSampleReception.__name__: [rec],
|
||||||
|
BizProtocolCollectionInfo.__name__: [coll],
|
||||||
|
BizProtocolPartyCustomer.__name__: [],
|
||||||
|
BizCollectionProtocol.__name__: [],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
with mock.patch.object(
|
||||||
|
qc_wo, "_enrich_protocol_sibling_samples", side_effect=lambda _db, items: items
|
||||||
|
), mock.patch.object(
|
||||||
|
qc_wo, "apply_special_to_item_from_samples", side_effect=lambda item, **_k: item
|
||||||
|
):
|
||||||
|
items = _enrich_work_order_list_items(db, [_item()])
|
||||||
|
|
||||||
|
self.assertEqual(items[0]["maternalBloodCollectTime"], "2026-11-07 09:15:00")
|
||||||
|
|
||||||
|
def test_missing_maternal_blood_stays_empty(self):
|
||||||
|
rec = mock.Mock(
|
||||||
|
id="rec-1",
|
||||||
|
sample_code="S001",
|
||||||
|
reception_source="cell_storage",
|
||||||
|
collection_protocol_id="proto-1",
|
||||||
|
research_donation_id="",
|
||||||
|
protocol_sample_id="",
|
||||||
|
donation_sample_id="",
|
||||||
|
reception_time=datetime(2026, 11, 8, 13, 30, 41),
|
||||||
|
handler_name="质检员",
|
||||||
|
lab_storage_code="",
|
||||||
|
)
|
||||||
|
db = mock.Mock()
|
||||||
|
db.query.side_effect = _query_router(
|
||||||
|
{
|
||||||
|
BizSampleReception.__name__: [rec],
|
||||||
|
BizProtocolCollectionInfo.__name__: [],
|
||||||
|
BizProtocolPartyCustomer.__name__: [],
|
||||||
|
BizCollectionProtocol.__name__: [],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
with mock.patch.object(
|
||||||
|
qc_wo, "_enrich_protocol_sibling_samples", side_effect=lambda _db, items: items
|
||||||
|
), mock.patch.object(
|
||||||
|
qc_wo, "apply_special_to_item_from_samples", side_effect=lambda item, **_k: item
|
||||||
|
):
|
||||||
|
items = _enrich_work_order_list_items(db, [_item()])
|
||||||
|
|
||||||
|
self.assertEqual(items[0]["maternalBloodCollectTime"], "")
|
||||||
|
|
||||||
|
def test_research_donation_fills_maternal_blood_collect_time(self):
|
||||||
|
rec = mock.Mock(
|
||||||
|
id="rec-2",
|
||||||
|
sample_code="D001",
|
||||||
|
reception_source="research_donation",
|
||||||
|
collection_protocol_id="",
|
||||||
|
research_donation_id="don-1",
|
||||||
|
protocol_sample_id="",
|
||||||
|
donation_sample_id="",
|
||||||
|
reception_time=datetime(2026, 11, 8, 10, 0, 0),
|
||||||
|
handler_name="质检员",
|
||||||
|
lab_storage_code="",
|
||||||
|
)
|
||||||
|
coll = mock.Mock(
|
||||||
|
research_donation_id="don-1",
|
||||||
|
maternal_blood_collect_time=datetime(2026, 11, 6, 8, 0, 0),
|
||||||
|
del_flag=0,
|
||||||
|
)
|
||||||
|
db = mock.Mock()
|
||||||
|
db.query.side_effect = _query_router(
|
||||||
|
{
|
||||||
|
BizSampleReception.__name__: [rec],
|
||||||
|
BizResearchDonationCollection.__name__: [coll],
|
||||||
|
BizResearchDonationParty.__name__: [],
|
||||||
|
BizResearchDonation.__name__: [],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
with mock.patch.object(
|
||||||
|
qc_wo, "_enrich_protocol_sibling_samples", side_effect=lambda _db, items: items
|
||||||
|
), mock.patch.object(
|
||||||
|
qc_wo, "apply_special_to_item_from_samples", side_effect=lambda item, **_k: item
|
||||||
|
):
|
||||||
|
items = _enrich_work_order_list_items(
|
||||||
|
db,
|
||||||
|
[
|
||||||
|
_item(
|
||||||
|
id="wo-2",
|
||||||
|
receptionId="rec-2",
|
||||||
|
sampleCode="D001",
|
||||||
|
collectionProtocolId="don-1",
|
||||||
|
receptionSource="research_donation",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(items[0]["maternalBloodCollectTime"], "2026-11-06 08:00:00")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
"""Static checks for market/pilot-service role-menu revoke migration (#156)."""
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
MIGRATION = (
|
||||||
|
Path(__file__).resolve().parents[2]
|
||||||
|
/ "docs/sql/migrations/2026-11-20-revoke-market-pilot-service-role-menus.sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _sql() -> str:
|
||||||
|
return MIGRATION.read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def _compact(sql: str) -> str:
|
||||||
|
return re.sub(r"\s+", " ", sql)
|
||||||
|
|
||||||
|
|
||||||
|
def _without_comments(sql: str) -> str:
|
||||||
|
return re.sub(r"--[^\n]*", "", sql)
|
||||||
|
|
||||||
|
|
||||||
|
def test_migration_file_exists():
|
||||||
|
assert MIGRATION.is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_scopes_to_market_pilot_service_tree():
|
||||||
|
compact = _compact(_without_comments(_sql()))
|
||||||
|
assert "menu:market" in compact
|
||||||
|
assert "中试服务" in compact
|
||||||
|
assert re.search(r"pilot\.menu_name\s*=\s*'中试服务'", compact)
|
||||||
|
assert re.search(r"market\.perms\s*=\s*'menu:market'", compact)
|
||||||
|
|
||||||
|
|
||||||
|
def test_revokes_role_menu_by_soft_delete_only():
|
||||||
|
compact = _compact(_without_comments(_sql()))
|
||||||
|
assert re.search(r"UPDATE\s+sys_role_menu", compact, re.IGNORECASE)
|
||||||
|
assert re.search(
|
||||||
|
r"UPDATE\s+sys_role_menu\s+rm\b.*SET\s+rm\.del_flag\s*=\s*1",
|
||||||
|
compact,
|
||||||
|
re.IGNORECASE,
|
||||||
|
)
|
||||||
|
assert not re.search(r"DELETE\s+FROM\s+sys_role_menu", compact, re.IGNORECASE)
|
||||||
|
assert not re.search(r"UPDATE\s+sys_menu\s+SET\s+del_flag\s*=\s*1", compact, re.IGNORECASE)
|
||||||
|
assert not re.search(r"DELETE\s+FROM\s+sys_menu", compact, re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
|
def test_includes_children_and_button_descendants():
|
||||||
|
compact = _compact(_without_comments(_sql()))
|
||||||
|
assert re.search(r"child\.parent_id\s*=\s*pilot\.id", compact)
|
||||||
|
assert re.search(r"btn\.parent_id\s*=\s*child\.id", compact)
|
||||||
|
assert compact.count("UNION") >= 2
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_only_touches_active_bindings():
|
||||||
|
compact = _compact(_without_comments(_sql()))
|
||||||
|
assert re.search(
|
||||||
|
r"SET\s+rm\.del_flag\s*=\s*1[\s\S]*WHERE\s+rm\.del_flag\s*=\s*0",
|
||||||
|
compact,
|
||||||
|
re.IGNORECASE,
|
||||||
|
)
|
||||||
@@ -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") == []
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
-- UC 入库编码自动派发:脐带MSC原代培养(内置模版)5 步
|
-- UC 入库编码自动派发:脐带MSC原代培养(内置模版)5 步
|
||||||
-- 步骤:原代培养 → 半换液 → 二次贴壁 → 重铺 → 冻存(不含传代)
|
-- 步骤:原代培养 → 半换液 → 二次贴壁 → 重铺 → 冻存(不含传代)
|
||||||
-- 内容从既有「干细胞培养(内置模版)」/ MSC培养-BUILTIN 按 process_code 拷贝
|
-- 内容从既有「干细胞培养(内置模版)」/ MSC培养-BUILTIN 按 process_code 拷贝
|
||||||
-- 幂等:已存在同名内置集合则跳过主数据创建-- 生产历史空任务工单回补(二选一,勿重复对同一工单各跑一遍):
|
-- 幂等:已存在同名内置集合则跳过主数据创建-- 兼容:跨表比较统一 COLLATE utf8mb4_unicode_ci,避免 unicode_ci/general_ci 混用失败
|
||||||
|
-- 生产历史空任务工单回补(二选一,勿重复对同一工单各跑一遍):
|
||||||
-- SQL:docs/sql/migrations/2026-11-13-uc-msc-production-task-backfill.sql
|
-- SQL:docs/sql/migrations/2026-11-13-uc-msc-production-task-backfill.sql
|
||||||
-- 或 Python:
|
-- 或 Python:
|
||||||
-- cd backend && python -m scripts.backfill_uc_msc_production_tasks
|
-- cd backend && python -m scripts.backfill_uc_msc_production_tasks
|
||||||
@@ -46,7 +47,7 @@ WHERE src.del_flag = 0
|
|||||||
)
|
)
|
||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1 FROM biz_process_route x
|
SELECT 1 FROM biz_process_route x
|
||||||
WHERE x.tenant_no = src.tenant_no
|
WHERE x.tenant_no COLLATE utf8mb4_unicode_ci = src.tenant_no COLLATE utf8mb4_unicode_ci
|
||||||
AND x.route_code = 'MSC原代-UC-BUILTIN'
|
AND x.route_code = 'MSC原代-UC-BUILTIN'
|
||||||
AND x.del_flag = 0
|
AND x.del_flag = 0
|
||||||
)
|
)
|
||||||
@@ -67,7 +68,9 @@ SELECT
|
|||||||
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
||||||
s.tenant_no, 1, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
s.tenant_no, 1, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
||||||
FROM biz_process_route_step s
|
FROM biz_process_route_step s
|
||||||
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0
|
JOIN biz_process_route r
|
||||||
|
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
|
||||||
|
AND r.del_flag = 0
|
||||||
WHERE s.del_flag = 0
|
WHERE s.del_flag = 0
|
||||||
AND s.process_code = 'SOP-SC-003-E01-01'
|
AND s.process_code = 'SOP-SC-003-E01-01'
|
||||||
AND (
|
AND (
|
||||||
@@ -97,7 +100,9 @@ SELECT
|
|||||||
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
||||||
s.tenant_no, 2, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
s.tenant_no, 2, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
||||||
FROM biz_process_route_step s
|
FROM biz_process_route_step s
|
||||||
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0
|
JOIN biz_process_route r
|
||||||
|
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
|
||||||
|
AND r.del_flag = 0
|
||||||
WHERE s.del_flag = 0
|
WHERE s.del_flag = 0
|
||||||
AND s.process_code = 'SOP-SC-004-E01-01'
|
AND s.process_code = 'SOP-SC-004-E01-01'
|
||||||
AND (
|
AND (
|
||||||
@@ -127,7 +132,9 @@ SELECT
|
|||||||
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
||||||
s.tenant_no, 3, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
s.tenant_no, 3, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
||||||
FROM biz_process_route_step s
|
FROM biz_process_route_step s
|
||||||
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0
|
JOIN biz_process_route r
|
||||||
|
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
|
||||||
|
AND r.del_flag = 0
|
||||||
WHERE s.del_flag = 0
|
WHERE s.del_flag = 0
|
||||||
AND s.process_code = 'SOP-SC-006-E01-01'
|
AND s.process_code = 'SOP-SC-006-E01-01'
|
||||||
AND (
|
AND (
|
||||||
@@ -157,7 +164,9 @@ SELECT
|
|||||||
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
||||||
s.tenant_no, 4, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
s.tenant_no, 4, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
||||||
FROM biz_process_route_step s
|
FROM biz_process_route_step s
|
||||||
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0
|
JOIN biz_process_route r
|
||||||
|
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
|
||||||
|
AND r.del_flag = 0
|
||||||
WHERE s.del_flag = 0
|
WHERE s.del_flag = 0
|
||||||
AND s.process_code = 'SOP-SC-005-E01-01'
|
AND s.process_code = 'SOP-SC-005-E01-01'
|
||||||
AND (
|
AND (
|
||||||
@@ -187,7 +196,9 @@ SELECT
|
|||||||
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
|
||||||
s.tenant_no, 5, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
s.tenant_no, 5, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
|
||||||
FROM biz_process_route_step s
|
FROM biz_process_route_step s
|
||||||
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0
|
JOIN biz_process_route r
|
||||||
|
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
|
||||||
|
AND r.del_flag = 0
|
||||||
WHERE s.del_flag = 0
|
WHERE s.del_flag = 0
|
||||||
AND s.process_code = 'SOP-SC-008-E01-01'
|
AND s.process_code = 'SOP-SC-008-E01-01'
|
||||||
AND (
|
AND (
|
||||||
@@ -228,7 +239,7 @@ WHERE r.id = 'UCMSCROUTEA5CC11F194118AC54085447A'
|
|||||||
AND r.del_flag = 0
|
AND r.del_flag = 0
|
||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1 FROM biz_production_task_set x
|
SELECT 1 FROM biz_production_task_set x
|
||||||
WHERE x.tenant_no = r.tenant_no
|
WHERE x.tenant_no COLLATE utf8mb4_unicode_ci = r.tenant_no COLLATE utf8mb4_unicode_ci
|
||||||
AND x.set_name = '脐带MSC原代培养(内置模版)'
|
AND x.set_name = '脐带MSC原代培养(内置模版)'
|
||||||
AND x.is_builtin = '1'
|
AND x.is_builtin = '1'
|
||||||
AND x.del_flag = 0
|
AND x.del_flag = 0
|
||||||
@@ -261,5 +272,6 @@ WHERE s.set_name = '脐带MSC原代培养(内置模版)'
|
|||||||
AND s.del_flag = 0
|
AND s.del_flag = 0
|
||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1 FROM biz_production_task_set_item x
|
SELECT 1 FROM biz_production_task_set_item x
|
||||||
WHERE x.set_id = s.id AND x.del_flag = 0
|
WHERE x.set_id COLLATE utf8mb4_unicode_ci = s.id COLLATE utf8mb4_unicode_ci
|
||||||
|
AND x.del_flag = 0
|
||||||
);
|
);
|
||||||
@@ -16,6 +16,10 @@
|
|||||||
-- 幂等:已有有效任务的工单不会进入候选;重复执行影响行数应为 0。
|
-- 幂等:已有有效任务的工单不会进入候选;重复执行影响行数应为 0。
|
||||||
-- 前置:biz_process_route.route_code='MSC原代-UC-BUILTIN'(或固定 id UCMSCROUTE…)及 5 步须已存在。
|
-- 前置:biz_process_route.route_code='MSC原代-UC-BUILTIN'(或固定 id UCMSCROUTE…)及 5 步须已存在。
|
||||||
-- MySQL 5.7 / utf8mb4。未在生产库执行;执行前请先跑下方「预览」SELECT。
|
-- MySQL 5.7 / utf8mb4。未在生产库执行;执行前请先跑下方「预览」SELECT。
|
||||||
|
-- 兼容:
|
||||||
|
-- 1) 跨表等值统一 COLLATE utf8mb4_general_ci,避免 unicode_ci/general_ci 混用失败
|
||||||
|
-- 2) 多行 ID 用 MD5(业务键) 生成,避免同语句多行 UUID() 撞主键
|
||||||
|
-- 3) task_no 序号用 UNSIGNED 整数拼接,避免用户变量浮点变成 RW…2.00
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
@@ -43,7 +47,7 @@ SET @uc_route_id := (
|
|||||||
SET @uc_step_count := (
|
SET @uc_step_count := (
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM biz_process_route_step s
|
FROM biz_process_route_step s
|
||||||
WHERE s.route_id = @uc_route_id
|
WHERE s.route_id COLLATE utf8mb4_unicode_ci = @uc_route_id COLLATE utf8mb4_unicode_ci
|
||||||
AND s.del_flag = 0
|
AND s.del_flag = 0
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -70,7 +74,7 @@ CREATE TEMPORARY TABLE tmp_uc_wo_backfill (
|
|||||||
route_id VARCHAR(64) NULL,
|
route_id VARCHAR(64) NULL,
|
||||||
PRIMARY KEY (seq),
|
PRIMARY KEY (seq),
|
||||||
UNIQUE KEY uk_wo (work_order_id)
|
UNIQUE KEY uk_wo (work_order_id)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
INSERT INTO tmp_uc_wo_backfill (
|
INSERT INTO tmp_uc_wo_backfill (
|
||||||
work_order_id, reception_id, lab_storage_code, tenant_no, sample_code, route_id
|
work_order_id, reception_id, lab_storage_code, tenant_no, sample_code, route_id
|
||||||
@@ -84,8 +88,8 @@ SELECT
|
|||||||
@uc_route_id
|
@uc_route_id
|
||||||
FROM biz_production_work_order wo
|
FROM biz_production_work_order wo
|
||||||
INNER JOIN biz_sample_reception rec
|
INNER JOIN biz_sample_reception rec
|
||||||
ON rec.id = wo.reception_id
|
ON rec.id COLLATE utf8mb4_general_ci = wo.reception_id COLLATE utf8mb4_general_ci
|
||||||
AND rec.tenant_no = wo.tenant_no
|
AND rec.tenant_no COLLATE utf8mb4_general_ci = wo.tenant_no COLLATE utf8mb4_general_ci
|
||||||
AND rec.del_flag = 0
|
AND rec.del_flag = 0
|
||||||
WHERE @uc_ready = 1
|
WHERE @uc_ready = 1
|
||||||
AND wo.del_flag = 0
|
AND wo.del_flag = 0
|
||||||
@@ -101,8 +105,8 @@ WHERE @uc_ready = 1
|
|||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM biz_production_task t
|
FROM biz_production_task t
|
||||||
WHERE t.work_order_id = wo.id
|
WHERE t.work_order_id COLLATE utf8mb4_general_ci = wo.id COLLATE utf8mb4_general_ci
|
||||||
AND t.tenant_no = wo.tenant_no
|
AND t.tenant_no COLLATE utf8mb4_general_ci = wo.tenant_no COLLATE utf8mb4_general_ci
|
||||||
AND t.del_flag = 0
|
AND t.del_flag = 0
|
||||||
)
|
)
|
||||||
ORDER BY rec.reception_time ASC, wo.create_time ASC;
|
ORDER BY rec.reception_time ASC, wo.create_time ASC;
|
||||||
@@ -125,12 +129,13 @@ SET @task_day := DATE_FORMAT(NOW(), '%Y%m%d');
|
|||||||
SET @task_no_base := (
|
SET @task_no_base := (
|
||||||
SELECT IFNULL(MAX(CAST(SUBSTRING(t.task_no, 11) AS UNSIGNED)), 0)
|
SELECT IFNULL(MAX(CAST(SUBSTRING(t.task_no, 11) AS UNSIGNED)), 0)
|
||||||
FROM biz_production_task t
|
FROM biz_production_task t
|
||||||
WHERE t.task_no LIKE CONCAT('RW', @task_day, '%')
|
WHERE t.task_no REGEXP CONCAT('^RW', @task_day, '[0-9]{4}$')
|
||||||
);
|
);
|
||||||
|
SET @task_no_base := CAST(IFNULL(@task_no_base, 0) AS UNSIGNED);
|
||||||
|
|
||||||
UPDATE tmp_uc_wo_backfill
|
UPDATE tmp_uc_wo_backfill
|
||||||
SET
|
SET
|
||||||
task_id = UPPER(REPLACE(UUID(), '-', '')),
|
task_id = UPPER(MD5(CONCAT('uc-msc-backfill-task:', work_order_id))),
|
||||||
task_no = CONCAT('RW', @task_day, LPAD(@task_no_base + seq, 4, '0'));
|
task_no = CONCAT('RW', @task_day, LPAD(@task_no_base + seq, 4, '0'));
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
@@ -170,14 +175,14 @@ SELECT
|
|||||||
0
|
0
|
||||||
FROM tmp_uc_wo_backfill c
|
FROM tmp_uc_wo_backfill c
|
||||||
INNER JOIN biz_process_route r
|
INNER JOIN biz_process_route r
|
||||||
ON r.id = c.route_id
|
ON r.id COLLATE utf8mb4_unicode_ci = c.route_id COLLATE utf8mb4_unicode_ci
|
||||||
AND r.del_flag = 0
|
AND r.del_flag = 0
|
||||||
WHERE @uc_ready = 1
|
WHERE @uc_ready = 1
|
||||||
AND c.task_id IS NOT NULL
|
AND c.task_id IS NOT NULL
|
||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1 FROM biz_production_task t
|
SELECT 1 FROM biz_production_task t
|
||||||
WHERE t.work_order_id = c.work_order_id
|
WHERE t.work_order_id COLLATE utf8mb4_general_ci = c.work_order_id COLLATE utf8mb4_general_ci
|
||||||
AND t.tenant_no = c.tenant_no
|
AND t.tenant_no COLLATE utf8mb4_general_ci = c.tenant_no COLLATE utf8mb4_general_ci
|
||||||
AND t.del_flag = 0
|
AND t.del_flag = 0
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -195,7 +200,7 @@ CREATE TEMPORARY TABLE tmp_uc_step_map (
|
|||||||
PRIMARY KEY (task_id, route_step_id),
|
PRIMARY KEY (task_id, route_step_id),
|
||||||
KEY ix_route_step (route_step_id),
|
KEY ix_route_step (route_step_id),
|
||||||
KEY ix_task_step (task_step_id)
|
KEY ix_task_step (task_step_id)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
INSERT INTO tmp_uc_step_map (
|
INSERT INTO tmp_uc_step_map (
|
||||||
task_id, work_order_id, tenant_no, route_step_id, task_step_id, step_order
|
task_id, work_order_id, tenant_no, route_step_id, task_step_id, step_order
|
||||||
@@ -205,16 +210,17 @@ SELECT
|
|||||||
c.work_order_id,
|
c.work_order_id,
|
||||||
c.tenant_no,
|
c.tenant_no,
|
||||||
rs.id,
|
rs.id,
|
||||||
UPPER(REPLACE(UUID(), '-', '')),
|
UPPER(MD5(CONCAT('uc-msc-backfill-step:', c.work_order_id, ':', rs.id))),
|
||||||
rs.step_order
|
rs.step_order
|
||||||
FROM tmp_uc_wo_backfill c
|
FROM tmp_uc_wo_backfill c
|
||||||
INNER JOIN biz_process_route_step rs
|
INNER JOIN biz_process_route_step rs
|
||||||
ON rs.route_id = c.route_id
|
ON rs.route_id COLLATE utf8mb4_unicode_ci = c.route_id COLLATE utf8mb4_unicode_ci
|
||||||
AND rs.del_flag = 0
|
AND rs.del_flag = 0
|
||||||
WHERE @uc_ready = 1
|
WHERE @uc_ready = 1
|
||||||
AND EXISTS (
|
AND EXISTS (
|
||||||
SELECT 1 FROM biz_production_task t
|
SELECT 1 FROM biz_production_task t
|
||||||
WHERE t.id = c.task_id AND t.del_flag = 0
|
WHERE t.id COLLATE utf8mb4_general_ci = c.task_id COLLATE utf8mb4_general_ci
|
||||||
|
AND t.del_flag = 0
|
||||||
);
|
);
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
@@ -257,11 +263,11 @@ SELECT
|
|||||||
0
|
0
|
||||||
FROM tmp_uc_step_map m
|
FROM tmp_uc_step_map m
|
||||||
INNER JOIN biz_process_route_step rs
|
INNER JOIN biz_process_route_step rs
|
||||||
ON rs.id = m.route_step_id
|
ON rs.id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
|
||||||
AND rs.del_flag = 0
|
AND rs.del_flag = 0
|
||||||
WHERE NOT EXISTS (
|
WHERE NOT EXISTS (
|
||||||
SELECT 1 FROM biz_production_task_step x
|
SELECT 1 FROM biz_production_task_step x
|
||||||
WHERE x.id = m.task_step_id
|
WHERE x.id COLLATE utf8mb4_general_ci = m.task_step_id COLLATE utf8mb4_general_ci
|
||||||
);
|
);
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
@@ -273,7 +279,7 @@ INSERT INTO biz_production_task_step_reagent (
|
|||||||
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
UPPER(REPLACE(UUID(), '-', '')),
|
UPPER(MD5(CONCAT('uc-msc-backfill-reag:', m.task_step_id, ':', src.id))),
|
||||||
m.task_step_id,
|
m.task_step_id,
|
||||||
src.reagent_code,
|
src.reagent_code,
|
||||||
src.reagent_name,
|
src.reagent_name,
|
||||||
@@ -292,7 +298,7 @@ SELECT
|
|||||||
0
|
0
|
||||||
FROM tmp_uc_step_map m
|
FROM tmp_uc_step_map m
|
||||||
INNER JOIN biz_process_route_step_reagent src
|
INNER JOIN biz_process_route_step_reagent src
|
||||||
ON src.step_id = m.route_step_id
|
ON src.step_id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
|
||||||
AND src.del_flag = 0;
|
AND src.del_flag = 0;
|
||||||
|
|
||||||
INSERT INTO biz_production_task_step_consumable (
|
INSERT INTO biz_production_task_step_consumable (
|
||||||
@@ -301,7 +307,7 @@ INSERT INTO biz_production_task_step_consumable (
|
|||||||
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
UPPER(REPLACE(UUID(), '-', '')),
|
UPPER(MD5(CONCAT('uc-msc-backfill-cons:', m.task_step_id, ':', src.id))),
|
||||||
m.task_step_id,
|
m.task_step_id,
|
||||||
src.consumable_code,
|
src.consumable_code,
|
||||||
src.consumable_name,
|
src.consumable_name,
|
||||||
@@ -320,7 +326,7 @@ SELECT
|
|||||||
0
|
0
|
||||||
FROM tmp_uc_step_map m
|
FROM tmp_uc_step_map m
|
||||||
INNER JOIN biz_process_route_step_consumable src
|
INNER JOIN biz_process_route_step_consumable src
|
||||||
ON src.step_id = m.route_step_id
|
ON src.step_id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
|
||||||
AND src.del_flag = 0;
|
AND src.del_flag = 0;
|
||||||
|
|
||||||
INSERT INTO biz_production_task_step_output (
|
INSERT INTO biz_production_task_step_output (
|
||||||
@@ -329,7 +335,7 @@ INSERT INTO biz_production_task_step_output (
|
|||||||
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
UPPER(REPLACE(UUID(), '-', '')),
|
UPPER(MD5(CONCAT('uc-msc-backfill-out:', m.task_step_id, ':', src.id))),
|
||||||
m.task_step_id,
|
m.task_step_id,
|
||||||
src.output_type_id,
|
src.output_type_id,
|
||||||
src.output_name,
|
src.output_name,
|
||||||
@@ -345,7 +351,7 @@ SELECT
|
|||||||
0
|
0
|
||||||
FROM tmp_uc_step_map m
|
FROM tmp_uc_step_map m
|
||||||
INNER JOIN biz_process_route_step_output src
|
INNER JOIN biz_process_route_step_output src
|
||||||
ON src.step_id = m.route_step_id
|
ON src.step_id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
|
||||||
AND src.del_flag = 0;
|
AND src.del_flag = 0;
|
||||||
|
|
||||||
INSERT INTO biz_production_task_step_data_collection (
|
INSERT INTO biz_production_task_step_data_collection (
|
||||||
@@ -353,7 +359,7 @@ INSERT INTO biz_production_task_step_data_collection (
|
|||||||
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
UPPER(REPLACE(UUID(), '-', '')),
|
UPPER(MD5(CONCAT('uc-msc-backfill-dc:', m.task_step_id, ':', src.id))),
|
||||||
m.task_step_id,
|
m.task_step_id,
|
||||||
src.collection_name,
|
src.collection_name,
|
||||||
src.unit,
|
src.unit,
|
||||||
@@ -368,14 +374,15 @@ SELECT
|
|||||||
0
|
0
|
||||||
FROM tmp_uc_step_map m
|
FROM tmp_uc_step_map m
|
||||||
INNER JOIN biz_process_route_step_data_collection src
|
INNER JOIN biz_process_route_step_data_collection src
|
||||||
ON src.step_id = m.route_step_id
|
ON src.step_id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
|
||||||
AND src.del_flag = 0;
|
AND src.del_flag = 0;
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
-- 6. 回写工单状态:有任务则 jxz(不改 ywc)
|
-- 6. 回写工单状态:有任务则 jxz(不改 ywc)
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
UPDATE biz_production_work_order wo
|
UPDATE biz_production_work_order wo
|
||||||
INNER JOIN tmp_uc_wo_backfill c ON c.work_order_id = wo.id
|
INNER JOIN tmp_uc_wo_backfill c
|
||||||
|
ON c.work_order_id COLLATE utf8mb4_general_ci = wo.id COLLATE utf8mb4_general_ci
|
||||||
SET
|
SET
|
||||||
wo.work_order_status = 'jxz',
|
wo.work_order_status = 'jxz',
|
||||||
wo.update_time = NOW()
|
wo.update_time = NOW()
|
||||||
@@ -383,8 +390,8 @@ WHERE wo.del_flag = 0
|
|||||||
AND wo.work_order_status = 'dpz'
|
AND wo.work_order_status = 'dpz'
|
||||||
AND EXISTS (
|
AND EXISTS (
|
||||||
SELECT 1 FROM biz_production_task t
|
SELECT 1 FROM biz_production_task t
|
||||||
WHERE t.work_order_id = wo.id
|
WHERE t.work_order_id COLLATE utf8mb4_general_ci = wo.id COLLATE utf8mb4_general_ci
|
||||||
AND t.tenant_no = wo.tenant_no
|
AND t.tenant_no COLLATE utf8mb4_general_ci = wo.tenant_no COLLATE utf8mb4_general_ci
|
||||||
AND t.del_flag = 0
|
AND t.del_flag = 0
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -399,10 +406,18 @@ SELECT
|
|||||||
t.id AS task_id,
|
t.id AS task_id,
|
||||||
t.task_no,
|
t.task_no,
|
||||||
t.task_name,
|
t.task_name,
|
||||||
(SELECT COUNT(*) FROM biz_production_task_step s WHERE s.task_id = t.id AND s.del_flag = 0) AS step_count
|
(
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM biz_production_task_step s
|
||||||
|
WHERE s.task_id COLLATE utf8mb4_general_ci = t.id COLLATE utf8mb4_general_ci
|
||||||
|
AND s.del_flag = 0
|
||||||
|
) AS step_count
|
||||||
FROM tmp_uc_wo_backfill c
|
FROM tmp_uc_wo_backfill c
|
||||||
LEFT JOIN biz_production_work_order wo ON wo.id = c.work_order_id
|
LEFT JOIN biz_production_work_order wo
|
||||||
LEFT JOIN biz_production_task t ON t.id = c.task_id AND t.del_flag = 0
|
ON wo.id COLLATE utf8mb4_general_ci = c.work_order_id COLLATE utf8mb4_general_ci
|
||||||
|
LEFT JOIN biz_production_task t
|
||||||
|
ON t.id COLLATE utf8mb4_general_ci = c.task_id COLLATE utf8mb4_general_ci
|
||||||
|
AND t.del_flag = 0
|
||||||
ORDER BY c.seq;
|
ORDER BY c.seq;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp_uc_step_map;
|
DROP TEMPORARY TABLE IF EXISTS tmp_uc_step_map;
|
||||||
|
|||||||
@@ -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,54 @@
|
|||||||
|
-- Issue #127:已作废 / 属地废弃协议下样本状态回刷为已作废
|
||||||
|
-- 细胞存储 + 科研捐赠;可重复执行。
|
||||||
|
-- 规则:协议 status 为 yzf/sdfq 且样本未删除时,sample_status 置 yzf,
|
||||||
|
-- void_date 为空时按协议 void_time / update_time 补齐 YYYYMMDD。
|
||||||
|
|
||||||
|
-- 细胞存储协议样本
|
||||||
|
UPDATE biz_protocol_sample s
|
||||||
|
INNER JOIN biz_collection_protocol p
|
||||||
|
ON p.id = s.collection_protocol_id
|
||||||
|
AND p.tenant_no = s.tenant_no
|
||||||
|
AND p.del_flag = 0
|
||||||
|
SET
|
||||||
|
s.sample_status = 'yzf',
|
||||||
|
s.void_date = CASE
|
||||||
|
WHEN s.void_date IS NOT NULL AND TRIM(s.void_date) <> '' THEN s.void_date
|
||||||
|
WHEN p.void_time IS NOT NULL THEN DATE_FORMAT(p.void_time, '%Y%m%d')
|
||||||
|
WHEN p.update_time IS NOT NULL THEN DATE_FORMAT(p.update_time, '%Y%m%d')
|
||||||
|
ELSE DATE_FORMAT(NOW(), '%Y%m%d')
|
||||||
|
END,
|
||||||
|
s.update_time = NOW()
|
||||||
|
WHERE s.del_flag = 0
|
||||||
|
AND p.protocol_status IN ('yzf', 'sdfq')
|
||||||
|
AND (
|
||||||
|
s.sample_status IS NULL
|
||||||
|
OR TRIM(s.sample_status) = ''
|
||||||
|
OR s.sample_status <> 'yzf'
|
||||||
|
OR s.void_date IS NULL
|
||||||
|
OR TRIM(s.void_date) = ''
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 科研捐赠样本
|
||||||
|
UPDATE biz_research_donation_sample s
|
||||||
|
INNER JOIN biz_research_donation d
|
||||||
|
ON d.id = s.research_donation_id
|
||||||
|
AND d.tenant_no = s.tenant_no
|
||||||
|
AND d.del_flag = 0
|
||||||
|
SET
|
||||||
|
s.sample_status = 'yzf',
|
||||||
|
s.void_date = CASE
|
||||||
|
WHEN s.void_date IS NOT NULL AND TRIM(s.void_date) <> '' THEN s.void_date
|
||||||
|
WHEN d.void_time IS NOT NULL THEN DATE_FORMAT(d.void_time, '%Y%m%d')
|
||||||
|
WHEN d.update_time IS NOT NULL THEN DATE_FORMAT(d.update_time, '%Y%m%d')
|
||||||
|
ELSE DATE_FORMAT(NOW(), '%Y%m%d')
|
||||||
|
END,
|
||||||
|
s.update_time = NOW()
|
||||||
|
WHERE s.del_flag = 0
|
||||||
|
AND d.donation_status IN ('yzf', 'sdfq')
|
||||||
|
AND (
|
||||||
|
s.sample_status IS NULL
|
||||||
|
OR TRIM(s.sample_status) = ''
|
||||||
|
OR s.sample_status <> 'yzf'
|
||||||
|
OR s.void_date IS NULL
|
||||||
|
OR TRIM(s.void_date) = ''
|
||||||
|
);
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
-- Issue #129:样本接收结论已为废弃(bj)、但样本状态尚未作废的历史回刷
|
||||||
|
-- 细胞存储 / 科研捐赠;可重复执行。
|
||||||
|
-- 仅处理协议仍有效(非 yzf/sdfq)的样本行;已作废协议样本由 #127 回刷脚本覆盖。
|
||||||
|
|
||||||
|
-- 细胞存储
|
||||||
|
UPDATE biz_protocol_sample s
|
||||||
|
INNER JOIN biz_sample_reception r
|
||||||
|
ON r.tenant_no = s.tenant_no
|
||||||
|
AND r.del_flag = 0
|
||||||
|
AND r.reception_source = 'cell_storage'
|
||||||
|
AND r.accept_conclusion = 'bj'
|
||||||
|
AND r.sample_code = s.sample_code
|
||||||
|
AND r.collection_protocol_id = s.collection_protocol_id
|
||||||
|
INNER JOIN biz_collection_protocol p
|
||||||
|
ON p.id = s.collection_protocol_id
|
||||||
|
AND p.tenant_no = s.tenant_no
|
||||||
|
AND p.del_flag = 0
|
||||||
|
SET
|
||||||
|
s.sample_status = 'yzf',
|
||||||
|
s.void_date = CASE
|
||||||
|
WHEN s.void_date IS NOT NULL AND TRIM(s.void_date) <> '' THEN s.void_date
|
||||||
|
WHEN r.reception_time IS NOT NULL THEN DATE_FORMAT(r.reception_time, '%Y%m%d')
|
||||||
|
WHEN s.update_time IS NOT NULL THEN DATE_FORMAT(s.update_time, '%Y%m%d')
|
||||||
|
ELSE DATE_FORMAT(NOW(), '%Y%m%d')
|
||||||
|
END,
|
||||||
|
s.update_time = NOW()
|
||||||
|
WHERE s.del_flag = 0
|
||||||
|
AND p.protocol_status NOT IN ('yzf', 'sdfq')
|
||||||
|
AND (
|
||||||
|
s.sample_status IS NULL
|
||||||
|
OR TRIM(s.sample_status) = ''
|
||||||
|
OR s.sample_status <> 'yzf'
|
||||||
|
OR s.void_date IS NULL
|
||||||
|
OR TRIM(s.void_date) = ''
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 科研捐赠
|
||||||
|
UPDATE biz_research_donation_sample s
|
||||||
|
INNER JOIN biz_sample_reception r
|
||||||
|
ON r.tenant_no = s.tenant_no
|
||||||
|
AND r.del_flag = 0
|
||||||
|
AND r.reception_source = 'research_donation'
|
||||||
|
AND r.accept_conclusion = 'bj'
|
||||||
|
AND r.sample_code = s.sample_code
|
||||||
|
AND r.research_donation_id = s.research_donation_id
|
||||||
|
INNER JOIN biz_research_donation d
|
||||||
|
ON d.id = s.research_donation_id
|
||||||
|
AND d.tenant_no = s.tenant_no
|
||||||
|
AND d.del_flag = 0
|
||||||
|
SET
|
||||||
|
s.sample_status = 'yzf',
|
||||||
|
s.void_date = CASE
|
||||||
|
WHEN s.void_date IS NOT NULL AND TRIM(s.void_date) <> '' THEN s.void_date
|
||||||
|
WHEN r.reception_time IS NOT NULL THEN DATE_FORMAT(r.reception_time, '%Y%m%d')
|
||||||
|
WHEN s.update_time IS NOT NULL THEN DATE_FORMAT(s.update_time, '%Y%m%d')
|
||||||
|
ELSE DATE_FORMAT(NOW(), '%Y%m%d')
|
||||||
|
END,
|
||||||
|
s.update_time = NOW()
|
||||||
|
WHERE s.del_flag = 0
|
||||||
|
AND d.donation_status NOT IN ('yzf', 'sdfq')
|
||||||
|
AND (
|
||||||
|
s.sample_status IS NULL
|
||||||
|
OR TRIM(s.sample_status) = ''
|
||||||
|
OR s.sample_status <> 'yzf'
|
||||||
|
OR s.void_date IS NULL
|
||||||
|
OR TRIM(s.void_date) = ''
|
||||||
|
);
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
-- Issue #131:样本作废原因字段 void_desc
|
||||||
|
-- 细胞存储 / 科研捐赠样本表;按列是否已存在可重复执行。
|
||||||
|
|
||||||
|
SET @db := DATABASE();
|
||||||
|
|
||||||
|
SET @exists := (
|
||||||
|
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'biz_protocol_sample' AND COLUMN_NAME = 'void_desc'
|
||||||
|
);
|
||||||
|
SET @sql := IF(
|
||||||
|
@exists = 0,
|
||||||
|
'ALTER TABLE biz_protocol_sample ADD COLUMN void_desc VARCHAR(512) NULL COMMENT ''样本作废原因'' AFTER void_date',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
SET @exists := (
|
||||||
|
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'biz_research_donation_sample' AND COLUMN_NAME = 'void_desc'
|
||||||
|
);
|
||||||
|
SET @sql := IF(
|
||||||
|
@exists = 0,
|
||||||
|
'ALTER TABLE biz_research_donation_sample ADD COLUMN void_desc VARCHAR(512) NULL COMMENT ''样本作废原因'' AFTER void_date',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
-- 软删【市场】下【中试服务】目录及其子菜单(含按钮),与前端静态路由下线对齐。
|
||||||
|
-- Issue #158(承接 #156:仅解绑角色对超管侧栏无效)
|
||||||
|
-- MySQL 5.7,可重复执行;不影响基础实验/临床应用下同名菜单。
|
||||||
|
|
||||||
|
-- 0) 预览目标菜单
|
||||||
|
SELECT
|
||||||
|
m.tenant_no,
|
||||||
|
m.id AS menu_id,
|
||||||
|
m.menu_name,
|
||||||
|
m.menu_type,
|
||||||
|
m.perms,
|
||||||
|
m.parent_id,
|
||||||
|
m.del_flag
|
||||||
|
FROM sys_menu m
|
||||||
|
JOIN (
|
||||||
|
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT child.id, child.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT btn.id, btn.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
JOIN sys_menu btn
|
||||||
|
ON btn.parent_id = child.id
|
||||||
|
AND btn.tenant_no = market.tenant_no
|
||||||
|
AND btn.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
) tgt
|
||||||
|
ON tgt.menu_id = m.id
|
||||||
|
AND tgt.tenant_no = m.tenant_no
|
||||||
|
WHERE m.del_flag = 0
|
||||||
|
ORDER BY m.tenant_no, m.menu_type, m.order_num, m.menu_name;
|
||||||
|
|
||||||
|
-- 1) 软删目标菜单
|
||||||
|
UPDATE sys_menu m
|
||||||
|
JOIN (
|
||||||
|
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT child.id, child.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT btn.id, btn.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
JOIN sys_menu btn
|
||||||
|
ON btn.parent_id = child.id
|
||||||
|
AND btn.tenant_no = market.tenant_no
|
||||||
|
AND btn.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
) tgt
|
||||||
|
ON tgt.menu_id = m.id
|
||||||
|
AND tgt.tenant_no = m.tenant_no
|
||||||
|
SET
|
||||||
|
m.del_flag = 1,
|
||||||
|
m.update_by = 'migration',
|
||||||
|
m.update_time = NOW()
|
||||||
|
WHERE m.del_flag = 0;
|
||||||
|
|
||||||
|
-- 2) 核对:市场下不应再有有效「中试服务」目录(期望 0 行)
|
||||||
|
SELECT
|
||||||
|
market.tenant_no,
|
||||||
|
pilot.id,
|
||||||
|
pilot.menu_name,
|
||||||
|
pilot.del_flag
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market';
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
-- 临床科研申请单:业务子类型 research_category
|
||||||
|
-- MySQL 5.7,可重复执行。
|
||||||
|
|
||||||
|
SET @col_exists := (
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'biz_pilot_application'
|
||||||
|
AND COLUMN_NAME = 'research_category'
|
||||||
|
);
|
||||||
|
|
||||||
|
SET @sql := IF(
|
||||||
|
@col_exists = 0,
|
||||||
|
"ALTER TABLE biz_pilot_application ADD COLUMN research_category VARCHAR(32) NULL COMMENT '临床科研业务子类型: bio_tech_clinical/joint_topic_declare/bio_pharma_rd' AFTER customer_phone",
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
@@ -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 '%基础实验%'
|
||||||
|
);
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
-- 解除【市场】下【中试服务】目录及其全部子菜单(含按钮)与角色的绑定。
|
||||||
|
-- Issue #156
|
||||||
|
-- 仅软删 sys_role_menu(del_flag=1),不删除/隐藏菜单本身。
|
||||||
|
-- 按树定位:menu:market → menu_name=中试服务 → 直系子菜单 → 孙级按钮;
|
||||||
|
-- 不匹配基础实验/临床应用等其他目录下的同名「出库放行审核」。
|
||||||
|
-- MySQL 5.7,可重复执行(只处理 del_flag=0 的绑定)。
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 0) 预览:将要解绑的目标菜单(目录 + 子菜单 + 按钮)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
SELECT
|
||||||
|
m.tenant_no,
|
||||||
|
m.id AS menu_id,
|
||||||
|
m.menu_name,
|
||||||
|
m.menu_type,
|
||||||
|
m.perms,
|
||||||
|
m.parent_id,
|
||||||
|
m.path
|
||||||
|
FROM sys_menu m
|
||||||
|
JOIN (
|
||||||
|
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT child.id, child.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT btn.id, btn.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
JOIN sys_menu btn
|
||||||
|
ON btn.parent_id = child.id
|
||||||
|
AND btn.tenant_no = market.tenant_no
|
||||||
|
AND btn.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
) tgt
|
||||||
|
ON tgt.menu_id = m.id
|
||||||
|
AND tgt.tenant_no = m.tenant_no
|
||||||
|
WHERE m.del_flag = 0
|
||||||
|
ORDER BY m.tenant_no, m.menu_type, m.order_num, m.menu_name;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 1) 预览:将要软删的角色-菜单绑定
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
SELECT
|
||||||
|
rm.tenant_no,
|
||||||
|
r.id AS role_id,
|
||||||
|
r.role_name,
|
||||||
|
m.id AS menu_id,
|
||||||
|
m.menu_name,
|
||||||
|
m.menu_type,
|
||||||
|
m.perms,
|
||||||
|
rm.id AS role_menu_id
|
||||||
|
FROM sys_role_menu rm
|
||||||
|
JOIN sys_role r
|
||||||
|
ON r.id = rm.role_id
|
||||||
|
AND r.tenant_no = rm.tenant_no
|
||||||
|
AND r.del_flag = 0
|
||||||
|
JOIN sys_menu m
|
||||||
|
ON m.id = rm.menu_id
|
||||||
|
AND m.tenant_no = rm.tenant_no
|
||||||
|
AND m.del_flag = 0
|
||||||
|
JOIN (
|
||||||
|
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT child.id, child.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT btn.id, btn.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
JOIN sys_menu btn
|
||||||
|
ON btn.parent_id = child.id
|
||||||
|
AND btn.tenant_no = market.tenant_no
|
||||||
|
AND btn.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
) tgt
|
||||||
|
ON tgt.menu_id = rm.menu_id
|
||||||
|
AND tgt.tenant_no = rm.tenant_no
|
||||||
|
WHERE rm.del_flag = 0
|
||||||
|
ORDER BY rm.tenant_no, r.role_name, m.menu_name;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 2) 软删绑定(可重复执行)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
UPDATE sys_role_menu rm
|
||||||
|
JOIN (
|
||||||
|
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT child.id, child.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT btn.id, btn.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
JOIN sys_menu btn
|
||||||
|
ON btn.parent_id = child.id
|
||||||
|
AND btn.tenant_no = market.tenant_no
|
||||||
|
AND btn.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
) tgt
|
||||||
|
ON tgt.menu_id = rm.menu_id
|
||||||
|
AND tgt.tenant_no = rm.tenant_no
|
||||||
|
SET
|
||||||
|
rm.del_flag = 1,
|
||||||
|
rm.update_by = 'migration',
|
||||||
|
rm.update_time = NOW()
|
||||||
|
WHERE rm.del_flag = 0;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 3) 核对:目标菜单上不应再有有效角色绑定(期望 0 行)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
SELECT
|
||||||
|
rm.tenant_no,
|
||||||
|
r.role_name,
|
||||||
|
m.menu_name,
|
||||||
|
m.perms,
|
||||||
|
COUNT(*) AS active_role_menu_rows
|
||||||
|
FROM sys_role_menu rm
|
||||||
|
JOIN sys_role r
|
||||||
|
ON r.id = rm.role_id
|
||||||
|
AND r.tenant_no = rm.tenant_no
|
||||||
|
AND r.del_flag = 0
|
||||||
|
JOIN sys_menu m
|
||||||
|
ON m.id = rm.menu_id
|
||||||
|
AND m.tenant_no = rm.tenant_no
|
||||||
|
AND m.del_flag = 0
|
||||||
|
JOIN (
|
||||||
|
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT child.id, child.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
UNION
|
||||||
|
SELECT btn.id, btn.tenant_no
|
||||||
|
FROM sys_menu market
|
||||||
|
JOIN sys_menu pilot
|
||||||
|
ON pilot.parent_id = market.id
|
||||||
|
AND pilot.tenant_no = market.tenant_no
|
||||||
|
AND pilot.del_flag = 0
|
||||||
|
AND pilot.menu_name = '中试服务'
|
||||||
|
JOIN sys_menu child
|
||||||
|
ON child.parent_id = pilot.id
|
||||||
|
AND child.tenant_no = market.tenant_no
|
||||||
|
AND child.del_flag = 0
|
||||||
|
JOIN sys_menu btn
|
||||||
|
ON btn.parent_id = child.id
|
||||||
|
AND btn.tenant_no = market.tenant_no
|
||||||
|
AND btn.del_flag = 0
|
||||||
|
WHERE market.del_flag = 0
|
||||||
|
AND market.perms = 'menu:market'
|
||||||
|
) tgt
|
||||||
|
ON tgt.menu_id = rm.menu_id
|
||||||
|
AND tgt.tenant_no = rm.tenant_no
|
||||||
|
WHERE rm.del_flag = 0
|
||||||
|
GROUP BY rm.tenant_no, r.role_name, m.menu_name, m.perms;
|
||||||
@@ -25,6 +25,17 @@ export function fetchCreateReceiveAccount(data) {
|
|||||||
return post('/web/admin/oa-approval/receive-accounts', data)
|
return post('/web/admin/oa-approval/receive-accounts', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fetchUpdateReceiveAccount(id, data) {
|
||||||
|
return put(`/web/admin/oa-approval/receive-accounts/${id}`, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchDeleteReceiveAccount(id) {
|
||||||
|
return request({
|
||||||
|
url: `/web/admin/oa-approval/receive-accounts/${id}`,
|
||||||
|
method: 'DELETE'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function fetchRelatedCandidates(params) {
|
export function fetchRelatedCandidates(params) {
|
||||||
return get('/web/admin/oa-approval/related-candidates', params)
|
return get('/web/admin/oa-approval/related-candidates', params)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,23 +23,11 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="market-list-card__fields">
|
<div class="market-list-card__fields">
|
||||||
<div
|
<MarketListField
|
||||||
v-for="field in previewFields"
|
v-for="field in previewFields"
|
||||||
:key="`${field.label}:${field.value}`"
|
:key="`${field.label}:${field.value}`"
|
||||||
class="market-list-card__field"
|
:field="field"
|
||||||
:class="{ 'is-wide': field.wide }"
|
/>
|
||||||
>
|
|
||||||
<span>{{ field.label }}</span>
|
|
||||||
<van-tag
|
|
||||||
v-if="field.tag"
|
|
||||||
class="market-tag"
|
|
||||||
:type="resolveStatusTone(field.value, field.tagType)"
|
|
||||||
size="medium"
|
|
||||||
round
|
|
||||||
:title="field.value"
|
|
||||||
>{{ field.value }}</van-tag>
|
|
||||||
<b v-else :class="{ 'is-money': field.money }">{{ field.value }}</b>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 每一期缴费:始终展示在「展开更多」上方,不收进总折叠 -->
|
<!-- 每一期缴费:始终展示在「展开更多」上方,不收进总折叠 -->
|
||||||
@@ -70,15 +58,11 @@
|
|||||||
</button>
|
</button>
|
||||||
<div v-show="periodOpenKeys[block.key]" class="market-list-card__period-body">
|
<div v-show="periodOpenKeys[block.key]" class="market-list-card__period-body">
|
||||||
<div class="market-list-card__fields market-list-card__fields--compact">
|
<div class="market-list-card__fields market-list-card__fields--compact">
|
||||||
<div
|
<MarketListField
|
||||||
v-for="field in block.fields"
|
v-for="field in block.fields"
|
||||||
:key="`${block.key}:${field.label}`"
|
:key="`${block.key}:${field.label}`"
|
||||||
class="market-list-card__field"
|
:field="field"
|
||||||
:class="{ 'is-wide': field.wide }"
|
/>
|
||||||
>
|
|
||||||
<span>{{ field.label }}</span>
|
|
||||||
<b :class="{ 'is-money': field.money }">{{ field.value }}</b>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -102,44 +86,20 @@
|
|||||||
<van-icon class="market-list-card__fields-toggle-chevron" name="arrow-down" />
|
<van-icon class="market-list-card__fields-toggle-chevron" name="arrow-down" />
|
||||||
</button>
|
</button>
|
||||||
<div v-show="fieldsOpen && collapsedFields.length" class="market-list-card__fields market-list-card__fields--folded">
|
<div v-show="fieldsOpen && collapsedFields.length" class="market-list-card__fields market-list-card__fields--folded">
|
||||||
<div
|
<MarketListField
|
||||||
v-for="field in collapsedFields"
|
v-for="field in collapsedFields"
|
||||||
:key="`more:${field.label}:${field.value}`"
|
:key="`more:${field.label}:${field.value}`"
|
||||||
class="market-list-card__field"
|
:field="field"
|
||||||
:class="{ 'is-wide': field.wide }"
|
/>
|
||||||
>
|
|
||||||
<span>{{ field.label }}</span>
|
|
||||||
<van-tag
|
|
||||||
v-if="field.tag"
|
|
||||||
class="market-tag"
|
|
||||||
:type="resolveStatusTone(field.value, field.tagType)"
|
|
||||||
size="medium"
|
|
||||||
round
|
|
||||||
:title="field.value"
|
|
||||||
>{{ field.value }}</van-tag>
|
|
||||||
<b v-else :class="{ 'is-money': field.money }">{{ field.value }}</b>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="card.footerFields?.length && showFoldedFooter" class="market-list-card__fields">
|
<div v-if="card.footerFields?.length && showFoldedFooter" class="market-list-card__fields">
|
||||||
<div
|
<MarketListField
|
||||||
v-for="field in card.footerFields"
|
v-for="field in card.footerFields"
|
||||||
:key="`footer:${field.label}:${field.value}`"
|
:key="`footer:${field.label}:${field.value}`"
|
||||||
class="market-list-card__field"
|
:field="field"
|
||||||
:class="{ 'is-wide': field.wide }"
|
/>
|
||||||
>
|
|
||||||
<span>{{ field.label }}</span>
|
|
||||||
<van-tag
|
|
||||||
v-if="field.tag"
|
|
||||||
class="market-tag"
|
|
||||||
:type="resolveStatusTone(field.value, field.tagType)"
|
|
||||||
size="medium"
|
|
||||||
round
|
|
||||||
:title="field.value"
|
|
||||||
>{{ field.value }}</van-tag>
|
|
||||||
<b v-else :class="{ 'is-money': field.money }">{{ field.value }}</b>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -181,15 +141,11 @@
|
|||||||
>{{ block.status }}</van-tag>
|
>{{ block.status }}</van-tag>
|
||||||
</div>
|
</div>
|
||||||
<div class="market-list-card__fields market-list-card__fields--compact">
|
<div class="market-list-card__fields market-list-card__fields--compact">
|
||||||
<div
|
<MarketListField
|
||||||
v-for="field in block.fields"
|
v-for="field in block.fields"
|
||||||
:key="`${block.key}:${field.label}`"
|
:key="`${block.key}:${field.label}`"
|
||||||
class="market-list-card__field"
|
:field="field"
|
||||||
:class="{ 'is-wide': field.wide }"
|
/>
|
||||||
>
|
|
||||||
<span>{{ field.label }}</span>
|
|
||||||
<b>{{ field.value }}</b>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -222,6 +178,7 @@
|
|||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { actionLabel, buildMarketCard } from '../list-presenter.js'
|
import { actionLabel, buildMarketCard } from '../list-presenter.js'
|
||||||
import { resolveStatusTone } from '../status-tone.js'
|
import { resolveStatusTone } from '../status-tone.js'
|
||||||
|
import MarketListField from './MarketListField.vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: { type: Object, required: true },
|
item: { type: Object, required: true },
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<template>
|
||||||
|
<div class="market-list-card__field" :class="{ 'is-wide': field.wide }">
|
||||||
|
<span>{{ field.label }}</span>
|
||||||
|
<span class="market-list-card__value">
|
||||||
|
<van-tag
|
||||||
|
v-if="field.tag"
|
||||||
|
class="market-tag"
|
||||||
|
:type="resolveStatusTone(field.value, field.tagType)"
|
||||||
|
size="medium"
|
||||||
|
round
|
||||||
|
:title="field.value"
|
||||||
|
>{{ field.value }}</van-tag>
|
||||||
|
<b v-else :class="{ 'is-money': field.money }">{{ field.value }}</b>
|
||||||
|
<button
|
||||||
|
v-if="field.helpTitle"
|
||||||
|
type="button"
|
||||||
|
class="market-list-card__help"
|
||||||
|
:aria-label="`查看${field.helpTitle}`"
|
||||||
|
:title="field.helpTitle"
|
||||||
|
@click="showHelp"
|
||||||
|
>
|
||||||
|
<van-icon name="question-o" />
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { showDialog } from 'vant'
|
||||||
|
import { resolveStatusTone } from '../status-tone.js'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
field: { type: Object, required: true }
|
||||||
|
})
|
||||||
|
|
||||||
|
function showHelp() {
|
||||||
|
showDialog({
|
||||||
|
title: props.field.helpTitle || '作废原因',
|
||||||
|
message: props.field.helpText || '—',
|
||||||
|
messageAlign: 'left',
|
||||||
|
confirmButtonText: '知道了'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -2,6 +2,7 @@ import { formatMoney } from './money.js'
|
|||||||
import {
|
import {
|
||||||
resolveStatusTag,
|
resolveStatusTag,
|
||||||
samplePaymentProgress,
|
samplePaymentProgress,
|
||||||
|
sampleStatus,
|
||||||
payMode,
|
payMode,
|
||||||
protocolStatus,
|
protocolStatus,
|
||||||
donationStatus,
|
donationStatus,
|
||||||
@@ -94,6 +95,30 @@ const personName = (name, id) => {
|
|||||||
: referenceId ? '未知人员' : '—'
|
: referenceId ? '未知人员' : '—'
|
||||||
}
|
}
|
||||||
const field = (labelText, value, options = {}) => ({ label: labelText, value: text(value), ...options })
|
const field = (labelText, value, options = {}) => ({ label: labelText, value: text(value), ...options })
|
||||||
|
|
||||||
|
function sampleVoidReason(item) {
|
||||||
|
if (item && Object.prototype.hasOwnProperty.call(item, 'sampleVoidDesc')) {
|
||||||
|
return String(item.sampleVoidDesc ?? '').trim()
|
||||||
|
}
|
||||||
|
return String(item?.voidDesc ?? '').trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 样本编码旁的样本状态;已作废时附带作废原因,供卡片问号展开 */
|
||||||
|
function sampleStatusField(item) {
|
||||||
|
const provided = String(item?.sampleStatusLabel ?? '').trim()
|
||||||
|
const code = String(item?.sampleStatus ?? '').trim()
|
||||||
|
if (!code && !provided) return field('样本状态', '')
|
||||||
|
const resolved = resolveStatusTag(sampleStatus, code)
|
||||||
|
const display = provided || resolved.label
|
||||||
|
const voided = code === 'yzf' || display === '已作废'
|
||||||
|
return field('样本状态', display, {
|
||||||
|
tag: true,
|
||||||
|
tagType: voided ? 'danger' : (code ? resolved.tagType : 'info'),
|
||||||
|
...(voided
|
||||||
|
? { helpTitle: '作废原因', helpText: sampleVoidReason(item) || '—' }
|
||||||
|
: {})
|
||||||
|
})
|
||||||
|
}
|
||||||
export function money(value) {
|
export function money(value) {
|
||||||
return formatMoney(value)
|
return formatMoney(value)
|
||||||
}
|
}
|
||||||
@@ -134,6 +159,7 @@ function protocolCard(item) {
|
|||||||
field('所属项目', item.projectName || item.basic?.projectName || ((item.projectId || item.basic?.projectId) ? '历史项目' : '未归属')),
|
field('所属项目', item.projectName || item.basic?.projectName || ((item.projectId || item.basic?.projectId) ? '历史项目' : '未归属')),
|
||||||
field('项目组', item.teamName || item.basic?.teamName),
|
field('项目组', item.teamName || item.basic?.teamName),
|
||||||
field('样本编码', item.sampleCode || item.labStorageCode),
|
field('样本编码', item.sampleCode || item.labStorageCode),
|
||||||
|
sampleStatusField(item),
|
||||||
field('采集日期', collectDate || item.donationDate),
|
field('采集日期', collectDate || item.donationDate),
|
||||||
field('当月核量号', item.monthlyVerifyNo),
|
field('当月核量号', item.monthlyVerifyNo),
|
||||||
field('实验室流转编号', item.labStorageCode || item.sampleCode),
|
field('实验室流转编号', item.labStorageCode || item.sampleCode),
|
||||||
@@ -172,6 +198,7 @@ function protocolCard(item) {
|
|||||||
field('所属项目', item.projectName || item.basic?.projectName || ((item.projectId || item.basic?.projectId) ? '历史项目' : '未归属')),
|
field('所属项目', item.projectName || item.basic?.projectName || ((item.projectId || item.basic?.projectId) ? '历史项目' : '未归属')),
|
||||||
field('项目组', item.teamName || item.basic?.teamName),
|
field('项目组', item.teamName || item.basic?.teamName),
|
||||||
field('样本编码', item.sampleCode),
|
field('样本编码', item.sampleCode),
|
||||||
|
sampleStatusField(item),
|
||||||
field('登记日期', item.registerDate || item.donationDate),
|
field('登记日期', item.registerDate || item.donationDate),
|
||||||
field('母亲电话', item.motherPhone),
|
field('母亲电话', item.motherPhone),
|
||||||
field('母亲身份证号', item.motherIdCard),
|
field('母亲身份证号', item.motherIdCard),
|
||||||
@@ -212,6 +239,7 @@ function chaseCard(item) {
|
|||||||
field('客户', item.motherName),
|
field('客户', item.motherName),
|
||||||
field('联系电话', item.motherPhone),
|
field('联系电话', item.motherPhone),
|
||||||
field('样本编码', item.sampleCode),
|
field('样本编码', item.sampleCode),
|
||||||
|
sampleStatusField(item),
|
||||||
field('市场专员', personName(item.salesUserName, item.salesUserId)),
|
field('市场专员', personName(item.salesUserName, item.salesUserId)),
|
||||||
field('缴费方式', mode.label, { tag: true, tagType: mode.tagType }),
|
field('缴费方式', mode.label, { tag: true, tagType: mode.tagType }),
|
||||||
field('期次', `第 ${text(item.scheduleNo, '1')} 期`),
|
field('期次', `第 ${text(item.scheduleNo, '1')} 期`),
|
||||||
@@ -281,7 +309,7 @@ function paymentCard(item) {
|
|||||||
statusTone: progress.tagType,
|
statusTone: progress.tagType,
|
||||||
fields: [
|
fields: [
|
||||||
field('姓名', item.motherName), field('手机号', item.motherPhone),
|
field('姓名', item.motherName), field('手机号', item.motherPhone),
|
||||||
field('样本编码', item.sampleCode), field('签署日期', item.signDate),
|
field('样本编码', item.sampleCode), sampleStatusField(item), field('签署日期', item.signDate),
|
||||||
field('存储项目', item.sampleTypeName), field('合同总额', money(item.contractAmount), { money: true }),
|
field('存储项目', item.sampleTypeName), field('合同总额', money(item.contractAmount), { money: true }),
|
||||||
field('缴费方式', mode.label, { tag: true, tagType: mode.tagType }),
|
field('缴费方式', mode.label, { tag: true, tagType: mode.tagType }),
|
||||||
field('应收总额', money(item.receivableAmount), { money: true })
|
field('应收总额', money(item.receivableAmount), { money: true })
|
||||||
@@ -311,6 +339,7 @@ function freightSampleBlock(row, index) {
|
|||||||
field('母亲姓名', row?.motherName),
|
field('母亲姓名', row?.motherName),
|
||||||
field('子女姓名', row?.newbornName),
|
field('子女姓名', row?.newbornName),
|
||||||
field('样本编码', row?.sampleCode, { wide: true }),
|
field('样本编码', row?.sampleCode, { wide: true }),
|
||||||
|
sampleStatusField(row),
|
||||||
field('样本类型', row?.sampleTypeName, { wide: true })
|
field('样本类型', row?.sampleTypeName, { wide: true })
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ test('research donation protocol card matches excel-parity field set', () => {
|
|||||||
const labels = card.fields.map((f) => f.label)
|
const labels = card.fields.map((f) => f.label)
|
||||||
assert.equal(labels[2], '样本编码')
|
assert.equal(labels[2], '样本编码')
|
||||||
for (const label of [
|
for (const label of [
|
||||||
'样本编码', '当月核量号', '实验室流转编号', '废弃原因', '样本类型',
|
'样本编码', '样本状态', '当月核量号', '实验室流转编号', '废弃原因', '样本类型',
|
||||||
'采集地区', '采集医院', '分娩时间', '采集时间', '市场专员', '地区经理',
|
'采集地区', '采集医院', '分娩时间', '采集时间', '市场专员', '地区经理',
|
||||||
'运输方式', '新生儿性别', '新生儿体重', '分娩方式', '胎次', '母血采集时间',
|
'运输方式', '新生儿性别', '新生儿体重', '分娩方式', '胎次', '母血采集时间',
|
||||||
'知情同意书', '传染病检测报告', '协议书', '备注'
|
'知情同意书', '传染病检测报告', '协议书', '备注'
|
||||||
@@ -245,11 +245,70 @@ test('freight card shows the scope-safe visible count and collapsible sample blo
|
|||||||
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '母亲姓名').value, '周雨桐')
|
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '母亲姓名').value, '周雨桐')
|
||||||
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '子女姓名').value, '宝宝乙')
|
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '子女姓名').value, '宝宝乙')
|
||||||
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '样本编码').value, 'S-2')
|
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '样本编码').value, 'S-2')
|
||||||
|
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '样本状态').value, '—')
|
||||||
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '样本类型').value, '脐带')
|
assert.equal(manager.sampleBlocks[1].fields.find((field) => field.label === '样本类型').value, '脐带')
|
||||||
assert.ok(manager.fields.some((field) => field.label === '更新时间' && field.value === '2026-10-13 10:00:00'))
|
assert.ok(manager.fields.some((field) => field.label === '更新时间' && field.value === '2026-10-13 10:00:00'))
|
||||||
assert.ok(manager.fields.some((field) => field.label === '备注' && field.value === '同批送达'))
|
assert.ok(manager.fields.some((field) => field.label === '备注' && field.value === '同批送达'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('sample-coded list cards show sample status and a void reason affordance', () => {
|
||||||
|
const cases = [
|
||||||
|
['protocol', { source: 'cell_storage', sampleCode: 'S-1', sampleStatus: 'yrk', sampleStatusLabel: '已入库' }],
|
||||||
|
['payment-chase', { sampleCode: 'S-1', sampleStatus: 'jcz' }],
|
||||||
|
['payment', { sampleCode: 'S-1', motherName: '周雨桐', sampleStatus: 'ycj', sampleStatusLabel: '已采集' }]
|
||||||
|
]
|
||||||
|
for (const [module, item] of cases) {
|
||||||
|
const card = buildMarketCard(module, 'specialist', item)
|
||||||
|
const status = card.fields.find((field) => field.label === '样本状态')
|
||||||
|
assert.ok(status, module)
|
||||||
|
assert.equal(status.tag, true)
|
||||||
|
assert.equal(status.helpTitle, undefined)
|
||||||
|
}
|
||||||
|
assert.equal(
|
||||||
|
buildMarketCard('protocol', 'specialist', {
|
||||||
|
source: 'cell_storage', sampleCode: 'S-1', sampleStatus: 'yrk', sampleStatusLabel: '已入库'
|
||||||
|
}).fields.find((field) => field.label === '样本状态').value,
|
||||||
|
'已入库'
|
||||||
|
)
|
||||||
|
const detecting = buildMarketCard('payment-chase', 'specialist', {
|
||||||
|
sampleCode: 'S-1', sampleStatus: 'jcz'
|
||||||
|
}).fields.find((field) => field.label === '样本状态')
|
||||||
|
assert.equal(detecting.value, '检测中')
|
||||||
|
assert.equal(detecting.helpTitle, undefined)
|
||||||
|
assert.equal(detecting.helpText, undefined)
|
||||||
|
|
||||||
|
const voided = buildMarketCard('payment', 'specialist', {
|
||||||
|
motherName: '作废客户',
|
||||||
|
sampleCode: 'S-VOID',
|
||||||
|
sampleStatus: 'yzf',
|
||||||
|
voidDesc: '客户放弃存储'
|
||||||
|
})
|
||||||
|
const voidField = voided.fields.find((field) => field.label === '样本状态')
|
||||||
|
assert.equal(voidField.value, '已作废')
|
||||||
|
assert.equal(voidField.tagType, 'danger')
|
||||||
|
assert.equal(voidField.helpTitle, '作废原因')
|
||||||
|
assert.equal(voidField.helpText, '客户放弃存储')
|
||||||
|
|
||||||
|
const donation = buildMarketCard('protocol', 'specialist', {
|
||||||
|
source: 'research_donation',
|
||||||
|
sampleCode: 'S-D',
|
||||||
|
sampleStatus: 'yzf',
|
||||||
|
sampleStatusLabel: '已作废',
|
||||||
|
voidDesc: '协议级废弃说明',
|
||||||
|
sampleVoidDesc: '样本溶血'
|
||||||
|
})
|
||||||
|
assert.equal(donation.fields.find((field) => field.label === '废弃原因').value, '协议级废弃说明')
|
||||||
|
assert.equal(donation.fields.find((field) => field.label === '样本状态').helpText, '样本溶血')
|
||||||
|
|
||||||
|
const freight = buildMarketCard('freight', 'manager', {
|
||||||
|
freightNo: 'YF-VOID',
|
||||||
|
items: [{ sampleCode: 'S-V', sampleStatus: 'yzf', voidDesc: '运输破损' }]
|
||||||
|
})
|
||||||
|
const sampleStatus = freight.sampleBlocks[0].fields.find((field) => field.label === '样本状态')
|
||||||
|
assert.equal(sampleStatus.value, '已作废')
|
||||||
|
assert.equal(sampleStatus.helpText, '运输破损')
|
||||||
|
})
|
||||||
|
|
||||||
test('action labels cover module-specific operations', () => {
|
test('action labels cover module-specific operations', () => {
|
||||||
assert.equal(actionLabel('link'), '关联样本')
|
assert.equal(actionLabel('link'), '关联样本')
|
||||||
assert.equal(actionLabel('unlink'), '取消样本关联')
|
assert.equal(actionLabel('unlink'), '取消样本关联')
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ test('market list visual contract keeps search white, tags filled and actions ri
|
|||||||
'./components/MarketDetailSection.vue',
|
'./components/MarketDetailSection.vue',
|
||||||
'./components/MarketDetailNestedCard.vue',
|
'./components/MarketDetailNestedCard.vue',
|
||||||
'./components/MarketListCard.vue',
|
'./components/MarketListCard.vue',
|
||||||
|
'./components/MarketListField.vue',
|
||||||
'./components/PresignOrderCard.vue',
|
'./components/PresignOrderCard.vue',
|
||||||
'./components/PresignTransferCard.vue',
|
'./components/PresignTransferCard.vue',
|
||||||
'./components/ProtocolSamplePaymentPanel.vue',
|
'./components/ProtocolSamplePaymentPanel.vue',
|
||||||
@@ -541,6 +542,16 @@ test('payment detail hosts PaymentDetailTransfersPanel and hides transfer bottom
|
|||||||
assert.match(panel, /应缴批次/)
|
assert.match(panel, /应缴批次/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('voided sample status uses a question icon and vant dialog', () => {
|
||||||
|
const field = source('./components/MarketListField.vue')
|
||||||
|
const card = source('./components/MarketListCard.vue')
|
||||||
|
assert.match(field, /name="question-o"/)
|
||||||
|
assert.match(field, /showDialog/)
|
||||||
|
assert.match(field, /field\.helpTitle/)
|
||||||
|
assert.match(field, /class="market-tag"/)
|
||||||
|
assert.match(card, /MarketListField/)
|
||||||
|
})
|
||||||
|
|
||||||
test('payment cards reproduce the Web Excel columns and operation labels', () => {
|
test('payment cards reproduce the Web Excel columns and operation labels', () => {
|
||||||
const presenter = source('./list-presenter.js')
|
const presenter = source('./list-presenter.js')
|
||||||
const card = source('./components/MarketListCard.vue')
|
const card = source('./components/MarketListCard.vue')
|
||||||
@@ -590,7 +601,7 @@ test('protocol cards expose the same business fields as the web list', async ()
|
|||||||
})
|
})
|
||||||
|
|
||||||
assert.deepEqual(card.fields.map((field) => field.label), [
|
assert.deepEqual(card.fields.map((field) => field.label), [
|
||||||
'所属项目', '项目组', '样本编码', '登记日期', '母亲电话', '母亲身份证号', '父亲姓名',
|
'所属项目', '项目组', '样本编码', '样本状态', '登记日期', '母亲电话', '母亲身份证号', '父亲姓名',
|
||||||
'新生儿性别', '分娩方式', '新生儿体重(克)', '采集地区', '采集医院',
|
'新生儿性别', '分娩方式', '新生儿体重(克)', '采集地区', '采集医院',
|
||||||
'市场专员', '样本采集时间', '创建时间'
|
'市场专员', '样本采集时间', '创建时间'
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -103,7 +103,15 @@ 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 保持一致 */
|
||||||
|
export const sampleStatus = createRegistry({
|
||||||
|
ycj: { label: '已采集', tagType: 'primary' },
|
||||||
|
jcz: { label: '检测中', tagType: 'warning' },
|
||||||
|
yrk: { label: '已入库', tagType: 'success' },
|
||||||
|
yzf: { label: '已作废', tagType: 'danger' }
|
||||||
})
|
})
|
||||||
|
|
||||||
export const presignOrderStatus = createRegistry({
|
export const presignOrderStatus = createRegistry({
|
||||||
|
|||||||
@@ -8,10 +8,19 @@ import {
|
|||||||
payMode,
|
payMode,
|
||||||
presignOrderStatus,
|
presignOrderStatus,
|
||||||
receptionSource,
|
receptionSource,
|
||||||
|
sampleStatus,
|
||||||
transportType,
|
transportType,
|
||||||
auditStatus
|
auditStatus
|
||||||
} from './status-tag-registry.js'
|
} from './status-tag-registry.js'
|
||||||
|
|
||||||
|
test('sample status yzf is 已作废/danger', () => {
|
||||||
|
assert.deepEqual(resolveStatusTag(sampleStatus, 'yzf'), {
|
||||||
|
label: '已作废',
|
||||||
|
tagType: 'danger'
|
||||||
|
})
|
||||||
|
assert.equal(resolveStatusTag(sampleStatus, 'yrk').label, '已入库')
|
||||||
|
})
|
||||||
|
|
||||||
test('sample progress dfj is 待缴费/info not 待缴清', () => {
|
test('sample progress dfj is 待缴费/info not 待缴清', () => {
|
||||||
assert.deepEqual(resolveStatusTag(samplePaymentProgress, 'dfj'), {
|
assert.deepEqual(resolveStatusTag(samplePaymentProgress, 'dfj'), {
|
||||||
label: '待缴费',
|
label: '待缴费',
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ import {
|
|||||||
uploadAttachment
|
uploadAttachment
|
||||||
} from '../../api/oa.js'
|
} from '../../api/oa.js'
|
||||||
import OaCommentFileCards from './OaCommentFileCards.vue'
|
import OaCommentFileCards from './OaCommentFileCards.vue'
|
||||||
|
import { hasOaCommentDraft } from '../oa-comment-draft.js'
|
||||||
import { attachmentFullUrl } from '../../utils/attachment.js'
|
import { attachmentFullUrl } from '../../utils/attachment.js'
|
||||||
import { isHarmonyWechat } from '../../utils/harmony-file-picker.js'
|
import { isHarmonyWechat } from '../../utils/harmony-file-picker.js'
|
||||||
import HarmonyFileSource from '../../components/HarmonyFileSource.vue'
|
import HarmonyFileSource from '../../components/HarmonyFileSource.vue'
|
||||||
@@ -215,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()
|
||||||
@@ -516,12 +518,25 @@ function confirmMention() {
|
|||||||
mentionVisible.value = false
|
mentionVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSend() {
|
function draftPending() {
|
||||||
const content = draft.value.trim()
|
return hasOaCommentDraft({
|
||||||
if (!content && !mentionUsers.value.length && !picked.value.length) {
|
content: draft.value,
|
||||||
showToast('请填写评论、@人员或添加附件')
|
mentionCount: mentionUsers.value.length,
|
||||||
return
|
attachmentCount: picked.value.length
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批动作前冲刷未发送草稿:无草稿直接成功;有草稿则等同点击「发送」。
|
||||||
|
* @returns {Promise<boolean>} false 表示发送失败或忙碌,调用方应中止审批动作
|
||||||
|
*/
|
||||||
|
async function flushDraft(opts = {}) {
|
||||||
|
if (!draftPending()) return true
|
||||||
|
if (sending.value || uploading.value) {
|
||||||
|
showToast(uploading.value ? '附件上传中,请稍后再试' : '评论发送中,请稍后再试')
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
const content = draft.value.trim()
|
||||||
sending.value = true
|
sending.value = true
|
||||||
try {
|
try {
|
||||||
await fetchCreateOaComment(props.instanceId, {
|
await fetchCreateOaComment(props.instanceId, {
|
||||||
@@ -533,15 +548,27 @@ async function onSend() {
|
|||||||
picked.value = []
|
picked.value = []
|
||||||
mentionUsers.value = []
|
mentionUsers.value = []
|
||||||
closeAtSuggest()
|
closeAtSuggest()
|
||||||
showToast('已发送')
|
if (!opts.quiet) showToast('已发送')
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
|
return true
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showToast(e?.message || '发送失败')
|
showToast(e?.message || '发送失败')
|
||||||
|
return false
|
||||||
} finally {
|
} finally {
|
||||||
sending.value = false
|
sending.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onSend() {
|
||||||
|
if (!draftPending()) {
|
||||||
|
showToast('请填写评论、@人员或添加附件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await flushDraft()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ flushDraft, draftPending })
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void ensureUserCache()
|
void ensureUserCache()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -52,6 +52,24 @@
|
|||||||
<div class="oa-sheet-row__title">{{ a.label }}</div>
|
<div class="oa-sheet-row__title">{{ a.label }}</div>
|
||||||
<div v-if="a.sub" class="oa-sheet-row__meta">{{ a.sub }}</div>
|
<div v-if="a.sub" class="oa-sheet-row__meta">{{ a.sub }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="oa-sheet-row__actions" @click.stop>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oa-sheet-row__icon is-edit"
|
||||||
|
aria-label="编辑"
|
||||||
|
@click="openEdit(a.id)"
|
||||||
|
>
|
||||||
|
<van-icon name="edit" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oa-sheet-row__icon is-delete"
|
||||||
|
aria-label="删除"
|
||||||
|
@click="confirmDelete(a.id)"
|
||||||
|
>
|
||||||
|
<van-icon name="delete-o" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</van-checkbox-group>
|
</van-checkbox-group>
|
||||||
<van-empty v-if="!loading && !filtered.length" description="暂无本人的收款账户" />
|
<van-empty v-if="!loading && !filtered.length" description="暂无本人的收款账户" />
|
||||||
@@ -63,17 +81,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</van-popup>
|
</van-popup>
|
||||||
|
|
||||||
<van-popup v-model:show="createVisible" position="bottom" round>
|
<van-popup v-model:show="formVisible" position="bottom" round>
|
||||||
<div class="oa-recv__sheet oa-recv__sheet--create">
|
<div class="oa-recv__sheet oa-recv__sheet--create">
|
||||||
<div class="oa-recv__hd">
|
<div class="oa-recv__hd">
|
||||||
<span @click="createVisible = false">取消</span>
|
<span @click="formVisible = false">取消</span>
|
||||||
<strong>新增收款账户</strong>
|
<strong>{{ formTitle }}</strong>
|
||||||
<span
|
<span
|
||||||
class="oa-recv__ok"
|
class="oa-recv__ok"
|
||||||
:class="{ 'is-busy': createLoading }"
|
:class="{ 'is-busy': formLoading }"
|
||||||
@click="submitCreate"
|
@click="submitForm"
|
||||||
>
|
>
|
||||||
{{ createLoading ? '提交中' : '确定' }}
|
{{ formLoading ? '提交中' : '确定' }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="oa-recv__form">
|
<div class="oa-recv__form">
|
||||||
@@ -87,45 +105,45 @@
|
|||||||
<label class="oa-recv-field">
|
<label class="oa-recv-field">
|
||||||
<span class="oa-recv-field__label">户名<b>*</b></span>
|
<span class="oa-recv-field__label">户名<b>*</b></span>
|
||||||
<span class="oa-recv-field__box">
|
<span class="oa-recv-field__box">
|
||||||
<input v-model="createForm.accountName" maxlength="128" placeholder="请输入户名" />
|
<input v-model="formModel.accountName" maxlength="128" placeholder="请输入户名" />
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="oa-recv-field">
|
<label class="oa-recv-field">
|
||||||
<span class="oa-recv-field__label">账号<b>*</b></span>
|
<span class="oa-recv-field__label">账号<b>*</b></span>
|
||||||
<span class="oa-recv-field__box">
|
<span class="oa-recv-field__box">
|
||||||
<input v-model="createForm.accountNo" maxlength="128" placeholder="请输入账号" />
|
<input v-model="formModel.accountNo" maxlength="128" placeholder="请输入账号" />
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<template v-if="createForm.accountType !== 'alipay'">
|
<template v-if="formModel.accountType !== 'alipay'">
|
||||||
<label class="oa-recv-field">
|
<label class="oa-recv-field">
|
||||||
<span class="oa-recv-field__label">银行<b>*</b></span>
|
<span class="oa-recv-field__label">银行<b>*</b></span>
|
||||||
<span class="oa-recv-field__box">
|
<span class="oa-recv-field__box">
|
||||||
<input v-model="createForm.bankName" maxlength="128" placeholder="如:中国工商银行" />
|
<input v-model="formModel.bankName" maxlength="128" placeholder="如:中国工商银行" />
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="oa-recv-field">
|
<label class="oa-recv-field">
|
||||||
<span class="oa-recv-field__label">银行所在省<b>*</b></span>
|
<span class="oa-recv-field__label">银行所在省<b>*</b></span>
|
||||||
<span class="oa-recv-field__box">
|
<span class="oa-recv-field__box">
|
||||||
<input v-model="createForm.bankProvince" maxlength="64" placeholder="如:安徽省" />
|
<input v-model="formModel.bankProvince" maxlength="64" placeholder="如:安徽省" />
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="oa-recv-field">
|
<label class="oa-recv-field">
|
||||||
<span class="oa-recv-field__label">银行所在市<b>*</b></span>
|
<span class="oa-recv-field__label">银行所在市<b>*</b></span>
|
||||||
<span class="oa-recv-field__box">
|
<span class="oa-recv-field__box">
|
||||||
<input v-model="createForm.bankCity" maxlength="64" placeholder="如:合肥市" />
|
<input v-model="formModel.bankCity" maxlength="64" placeholder="如:合肥市" />
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="oa-recv-field">
|
<label class="oa-recv-field">
|
||||||
<span class="oa-recv-field__label">银行支行<b>*</b></span>
|
<span class="oa-recv-field__label">银行支行<b>*</b></span>
|
||||||
<span class="oa-recv-field__box">
|
<span class="oa-recv-field__box">
|
||||||
<input v-model="createForm.bankBranch" maxlength="256" placeholder="请输入开户支行全称" />
|
<input v-model="formModel.bankBranch" maxlength="256" placeholder="请输入开户支行全称" />
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</template>
|
</template>
|
||||||
<label class="oa-recv-field">
|
<label class="oa-recv-field">
|
||||||
<span class="oa-recv-field__label">备注</span>
|
<span class="oa-recv-field__label">备注</span>
|
||||||
<span class="oa-recv-field__box oa-recv-field__box--area">
|
<span class="oa-recv-field__box oa-recv-field__box--area">
|
||||||
<textarea v-model="createForm.remark" maxlength="512" rows="2" placeholder="选填" />
|
<textarea v-model="formModel.remark" maxlength="512" rows="2" placeholder="选填" />
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -135,7 +153,7 @@
|
|||||||
<van-popup v-model:show="typePickerVisible" position="bottom" round>
|
<van-popup v-model:show="typePickerVisible" position="bottom" round>
|
||||||
<van-picker
|
<van-picker
|
||||||
:columns="accountTypeColumns"
|
:columns="accountTypeColumns"
|
||||||
:model-value="[createForm.accountType]"
|
:model-value="[formModel.accountType]"
|
||||||
@confirm="onTypeConfirm"
|
@confirm="onTypeConfirm"
|
||||||
@cancel="typePickerVisible = false"
|
@cancel="typePickerVisible = false"
|
||||||
/>
|
/>
|
||||||
@@ -145,8 +163,13 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { showToast } from 'vant'
|
import { showConfirmDialog, showToast } from 'vant'
|
||||||
import { fetchCreateReceiveAccount, fetchReceiveAccountOptions } from '../../api/oa.js'
|
import {
|
||||||
|
fetchCreateReceiveAccount,
|
||||||
|
fetchDeleteReceiveAccount,
|
||||||
|
fetchReceiveAccountOptions,
|
||||||
|
fetchUpdateReceiveAccount
|
||||||
|
} from '../../api/oa.js'
|
||||||
import {
|
import {
|
||||||
ACCOUNT_TYPE_LABEL,
|
ACCOUNT_TYPE_LABEL,
|
||||||
formatReceiveAccountLine,
|
formatReceiveAccountLine,
|
||||||
@@ -170,17 +193,19 @@ const keyword = ref('')
|
|||||||
const pendingIds = ref([])
|
const pendingIds = ref([])
|
||||||
const snapshotMap = ref(new Map())
|
const snapshotMap = ref(new Map())
|
||||||
const accountOptions = ref([])
|
const accountOptions = ref([])
|
||||||
const createVisible = ref(false)
|
const formVisible = ref(false)
|
||||||
const createLoading = ref(false)
|
const formLoading = ref(false)
|
||||||
|
const formMode = ref('create')
|
||||||
|
const editingId = ref('')
|
||||||
const typePickerVisible = ref(false)
|
const typePickerVisible = ref(false)
|
||||||
const accountTypeColumns = [
|
const accountTypeColumns = [
|
||||||
{ text: '支付宝', value: 'alipay' },
|
{ text: '支付宝', value: 'alipay' },
|
||||||
{ text: '个人银行卡', value: 'personal' },
|
{ text: '个人银行卡', value: 'personal' },
|
||||||
{ text: '对公银行账户', value: 'corporate' }
|
{ text: '对公银行账户', value: 'corporate' }
|
||||||
]
|
]
|
||||||
const createForm = ref(emptyCreateForm())
|
const formModel = ref(emptyForm())
|
||||||
|
|
||||||
function emptyCreateForm() {
|
function emptyForm() {
|
||||||
return {
|
return {
|
||||||
accountType: 'alipay',
|
accountType: 'alipay',
|
||||||
accountName: '',
|
accountName: '',
|
||||||
@@ -193,8 +218,12 @@ function emptyCreateForm() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formTitle = computed(() =>
|
||||||
|
formMode.value === 'edit' ? '编辑收款账户' : '新增收款账户'
|
||||||
|
)
|
||||||
|
|
||||||
const accountTypeLabel = computed(
|
const accountTypeLabel = computed(
|
||||||
() => ACCOUNT_TYPE_LABEL[createForm.value.accountType] || ''
|
() => ACCOUNT_TYPE_LABEL[formModel.value.accountType] || ''
|
||||||
)
|
)
|
||||||
|
|
||||||
const normalized = computed(() => normalizeReceiveAccountModelValue(props.modelValue))
|
const normalized = computed(() => normalizeReceiveAccountModelValue(props.modelValue))
|
||||||
@@ -260,26 +289,78 @@ function optionFromSnap(snap) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function upsertLocalSnap(snap) {
|
||||||
|
if (!snap.id) return
|
||||||
|
const map = new Map(snapshotMap.value)
|
||||||
|
map.set(snap.id, snap)
|
||||||
|
snapshotMap.value = map
|
||||||
|
const opt = optionFromSnap(snap)
|
||||||
|
const idx = accountOptions.value.findIndex((x) => x.id === snap.id)
|
||||||
|
if (idx >= 0) {
|
||||||
|
const next = [...accountOptions.value]
|
||||||
|
next[idx] = opt
|
||||||
|
accountOptions.value = next
|
||||||
|
} else {
|
||||||
|
accountOptions.value = [...accountOptions.value, opt]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillFormFromSnap(snap) {
|
||||||
|
const form = {
|
||||||
|
accountType: snap.accountType || 'alipay',
|
||||||
|
accountName: snap.accountName || '',
|
||||||
|
accountNo: snap.accountNo || '',
|
||||||
|
bankName: snap.bankName || '',
|
||||||
|
bankProvince: snap.bankProvince || '',
|
||||||
|
bankCity: snap.bankCity || '',
|
||||||
|
bankBranch: snap.bankBranch || '',
|
||||||
|
remark: snap.remark || ''
|
||||||
|
}
|
||||||
|
if (form.accountType === 'alipay') {
|
||||||
|
form.bankName = ''
|
||||||
|
form.bankProvince = ''
|
||||||
|
form.bankCity = ''
|
||||||
|
form.bankBranch = ''
|
||||||
|
}
|
||||||
|
formModel.value = form
|
||||||
|
}
|
||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
createForm.value = emptyCreateForm()
|
formMode.value = 'create'
|
||||||
|
editingId.value = ''
|
||||||
|
formModel.value = emptyForm()
|
||||||
typePickerVisible.value = false
|
typePickerVisible.value = false
|
||||||
createVisible.value = true
|
formVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEdit(id) {
|
||||||
|
const tid = String(id || '').trim()
|
||||||
|
const snap = snapshotMap.value.get(tid)
|
||||||
|
if (!snap) {
|
||||||
|
showToast('账户不存在或已删除')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formMode.value = 'edit'
|
||||||
|
editingId.value = tid
|
||||||
|
fillFormFromSnap(snap)
|
||||||
|
typePickerVisible.value = false
|
||||||
|
formVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTypeConfirm({ selectedOptions }) {
|
function onTypeConfirm({ selectedOptions }) {
|
||||||
const next = selectedOptions?.[0]?.value || 'alipay'
|
const next = selectedOptions?.[0]?.value || 'alipay'
|
||||||
const form = { ...createForm.value, accountType: next }
|
const form = { ...formModel.value, accountType: next }
|
||||||
if (next === 'alipay') {
|
if (next === 'alipay') {
|
||||||
form.bankName = ''
|
form.bankName = ''
|
||||||
form.bankProvince = ''
|
form.bankProvince = ''
|
||||||
form.bankCity = ''
|
form.bankCity = ''
|
||||||
form.bankBranch = ''
|
form.bankBranch = ''
|
||||||
}
|
}
|
||||||
createForm.value = form
|
formModel.value = form
|
||||||
typePickerVisible.value = false
|
typePickerVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateCreate(form) {
|
function validateForm(form) {
|
||||||
if (!form.accountName.trim()) return '请输入户名'
|
if (!form.accountName.trim()) return '请输入户名'
|
||||||
if (!form.accountNo.trim()) return '请输入账号'
|
if (!form.accountNo.trim()) return '请输入账号'
|
||||||
if (form.accountType !== 'alipay') {
|
if (form.accountType !== 'alipay') {
|
||||||
@@ -291,14 +372,7 @@ function validateCreate(form) {
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitCreate() {
|
function buildPayload(form) {
|
||||||
if (createLoading.value) return
|
|
||||||
const form = createForm.value
|
|
||||||
const invalid = validateCreate(form)
|
|
||||||
if (invalid) {
|
|
||||||
showToast(invalid)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const payload = {
|
const payload = {
|
||||||
accountType: form.accountType,
|
accountType: form.accountType,
|
||||||
accountName: form.accountName.trim(),
|
accountName: form.accountName.trim(),
|
||||||
@@ -316,36 +390,80 @@ async function submitCreate() {
|
|||||||
payload.bankCity = form.bankCity.trim()
|
payload.bankCity = form.bankCity.trim()
|
||||||
payload.bankBranch = form.bankBranch.trim()
|
payload.bankBranch = form.bankBranch.trim()
|
||||||
}
|
}
|
||||||
createLoading.value = true
|
return payload
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
if (formLoading.value) return
|
||||||
|
const form = formModel.value
|
||||||
|
const invalid = validateForm(form)
|
||||||
|
if (invalid) {
|
||||||
|
showToast(invalid)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const payload = buildPayload(form)
|
||||||
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const created = await fetchCreateReceiveAccount(payload)
|
const row =
|
||||||
const snap = snapshotFromRow(created)
|
formMode.value === 'edit' && editingId.value
|
||||||
|
? await fetchUpdateReceiveAccount(editingId.value, payload)
|
||||||
|
: await fetchCreateReceiveAccount(payload)
|
||||||
|
const snap = snapshotFromRow(row)
|
||||||
if (!snap.id) {
|
if (!snap.id) {
|
||||||
showToast('创建成功但未返回账户 ID')
|
showToast(formMode.value === 'edit' ? '更新成功但未返回账户 ID' : '创建成功但未返回账户 ID')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await loadOptions()
|
await loadOptions()
|
||||||
if (!snapshotMap.value.has(snap.id)) {
|
upsertLocalSnap(snap)
|
||||||
const map = new Map(snapshotMap.value)
|
if (formMode.value === 'edit') {
|
||||||
map.set(snap.id, snap)
|
const selected = normalized.value.map((x) => x.id)
|
||||||
snapshotMap.value = map
|
if (selected.includes(snap.id)) {
|
||||||
if (!accountOptions.value.some((x) => x.id === snap.id)) {
|
emitItems(selected.map((id) => snapshotMap.value.get(id)).filter(Boolean))
|
||||||
accountOptions.value = [...accountOptions.value, optionFromSnap(snap)]
|
|
||||||
}
|
}
|
||||||
|
showToast('更新成功')
|
||||||
|
} else {
|
||||||
|
const selected = new Set(normalized.value.map((x) => x.id))
|
||||||
|
selected.add(snap.id)
|
||||||
|
emitItems([...selected].map((id) => snapshotMap.value.get(id)).filter(Boolean))
|
||||||
|
if (!pendingIds.value.includes(snap.id)) {
|
||||||
|
pendingIds.value = [...pendingIds.value, snap.id]
|
||||||
|
}
|
||||||
|
keyword.value = ''
|
||||||
|
showToast('创建成功')
|
||||||
}
|
}
|
||||||
const selected = new Set(normalized.value.map((x) => x.id))
|
formVisible.value = false
|
||||||
selected.add(snap.id)
|
|
||||||
emitItems([...selected].map((id) => snapshotMap.value.get(id)).filter(Boolean))
|
|
||||||
if (!pendingIds.value.includes(snap.id)) {
|
|
||||||
pendingIds.value = [...pendingIds.value, snap.id]
|
|
||||||
}
|
|
||||||
keyword.value = ''
|
|
||||||
createVisible.value = false
|
|
||||||
showToast('创建成功')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showToast(e?.message || '新增收款账户失败')
|
showToast(e?.message || (formMode.value === 'edit' ? '编辑收款账户失败' : '新增收款账户失败'))
|
||||||
} finally {
|
} finally {
|
||||||
createLoading.value = false
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmDelete(id) {
|
||||||
|
const tid = String(id || '').trim()
|
||||||
|
const snap = snapshotMap.value.get(tid)
|
||||||
|
const name = snap?.accountName || tid
|
||||||
|
try {
|
||||||
|
await showConfirmDialog({
|
||||||
|
title: '删除收款账户',
|
||||||
|
message: `确定删除收款账户「${name}」吗?删除后不可再选;已提交单据中的账户快照仍保留。`
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await fetchDeleteReceiveAccount(tid)
|
||||||
|
await loadOptions()
|
||||||
|
const nextSelected = normalized.value
|
||||||
|
.map((x) => x.id)
|
||||||
|
.filter((x) => x !== tid)
|
||||||
|
.map((x) => snapshotMap.value.get(x))
|
||||||
|
.filter(Boolean)
|
||||||
|
emitItems(nextSelected)
|
||||||
|
pendingIds.value = pendingIds.value.filter((x) => x !== tid)
|
||||||
|
showToast('删除成功')
|
||||||
|
} catch (e) {
|
||||||
|
showToast(e?.message || '删除收款账户失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,6 +529,39 @@ onMounted(() => {
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.oa-sheet-row__actions {
|
||||||
|
display: inline-flex;
|
||||||
|
flex: none;
|
||||||
|
gap: 6px;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-sheet-row__icon {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
font-size: 18px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-sheet-row__icon.is-edit {
|
||||||
|
background: #ecfdf5;
|
||||||
|
color: var(--brand-green-dark, #16a34a);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-sheet-row__icon.is-delete {
|
||||||
|
background: #fef2f2;
|
||||||
|
color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
.oa-recv__add {
|
.oa-recv__add {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/** 评论区是否有未发送草稿(文字 / @ / 附件) */
|
||||||
|
export function hasOaCommentDraft(input = {}) {
|
||||||
|
const content = String(input.content || '').trim()
|
||||||
|
const mentionCount = Number(input.mentionCount || 0)
|
||||||
|
const attachmentCount = Number(input.attachmentCount || 0)
|
||||||
|
return !!(content || mentionCount > 0 || attachmentCount > 0)
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import test from 'node:test'
|
||||||
|
import { hasOaCommentDraft } from './oa-comment-draft.js'
|
||||||
|
|
||||||
|
test('empty draft is false', () => {
|
||||||
|
assert.equal(hasOaCommentDraft({}), false)
|
||||||
|
assert.equal(hasOaCommentDraft({ content: ' ', mentionCount: 0, attachmentCount: 0 }), false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('text / mention / attachment counts as draft', () => {
|
||||||
|
assert.equal(hasOaCommentDraft({ content: '@test' }), true)
|
||||||
|
assert.equal(hasOaCommentDraft({ mentionCount: 1 }), true)
|
||||||
|
assert.equal(hasOaCommentDraft({ attachmentCount: 2 }), true)
|
||||||
|
})
|
||||||
@@ -631,6 +631,29 @@ body.van-toast--unclickable .presign-order-page * {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.market-list-card__value {
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.market-list-card__help {
|
||||||
|
display: inline-flex;
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
flex: 0 0 44px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin: -10px -8px -10px -4px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--market-primary-dark, #087f57);
|
||||||
|
font-size: 18px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.market-list-card__samples {
|
.market-list-card__samples {
|
||||||
margin: 0 0 12px;
|
margin: 0 0 12px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
@refresh="reloadDetail"
|
@refresh="reloadDetail"
|
||||||
/>
|
/>
|
||||||
<OaCommentComposer
|
<OaCommentComposer
|
||||||
|
ref="commentComposerRef"
|
||||||
:instance-id="instanceId"
|
:instance-id="instanceId"
|
||||||
:instance-status="detail?.status || ''"
|
:instance-status="detail?.status || ''"
|
||||||
@refresh="reloadDetail"
|
@refresh="reloadDetail"
|
||||||
@@ -238,6 +239,7 @@ const currentUserId = ref('')
|
|||||||
const currentUserName = ref('')
|
const currentUserName = ref('')
|
||||||
const autoPrinted = ref(false)
|
const autoPrinted = ref(false)
|
||||||
|
|
||||||
|
const commentComposerRef = ref(null)
|
||||||
const commentVisible = ref(false)
|
const commentVisible = ref(false)
|
||||||
const commentKind = ref('approve') // approve | reject | return
|
const commentKind = ref('approve') // approve | reject | return
|
||||||
const commentText = ref('')
|
const commentText = ref('')
|
||||||
@@ -492,8 +494,16 @@ function goCopyRestart() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function openComment(kind) {
|
/** 同意/拒绝/打回前先发送评论区未提交草稿 */
|
||||||
|
async function flushPendingComment() {
|
||||||
|
const flush = commentComposerRef.value?.flushDraft
|
||||||
|
if (!flush) return true
|
||||||
|
return await flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openComment(kind) {
|
||||||
if (!myPendingTask.value) return
|
if (!myPendingTask.value) return
|
||||||
|
if (!(await flushPendingComment())) return
|
||||||
commentKind.value = kind
|
commentKind.value = kind
|
||||||
commentText.value = defaultComment(kind)
|
commentText.value = defaultComment(kind)
|
||||||
commentVisible.value = true
|
commentVisible.value = true
|
||||||
|
|||||||
@@ -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
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import request from '@/utils/http'
|
||||||
|
|
||||||
|
export type SampleVoidTarget = {
|
||||||
|
receptionSource: 'cell_storage' | 'research_donation'
|
||||||
|
sampleId?: string
|
||||||
|
sampleCode?: string
|
||||||
|
/** 仅弹窗展示,不参与作废请求 */
|
||||||
|
labStorageCode?: string
|
||||||
|
protocolId?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type VoidBusinessSamplePayload = SampleVoidTarget & {
|
||||||
|
voidDesc: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type VoidBusinessSampleResult = {
|
||||||
|
id: string
|
||||||
|
sampleCode: string
|
||||||
|
sampleStatus: string
|
||||||
|
voidDate: string
|
||||||
|
voidDesc: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchVoidBusinessSample(data: VoidBusinessSamplePayload) {
|
||||||
|
return request.put<VoidBusinessSampleResult>({
|
||||||
|
url: '/web/admin/business-samples/void',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -17,6 +17,10 @@ export interface ProductionWorkOrderItem {
|
|||||||
workOrderType?: string
|
workOrderType?: string
|
||||||
protocolNo?: string
|
protocolNo?: string
|
||||||
sampleCode?: string
|
sampleCode?: string
|
||||||
|
sampleStatus?: string
|
||||||
|
voidDesc?: string
|
||||||
|
protocolSampleId?: string
|
||||||
|
collectionProtocolId?: string
|
||||||
receptionSource?: string
|
receptionSource?: string
|
||||||
receptionSourceLabel?: string
|
receptionSourceLabel?: string
|
||||||
sampleTypeName?: string
|
sampleTypeName?: string
|
||||||
@@ -52,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(',') }
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -100,6 +100,8 @@ export type QcWorkOrder = {
|
|||||||
collectionProtocolId: string
|
collectionProtocolId: string
|
||||||
protocolNo: string
|
protocolNo: string
|
||||||
sampleCode: string
|
sampleCode: string
|
||||||
|
sampleStatus?: string
|
||||||
|
voidDesc?: string
|
||||||
labStorageCode?: string
|
labStorageCode?: string
|
||||||
receptionSource?: string
|
receptionSource?: string
|
||||||
receptionSourceLabel?: string
|
receptionSourceLabel?: string
|
||||||
@@ -141,6 +143,8 @@ export type QcWorkOrder = {
|
|||||||
patientName?: string
|
patientName?: string
|
||||||
/** 入库工单(细胞存储/科研捐赠):母亲姓名 */
|
/** 入库工单(细胞存储/科研捐赠):母亲姓名 */
|
||||||
motherName?: string
|
motherName?: string
|
||||||
|
/** 协议单母血采集时间;未录入时为空,前端展示为 — */
|
||||||
|
maternalBloodCollectTime?: string
|
||||||
/** 入库工单(细胞存储/科研捐赠):新生儿姓名 */
|
/** 入库工单(细胞存储/科研捐赠):新生儿姓名 */
|
||||||
newbornName?: string
|
newbornName?: string
|
||||||
/** 出库工单:当前为第几次输注计划 */
|
/** 出库工单:当前为第几次输注计划 */
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ export type SampleFreightItem = {
|
|||||||
sampleId: string
|
sampleId: string
|
||||||
protocolId?: string
|
protocolId?: string
|
||||||
sampleCode?: string
|
sampleCode?: string
|
||||||
|
sampleStatus?: string
|
||||||
|
voidDesc?: string
|
||||||
protocolNo?: string
|
protocolNo?: string
|
||||||
sampleTypeName?: string
|
sampleTypeName?: string
|
||||||
motherName?: string
|
motherName?: string
|
||||||
|
|||||||
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;
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<!-- 样本状态:标签;仅已作废时展示问号与作废原因 -->
|
||||||
|
<template>
|
||||||
|
<span class="sample-status-tag">
|
||||||
|
<el-tag :type="tagType" size="small">{{ label }}</el-tag>
|
||||||
|
<el-popover v-if="voided" placement="top" trigger="click" :width="240">
|
||||||
|
<template #reference>
|
||||||
|
<button type="button" class="sample-status-tag__q" aria-label="作废原因" @click.stop>
|
||||||
|
<el-icon><QuestionFilled /></el-icon>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
<div class="sample-status-tag__reason">
|
||||||
|
<div class="sample-status-tag__reason-title">作废原因</div>
|
||||||
|
<div>{{ reasonText }}</div>
|
||||||
|
</div>
|
||||||
|
</el-popover>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { QuestionFilled } from '@element-plus/icons-vue'
|
||||||
|
import { sampleStatusLabel, sampleStatusTagType } from '@/utils/status-tag-registry'
|
||||||
|
|
||||||
|
defineOptions({ name: 'SampleStatusTag' })
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
status?: string | null
|
||||||
|
voidDesc?: string | null
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const code = computed(() => String(props.status || '').trim())
|
||||||
|
const label = computed(() => (code.value ? sampleStatusLabel(code.value) : '—'))
|
||||||
|
const tagType = computed(() => (code.value ? sampleStatusTagType(code.value) : 'info'))
|
||||||
|
/** 问号仅已作废(yzf)展示 */
|
||||||
|
const voided = computed(() => code.value === 'yzf')
|
||||||
|
const reasonText = computed(() => String(props.voidDesc || '').trim() || '暂无作废原因')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.sample-status-tag {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 4px;
|
||||||
|
max-width: 100%;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sample-status-tag__q {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--mint-text-muted, #64748b);
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 1;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #059669;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sample-status-tag__reason-title {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--mint-text-muted, #64748b);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
<!-- 样本废弃:填写作废原因后提交 -->
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-model="dialogVisible"
|
||||||
|
title="样本废弃"
|
||||||
|
width="560px"
|
||||||
|
class="dialog-form-layout"
|
||||||
|
align-center
|
||||||
|
append-to-body
|
||||||
|
modal-class="protocol-dialog-mask"
|
||||||
|
destroy-on-close
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
@close="handleClose"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
label-position="top"
|
||||||
|
class="biz-dialog-form"
|
||||||
|
>
|
||||||
|
<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">
|
||||||
|
<span class="sample-void-dialog__code">{{ sampleCode }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="作废原因" prop="voidDesc" class="form-col-span-2">
|
||||||
|
<el-input
|
||||||
|
v-model="form.voidDesc"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
maxlength="512"
|
||||||
|
show-word-limit
|
||||||
|
placeholder="请填写作废原因"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button class="btn-ghost" @click="handleClose">
|
||||||
|
<el-icon><Close /></el-icon>取消
|
||||||
|
</el-button>
|
||||||
|
<el-button class="btn-main" type="primary" :loading="submitting" @click="handleSubmit">
|
||||||
|
<el-icon><Check /></el-icon>确定
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
|
import { Check, Close } from '@element-plus/icons-vue'
|
||||||
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||||
|
import { fetchVoidBusinessSample, type SampleVoidTarget } from '@/api/business-sample'
|
||||||
|
|
||||||
|
defineOptions({ name: 'SampleVoidDialog' })
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
visible: boolean
|
||||||
|
target: SampleVoidTarget | null
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:visible': [visible: boolean]
|
||||||
|
success: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const submitting = ref(false)
|
||||||
|
const formRef = ref<FormInstance>()
|
||||||
|
const form = reactive({
|
||||||
|
voidDesc: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const rules: FormRules = {
|
||||||
|
voidDesc: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
validator: (_rule, value, callback) => {
|
||||||
|
if (!String(value || '').trim()) callback(new Error('请填写作废原因'))
|
||||||
|
else callback()
|
||||||
|
},
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const labStorageCodeDisplay = computed(
|
||||||
|
() => String(props.target?.labStorageCode || '').trim() || '—'
|
||||||
|
)
|
||||||
|
const sampleCode = computed(() => String(props.target?.sampleCode || '').trim())
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.visible,
|
||||||
|
(visible) => {
|
||||||
|
dialogVisible.value = visible
|
||||||
|
if (visible) form.voidDesc = ''
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(dialogVisible, (visible) => {
|
||||||
|
emit('update:visible', visible)
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
dialogVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
const target = props.target
|
||||||
|
if (!target?.receptionSource || (!target.sampleId && !target.sampleCode)) {
|
||||||
|
ElMessage.warning('缺少样本信息,无法废弃')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const valid = await formRef.value?.validate().catch(() => false)
|
||||||
|
if (!valid) return
|
||||||
|
submitting.value = true
|
||||||
|
try {
|
||||||
|
await fetchVoidBusinessSample({
|
||||||
|
receptionSource: target.receptionSource,
|
||||||
|
sampleId: target.sampleId,
|
||||||
|
sampleCode: target.sampleCode,
|
||||||
|
protocolId: target.protocolId,
|
||||||
|
voidDesc: form.voidDesc.trim()
|
||||||
|
})
|
||||||
|
ElMessage.success('样本已废弃')
|
||||||
|
emit('success')
|
||||||
|
handleClose()
|
||||||
|
} finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.sample-void-dialog__code {
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1e293b;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -192,6 +192,7 @@
|
|||||||
} from '@/api/oaApproval'
|
} from '@/api/oaApproval'
|
||||||
import OaCommentFileCards from '@/components/oa-approval/OaCommentFileCards.vue'
|
import OaCommentFileCards from '@/components/oa-approval/OaCommentFileCards.vue'
|
||||||
import { attachmentFullUrl } from '@/composables/useAttachmentActions'
|
import { attachmentFullUrl } from '@/composables/useAttachmentActions'
|
||||||
|
import { hasOaCommentDraft } from '@/utils/oa-comment-draft'
|
||||||
import { isOaUploadImageFile, isOaUploadVideoFile } from '@/utils/oa-upload-file-type'
|
import { isOaUploadImageFile, isOaUploadVideoFile } from '@/utils/oa-upload-file-type'
|
||||||
|
|
||||||
defineOptions({ name: 'OaCommentPanel' })
|
defineOptions({ name: 'OaCommentPanel' })
|
||||||
@@ -254,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>()
|
||||||
@@ -546,12 +548,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSend() {
|
function draftPending() {
|
||||||
const content = draft.value.trim()
|
return hasOaCommentDraft({
|
||||||
if (!content && !mentionUsers.value.length && !picked.value.length) {
|
content: draft.value,
|
||||||
ElMessage.warning('请填写评论、@人员或添加附件')
|
mentionCount: mentionUsers.value.length,
|
||||||
return
|
attachmentCount: picked.value.length
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批动作前冲刷未发送草稿:无草稿直接成功;有草稿则等同点击「发送」。
|
||||||
|
* @returns false 表示发送失败或忙碌,调用方应中止审批动作
|
||||||
|
*/
|
||||||
|
async function flushDraft(opts?: { quiet?: boolean }): Promise<boolean> {
|
||||||
|
if (!draftPending()) return true
|
||||||
|
if (sending.value || uploading.value) {
|
||||||
|
ElMessage.warning(uploading.value ? '附件上传中,请稍后再试' : '评论发送中,请稍后再试')
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
const content = draft.value.trim()
|
||||||
sending.value = true
|
sending.value = true
|
||||||
try {
|
try {
|
||||||
await fetchCreateOaComment(props.instanceId, {
|
await fetchCreateOaComment(props.instanceId, {
|
||||||
@@ -565,15 +580,27 @@
|
|||||||
picked.value = []
|
picked.value = []
|
||||||
mentionUsers.value = []
|
mentionUsers.value = []
|
||||||
closeAtSuggest()
|
closeAtSuggest()
|
||||||
ElMessage.success('已发送')
|
if (!opts?.quiet) ElMessage.success('已发送')
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
|
return true
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.message || '发送失败')
|
ElMessage.error(e?.message || '发送失败')
|
||||||
|
return false
|
||||||
} finally {
|
} finally {
|
||||||
sending.value = false
|
sending.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onSend() {
|
||||||
|
if (!draftPending()) {
|
||||||
|
ElMessage.warning('请填写评论、@人员或添加附件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await flushDraft()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ flushDraft, draftPending })
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void ensureUserCache()
|
void ensureUserCache()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -40,17 +40,39 @@
|
|||||||
class="oa-receive-account-select__search"
|
class="oa-receive-account-select__search"
|
||||||
/>
|
/>
|
||||||
<div class="oa-receive-account-select__list">
|
<div class="oa-receive-account-select__list">
|
||||||
<label
|
<div
|
||||||
v-for="a in filteredOptions"
|
v-for="a in filteredOptions"
|
||||||
:key="a.id"
|
:key="a.id"
|
||||||
class="oa-receive-account-select__row"
|
class="oa-receive-account-select__row"
|
||||||
>
|
>
|
||||||
<el-checkbox
|
<label class="oa-receive-account-select__row-main">
|
||||||
:model-value="pendingIds.includes(a.id)"
|
<el-checkbox
|
||||||
@change="(v: boolean | string | number) => onNarrowCheck(a.id, !!v)"
|
:model-value="pendingIds.includes(a.id)"
|
||||||
/>
|
@change="(v: boolean | string | number) => onNarrowCheck(a.id, !!v)"
|
||||||
<span class="oa-receive-account-select__row-label">{{ a.label }}</span>
|
/>
|
||||||
</label>
|
<span class="oa-receive-account-select__row-label">{{ a.label }}</span>
|
||||||
|
</label>
|
||||||
|
<div class="oa-receive-account-select__row-actions">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oa-receive-account-select__icon-btn is-edit"
|
||||||
|
title="编辑"
|
||||||
|
aria-label="编辑"
|
||||||
|
@click="openEditDialog(a.id)"
|
||||||
|
>
|
||||||
|
<el-icon><Edit /></el-icon>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oa-receive-account-select__icon-btn is-delete"
|
||||||
|
title="删除"
|
||||||
|
aria-label="删除"
|
||||||
|
@click="confirmDelete(a.id)"
|
||||||
|
>
|
||||||
|
<el-icon><Delete /></el-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div v-if="!filteredOptions.length" class="oa-receive-account-select__empty">
|
<div v-if="!filteredOptions.length" class="oa-receive-account-select__empty">
|
||||||
暂无本人的收款账户
|
暂无本人的收款账户
|
||||||
</div>
|
</div>
|
||||||
@@ -92,7 +114,31 @@
|
|||||||
:key="a.id"
|
:key="a.id"
|
||||||
:label="a.label"
|
:label="a.label"
|
||||||
:value="a.id"
|
:value="a.id"
|
||||||
/>
|
>
|
||||||
|
<div class="oa-receive-account-select__option">
|
||||||
|
<span class="oa-receive-account-select__option-label">{{ a.label }}</span>
|
||||||
|
<span class="oa-receive-account-select__option-actions" @mousedown.prevent @click.stop>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oa-receive-account-select__icon-btn is-edit"
|
||||||
|
title="编辑"
|
||||||
|
aria-label="编辑"
|
||||||
|
@click="openEditDialog(a.id)"
|
||||||
|
>
|
||||||
|
<el-icon><Edit /></el-icon>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="oa-receive-account-select__icon-btn is-delete"
|
||||||
|
title="删除"
|
||||||
|
aria-label="删除"
|
||||||
|
@click="confirmDelete(a.id)"
|
||||||
|
>
|
||||||
|
<el-icon><Delete /></el-icon>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</el-option>
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<div class="oa-receive-account-select__empty">
|
<div class="oa-receive-account-select__empty">
|
||||||
{{ accountOptions.length === 0 ? '暂无本人的收款账户' : '无匹配数据' }}
|
{{ accountOptions.length === 0 ? '暂无本人的收款账户' : '无匹配数据' }}
|
||||||
@@ -120,8 +166,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="createVisible"
|
v-model="formVisible"
|
||||||
title="新增收款账户"
|
:title="formTitle"
|
||||||
width="720px"
|
width="720px"
|
||||||
class="dialog-form-layout"
|
class="dialog-form-layout"
|
||||||
align-center
|
align-center
|
||||||
@@ -131,9 +177,9 @@
|
|||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
>
|
>
|
||||||
<el-form
|
<el-form
|
||||||
ref="createFormRef"
|
ref="formRef"
|
||||||
:model="createForm"
|
:model="formModel"
|
||||||
:rules="createRules"
|
:rules="formRules"
|
||||||
label-position="top"
|
label-position="top"
|
||||||
scroll-to-error
|
scroll-to-error
|
||||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||||
@@ -141,9 +187,9 @@
|
|||||||
<div class="form-grid-2">
|
<div class="form-grid-2">
|
||||||
<el-form-item label="账户类型" prop="accountType" class="form-col-span-2">
|
<el-form-item label="账户类型" prop="accountType" class="form-col-span-2">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="createForm.accountType"
|
v-model="formModel.accountType"
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
@change="onCreateTypeChange"
|
@change="onFormTypeChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(label, value) in ACCOUNT_TYPE_LABEL"
|
v-for="(label, value) in ACCOUNT_TYPE_LABEL"
|
||||||
@@ -154,22 +200,22 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="户名" prop="accountName">
|
<el-form-item label="户名" prop="accountName">
|
||||||
<el-input v-model="createForm.accountName" placeholder="请输入户名" maxlength="128" />
|
<el-input v-model="formModel.accountName" placeholder="请输入户名" maxlength="128" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="账号" prop="accountNo">
|
<el-form-item label="账号" prop="accountNo">
|
||||||
<el-input v-model="createForm.accountNo" placeholder="请输入账号" maxlength="128" />
|
<el-input v-model="formModel.accountNo" placeholder="请输入账号" maxlength="128" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<template v-if="createForm.accountType !== 'alipay'">
|
<template v-if="formModel.accountType !== 'alipay'">
|
||||||
<el-form-item label="银行" prop="bankName">
|
<el-form-item label="银行" prop="bankName">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="createForm.bankName"
|
v-model="formModel.bankName"
|
||||||
placeholder="如:中国工商银行"
|
placeholder="如:中国工商银行"
|
||||||
maxlength="128"
|
maxlength="128"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="银行所在省" prop="bankProvince">
|
<el-form-item label="银行所在省" prop="bankProvince">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="createForm.bankProvince"
|
v-model="formModel.bankProvince"
|
||||||
placeholder="如:安徽省"
|
placeholder="如:安徽省"
|
||||||
maxlength="64"
|
maxlength="64"
|
||||||
clearable
|
clearable
|
||||||
@@ -177,7 +223,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="银行所在市" prop="bankCity">
|
<el-form-item label="银行所在市" prop="bankCity">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="createForm.bankCity"
|
v-model="formModel.bankCity"
|
||||||
placeholder="如:合肥市"
|
placeholder="如:合肥市"
|
||||||
maxlength="64"
|
maxlength="64"
|
||||||
clearable
|
clearable
|
||||||
@@ -185,7 +231,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="银行支行" prop="bankBranch" class="form-col-span-2">
|
<el-form-item label="银行支行" prop="bankBranch" class="form-col-span-2">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="createForm.bankBranch"
|
v-model="formModel.bankBranch"
|
||||||
placeholder="请输入开户支行全称"
|
placeholder="请输入开户支行全称"
|
||||||
maxlength="256"
|
maxlength="256"
|
||||||
/>
|
/>
|
||||||
@@ -193,7 +239,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-form-item label="备注" class="form-col-span-2">
|
<el-form-item label="备注" class="form-col-span-2">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="createForm.remark"
|
v-model="formModel.remark"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="2"
|
:rows="2"
|
||||||
placeholder="选填"
|
placeholder="选填"
|
||||||
@@ -203,15 +249,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button class="btn-ghost" @click="createVisible = false">
|
<el-button class="btn-ghost" @click="formVisible = false">
|
||||||
<el-icon><Close /></el-icon>
|
<el-icon><Close /></el-icon>
|
||||||
取消
|
取消
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
class="btn-main"
|
class="btn-main"
|
||||||
type="primary"
|
type="primary"
|
||||||
:loading="createLoading"
|
:loading="formLoading"
|
||||||
@click="submitCreate"
|
@click="submitForm"
|
||||||
>
|
>
|
||||||
<el-icon><Check /></el-icon>
|
<el-icon><Check /></el-icon>
|
||||||
确定
|
确定
|
||||||
@@ -223,11 +269,13 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||||
import { Check, Close, Plus } from '@element-plus/icons-vue'
|
import { Check, Close, Delete, Edit, Plus } from '@element-plus/icons-vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import {
|
import {
|
||||||
fetchCreateOaReceiveAccount,
|
fetchCreateOaReceiveAccount,
|
||||||
fetchOaReceiveAccountOptions
|
fetchDeleteOaReceiveAccount,
|
||||||
|
fetchOaReceiveAccountOptions,
|
||||||
|
fetchUpdateOaReceiveAccount
|
||||||
} from '@/api/oaApproval'
|
} from '@/api/oaApproval'
|
||||||
import {
|
import {
|
||||||
ACCOUNT_TYPE_LABEL,
|
ACCOUNT_TYPE_LABEL,
|
||||||
@@ -253,6 +301,7 @@
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
type AccountOpt = { id: string; label: string }
|
type AccountOpt = { id: string; label: string }
|
||||||
|
type FormMode = 'create' | 'edit'
|
||||||
|
|
||||||
const snapshotMap = ref(new Map<string, ReceiveAccountSnapshot>())
|
const snapshotMap = ref(new Map<string, ReceiveAccountSnapshot>())
|
||||||
const accountOptions = ref<AccountOpt[]>([])
|
const accountOptions = ref<AccountOpt[]>([])
|
||||||
@@ -263,10 +312,12 @@
|
|||||||
const selectRef = ref<{ blur?: () => void } | null>(null)
|
const selectRef = ref<{ blur?: () => void } | null>(null)
|
||||||
let mql: MediaQueryList | null = null
|
let mql: MediaQueryList | null = null
|
||||||
|
|
||||||
const createVisible = ref(false)
|
const formVisible = ref(false)
|
||||||
const createLoading = ref(false)
|
const formLoading = ref(false)
|
||||||
const createFormRef = ref()
|
const formMode = ref<FormMode>('create')
|
||||||
const createForm = reactive({
|
const editingId = ref('')
|
||||||
|
const formRef = ref()
|
||||||
|
const formModel = reactive({
|
||||||
accountType: 'alipay' as ReceiveAccountType,
|
accountType: 'alipay' as ReceiveAccountType,
|
||||||
accountName: '',
|
accountName: '',
|
||||||
accountNo: '',
|
accountNo: '',
|
||||||
@@ -277,8 +328,12 @@
|
|||||||
remark: ''
|
remark: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const formTitle = computed(() =>
|
||||||
|
formMode.value === 'edit' ? '编辑收款账户' : '新增收款账户'
|
||||||
|
)
|
||||||
|
|
||||||
const requireWhenBank = (_rule: any, value: string, callback: (e?: Error) => void) => {
|
const requireWhenBank = (_rule: any, value: string, callback: (e?: Error) => void) => {
|
||||||
if (createForm.accountType === 'alipay') {
|
if (formModel.accountType === 'alipay') {
|
||||||
callback()
|
callback()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -289,7 +344,7 @@
|
|||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
const createRules = computed(() => ({
|
const formRules = computed(() => ({
|
||||||
accountType: [{ required: true, message: '请选择账户类型', trigger: 'change' }],
|
accountType: [{ required: true, message: '请选择账户类型', trigger: 'change' }],
|
||||||
accountName: [{ required: true, message: '请输入户名', trigger: 'blur' }],
|
accountName: [{ required: true, message: '请输入户名', trigger: 'blur' }],
|
||||||
accountNo: [{ required: true, message: '请输入账号', trigger: 'blur' }],
|
accountNo: [{ required: true, message: '请输入账号', trigger: 'blur' }],
|
||||||
@@ -358,90 +413,161 @@
|
|||||||
drawerVisible.value = false
|
drawerVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearCreateBankFields() {
|
function clearBankFields() {
|
||||||
createForm.bankName = ''
|
formModel.bankName = ''
|
||||||
createForm.bankProvince = ''
|
formModel.bankProvince = ''
|
||||||
createForm.bankCity = ''
|
formModel.bankCity = ''
|
||||||
createForm.bankBranch = ''
|
formModel.bankBranch = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetCreateForm() {
|
function resetFormModel() {
|
||||||
createForm.accountType = 'alipay'
|
formModel.accountType = 'alipay'
|
||||||
createForm.accountName = ''
|
formModel.accountName = ''
|
||||||
createForm.accountNo = ''
|
formModel.accountNo = ''
|
||||||
clearCreateBankFields()
|
clearBankFields()
|
||||||
createForm.remark = ''
|
formModel.remark = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCreateTypeChange() {
|
function fillFormFromSnap(snap: ReceiveAccountSnapshot) {
|
||||||
if (createForm.accountType === 'alipay') clearCreateBankFields()
|
formModel.accountType = snap.accountType
|
||||||
createFormRef.value?.clearValidate?.()
|
formModel.accountName = snap.accountName
|
||||||
|
formModel.accountNo = snap.accountNo
|
||||||
|
formModel.bankName = snap.bankName
|
||||||
|
formModel.bankProvince = snap.bankProvince
|
||||||
|
formModel.bankCity = snap.bankCity
|
||||||
|
formModel.bankBranch = snap.bankBranch
|
||||||
|
formModel.remark = snap.remark
|
||||||
|
if (formModel.accountType === 'alipay') clearBankFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFormTypeChange() {
|
||||||
|
if (formModel.accountType === 'alipay') clearBankFields()
|
||||||
|
formRef.value?.clearValidate?.()
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPayload() {
|
||||||
|
const payload: Record<string, unknown> = {
|
||||||
|
accountType: formModel.accountType,
|
||||||
|
accountName: formModel.accountName.trim(),
|
||||||
|
accountNo: formModel.accountNo.trim(),
|
||||||
|
remark: formModel.remark?.trim() || undefined
|
||||||
|
}
|
||||||
|
if (formModel.accountType === 'alipay') {
|
||||||
|
payload.bankName = ''
|
||||||
|
payload.bankProvince = ''
|
||||||
|
payload.bankCity = ''
|
||||||
|
payload.bankBranch = ''
|
||||||
|
} else {
|
||||||
|
payload.bankName = formModel.bankName.trim()
|
||||||
|
payload.bankProvince = formModel.bankProvince.trim()
|
||||||
|
payload.bankCity = formModel.bankCity.trim()
|
||||||
|
payload.bankBranch = formModel.bankBranch.trim()
|
||||||
|
}
|
||||||
|
return payload
|
||||||
|
}
|
||||||
|
|
||||||
|
function upsertLocalSnap(snap: ReceiveAccountSnapshot) {
|
||||||
|
if (!snap.id) return
|
||||||
|
const map = new Map(snapshotMap.value)
|
||||||
|
map.set(snap.id, snap)
|
||||||
|
snapshotMap.value = map
|
||||||
|
const label = optionLabelFromRow(snap)
|
||||||
|
const idx = accountOptions.value.findIndex((x) => x.id === snap.id)
|
||||||
|
if (idx >= 0) {
|
||||||
|
const next = [...accountOptions.value]
|
||||||
|
next[idx] = { id: snap.id, label }
|
||||||
|
accountOptions.value = next
|
||||||
|
} else {
|
||||||
|
accountOptions.value = [...accountOptions.value, { id: snap.id, label }]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openCreateDialog() {
|
function openCreateDialog() {
|
||||||
selectRef.value?.blur?.()
|
selectRef.value?.blur?.()
|
||||||
resetCreateForm()
|
formMode.value = 'create'
|
||||||
createVisible.value = true
|
editingId.value = ''
|
||||||
nextTick(() => createFormRef.value?.clearValidate?.())
|
resetFormModel()
|
||||||
|
formVisible.value = true
|
||||||
|
nextTick(() => formRef.value?.clearValidate?.())
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitCreate() {
|
function openEditDialog(id: string) {
|
||||||
|
const tid = String(id || '').trim()
|
||||||
|
const snap = snapshotMap.value.get(tid)
|
||||||
|
if (!snap) {
|
||||||
|
ElMessage.error('账户不存在或已删除')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
selectRef.value?.blur?.()
|
||||||
|
formMode.value = 'edit'
|
||||||
|
editingId.value = tid
|
||||||
|
fillFormFromSnap(snap)
|
||||||
|
formVisible.value = true
|
||||||
|
nextTick(() => formRef.value?.clearValidate?.())
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
try {
|
try {
|
||||||
await createFormRef.value?.validate?.()
|
await formRef.value?.validate?.()
|
||||||
} catch {
|
} catch {
|
||||||
ElMessageBox.alert('请完善必填项后再提交', '提示', { type: 'warning' })
|
ElMessageBox.alert('请完善必填项后再提交', '提示', { type: 'warning' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
createLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const payload: Record<string, unknown> = {
|
const payload = buildPayload()
|
||||||
accountType: createForm.accountType,
|
let row: any
|
||||||
accountName: createForm.accountName.trim(),
|
if (formMode.value === 'edit' && editingId.value) {
|
||||||
accountNo: createForm.accountNo.trim(),
|
row = await fetchUpdateOaReceiveAccount(editingId.value, payload)
|
||||||
remark: createForm.remark?.trim() || undefined
|
|
||||||
}
|
|
||||||
if (createForm.accountType === 'alipay') {
|
|
||||||
payload.bankName = ''
|
|
||||||
payload.bankProvince = ''
|
|
||||||
payload.bankCity = ''
|
|
||||||
payload.bankBranch = ''
|
|
||||||
} else {
|
} else {
|
||||||
payload.bankName = createForm.bankName.trim()
|
row = await fetchCreateOaReceiveAccount(payload)
|
||||||
payload.bankProvince = createForm.bankProvince.trim()
|
|
||||||
payload.bankCity = createForm.bankCity.trim()
|
|
||||||
payload.bankBranch = createForm.bankBranch.trim()
|
|
||||||
}
|
}
|
||||||
const created = await fetchCreateOaReceiveAccount(payload)
|
const snap = snapshotFromRow(row)
|
||||||
const snap = snapshotFromRow(created)
|
|
||||||
if (!snap.id) {
|
if (!snap.id) {
|
||||||
ElMessage.error('创建成功但未返回账户 ID')
|
ElMessage.error(formMode.value === 'edit' ? '更新成功但未返回账户 ID' : '创建成功但未返回账户 ID')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await loadOptions()
|
await loadOptions()
|
||||||
// 确保新账户在 map 中(options 可能短暂未刷新)
|
upsertLocalSnap(snap)
|
||||||
if (!snapshotMap.value.has(snap.id)) {
|
if (formMode.value === 'edit') {
|
||||||
const map = new Map(snapshotMap.value)
|
if (selectModel.value.includes(snap.id)) {
|
||||||
map.set(snap.id, snap)
|
emitFromIds(selectModel.value)
|
||||||
snapshotMap.value = map
|
}
|
||||||
if (!accountOptions.value.some((x) => x.id === snap.id)) {
|
} else {
|
||||||
accountOptions.value = [
|
const nextIds = [...selectModel.value]
|
||||||
...accountOptions.value,
|
if (!nextIds.includes(snap.id)) nextIds.push(snap.id)
|
||||||
{ id: snap.id, label: optionLabelFromRow(snap) }
|
emitFromIds(nextIds)
|
||||||
]
|
if (drawerVisible.value && !pendingIds.value.includes(snap.id)) {
|
||||||
|
pendingIds.value = [...pendingIds.value, snap.id]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const nextIds = [...selectModel.value]
|
formVisible.value = false
|
||||||
if (!nextIds.includes(snap.id)) nextIds.push(snap.id)
|
|
||||||
emitFromIds(nextIds)
|
|
||||||
if (drawerVisible.value && !pendingIds.value.includes(snap.id)) {
|
|
||||||
pendingIds.value = [...pendingIds.value, snap.id]
|
|
||||||
}
|
|
||||||
createVisible.value = false
|
|
||||||
} finally {
|
} finally {
|
||||||
createLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function confirmDelete(id: string) {
|
||||||
|
const tid = String(id || '').trim()
|
||||||
|
const snap = snapshotMap.value.get(tid)
|
||||||
|
const name = snap?.accountName || tid
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确定删除收款账户「${name}」吗?删除后不可再选;已提交单据中的账户快照仍保留。`,
|
||||||
|
'删除收款账户',
|
||||||
|
{ type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
selectRef.value?.blur?.()
|
||||||
|
await fetchDeleteOaReceiveAccount(tid)
|
||||||
|
await loadOptions()
|
||||||
|
const nextSelected = selectModel.value.filter((x) => x !== tid)
|
||||||
|
emitFromIds(nextSelected)
|
||||||
|
pendingIds.value = pendingIds.value.filter((x) => x !== tid)
|
||||||
|
}
|
||||||
|
|
||||||
async function loadOptions() {
|
async function loadOptions() {
|
||||||
try {
|
try {
|
||||||
const res = await fetchOaReceiveAccountOptions()
|
const res = await fetchOaReceiveAccountOptions()
|
||||||
@@ -512,6 +638,53 @@
|
|||||||
min-height: 40px;
|
min-height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.oa-receive-account-select__option {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-receive-account-select__option-label {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-receive-account-select__option-actions,
|
||||||
|
.oa-receive-account-select__row-actions {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-receive-account-select__icon-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-receive-account-select__icon-btn.is-edit {
|
||||||
|
background: var(--mint-primary-bg, #ecfdf5);
|
||||||
|
color: var(--mint-primary-dark, #059669);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-receive-account-select__icon-btn.is-delete {
|
||||||
|
background: #fef2f2;
|
||||||
|
color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
.oa-receive-account-select__add-footer {
|
.oa-receive-account-select__add-footer {
|
||||||
padding: 4px 8px 8px;
|
padding: 4px 8px 8px;
|
||||||
border-top: 1px solid var(--mint-border, #d9e8e2);
|
border-top: 1px solid var(--mint-border, #d9e8e2);
|
||||||
@@ -597,6 +770,14 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
padding: 6px 4px;
|
padding: 6px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oa-receive-account-select__row-main {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,5 +811,10 @@
|
|||||||
.oa-receive-account-select__trigger {
|
.oa-receive-account-select__trigger {
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.oa-receive-account-select__icon-btn {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/** 临床科研申请单 · 业务子类型(researchCategory) */
|
||||||
|
export const CLINICAL_RESEARCH_CATEGORY_OPTIONS = [
|
||||||
|
{ value: 'bio_tech_clinical', label: '生物新技术临床科研' },
|
||||||
|
{ value: 'joint_topic_declare', label: '临床课题联合申报' },
|
||||||
|
{ value: 'bio_pharma_rd', label: '生物制药研发' }
|
||||||
|
] as const
|
||||||
|
|
||||||
|
export type ClinicalResearchCategory =
|
||||||
|
(typeof CLINICAL_RESEARCH_CATEGORY_OPTIONS)[number]['value']
|
||||||
|
|
||||||
|
const LABEL_MAP = Object.fromEntries(
|
||||||
|
CLINICAL_RESEARCH_CATEGORY_OPTIONS.map((o) => [o.value, o.label])
|
||||||
|
) as Record<string, string>
|
||||||
|
|
||||||
|
export function clinicalResearchCategoryLabel(code?: string | null): string {
|
||||||
|
if (!code) return ''
|
||||||
|
return LABEL_MAP[code] || code
|
||||||
|
}
|
||||||
@@ -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',
|
||||||
@@ -553,80 +553,14 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 中试服务 ──────────────────────────────────────────────────────────
|
// ── 临床科研 ──────────────────────────────────────────────────────────
|
||||||
{
|
|
||||||
id: 'PIL00000000000000000000000000001',
|
|
||||||
name: 'PilotService',
|
|
||||||
path: 'pilot-service',
|
|
||||||
component: '',
|
|
||||||
meta: {
|
|
||||||
title: '中试服务',
|
|
||||||
icon: 'ri:flask-line',
|
|
||||||
keepAlive: false,
|
|
||||||
roles: ['admin']
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
id: '80000000000000000000000000000010',
|
|
||||||
name: 'PilotApplication',
|
|
||||||
path: 'pilot-application',
|
|
||||||
component: '/pilot-service/pilot-application/index',
|
|
||||||
meta: {
|
|
||||||
title: '中试服务申请单',
|
|
||||||
keepAlive: true,
|
|
||||||
menuCode: 'pilot-service:pilot-application:list'
|
|
||||||
},
|
|
||||||
props: { bizType: 'pilot_service' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'PIL00000000000000000000000000002',
|
|
||||||
name: 'PilotCheckupManagement',
|
|
||||||
path: 'checkup-management',
|
|
||||||
component: '/pilot-service/checkup-management/index',
|
|
||||||
meta: {
|
|
||||||
title: '体检管理',
|
|
||||||
keepAlive: false,
|
|
||||||
isHide: true,
|
|
||||||
menuCode: 'pilot-service:checkup-management:list'
|
|
||||||
},
|
|
||||||
props: { bizType: 'pilot_service' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'PIL00000000000000000000000000003',
|
|
||||||
name: 'PilotInfusionSchedule',
|
|
||||||
path: 'infusion-schedule-management',
|
|
||||||
component: '/pilot-service/infusion-schedule-management/index',
|
|
||||||
meta: {
|
|
||||||
title: '输注计划管理',
|
|
||||||
keepAlive: false,
|
|
||||||
isHide: true,
|
|
||||||
menuCode: 'pilot-service:infusion-schedule-management:list'
|
|
||||||
},
|
|
||||||
props: { bizType: 'pilot_service' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'PIL00000000000000000000000000004',
|
|
||||||
name: 'PilotOutboundRelease',
|
|
||||||
path: 'outbound-release-review',
|
|
||||||
component: '/pilot-service/outbound-release-review/index',
|
|
||||||
meta: {
|
|
||||||
title: '出库放行审核',
|
|
||||||
keepAlive: true,
|
|
||||||
menuCode: 'pilot-service:outbound-release-review:list'
|
|
||||||
},
|
|
||||||
props: { bizType: 'pilot_service' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
// ── 基础实验 ──────────────────────────────────────────────────────────
|
|
||||||
{
|
{
|
||||||
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 +572,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 +603,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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export const LAB_PROCESS_TABS: Array<{
|
|||||||
|
|
||||||
const CELL_HSC_COLUMNS: LabColumn[] = [
|
const CELL_HSC_COLUMNS: LabColumn[] = [
|
||||||
{ prop: 'cellCode', label: '细胞编码', minWidth: 140 },
|
{ prop: 'cellCode', label: '细胞编码', minWidth: 140 },
|
||||||
|
{ prop: 'sampleStatus', label: '样本状态', minWidth: 140 },
|
||||||
{ prop: 'motherName', label: '准妈妈姓名', minWidth: 110 },
|
{ prop: 'motherName', label: '准妈妈姓名', minWidth: 110 },
|
||||||
{ prop: 'collectionTime', label: '采集时间', minWidth: 200 },
|
{ prop: 'collectionTime', label: '采集时间', minWidth: 200 },
|
||||||
{ prop: 'hospitalName', label: '采集医院', minWidth: 140 },
|
{ prop: 'hospitalName', label: '采集医院', minWidth: 140 },
|
||||||
@@ -72,6 +73,7 @@ const CELL_HSC_COLUMNS: LabColumn[] = [
|
|||||||
|
|
||||||
const DONATION_HSC_COLUMNS: LabColumn[] = [
|
const DONATION_HSC_COLUMNS: LabColumn[] = [
|
||||||
{ prop: 'cellCode', label: '细胞编码', minWidth: 140 },
|
{ prop: 'cellCode', label: '细胞编码', minWidth: 140 },
|
||||||
|
{ prop: 'sampleStatus', label: '样本状态', minWidth: 140 },
|
||||||
{ prop: 'motherName', label: '准妈妈姓名', minWidth: 110 },
|
{ prop: 'motherName', label: '准妈妈姓名', minWidth: 110 },
|
||||||
{ prop: 'labMaterialCode', label: '实验室物料编码', minWidth: 130 },
|
{ prop: 'labMaterialCode', label: '实验室物料编码', minWidth: 130 },
|
||||||
{ prop: 'inboundCode', label: '入库编码', minWidth: 140 },
|
{ prop: 'inboundCode', label: '入库编码', minWidth: 140 },
|
||||||
@@ -98,6 +100,7 @@ const DONATION_HSC_COLUMNS: LabColumn[] = [
|
|||||||
|
|
||||||
const MSC_COLUMNS: LabColumn[] = [
|
const MSC_COLUMNS: LabColumn[] = [
|
||||||
{ prop: 'labFlowCode', label: '实验室流转编码', minWidth: 140 },
|
{ prop: 'labFlowCode', label: '实验室流转编码', minWidth: 140 },
|
||||||
|
{ prop: 'sampleStatus', label: '样本状态', minWidth: 140 },
|
||||||
{ prop: 'motherName', label: '母亲姓名', minWidth: 110 },
|
{ prop: 'motherName', label: '母亲姓名', minWidth: 110 },
|
||||||
{ prop: 'cordCollectTime', label: '脐带采集时间', minWidth: 200 },
|
{ prop: 'cordCollectTime', label: '脐带采集时间', minWidth: 200 },
|
||||||
{ prop: 'transportTempC', label: '运输温度/℃', minWidth: 110 },
|
{ prop: 'transportTempC', label: '运输温度/℃', minWidth: 110 },
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { describe, it } from 'node:test'
|
||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { hasOaCommentDraft } from './oa-comment-draft.ts'
|
||||||
|
|
||||||
|
describe('hasOaCommentDraft', () => {
|
||||||
|
it('treats blank content without mentions/files as empty', () => {
|
||||||
|
assert.equal(hasOaCommentDraft({}), false)
|
||||||
|
assert.equal(hasOaCommentDraft({ content: ' ', mentionCount: 0, attachmentCount: 0 }), false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('detects text, mentions and attachments', () => {
|
||||||
|
assert.equal(hasOaCommentDraft({ content: '@test' }), true)
|
||||||
|
assert.equal(hasOaCommentDraft({ mentionCount: 1 }), true)
|
||||||
|
assert.equal(hasOaCommentDraft({ attachmentCount: 2 }), true)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/** 评论区是否有未发送草稿(文字 / @ / 附件) */
|
||||||
|
export function hasOaCommentDraft(input: {
|
||||||
|
content?: string | null
|
||||||
|
mentionCount?: number
|
||||||
|
attachmentCount?: number
|
||||||
|
}): boolean {
|
||||||
|
return !!(
|
||||||
|
String(input.content || '').trim() ||
|
||||||
|
(input.mentionCount || 0) > 0 ||
|
||||||
|
(input.attachmentCount || 0) > 0
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ const SECTION_TITLES: Record<
|
|||||||
schedule: '临床应用输注计划信息'
|
schedule: '临床应用输注计划信息'
|
||||||
},
|
},
|
||||||
basic_experiment: {
|
basic_experiment: {
|
||||||
application: '基础实验申请信息',
|
application: '临床科研申请信息',
|
||||||
schedule: '交付计划信息'
|
schedule: '交付计划信息'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import {
|
|||||||
resolveTabKeyFromWorkOrder,
|
resolveTabKeyFromWorkOrder,
|
||||||
getProductionWorkOrderTab,
|
getProductionWorkOrderTab,
|
||||||
toWorkOrderListQuery,
|
toWorkOrderListQuery,
|
||||||
isAllProductionWorkOrderTab
|
isAllProductionWorkOrderTab,
|
||||||
|
workOrderMatchesTab
|
||||||
} from '@/utils/production-work-order-tabs'
|
} from '@/utils/production-work-order-tabs'
|
||||||
import { toAllTabListQuery, workOrderMatchesCategory } from '@/utils/production-work-order-category'
|
import { toAllTabListQuery, workOrderMatchesCategory } from '@/utils/production-work-order-category'
|
||||||
import { matchesWorkOrderStatusFilter } from '@/utils/status-tag-registry'
|
import { matchesWorkOrderStatusFilter } from '@/utils/status-tag-registry'
|
||||||
@@ -231,9 +232,7 @@ export function filterMineEntriesByWorkOrderSearch(
|
|||||||
const tabKey = filters.tabKey
|
const tabKey = filters.tabKey
|
||||||
return entries.filter((entry) => {
|
return entries.filter((entry) => {
|
||||||
const row = entry.workOrder
|
const row = entry.workOrder
|
||||||
if (!isAllProductionWorkOrderTab(tabKey) && resolveTabKeyFromWorkOrder(row) !== tabKey) {
|
if (!workOrderMatchesTab(row, tabKey)) return false
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
isAllProductionWorkOrderTab(tabKey) &&
|
isAllProductionWorkOrderTab(tabKey) &&
|
||||||
!workOrderMatchesCategory(row, filters.productionCategory || '')
|
!workOrderMatchesCategory(row, filters.productionCategory || '')
|
||||||
|
|||||||
Loaded 100 of 152 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user