diff --git a/inventory-backend/app/api/v1/outbound.py b/inventory-backend/app/api/v1/outbound.py index d3e5019..b5896ed 100644 --- a/inventory-backend/app/api/v1/outbound.py +++ b/inventory-backend/app/api/v1/outbound.py @@ -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, ) diff --git a/inventory-backend/app/services/outbound_service.py b/inventory-backend/app/services/outbound_service.py index 6b86b92..7b03c33 100644 --- a/inventory-backend/app/services/outbound_service.py +++ b/inventory-backend/app/services/outbound_service.py @@ -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: