From a163ac17666fdcefcf7bdb5788a70c65cbb5cf16 Mon Sep 17 00:00:00 2001 From: li Date: Sat, 14 Mar 2026 23:14:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=81=A5=E5=BA=B7=E6=8C=87=E6=A0=87?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AD=97=E6=AE=B5=E5=90=8D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/Http/Controllers/Client/CareController.php | 7 +++++-- client/src/views/grow/HealthMetrics.vue | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/app/Http/Controllers/Client/CareController.php b/backend/app/Http/Controllers/Client/CareController.php index 9f374bf..854a172 100644 --- a/backend/app/Http/Controllers/Client/CareController.php +++ b/backend/app/Http/Controllers/Client/CareController.php @@ -80,10 +80,13 @@ class CareController extends Controller ->where('care_profile_id', $profile->id); if ($request->filled('metric_type')) { - $query->where('metric_type', $request->input('metric_type')); + $query->where('metric_type', (string) $request->input('metric_type')); } - $list = $query->orderByDesc('measured_at')->limit(30)->get(); + $limit = (int) $request->input('limit', 30); + $limit = max(1, min($limit, 50)); + + $list = $query->orderByDesc('recorded_at')->limit($limit)->get(); return $this->success($list); } diff --git a/client/src/views/grow/HealthMetrics.vue b/client/src/views/grow/HealthMetrics.vue index f675a8d..603da77 100644 --- a/client/src/views/grow/HealthMetrics.vue +++ b/client/src/views/grow/HealthMetrics.vue @@ -32,7 +32,7 @@ onMounted(async () => {
{{ metricTypeLabel[m.metric_type] || '指标' }} - {{ m.measured_at?.slice(0, 16) }} + {{ m.recorded_at?.slice(0, 16) }}
{{ m.value }} {{ metricUnit[m.metric_type] || '' }}