diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 18c28131a..c0eb6a5f7 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -403,7 +403,8 @@ class Pages extends Controller // 筛选栏的月份选择器提交 Y-m,这里补成当月 1 号再匹配。 $requested .= '-01'; } - $month = in_array($requested, $months, true) ? $requested : ($months[0] ?? null); + // 明确指定月份时严格按该月份取数(该月没算出来就显示空表),避免筛选条件与数据不一致。 + $month = $requested !== '' ? $requested : ($months[0] ?? null); $limit = min(max((int) setting('default.list_limit', 25), 1), 50); $page = max((int) request('page', 1), 1); @@ -493,7 +494,7 @@ class Pages extends Controller ->where('status', 'computed')->orderByDesc('report_month')->pluck('report_month') ->map(static fn ($month): string => substr((string) $month, 0, 10))->all(); $requested = substr(trim((string) $request->query('month', '')), 0, 10); - $month = in_array($requested, $months, true) ? $requested : ($months[0] ?? null); + $month = $requested !== '' ? $requested : ($months[0] ?? null); $query = DB::connection($connection)->table('product_monthly_weighted_average_rows'); if ($month !== null) {