feat(detailedReport): 基础指标label写死缺失显示-、躯干四肢无数据隐藏
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
fb7c33c05f
commit
bf501de628
@@ -124,6 +124,15 @@ const BMI_TYPE_COLOR: Record<string, string> = {
|
|||||||
肥胖: '#F24439',
|
肥胖: '#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 -> 指标 的映射 */
|
/** 将 bodyDataList 转为 key -> 指标 的映射 */
|
||||||
const toMap = (list: LefuBodyDatum[] = []): Record<string, LefuBodyDatum> => {
|
const toMap = (list: LefuBodyDatum[] = []): Record<string, LefuBodyDatum> => {
|
||||||
const map: Record<string, LefuBodyDatum> = {}
|
const map: Record<string, LefuBodyDatum> = {}
|
||||||
@@ -259,21 +268,22 @@ Page({
|
|||||||
changeText,
|
changeText,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 基础指标(2 行 x 3 列,第 6 格留空保持布局)
|
// 基础指标(2 行 x 3 列,第 6 格留空保持布局;label 前端写死,缺失值显示 -)
|
||||||
const basicKeys = ['ppWeightKg', 'ppBMI', 'ppFat', 'ppBodyScore', 'ppBodyHealth']
|
const basicCells: BasicCell[] = BASIC_INDICATORS.map(({ key, label }) => {
|
||||||
const basicCells: BasicCell[] = basicKeys.map((k) => {
|
const d = map[key]
|
||||||
const d = map[k]
|
const isScore = key === 'ppBodyScore'
|
||||||
if (!d) return { ...EMPTY_BASIC_CELL }
|
const isHealth = key === 'ppBodyHealth'
|
||||||
const isScore = k === 'ppBodyScore'
|
const isBmi = key === 'ppBMI'
|
||||||
const isHealth = k === 'ppBodyHealth'
|
if (!d) {
|
||||||
const isBmi = k === 'ppBMI'
|
return { label, labelExtra: '', labelExtraColor: '', value: '-', unit: '' }
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
label: d.bodyParamName || k,
|
label,
|
||||||
// BMI 名称后跟体型状态(消瘦/正常/超重/肥胖)
|
// BMI 名称后跟体型状态(消瘦/正常/超重/肥胖)
|
||||||
labelExtra: isBmi ? data.bmiType || '' : '',
|
labelExtra: isBmi ? data.bmiType || '' : '',
|
||||||
labelExtraColor: isBmi ? BMI_TYPE_COLOR[data.bmiType || ''] || DEFAULT_STATUS_COLOR : '',
|
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 || '',
|
unit: isScore ? d.unit || '分' : isHealth ? '' : d.unit || '',
|
||||||
}
|
}
|
||||||
@@ -350,7 +360,8 @@ Page({
|
|||||||
['右腿', 'ppBodyFatKgRightLeg', 'ppBodyFatRateRightLeg'],
|
['右腿', 'ppBodyFatKgRightLeg', 'ppBodyFatRateRightLeg'],
|
||||||
['躯干', 'ppBodyFatKgTrunk', 'ppBodyFatRateTrunk'],
|
['躯干', 'ppBodyFatKgTrunk', 'ppBodyFatRateTrunk'],
|
||||||
]
|
]
|
||||||
const bodyFat = isEight
|
const hasBodyFatData = fatPartLabels.some(([, massKey, rateKey]) => map[massKey] || map[rateKey])
|
||||||
|
const bodyFat = isEight && hasBodyFatData
|
||||||
? {
|
? {
|
||||||
title: '躯干/四肢脂肪',
|
title: '躯干/四肢脂肪',
|
||||||
rows: chunkParts(
|
rows: chunkParts(
|
||||||
@@ -368,7 +379,8 @@ Page({
|
|||||||
['右腿', 'ppMuscleKgRightLeg', 'ppMuscleRateRightLeg'],
|
['右腿', 'ppMuscleKgRightLeg', 'ppMuscleRateRightLeg'],
|
||||||
['躯干', 'ppMuscleKgTrunk', 'ppMuscleRateTrunk'],
|
['躯干', 'ppMuscleKgTrunk', 'ppMuscleRateTrunk'],
|
||||||
]
|
]
|
||||||
const bodyMuscle = isEight
|
const hasBodyMuscleData = musclePartLabels.some(([, massKey, rateKey]) => map[massKey] || map[rateKey])
|
||||||
|
const bodyMuscle = isEight && hasBodyMuscleData
|
||||||
? {
|
? {
|
||||||
title: '躯干/四肢肌肉',
|
title: '躯干/四肢肌肉',
|
||||||
rows: chunkParts(
|
rows: chunkParts(
|
||||||
|
|||||||
Reference in New Issue
Block a user