Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d7b2ada59 | ||
|
|
332711ad36 | ||
|
|
03acf5115a | ||
|
|
12cf373a49 | ||
|
|
0434999603 | ||
|
|
f40d33b07a | ||
|
|
e5f84b4693 | ||
|
|
71424ff576 | ||
|
|
fbe62c7a9b | ||
|
|
034a4da1ad | ||
|
|
dbc4a24543 | ||
|
|
b59c921b50 | ||
|
|
b57898fabb | ||
|
|
9fd1cc4370 | ||
|
|
af02e2cdd2 | ||
|
|
6ddd07dbb5 | ||
|
|
f9aa16ef31 |
No files matched your search
@@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1394,6 +1394,7 @@ def list_collection_protocols(
|
|||||||
"sampleTypeName": type_name,
|
"sampleTypeName": type_name,
|
||||||
"sampleCode": code,
|
"sampleCode": code,
|
||||||
"sampleStatus": (s.sample_status or "").strip(),
|
"sampleStatus": (s.sample_status or "").strip(),
|
||||||
|
"voidDesc": (getattr(s, "void_desc", None) or "").strip(),
|
||||||
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
||||||
"transport": transport_dict,
|
"transport": transport_dict,
|
||||||
"freight": freight_by_sample.get(s.id),
|
"freight": freight_by_sample.get(s.id),
|
||||||
|
|||||||
@@ -269,10 +269,13 @@ def _build_cell_system(
|
|||||||
clear_flag = checked
|
clear_flag = checked
|
||||||
break
|
break
|
||||||
|
|
||||||
|
sample_status = str(getattr(sample, "sample_status", None) or "").strip()
|
||||||
base: Dict[str, Any] = {
|
base: Dict[str, Any] = {
|
||||||
"receptionId": rec.id,
|
"receptionId": rec.id,
|
||||||
"sampleCode": (rec.sample_code or sample.sample_code or "").strip(),
|
"sampleCode": (rec.sample_code or sample.sample_code or "").strip(),
|
||||||
"labStorageCode": (rec.lab_storage_code or "").strip(),
|
"labStorageCode": (rec.lab_storage_code or "").strip(),
|
||||||
|
"sampleStatus": sample_status,
|
||||||
|
"voidDesc": str(getattr(sample, "void_desc", None) or "").strip(),
|
||||||
"motherName": (party.mother_name if party else "") or "",
|
"motherName": (party.mother_name if party else "") or "",
|
||||||
"collectionTime": ledger.format_cn_datetime(coll.sample_collect_time if coll else None),
|
"collectionTime": ledger.format_cn_datetime(coll.sample_collect_time if coll else None),
|
||||||
"collectionTimeRaw": _fmt_raw(coll.sample_collect_time if coll else None),
|
"collectionTimeRaw": _fmt_raw(coll.sample_collect_time if coll else None),
|
||||||
@@ -353,10 +356,13 @@ def _build_donation_system(
|
|||||||
qc_process: Dict[str, str],
|
qc_process: Dict[str, str],
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
prod = prod or {}
|
prod = prod or {}
|
||||||
|
sample_status = str(getattr(sample, "sample_status", None) or "").strip()
|
||||||
base: Dict[str, Any] = {
|
base: Dict[str, Any] = {
|
||||||
"receptionId": rec.id,
|
"receptionId": rec.id,
|
||||||
"sampleCode": (rec.sample_code or sample.sample_code or "").strip(),
|
"sampleCode": (rec.sample_code or sample.sample_code or "").strip(),
|
||||||
"labStorageCode": (rec.lab_storage_code or "").strip(),
|
"labStorageCode": (rec.lab_storage_code or "").strip(),
|
||||||
|
"sampleStatus": sample_status,
|
||||||
|
"voidDesc": str(getattr(sample, "void_desc", None) or "").strip(),
|
||||||
"motherName": (party.mother_name if party else "") or "",
|
"motherName": (party.mother_name if party else "") or "",
|
||||||
"receptionTime": ledger.format_cn_datetime(rec.reception_time),
|
"receptionTime": ledger.format_cn_datetime(rec.reception_time),
|
||||||
"receptionTimeRaw": _fmt_raw(rec.reception_time),
|
"receptionTimeRaw": _fmt_raw(rec.reception_time),
|
||||||
|
|||||||
@@ -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 "", ""
|
||||||
|
|||||||
@@ -976,6 +976,7 @@ def list_donations(
|
|||||||
"sampleTypeName": type_name,
|
"sampleTypeName": type_name,
|
||||||
"sampleCode": code,
|
"sampleCode": code,
|
||||||
"sampleStatus": (s.sample_status or "").strip(),
|
"sampleStatus": (s.sample_status or "").strip(),
|
||||||
|
"voidDesc": (getattr(s, "void_desc", None) or "").strip(),
|
||||||
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
||||||
"transport": transport_dict,
|
"transport": transport_dict,
|
||||||
"freight": freight_by_sample.get(s.id),
|
"freight": freight_by_sample.get(s.id),
|
||||||
|
|||||||
@@ -194,6 +194,14 @@ def _item_to_dict(item: BizSampleFreightItem) -> Dict[str, Any]:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_SAMPLE_STATUS_LABELS = {
|
||||||
|
"ycj": "已采集",
|
||||||
|
"jcz": "检测中",
|
||||||
|
"yrk": "已入库",
|
||||||
|
"yzf": "已作废",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _item_to_dict_enriched(
|
def _item_to_dict_enriched(
|
||||||
item: BizSampleFreightItem,
|
item: BizSampleFreightItem,
|
||||||
*,
|
*,
|
||||||
@@ -201,12 +209,19 @@ def _item_to_dict_enriched(
|
|||||||
sample_type_name: str = "",
|
sample_type_name: str = "",
|
||||||
mother_name: str = "",
|
mother_name: str = "",
|
||||||
newborn_name: str = "",
|
newborn_name: str = "",
|
||||||
|
sample_status: str = "",
|
||||||
|
void_desc: str = "",
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
data = _item_to_dict(item)
|
data = _item_to_dict(item)
|
||||||
data["protocolNo"] = protocol_no or ""
|
data["protocolNo"] = protocol_no or ""
|
||||||
data["sampleTypeName"] = sample_type_name or ""
|
data["sampleTypeName"] = sample_type_name or ""
|
||||||
data["motherName"] = mother_name or ""
|
data["motherName"] = mother_name or ""
|
||||||
data["newbornName"] = newborn_name or ""
|
data["newbornName"] = newborn_name or ""
|
||||||
|
status = str(sample_status or "").strip()
|
||||||
|
if str(item.sample_code or "").strip():
|
||||||
|
data["sampleStatus"] = status
|
||||||
|
data["sampleStatusLabel"] = _SAMPLE_STATUS_LABELS.get(status, "")
|
||||||
|
data["voidDesc"] = str(void_desc or "").strip()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@@ -257,6 +272,8 @@ def _enrich_items_maps(
|
|||||||
BizCellSampleType.type_name,
|
BizCellSampleType.type_name,
|
||||||
BizProtocolPartyCustomer.mother_name,
|
BizProtocolPartyCustomer.mother_name,
|
||||||
BizProtocolPartyCustomer.newborn_name,
|
BizProtocolPartyCustomer.newborn_name,
|
||||||
|
BizProtocolSample.sample_status,
|
||||||
|
BizProtocolSample.void_desc,
|
||||||
)
|
)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
BizCollectionProtocol,
|
BizCollectionProtocol,
|
||||||
@@ -287,12 +304,14 @@ def _enrich_items_maps(
|
|||||||
)
|
)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
for sid, pno, tname, mname, nname in rows:
|
for sid, pno, tname, mname, nname, status, void_desc in rows:
|
||||||
out[f"{SAMPLE_SOURCE_CELL}|{sid}"] = {
|
out[f"{SAMPLE_SOURCE_CELL}|{sid}"] = {
|
||||||
"protocolNo": pno or "",
|
"protocolNo": pno or "",
|
||||||
"sampleTypeName": tname or "",
|
"sampleTypeName": tname or "",
|
||||||
"motherName": mname or "",
|
"motherName": mname or "",
|
||||||
"newbornName": nname or "",
|
"newbornName": nname or "",
|
||||||
|
"sampleStatus": str(status or "").strip(),
|
||||||
|
"voidDesc": str(void_desc or "").strip(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if donation_ids:
|
if donation_ids:
|
||||||
@@ -303,6 +322,8 @@ def _enrich_items_maps(
|
|||||||
BizCellSampleType.type_name,
|
BizCellSampleType.type_name,
|
||||||
BizResearchDonationParty.mother_name,
|
BizResearchDonationParty.mother_name,
|
||||||
BizResearchDonationParty.newborn_name,
|
BizResearchDonationParty.newborn_name,
|
||||||
|
BizResearchDonationSample.sample_status,
|
||||||
|
BizResearchDonationSample.void_desc,
|
||||||
)
|
)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
BizResearchDonation,
|
BizResearchDonation,
|
||||||
@@ -334,12 +355,14 @@ def _enrich_items_maps(
|
|||||||
)
|
)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
for sid, dno, tname, mname, nname in rows:
|
for sid, dno, tname, mname, nname, status, void_desc in rows:
|
||||||
out[f"{SAMPLE_SOURCE_DONATION}|{sid}"] = {
|
out[f"{SAMPLE_SOURCE_DONATION}|{sid}"] = {
|
||||||
"protocolNo": dno or "",
|
"protocolNo": dno or "",
|
||||||
"sampleTypeName": tname or "",
|
"sampleTypeName": tname or "",
|
||||||
"motherName": mname or "",
|
"motherName": mname or "",
|
||||||
"newbornName": nname or "",
|
"newbornName": nname or "",
|
||||||
|
"sampleStatus": str(status or "").strip(),
|
||||||
|
"voidDesc": str(void_desc or "").strip(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return out
|
return out
|
||||||
@@ -541,6 +564,8 @@ def list_freights(
|
|||||||
sample_type_name=info.get("sampleTypeName", ""),
|
sample_type_name=info.get("sampleTypeName", ""),
|
||||||
mother_name=info.get("motherName", ""),
|
mother_name=info.get("motherName", ""),
|
||||||
newborn_name=info.get("newbornName", ""),
|
newborn_name=info.get("newbornName", ""),
|
||||||
|
sample_status=info.get("sampleStatus", ""),
|
||||||
|
void_desc=info.get("voidDesc", ""),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
data["items"] = enriched
|
data["items"] = enriched
|
||||||
@@ -584,6 +609,8 @@ def get_freight_detail(
|
|||||||
sample_type_name=info.get("sampleTypeName", ""),
|
sample_type_name=info.get("sampleTypeName", ""),
|
||||||
mother_name=info.get("motherName", ""),
|
mother_name=info.get("motherName", ""),
|
||||||
newborn_name=info.get("newbornName", ""),
|
newborn_name=info.get("newbornName", ""),
|
||||||
|
sample_status=info.get("sampleStatus", ""),
|
||||||
|
void_desc=info.get("voidDesc", ""),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
data["items"] = enriched
|
data["items"] = enriched
|
||||||
|
|||||||
@@ -444,6 +444,7 @@ def _rows_to_sample_list_items(
|
|||||||
"sampleTypeName": type_map.get(sample.sample_type_id or "", ""),
|
"sampleTypeName": type_map.get(sample.sample_type_id or "", ""),
|
||||||
"collectAmount": _dec(sample.collect_amount),
|
"collectAmount": _dec(sample.collect_amount),
|
||||||
"sampleStatus": sample.sample_status or "",
|
"sampleStatus": sample.sample_status or "",
|
||||||
|
"voidDesc": (getattr(sample, "void_desc", None) or "").strip(),
|
||||||
"motherName": (party.mother_name if party else "") or "",
|
"motherName": (party.mother_name if party else "") or "",
|
||||||
"newbornName": (party.newborn_name if party else "") or "",
|
"newbornName": (party.newborn_name if party else "") or "",
|
||||||
"sampleCollectTime": (
|
"sampleCollectTime": (
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
"""市场协议无效态 ↔ 样本接收废弃 / 样本状态作废联动。
|
"""市场协议无效态 ↔ 样本接收废弃 / 样本状态作废联动。
|
||||||
|
|
||||||
规则(细胞存储 / 科研捐赠):
|
规则(细胞存储 / 科研捐赠):
|
||||||
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf)并写 `void_date`;
|
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf),
|
||||||
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态与 void_date。
|
写 `void_date`,并将接收备注写入 `void_desc`(备注为空则作废原因为空);
|
||||||
|
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态、void_date 与 void_desc。
|
||||||
2. 协议变为已作废(yzf)或属地废弃(sdfq)时:
|
2. 协议变为已作废(yzf)或属地废弃(sdfq)时:
|
||||||
- 协议下全部样本接收结论自动为废弃(bj);
|
- 协议下全部样本接收结论自动为废弃(bj);
|
||||||
- 协议下全部有效样本 `sample_status` 置为已作废(yzf),并写入 `void_date`。
|
- 协议下全部有效样本 `sample_status` 置为已作废(yzf),并写入 `void_date`。
|
||||||
@@ -585,13 +586,17 @@ def void_sample_for_discarded_reception(
|
|||||||
tenant_no: str,
|
tenant_no: str,
|
||||||
user_id: Optional[str] = None,
|
user_id: Optional[str] = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""单条接收废弃:仅将该样本置为已作废。"""
|
"""单条接收废弃:将该样本置为已作废,作废原因取接收备注。"""
|
||||||
_source, sample = _find_sample_for_reception(db, reception=reception, tenant_no=tenant_no)
|
_source, sample = _find_sample_for_reception(db, reception=reception, tenant_no=tenant_no)
|
||||||
if not sample:
|
if not sample:
|
||||||
return False
|
return False
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
reason = (reception.remark or "").strip()
|
||||||
|
if len(reason) > 512:
|
||||||
|
reason = reason[:512]
|
||||||
sample.sample_status = SAMPLE_VOID_STATUS
|
sample.sample_status = SAMPLE_VOID_STATUS
|
||||||
sample.void_date = _void_date_yyyymmdd(void_time=reception.reception_time or now)
|
sample.void_date = _void_date_yyyymmdd(void_time=reception.reception_time or now)
|
||||||
|
sample.void_desc = reason or None
|
||||||
sample.update_by = user_id
|
sample.update_by = user_id
|
||||||
sample.update_time = now
|
sample.update_time = now
|
||||||
db.add(sample)
|
db.add(sample)
|
||||||
|
|||||||
@@ -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,
|
||||||
|
)
|
||||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
from app.services.lab_sample_process import (
|
from app.services.lab_sample_process import (
|
||||||
format_cn_datetime,
|
format_cn_datetime,
|
||||||
@@ -38,5 +39,65 @@ class LabSampleProcessServiceTests(unittest.TestCase):
|
|||||||
self.assertEqual(merged["motherName"], "张三")
|
self.assertEqual(merged["motherName"], "张三")
|
||||||
|
|
||||||
|
|
||||||
|
class LabSampleProcessRowStatusTests(unittest.TestCase):
|
||||||
|
def test_cell_and_donation_rows_expose_sample_status(self):
|
||||||
|
from app.crud.lab_sample_process import (
|
||||||
|
_build_cell_system,
|
||||||
|
_build_donation_system,
|
||||||
|
)
|
||||||
|
|
||||||
|
rec = SimpleNamespace(
|
||||||
|
id="r1",
|
||||||
|
sample_code="S1",
|
||||||
|
lab_storage_code="B0000108",
|
||||||
|
reception_time=None,
|
||||||
|
receive_temperature="",
|
||||||
|
handler_name="",
|
||||||
|
remark="",
|
||||||
|
create_time=None,
|
||||||
|
)
|
||||||
|
sample = SimpleNamespace(
|
||||||
|
sample_code="S1",
|
||||||
|
sample_status="yrk",
|
||||||
|
void_desc="",
|
||||||
|
)
|
||||||
|
voided = SimpleNamespace(
|
||||||
|
sample_code="S2",
|
||||||
|
sample_status="yzf",
|
||||||
|
void_desc="溶血",
|
||||||
|
)
|
||||||
|
cell = _build_cell_system(
|
||||||
|
tab_key="cell_hsc",
|
||||||
|
rec=rec,
|
||||||
|
sample=sample,
|
||||||
|
party=None,
|
||||||
|
coll=None,
|
||||||
|
protocol=None,
|
||||||
|
prod={},
|
||||||
|
hospital_name="",
|
||||||
|
check_flags={},
|
||||||
|
storage_status="已入库",
|
||||||
|
qc_mother={},
|
||||||
|
qc_process={},
|
||||||
|
)
|
||||||
|
self.assertEqual(cell["sampleStatus"], "yrk")
|
||||||
|
self.assertEqual(cell["voidDesc"], "")
|
||||||
|
self.assertEqual(cell["cellCode"], "B0000108")
|
||||||
|
|
||||||
|
donation = _build_donation_system(
|
||||||
|
tab_key="donation_hsc",
|
||||||
|
rec=rec,
|
||||||
|
sample=voided,
|
||||||
|
party=None,
|
||||||
|
coll=None,
|
||||||
|
prod={},
|
||||||
|
storage_status="",
|
||||||
|
qc_mother={},
|
||||||
|
qc_process={},
|
||||||
|
)
|
||||||
|
self.assertEqual(donation["sampleStatus"], "yzf")
|
||||||
|
self.assertEqual(donation["voidDesc"], "溶血")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
"""协议/捐赠列表 sampleItems 须返回样本 voidDesc,供审核列表问号展示。"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
import re
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
_SAMPLE_ITEM_VOID_DESC = re.compile(
|
||||||
|
r'"sampleStatus"\s*:\s*\(s\.sample_status[^)]*\)\.strip\(\),\s*'
|
||||||
|
r'"voidDesc"\s*:\s*\(getattr\(s,\s*"void_desc"',
|
||||||
|
re.S,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestProtocolListSampleVoidDesc(unittest.TestCase):
|
||||||
|
def test_collection_protocol_list_includes_sample_void_desc(self):
|
||||||
|
from app.crud import collection_protocol as cp
|
||||||
|
|
||||||
|
src = inspect.getsource(cp.list_collection_protocols)
|
||||||
|
self.assertRegex(src, _SAMPLE_ITEM_VOID_DESC)
|
||||||
|
|
||||||
|
def test_research_donation_list_includes_sample_void_desc(self):
|
||||||
|
from app.crud import research_donation as rd
|
||||||
|
|
||||||
|
# 捐赠列表函数名
|
||||||
|
fn = None
|
||||||
|
for name, obj in inspect.getmembers(rd, inspect.isfunction):
|
||||||
|
if "list" in name and "donation" in name:
|
||||||
|
src = inspect.getsource(obj)
|
||||||
|
if "sample_items.append" in src and '"sampleStatus"' in src:
|
||||||
|
fn = obj
|
||||||
|
break
|
||||||
|
self.assertIsNotNone(fn, "未找到组装 sampleItems 的捐赠列表函数")
|
||||||
|
self.assertRegex(inspect.getsource(fn), _SAMPLE_ITEM_VOID_DESC)
|
||||||
|
|
||||||
|
def test_sample_collection_list_uses_sample_void_desc(self):
|
||||||
|
from app.crud import protocol_sample_collection as psc
|
||||||
|
|
||||||
|
src = inspect.getsource(psc)
|
||||||
|
self.assertIn('getattr(psample, "void_desc"', src)
|
||||||
|
self.assertNotIn('item["voidDesc"] = (proto.void_desc or "") if proto else ""', src)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -440,6 +440,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
accept_conclusion="bj",
|
accept_conclusion="bj",
|
||||||
reception_source="cell_storage",
|
reception_source="cell_storage",
|
||||||
sample_code="ZKA",
|
sample_code="ZKA",
|
||||||
|
remark="母血乙肝阳性",
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -471,6 +472,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
self.assertEqual(by_id["sa"].sample_status, SAMPLE_VOID_STATUS)
|
self.assertEqual(by_id["sa"].sample_status, SAMPLE_VOID_STATUS)
|
||||||
self.assertEqual(by_id["sa"].void_date, "20261105")
|
self.assertEqual(by_id["sa"].void_date, "20261105")
|
||||||
|
self.assertEqual(by_id["sa"].void_desc, "母血乙肝阳性")
|
||||||
self.assertEqual(by_id["sb"].sample_status, "ycj")
|
self.assertEqual(by_id["sb"].sample_status, "ycj")
|
||||||
self.assertEqual(by_id["sc"].sample_status, "ycj")
|
self.assertEqual(by_id["sc"].sample_status, "ycj")
|
||||||
|
|
||||||
@@ -496,6 +498,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
sample_code="ZKCLR",
|
sample_code="ZKCLR",
|
||||||
sample_status=SAMPLE_VOID_STATUS,
|
sample_status=SAMPLE_VOID_STATUS,
|
||||||
void_date="20261101",
|
void_date="20261101",
|
||||||
|
void_desc="旧作废原因",
|
||||||
tenant_no="tenant-a",
|
tenant_no="tenant-a",
|
||||||
create_dept_id="",
|
create_dept_id="",
|
||||||
create_time=now,
|
create_time=now,
|
||||||
@@ -535,6 +538,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
|||||||
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s-clear").one()
|
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s-clear").one()
|
||||||
self.assertFalse((sample.sample_status or "").strip())
|
self.assertFalse((sample.sample_status or "").strip())
|
||||||
self.assertFalse((sample.void_date or "").strip())
|
self.assertFalse((sample.void_date or "").strip())
|
||||||
|
self.assertFalse((sample.void_desc or "").strip())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -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") == []
|
||||||
@@ -270,12 +270,12 @@ test('sample-coded list cards show sample status and a void reason affordance',
|
|||||||
}).fields.find((field) => field.label === '样本状态').value,
|
}).fields.find((field) => field.label === '样本状态').value,
|
||||||
'已入库'
|
'已入库'
|
||||||
)
|
)
|
||||||
assert.equal(
|
const detecting = buildMarketCard('payment-chase', 'specialist', {
|
||||||
buildMarketCard('payment-chase', 'specialist', {
|
sampleCode: 'S-1', sampleStatus: 'jcz'
|
||||||
sampleCode: 'S-1', sampleStatus: 'jcz'
|
}).fields.find((field) => field.label === '样本状态')
|
||||||
}).fields.find((field) => field.label === '样本状态').value,
|
assert.equal(detecting.value, '检测中')
|
||||||
'检测中'
|
assert.equal(detecting.helpTitle, undefined)
|
||||||
)
|
assert.equal(detecting.helpText, undefined)
|
||||||
|
|
||||||
const voided = buildMarketCard('payment', 'specialist', {
|
const voided = buildMarketCard('payment', 'specialist', {
|
||||||
motherName: '作废客户',
|
motherName: '作废客户',
|
||||||
|
|||||||
@@ -216,7 +216,8 @@ async function ensureUserCache() {
|
|||||||
if (userCachePromise) return userCachePromise
|
if (userCachePromise) return userCachePromise
|
||||||
userCachePromise = (async () => {
|
userCachePromise = (async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetchUserOptions()
|
// 同部门优先:由后端按当前登录用户部门排序
|
||||||
|
const res = await fetchUserOptions({ prioritizeCallerDept: true })
|
||||||
const list = Array.isArray(res) ? res : res?.list || []
|
const list = Array.isArray(res) ? res : res?.list || []
|
||||||
const next = []
|
const next = []
|
||||||
const seen = new Set()
|
const seen = new Set()
|
||||||
|
|||||||
@@ -22,9 +22,12 @@ export function fetchGetRoleList() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 流程设计器:用户下拉选项(label=昵称,value=用户ID) */
|
/** 用户下拉选项(label=昵称,value=用户ID;可选 deptId / prioritizeCallerDept) */
|
||||||
export function fetchUserOptions(params?: { roleName?: string }) {
|
export function fetchUserOptions(params?: {
|
||||||
return request.get<Array<{ label: string; value: string }>>({
|
roleName?: string
|
||||||
|
prioritizeCallerDept?: boolean
|
||||||
|
}) {
|
||||||
|
return request.get<Array<{ label: string; value: string; deptId?: string }>>({
|
||||||
url: '/web/admin/users/options',
|
url: '/web/admin/users/options',
|
||||||
params
|
params
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ export type SampleVoidTarget = {
|
|||||||
receptionSource: 'cell_storage' | 'research_donation'
|
receptionSource: 'cell_storage' | 'research_donation'
|
||||||
sampleId?: string
|
sampleId?: string
|
||||||
sampleCode?: string
|
sampleCode?: string
|
||||||
|
/** 仅弹窗展示,不参与作废请求 */
|
||||||
|
labStorageCode?: string
|
||||||
protocolId?: string
|
protocolId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<!-- 样本状态:标签 + 作废原因 -->
|
<!-- 样本状态:标签;仅已作废时展示问号与作废原因 -->
|
||||||
<template>
|
<template>
|
||||||
<span class="sample-status-tag">
|
<span class="sample-status-tag">
|
||||||
<el-tag :type="tagType" size="small">{{ label }}</el-tag>
|
<el-tag :type="tagType" size="small">{{ label }}</el-tag>
|
||||||
<el-popover placement="top" trigger="click" :width="240">
|
<el-popover v-if="voided" placement="top" trigger="click" :width="240">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<button type="button" class="sample-status-tag__q" aria-label="作废原因" @click.stop>
|
<button type="button" class="sample-status-tag__q" aria-label="作废原因" @click.stop>
|
||||||
<el-icon><QuestionFilled /></el-icon>
|
<el-icon><QuestionFilled /></el-icon>
|
||||||
@@ -31,6 +31,8 @@
|
|||||||
const code = computed(() => String(props.status || '').trim())
|
const code = computed(() => String(props.status || '').trim())
|
||||||
const label = computed(() => (code.value ? sampleStatusLabel(code.value) : '—'))
|
const label = computed(() => (code.value ? sampleStatusLabel(code.value) : '—'))
|
||||||
const tagType = computed(() => (code.value ? sampleStatusTagType(code.value) : 'info'))
|
const tagType = computed(() => (code.value ? sampleStatusTagType(code.value) : 'info'))
|
||||||
|
/** 问号仅已作废(yzf)展示 */
|
||||||
|
const voided = computed(() => code.value === 'yzf')
|
||||||
const reasonText = computed(() => String(props.voidDesc || '').trim() || '暂无作废原因')
|
const reasonText = computed(() => String(props.voidDesc || '').trim() || '暂无作废原因')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
class="biz-dialog-form"
|
class="biz-dialog-form"
|
||||||
>
|
>
|
||||||
<div class="form-grid-2">
|
<div class="form-grid-2">
|
||||||
|
<el-form-item label="实验室入库编码" class="form-col-span-2">
|
||||||
|
<span class="sample-void-dialog__code">{{ labStorageCodeDisplay }}</span>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item v-if="sampleCode" label="样本编码" class="form-col-span-2">
|
<el-form-item v-if="sampleCode" label="样本编码" class="form-col-span-2">
|
||||||
<span class="sample-void-dialog__code">{{ sampleCode }}</span>
|
<span class="sample-void-dialog__code">{{ sampleCode }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -84,6 +87,9 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const labStorageCodeDisplay = computed(
|
||||||
|
() => String(props.target?.labStorageCode || '').trim() || '—'
|
||||||
|
)
|
||||||
const sampleCode = computed(() => String(props.target?.sampleCode || '').trim())
|
const sampleCode = computed(() => String(props.target?.sampleCode || '').trim())
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
@@ -255,7 +255,8 @@
|
|||||||
if (userCachePromise) return userCachePromise
|
if (userCachePromise) return userCachePromise
|
||||||
userCachePromise = (async () => {
|
userCachePromise = (async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetchUserOptions()
|
// 同部门优先:由后端按当前登录用户部门排序
|
||||||
|
const res = await fetchUserOptions({ prioritizeCallerDept: true })
|
||||||
const list = Array.isArray(res) ? res : []
|
const list = Array.isArray(res) ? res : []
|
||||||
const next: MentionUser[] = []
|
const next: MentionUser[] = []
|
||||||
const seen = new Set<string>()
|
const seen = new Set<string>()
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ describe('resolveSampleVoidTarget', () => {
|
|||||||
receptionSource: 'cell_storage',
|
receptionSource: 'cell_storage',
|
||||||
protocolSampleId: 'ps-1',
|
protocolSampleId: 'ps-1',
|
||||||
sampleCode: 'S1',
|
sampleCode: 'S1',
|
||||||
|
labStorageCode: 'B0000108',
|
||||||
collectionProtocolId: 'p-1'
|
collectionProtocolId: 'p-1'
|
||||||
})
|
})
|
||||||
assert.deepEqual(target, {
|
assert.deepEqual(target, {
|
||||||
receptionSource: 'cell_storage',
|
receptionSource: 'cell_storage',
|
||||||
sampleId: 'ps-1',
|
sampleId: 'ps-1',
|
||||||
sampleCode: 'S1',
|
sampleCode: 'S1',
|
||||||
|
labStorageCode: 'B0000108',
|
||||||
protocolId: 'p-1'
|
protocolId: 'p-1'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export function resolveSampleVoidTarget(input: {
|
|||||||
receptionSource?: string | null
|
receptionSource?: string | null
|
||||||
protocolSampleId?: string | null
|
protocolSampleId?: string | null
|
||||||
sampleCode?: string | null
|
sampleCode?: string | null
|
||||||
|
labStorageCode?: string | null
|
||||||
collectionProtocolId?: string | null
|
collectionProtocolId?: string | null
|
||||||
fallbackSource?: string | null
|
fallbackSource?: string | null
|
||||||
}): SampleVoidTarget | null {
|
}): SampleVoidTarget | null {
|
||||||
@@ -18,12 +19,14 @@ export function resolveSampleVoidTarget(input: {
|
|||||||
if (source !== 'cell_storage' && source !== 'research_donation') return null
|
if (source !== 'cell_storage' && source !== 'research_donation') return null
|
||||||
const sampleId = String(input.protocolSampleId || '').trim()
|
const sampleId = String(input.protocolSampleId || '').trim()
|
||||||
const sampleCode = String(input.sampleCode || '').trim()
|
const sampleCode = String(input.sampleCode || '').trim()
|
||||||
|
const labStorageCode = String(input.labStorageCode || '').trim()
|
||||||
const protocolId = String(input.collectionProtocolId || '').trim()
|
const protocolId = String(input.collectionProtocolId || '').trim()
|
||||||
if (!sampleId && !sampleCode) return null
|
if (!sampleId && !sampleCode) return null
|
||||||
return {
|
return {
|
||||||
receptionSource: source,
|
receptionSource: source,
|
||||||
sampleId: sampleId || undefined,
|
sampleId: sampleId || undefined,
|
||||||
sampleCode: sampleCode || undefined,
|
sampleCode: sampleCode || undefined,
|
||||||
|
labStorageCode: labStorageCode || undefined,
|
||||||
protocolId: protocolId || undefined
|
protocolId: protocolId || undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,9 +141,10 @@
|
|||||||
<span class="sample-card__seq">{{ sIdx + 1 }}</span>
|
<span class="sample-card__seq">{{ sIdx + 1 }}</span>
|
||||||
{{ sampleTypeName(row.sampleTypeId) }}
|
{{ sampleTypeName(row.sampleTypeId) }}
|
||||||
</div>
|
</div>
|
||||||
<el-tag :type="sampleStatusTagType(String(row.sampleStatus || ''))" size="small">
|
<SampleStatusTag
|
||||||
{{ sampleStatusLabel(String(row.sampleStatus || '')) }}
|
:status="row.sampleStatus"
|
||||||
</el-tag>
|
:void-desc="row.voidDesc"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="sample-card__body">
|
<div class="sample-card__body">
|
||||||
<div class="sample-card__section">
|
<div class="sample-card__section">
|
||||||
@@ -1254,6 +1255,7 @@
|
|||||||
import SampleQcInfoGroupedPanel from '@/components/business/sample-qc-info-grouped-panel/index.vue'
|
import SampleQcInfoGroupedPanel from '@/components/business/sample-qc-info-grouped-panel/index.vue'
|
||||||
import SampleReceptionDualReadonlyPanel from '@/components/business/sample-reception-dual-readonly-panel/index.vue'
|
import SampleReceptionDualReadonlyPanel from '@/components/business/sample-reception-dual-readonly-panel/index.vue'
|
||||||
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/index.vue'
|
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/index.vue'
|
||||||
|
import SampleStatusTag from '@/components/business/sample-status-tag/index.vue'
|
||||||
import SampleProductionInfoCards from '@/components/business/sample-production-info-cards/index.vue'
|
import SampleProductionInfoCards from '@/components/business/sample-production-info-cards/index.vue'
|
||||||
import SampleStorageReleaseInfo from '@/components/business/sample-storage-release-info/index.vue'
|
import SampleStorageReleaseInfo from '@/components/business/sample-storage-release-info/index.vue'
|
||||||
import ProtocolHandlePanel from '@/components/business/protocol-handle-panel/index.vue'
|
import ProtocolHandlePanel from '@/components/business/protocol-handle-panel/index.vue'
|
||||||
@@ -1284,8 +1286,6 @@
|
|||||||
payModeTagType,
|
payModeTagType,
|
||||||
newbornSexLabel,
|
newbornSexLabel,
|
||||||
deliveryModeLabel,
|
deliveryModeLabel,
|
||||||
sampleStatusLabel,
|
|
||||||
sampleStatusTagType,
|
|
||||||
transportTypeLabel,
|
transportTypeLabel,
|
||||||
payStatusLabel,
|
payStatusLabel,
|
||||||
payStatusTagType
|
payStatusTagType
|
||||||
|
|||||||
@@ -499,6 +499,7 @@
|
|||||||
receptionSource: row.receptionSource,
|
receptionSource: row.receptionSource,
|
||||||
protocolSampleId: row.protocolSampleId,
|
protocolSampleId: row.protocolSampleId,
|
||||||
sampleCode: row.sampleCode,
|
sampleCode: row.sampleCode,
|
||||||
|
labStorageCode: row.labStorageCode,
|
||||||
collectionProtocolId: row.collectionProtocolId,
|
collectionProtocolId: row.collectionProtocolId,
|
||||||
fallbackSource: productionVoidFallbackSource(row)
|
fallbackSource: productionVoidFallbackSource(row)
|
||||||
})
|
})
|
||||||
@@ -509,6 +510,7 @@
|
|||||||
receptionSource: row.receptionSource,
|
receptionSource: row.receptionSource,
|
||||||
protocolSampleId: row.protocolSampleId,
|
protocolSampleId: row.protocolSampleId,
|
||||||
sampleCode: row.sampleCode,
|
sampleCode: row.sampleCode,
|
||||||
|
labStorageCode: row.labStorageCode,
|
||||||
collectionProtocolId: row.collectionProtocolId,
|
collectionProtocolId: row.collectionProtocolId,
|
||||||
fallbackSource: productionVoidFallbackSource(row)
|
fallbackSource: productionVoidFallbackSource(row)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -419,6 +419,7 @@
|
|||||||
receptionSource: props.row.receptionSource,
|
receptionSource: props.row.receptionSource,
|
||||||
protocolSampleId: props.row.protocolSampleId,
|
protocolSampleId: props.row.protocolSampleId,
|
||||||
sampleCode: props.row.sampleCode,
|
sampleCode: props.row.sampleCode,
|
||||||
|
labStorageCode: props.row.labStorageCode,
|
||||||
collectionProtocolId: props.row.collectionProtocolId,
|
collectionProtocolId: props.row.collectionProtocolId,
|
||||||
fallbackSource: inboundVoidFallbackSource()
|
fallbackSource: inboundVoidFallbackSource()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user