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] || '' }}