feat(detailedReport): 基础指标label写死缺失显示-、躯干四肢无数据隐藏

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-09-03 11:45:39 +08:00
co-authored by Claude Opus 4.7
parent fb7c33c05f
commit bf501de628
@@ -124,6 +124,15 @@ const BMI_TYPE_COLOR: Record<string, string> = {
: '#F24439',
}
/** 基础指标:label 前端写死 */
const BASIC_INDICATORS: { key: string; label: string }[] = [
{ key: 'ppWeightKg', label: '体重' },
{ key: 'ppBMI', label: 'BMI' },
{ key: 'ppFat', label: '体脂率' },
{ key: 'ppBodyScore', label: '健康评分' },
{ key: 'ppBodyHealth', label: '健康评价' },
]
/** 将 bodyDataList 转为 key -> 指标 的映射 */
const toMap = (list: LefuBodyDatum[] = []): Record<string, LefuBodyDatum> => {
const map: Record<string, LefuBodyDatum> = {}
@@ -259,21 +268,22 @@ Page({
changeText,
}
// 基础指标(2 行 x 3 列,第 6 格留空保持布局)
const basicKeys = ['ppWeightKg', 'ppBMI', 'ppFat', 'ppBodyScore', 'ppBodyHealth']
const basicCells: BasicCell[] = basicKeys.map((k) => {
const d = map[k]
if (!d) return { ...EMPTY_BASIC_CELL }
const isScore = k === 'ppBodyScore'
const isHealth = k === 'ppBodyHealth'
const isBmi = k === 'ppBMI'
// 基础指标(2 行 x 3 列,第 6 格留空保持布局label 前端写死,缺失值显示 -
const basicCells: BasicCell[] = BASIC_INDICATORS.map(({ key, label }) => {
const d = map[key]
const isScore = key === 'ppBodyScore'
const isHealth = key === 'ppBodyHealth'
const isBmi = key === 'ppBMI'
if (!d) {
return { label, labelExtra: '', labelExtraColor: '', value: '-', unit: '' }
}
return {
label: d.bodyParamName || k,
label,
// BMI 名称后跟体型状态(消瘦/正常/超重/肥胖)
labelExtra: isBmi ? data.bmiType || '' : '',
labelExtraColor: isBmi ? BMI_TYPE_COLOR[data.bmiType || ''] || DEFAULT_STATUS_COLOR : '',
// 健康评价展示等级文案(如"亚健康"),其余展示测量数值
value: isHealth ? d.standardTitle || d.currentValue || '' : d.currentValue || '',
value: isHealth ? d.standardTitle || d.currentValue || '-' : d.currentValue || '-',
// 健康评分补"分"
unit: isScore ? d.unit || '分' : isHealth ? '' : d.unit || '',
}
@@ -350,7 +360,8 @@ Page({
['右腿', 'ppBodyFatKgRightLeg', 'ppBodyFatRateRightLeg'],
['躯干', 'ppBodyFatKgTrunk', 'ppBodyFatRateTrunk'],
]
const bodyFat = isEight
const hasBodyFatData = fatPartLabels.some(([, massKey, rateKey]) => map[massKey] || map[rateKey])
const bodyFat = isEight && hasBodyFatData
? {
title: '躯干/四肢脂肪',
rows: chunkParts(
@@ -368,7 +379,8 @@ Page({
['右腿', 'ppMuscleKgRightLeg', 'ppMuscleRateRightLeg'],
['躯干', 'ppMuscleKgTrunk', 'ppMuscleRateTrunk'],
]
const bodyMuscle = isEight
const hasBodyMuscleData = musclePartLabels.some(([, massKey, rateKey]) => map[massKey] || map[rateKey])
const bodyMuscle = isEight && hasBodyMuscleData
? {
title: '躯干/四肢肌肉',
rows: chunkParts(