- {renderHeader()}
-
-
- 暂无趋势数据
-
+
+
+ 暂无{LABEL}趋势数据
);
}
- const config = {
- data,
- xField: 'date',
- yField: 'value',
- smooth: true,
- height: 180,
- point: { shapeField: 'circle', sizeField: 3 },
- axis: {
- x: { labelAutoRotate: false },
- y: { title: unit || undefined },
- },
- style: {
- lineWidth: 2,
- },
- };
+ const latestValue = data[data.length - 1].value;
return (
- {renderHeader()}
-
-
+
+ {LABEL}趋势
+ {latestValue != null && (
+
+ 最新:{latestValue} {UNIT}
+
+ )}
+
);
}
diff --git a/crates/erp-health/src/dto/health_data_dto.rs b/crates/erp-health/src/dto/health_data_dto.rs
index 9e73f84..90b9608 100644
--- a/crates/erp-health/src/dto/health_data_dto.rs
+++ b/crates/erp-health/src/dto/health_data_dto.rs
@@ -192,7 +192,7 @@ pub struct TrendResp {
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct IndicatorTimeseriesResp {
pub indicator: String,
- pub data: Vec<(NaiveDate, f64)>,
+ pub data: Vec
,
}
// ---------------------------------------------------------------------------
diff --git a/crates/erp-health/src/service/trend_service.rs b/crates/erp-health/src/service/trend_service.rs
index 2ce542a..4c064ca 100644
--- a/crates/erp-health/src/service/trend_service.rs
+++ b/crates/erp-health/src/service/trend_service.rs
@@ -214,7 +214,7 @@ pub async fn get_indicator_timeseries(
.all(&state.db)
.await?;
- let data: Vec<(chrono::NaiveDate, f64)> = vitals.into_iter().filter_map(|v| {
+ let data: Vec = vitals.into_iter().filter_map(|v| {
let val = match indicator.as_str() {
"heart_rate" => v.heart_rate.map(|x| x as f64),
"weight" => v.weight.map(|d| d.to_f64().unwrap_or(0.0)),
@@ -225,7 +225,10 @@ pub async fn get_indicator_timeseries(
"diastolic_bp_evening" => v.diastolic_bp_evening.map(|x| x as f64),
_ => None,
};
- val.map(|fv| (v.record_date, fv))
+ val.map(|fv| DataPoint {
+ date: v.record_date.to_string(),
+ value: fv,
+ })
}).collect();
Ok(IndicatorTimeseriesResp { indicator, data })
@@ -393,15 +396,8 @@ pub async fn get_mini_trend(
)
.await?;
- // 4. 转换为 DataPoint 格式
- let data_points = timeseries
- .data
- .into_iter()
- .map(|(date, value)| DataPoint {
- date: date.to_string(),
- value,
- })
- .collect();
+ // 4. 直接使用 DataPoint
+ let data_points = timeseries.data;
Ok(MiniTrendResp {
indicator,