fix(outbound): 出库列表补传日期参数,修复日期筛选静默失效
前端 el-date-picker 一直传 start_date/end_date(outbound/index.vue:472),
service 层 get_grouped_list() 也早有完整实现(签名接收 + 10 位日期补全
时分秒 + outbound_time 过滤),但中间 API 层从未读取这两个参数:
outbound.py: get_outbound_list() 只读 page/limit/keyword/search_type/
company/advancedFilters,调用 get_grouped_list() 时也没传日期。
get_grouped_list 全项目仅此一个调用方,因此 start_date/end_date 恒为
None,service 层 `if start_date and end_date:` 永远为假——用户在页面上
选了日期,后端直接忽略,结果集与不筛选时完全一致,且不报错。
修复:
· outbound.py 读取 start_date/end_date 并透传给 service
· outbound_service.py 把 BETWEEN 改为分别判断(原写法只传一侧时
整段条件静默失效,与 /returns 等接口的边界处理对齐)
实测验证(SUPER_ADMIN 全量口径,与 SQL count(distinct outbound_no) 逐项对齐):
无日期 494 (基准)
2026-08-24 单日 3 SQL=3
2026-05-11 单日 9 SQL=9
2026-08 整月 88 SQL=88
只传 start_date 229 SQL=229
修复前上述四项均恒等于 494。运行中容器经 --reload 重载后实测一致。
影响范围:仅出库主列表。其余带日期筛选的接口(/returns、transactions、
scrap、purchase、audit、inbound_summary)均已正确读取参数,未受影响。
This commit is contained in:
@ -238,6 +238,10 @@ def get_outbound_list():
|
||||
keyword = request.args.get('keyword', '')
|
||||
search_type = request.args.get('search_type', 'all')
|
||||
company = request.args.get('company', '')
|
||||
# ★ 出库日期范围:前端 el-date-picker 传 10 位 YYYY-MM-DD,
|
||||
# 时分秒补全在 service 层完成(与 /returns 等处口径一致)
|
||||
start_date = (request.args.get('start_date') or '').strip()
|
||||
end_date = (request.args.get('end_date') or '').strip()
|
||||
|
||||
# ★ 高级筛选:JSON 字符串 → 条件列表(解析失败退化为空,不影响主查询)
|
||||
from app.utils.advanced_filter import parse_advanced_filters
|
||||
@ -259,6 +263,7 @@ def get_outbound_list():
|
||||
# ★ [修改] 调用分组查询服务,支持搜索类型
|
||||
result = OutboundService.get_grouped_list(
|
||||
page, limit, keyword, search_type=search_type,
|
||||
start_date=start_date, end_date=end_date,
|
||||
company=company, consumer_name=consumer_name,
|
||||
advanced_filters=advanced_filters,
|
||||
)
|
||||
|
||||
@ -708,8 +708,11 @@ class OutboundService:
|
||||
)
|
||||
continue
|
||||
|
||||
if start_date and end_date:
|
||||
stmt = stmt.filter(TransOutbound.outbound_time.between(start_date, end_date))
|
||||
# ★ 日期边界分别判断:用 BETWEEN 时若只传一侧会整段静默失效
|
||||
if start_date:
|
||||
stmt = stmt.filter(TransOutbound.outbound_time >= start_date)
|
||||
if end_date:
|
||||
stmt = stmt.filter(TransOutbound.outbound_time <= end_date)
|
||||
|
||||
# 【行级数据隔离】应用公司过滤到主查询
|
||||
if company_limit is not None:
|
||||
|
||||
Reference in New Issue
Block a user