Compare commits

...
Author SHA1 Message Date
zlwuandCursor b59c921b50 fix(payment): 缴费信息列表返回样本状态与作废原因
Web 列表走 list_sample_payments_page,补齐 sampleStatus/voidDesc(#136)。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 14:51:29 +08:00
cykj b57898fabb fix(sample): 样本状态问号仅已作废时展示 (#134) (#135)
fix(sample): 样本状态问号仅已作废时展示 (#134)
2026-11-19 06:30:49 +00:00
zlwuandCursor 9fd1cc4370 fix(sample): 样本状态问号仅已作废时展示
Web SampleStatusTag 仅在 sampleStatus=yzf 时显示问号;移动市场部回归断言非作废无 help(#134)。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 14:29:07 +08:00
cykj af02e2cdd2 Merge pull request 'feat(sample): 展示样本状态并支持样本废弃与作废原因 (#131)' (#133)
feat(sample): 展示样本状态并支持样本废弃与作废原因 (#131)
2026-11-19 06:26:05 +00:00
cykj 6ddd07dbb5 feat(oa): 评论@人员优先展示同部门用户 (#117)
feat(oa): 评论@人员优先展示同部门用户 (#117)
2026-11-19 06:25:21 +00:00
zlwuandCursor f9aa16ef31 feat(oa): 评论@人员优先展示同部门用户
OA 评论选人列表改为请求 users/options 时按当前登录用户部门优先排序,Web 与移动 OA 共用后端稳定排序,便于先选到同部门同事。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 14:24:21 +08:00
10 changed files with 164 additions and 17 deletions

No files matched your search

+15 -2
View File
@@ -29,6 +29,7 @@ from app.crud import user as user_svc
from app.crud.collection_protocol import _lookup_attachment_by_url
from app.models.models import BizAttachment, SysDept, SysRole, SysUser, SysMenu, SysPost
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 (
_map_role_name_to_web,
list_user_ids_with_effective_role_name,
@@ -77,12 +78,15 @@ async def list_roles_for_select(
@router.get("/users/options")
async def list_users_for_select(
roleName: Optional[str] = Query(None, alias="roleName"),
prioritizeCallerDept: bool = Query(False, alias="prioritizeCallerDept"),
_user: dict = Depends(require_admin_or_super_admin),
db: Session = Depends(get_db),
):
"""返回用户下拉选项(label=昵称,value=用户ID),供流程设计器审批人选择使用。
"""返回用户下拉选项(label=昵称,value=用户ID,deptId=部门ID)。
供流程设计器审批人选择、OA 评论 @ 人员等使用。
可选 roleName:按有效角色(直接绑定 ∪ 职位继承)精确过滤。
可选 prioritizeCallerDept:当前登录用户同部门人员排在前面(组内仍按创建时间倒序)。
"""
tenant_no = _user.get("tenant_no", "")
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([])
q = q.filter(SysUser.id.in_(matched_ids))
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)
@@ -45,6 +45,14 @@ from app.services.sample_payment_progress import (
)
_SAMPLE_STATUS_LABELS = {
"ycj": "已采集",
"jcz": "检测中",
"yrk": "已入库",
"yzf": "已作废",
}
def _fmt_ymd8(v: Any) -> str:
s = str(v or "").strip()
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
discount = meta.get("discountAmount")
sample_status = str(meta.get("sampleStatus") or "").strip()
row: Dict[str, Any] = {
"id": sp.id,
"collectionProtocolId": sp.collection_protocol_id,
@@ -1891,6 +1900,10 @@ def _build_list_summary_row(
"motherName": (party.mother_name if party else "") or "",
"motherPhone": (party.mother_phone if party else "") 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 "",
"contractAmount": float(sp.contract_amount)
if sp.contract_amount is not None
@@ -2020,10 +2033,14 @@ def list_sample_payments_page(
discount = None
if orig is not None and price is not None and orig > price:
discount = round(orig - price, 2)
status = str(s.sample_status or "").strip()
sample_meta_by_key[key] = {
"storageYears": s.storage_years,
"sampleTypeName": type_name_map.get(s.sample_type_id or "", ""),
"discountAmount": discount,
"sampleStatus": status,
"sampleStatusLabel": _SAMPLE_STATUS_LABELS.get(status, ""),
"voidDesc": str(getattr(s, "void_desc", None) or "").strip(),
}
rows: List[Dict[str, Any]] = []
for sp, proto, party in candidates:
@@ -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,
)
@@ -1,8 +1,12 @@
"""样本缴费列表:进度过滤与分页顺序"""
"""样本缴费列表:进度过滤与分页顺序、样本状态汇总字段"""
from types import SimpleNamespace
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):
@@ -33,5 +37,65 @@ class TestFilterAndPageProgress(unittest.TestCase):
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"], "客户放弃存储")
if __name__ == "__main__":
unittest.main()
+27
View File
@@ -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,
'已入库'
)
assert.equal(
buildMarketCard('payment-chase', 'specialist', {
sampleCode: 'S-1', sampleStatus: 'jcz'
}).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: '作废客户',
@@ -216,7 +216,8 @@ async function ensureUserCache() {
if (userCachePromise) return userCachePromise
userCachePromise = (async () => {
try {
const res = await fetchUserOptions()
// 同部门优先:由后端按当前登录用户部门排序
const res = await fetchUserOptions({ prioritizeCallerDept: true })
const list = Array.isArray(res) ? res : res?.list || []
const next = []
const seen = new Set()
+6 -3
View File
@@ -22,9 +22,12 @@ export function fetchGetRoleList() {
})
}
/** 流程设计器:用户下拉选项(label=昵称,value=用户ID) */
export function fetchUserOptions(params?: { roleName?: string }) {
return request.get<Array<{ label: string; value: string }>>({
/** 用户下拉选项(label=昵称,value=用户ID;可选 deptId / prioritizeCallerDept) */
export function fetchUserOptions(params?: {
roleName?: string
prioritizeCallerDept?: boolean
}) {
return request.get<Array<{ label: string; value: string; deptId?: string }>>({
url: '/web/admin/users/options',
params
})
@@ -1,8 +1,8 @@
<!-- 样本状态:标签 + 作废原因 -->
<!-- 样本状态:标签;仅已作废时展示问号与作废原因 -->
<template>
<span class="sample-status-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>
<button type="button" class="sample-status-tag__q" aria-label="作废原因" @click.stop>
<el-icon><QuestionFilled /></el-icon>
@@ -31,6 +31,8 @@
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>
@@ -255,7 +255,8 @@
if (userCachePromise) return userCachePromise
userCachePromise = (async () => {
try {
const res = await fetchUserOptions()
// 同部门优先:由后端按当前登录用户部门排序
const res = await fetchUserOptions({ prioritizeCallerDept: true })
const list = Array.isArray(res) ? res : []
const next: MentionUser[] = []
const seen = new Set<string>()