fix(qc): 科研捐赠协议状态筛选空选与 mine 漏传 #166
No files matched your search
@@ -1178,6 +1178,9 @@ async def list_my_qc_tasks(
|
||||
qcBizType: Optional[str] = None,
|
||||
receptionSource: Optional[str] = Query(None, alias="receptionSource"),
|
||||
bizType: Optional[str] = Query(None, alias="bizType"),
|
||||
protocolStatus: Optional[str] = Query(
|
||||
None, alias="protocolStatus", description="协议/捐赠状态,多个用英文逗号分隔"
|
||||
),
|
||||
db: Session = Depends(get_db),
|
||||
user: dict = Depends(require_menu_code("biz:myQcTask:list")),
|
||||
):
|
||||
@@ -1194,6 +1197,7 @@ async def list_my_qc_tasks(
|
||||
qc_biz_type=qcBizType,
|
||||
reception_source=receptionSource,
|
||||
biz_type=bizType,
|
||||
protocol_status=protocolStatus,
|
||||
tenant_no=tenant_no,
|
||||
)
|
||||
return success_response(_page_payload(items, total, page, pageSize))
|
||||
|
||||
@@ -23,14 +23,14 @@ def resolve_research_donation_protocol_status_filter(
|
||||
|
||||
Returns:
|
||||
("in", statuses) — 按所选状态 IN 过滤
|
||||
("none", []) — 显式空选择,无匹配结果
|
||||
("all", []) — 显式空选择,不限制协议状态
|
||||
("default", DEFAULT_QC_DONATION_PROTOCOL_STATUSES) — 未传参,与列表默认一致
|
||||
"""
|
||||
if protocol_status is None:
|
||||
return ("default", list(DEFAULT_QC_DONATION_PROTOCOL_STATUSES))
|
||||
statuses = [s.strip() for s in str(protocol_status).split(",") if s.strip()]
|
||||
if not statuses:
|
||||
return ("none", [])
|
||||
return ("all", [])
|
||||
return ("in", statuses)
|
||||
|
||||
_PROTOCOL_STATUS_LABELS = {
|
||||
|
||||
@@ -19,6 +19,7 @@ from app.crud.qc_work_order import (
|
||||
_sample_type_name_for_reception,
|
||||
_work_order_qc_biz_type,
|
||||
_OUTBOUND_BIZ_TYPE_LABELS,
|
||||
apply_research_donation_protocol_status_filter,
|
||||
build_work_order_list_summaries,
|
||||
)
|
||||
from app.core.db_collation import eq_unicode, unicode_ci
|
||||
@@ -574,6 +575,7 @@ def list_mine_tasks(
|
||||
qc_biz_type: Optional[str] = None,
|
||||
reception_source: Optional[str] = None,
|
||||
biz_type: Optional[str] = None,
|
||||
protocol_status: Optional[str] = None,
|
||||
tenant_no: Optional[str] = None,
|
||||
) -> Tuple[List[Dict[str, Any]], int]:
|
||||
def _filtered():
|
||||
@@ -632,6 +634,11 @@ def list_mine_tasks(
|
||||
bt_out = (biz_type or "").strip()
|
||||
if bt_out:
|
||||
q0 = q0.filter(BizQcWorkOrder.biz_type == bt_out)
|
||||
q0 = apply_research_donation_protocol_status_filter(
|
||||
q0,
|
||||
protocol_status,
|
||||
reception_source=reception_source,
|
||||
)
|
||||
return q0
|
||||
|
||||
total = _filtered().order_by(None).with_entities(func.count(BizQcTask.id)).scalar() or 0
|
||||
|
||||
@@ -1718,8 +1718,8 @@ def apply_research_donation_protocol_status_filter(
|
||||
return query
|
||||
|
||||
mode, statuses = resolve_research_donation_protocol_status_filter(protocol_status)
|
||||
if mode == "none":
|
||||
return query.filter(BizQcWorkOrder.id.in_([]))
|
||||
if mode == "all":
|
||||
return query
|
||||
if mode == "in":
|
||||
return query.filter(_research_donation_status_exists(statuses))
|
||||
# default:与前端默认勾选一致
|
||||
|
||||
@@ -17,8 +17,8 @@ def test_explicit_statuses_returned():
|
||||
assert resolve_research_donation_protocol_status_filter("dsx,sxz") == ("in", ["dsx", "sxz"])
|
||||
|
||||
|
||||
def test_explicit_empty_means_none():
|
||||
assert resolve_research_donation_protocol_status_filter("") == ("none", [])
|
||||
def test_explicit_empty_means_all():
|
||||
assert resolve_research_donation_protocol_status_filter("") == ("all", [])
|
||||
|
||||
|
||||
def test_missing_means_default_dsx_sxz():
|
||||
@@ -27,5 +27,5 @@ def test_missing_means_default_dsx_sxz():
|
||||
assert statuses == ["dsx", "sxz"]
|
||||
|
||||
|
||||
def test_whitespace_only_means_none():
|
||||
assert resolve_research_donation_protocol_status_filter(" , ") == ("none", [])
|
||||
def test_whitespace_only_means_all():
|
||||
assert resolve_research_donation_protocol_status_filter(" , ") == ("all", [])
|
||||
@@ -170,6 +170,8 @@ export function fetchMyQcTaskList(params?: {
|
||||
qcBizType?: string
|
||||
receptionSource?: string
|
||||
bizType?: string
|
||||
/** 科研捐赠:协议/捐赠状态,多个逗号分隔;空串=不限制 */
|
||||
protocolStatus?: string
|
||||
}) {
|
||||
return request.get<PageList<QcTask>>({
|
||||
url: '/web/admin/qc-tasks/mine',
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('donation protocol status filter helpers', () => {
|
||||
|
||||
it('matchesProtocolStatusFilter semantics', () => {
|
||||
assert.equal(matchesProtocolStatusFilter('yzf', undefined), true)
|
||||
assert.equal(matchesProtocolStatusFilter('yzf', []), false)
|
||||
assert.equal(matchesProtocolStatusFilter('yzf', []), true)
|
||||
assert.equal(matchesProtocolStatusFilter('sxz', ['dsx', 'sxz']), true)
|
||||
assert.equal(matchesProtocolStatusFilter('yzf', ['dsx', 'sxz']), false)
|
||||
assert.equal(matchesProtocolStatusFilter('', ['dsx']), false)
|
||||
|
||||
@@ -18,7 +18,7 @@ export const DEFAULT_DONATION_PROTOCOL_STATUS_FILTER = ['dsx', 'sxz']
|
||||
/**
|
||||
* 拼协议状态查询参数。
|
||||
* - 有选中:逗号串
|
||||
* - 空数组:返回 ''(显式空;勿当 undefined)
|
||||
* - 空数组:返回 ''(显式空=不限制;勿当 undefined,undefined 会走后端默认勾选)
|
||||
*/
|
||||
export function joinProtocolStatusFilter(statuses: string[]): string {
|
||||
return statuses.map((s) => s.trim()).filter(Boolean).join(',')
|
||||
@@ -27,13 +27,12 @@ export function joinProtocolStatusFilter(statuses: string[]): string {
|
||||
/**
|
||||
* 协议状态是否命中筛选。
|
||||
* - filter === undefined:不限制
|
||||
* - filter 为空数组:无匹配
|
||||
* - filter 为空数组:不限制(显式清空)
|
||||
*/
|
||||
export function matchesProtocolStatusFilter(
|
||||
status: string,
|
||||
filter: string[] | undefined
|
||||
): boolean {
|
||||
if (filter === undefined) return true
|
||||
if (!filter.length) return false
|
||||
if (filter === undefined || !filter.length) return true
|
||||
return filter.includes((status || '').trim())
|
||||
}
|
||||
@@ -27,13 +27,15 @@ export type QcTaskMineFilters = {
|
||||
keyword?: string
|
||||
taskType?: string
|
||||
taskStatus?: string
|
||||
/** 科研捐赠:协议状态逗号串;''=不限制;缺省不传 */
|
||||
protocolStatus?: string
|
||||
tabKey: QcWorkOrderTabKey
|
||||
}
|
||||
|
||||
export type MineWorkOrderSearchFilters = {
|
||||
keyword?: string
|
||||
workOrderStatus?: string | string[]
|
||||
/** 科研捐赠 Tab:协议/捐赠状态多选;undefined=不限制;[]=无匹配 */
|
||||
/** 科研捐赠 Tab:协议/捐赠状态多选;undefined/[]=不限制 */
|
||||
protocolStatus?: string[]
|
||||
triggerSource?: string
|
||||
qcCategory?: string
|
||||
@@ -145,6 +147,8 @@ export async function fetchAllMineTasks(filters: QcTaskMineFilters): Promise<QcT
|
||||
let page = 1
|
||||
const all: QcTask[] = []
|
||||
let total = 0
|
||||
const protocolStatusParam =
|
||||
filters.tabKey === 'inbound_research_donation' ? (filters.protocolStatus ?? '') : undefined
|
||||
while (true) {
|
||||
const res = await fetchMyQcTaskList({
|
||||
page,
|
||||
@@ -154,7 +158,8 @@ export async function fetchAllMineTasks(filters: QcTaskMineFilters): Promise<QcT
|
||||
taskStatus: filters.taskStatus || undefined,
|
||||
qcBizType: listQuery.workOrderType,
|
||||
receptionSource: listQuery.receptionSource,
|
||||
bizType: listQuery.bizType
|
||||
bizType: listQuery.bizType,
|
||||
...(protocolStatusParam !== undefined ? { protocolStatus: protocolStatusParam } : {})
|
||||
})
|
||||
const list = res.list || []
|
||||
all.push(...list)
|
||||
|
||||
+4
-6
@@ -153,6 +153,10 @@ export function useQcWorkOrderTabPage(
|
||||
keyword: searchForm.keyword || undefined,
|
||||
taskStatus: searchForm.taskStatus || undefined,
|
||||
taskType: searchForm.taskType || undefined,
|
||||
protocolStatus:
|
||||
tabKey.value === 'inbound_research_donation'
|
||||
? joinProtocolStatusFilter(searchForm.protocolStatus)
|
||||
: undefined,
|
||||
tabKey: tabKey.value
|
||||
})
|
||||
let entries = groupMineTasksByWorkOrder(tasks)
|
||||
@@ -172,12 +176,6 @@ export function useQcWorkOrderTabPage(
|
||||
}
|
||||
|
||||
const tab = tabConfig.value
|
||||
if (tabKey.value === 'inbound_research_donation' && !searchForm.protocolStatus.length) {
|
||||
tableData.value = []
|
||||
presetBatchesByWorkOrderId.value = undefined
|
||||
pagination.total = 0
|
||||
return
|
||||
}
|
||||
const timeParams =
|
||||
isAllQcWorkOrderTab(tabKey.value) || !tabUsesInfusionTimeFilter(tab)
|
||||
? {
|
||||
|
||||
Reference in new issue
Block a user