feat(miniprogram): 血压录入跳焦 + 历史参考值 (U2-2)
- 收缩压 onConfirm 自动聚焦到舒张压输入框 - 显示上次血压测量值作为参考 - 新增 .input-field-ref 样式
This commit is contained in:
@@ -149,6 +149,12 @@
|
|||||||
margin-bottom: var(--tk-gap-xs);
|
margin-bottom: var(--tk-gap-xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-field-ref {
|
||||||
|
color: var(--tk-text-secondary);
|
||||||
|
font-size: var(--tk-font-cap);
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.input-bp-divider {
|
.input-bp-divider {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ export default function HealthInput() {
|
|||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const { safeSetTimeout } = useSafeTimeout();
|
const { safeSetTimeout } = useSafeTimeout();
|
||||||
const [loadingThresholds, setLoadingThresholds] = useState(true);
|
const [loadingThresholds, setLoadingThresholds] = useState(true);
|
||||||
|
const [focusedField, setFocusedField] = useState<string | null>(null);
|
||||||
|
const [lastBp, setLastBp] = useState<{ systolic: number; diastolic: number } | null>(null);
|
||||||
const currentPatient = useAuthStore((s) => s.currentPatient);
|
const currentPatient = useAuthStore((s) => s.currentPatient);
|
||||||
const clearCache = useHealthStore((s) => s.clearCache);
|
const clearCache = useHealthStore((s) => s.clearCache);
|
||||||
|
|
||||||
@@ -102,7 +104,24 @@ export default function HealthInput() {
|
|||||||
} catch {
|
} catch {
|
||||||
// 解析失败则忽略,不影响正常使用
|
// 解析失败则忽略,不影响正常使用
|
||||||
}
|
}
|
||||||
}, []);
|
|
||||||
|
// 加载上次血压参考值
|
||||||
|
try {
|
||||||
|
const pid = currentPatient?.id;
|
||||||
|
if (pid) {
|
||||||
|
const res = await import('../../../services/request').then((m) => m.api);
|
||||||
|
const data = await res.get<{ data: Array<{ morning_bp_systolic?: number; morning_bp_diastolic?: number }> }>(
|
||||||
|
`/health/patients/${pid}/daily-monitoring`,
|
||||||
|
{ page: 1, page_size: 1 },
|
||||||
|
);
|
||||||
|
const items = Array.isArray(data) ? data : (data as Record<string, unknown>)?.data;
|
||||||
|
const latest = Array.isArray(items) ? items[0] : null;
|
||||||
|
if (latest?.morning_bp_systolic && latest?.morning_bp_diastolic) {
|
||||||
|
setLastBp({ systolic: latest.morning_bp_systolic, diastolic: latest.morning_bp_diastolic });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch { /* 不影响主流程 */ }
|
||||||
|
}, [currentPatient?.id]);
|
||||||
|
|
||||||
usePageData(loadThresholdsAndSync, { throttleMs: 10000 });
|
usePageData(loadThresholdsAndSync, { throttleMs: 10000 });
|
||||||
|
|
||||||
@@ -226,13 +245,18 @@ export default function HealthInput() {
|
|||||||
<Text className='input-section-title'>血压数值</Text>
|
<Text className='input-section-title'>血压数值</Text>
|
||||||
<View className='input-bp-group'>
|
<View className='input-bp-group'>
|
||||||
<View className='input-bp-field'>
|
<View className='input-bp-field'>
|
||||||
<Text className='input-field-label'>收缩压</Text>
|
<Text className='input-field-label'>
|
||||||
|
收缩压
|
||||||
|
{lastBp && <Text className='input-field-ref'>上次 {lastBp.systolic}</Text>}
|
||||||
|
</Text>
|
||||||
<Input
|
<Input
|
||||||
type='digit'
|
type='digit'
|
||||||
className='input-field-box'
|
className='input-field-box'
|
||||||
placeholder='如 120'
|
placeholder='如 120'
|
||||||
value={systolic}
|
value={systolic}
|
||||||
|
focus={focusedField === 'systolic'}
|
||||||
onInput={(e) => setSystolic(e.detail.value)}
|
onInput={(e) => setSystolic(e.detail.value)}
|
||||||
|
onConfirm={() => setFocusedField('diastolic')}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View className='input-bp-divider'>
|
<View className='input-bp-divider'>
|
||||||
@@ -241,13 +265,18 @@ export default function HealthInput() {
|
|||||||
<View className='input-bp-line' />
|
<View className='input-bp-line' />
|
||||||
</View>
|
</View>
|
||||||
<View className='input-bp-field'>
|
<View className='input-bp-field'>
|
||||||
<Text className='input-field-label'>舒张压</Text>
|
<Text className='input-field-label'>
|
||||||
|
舒张压
|
||||||
|
{lastBp && <Text className='input-field-ref'>上次 {lastBp.diastolic}</Text>}
|
||||||
|
</Text>
|
||||||
<Input
|
<Input
|
||||||
type='digit'
|
type='digit'
|
||||||
className='input-field-box'
|
className='input-field-box'
|
||||||
placeholder='如 80'
|
placeholder='如 80'
|
||||||
value={diastolic}
|
value={diastolic}
|
||||||
|
focus={focusedField === 'diastolic'}
|
||||||
onInput={(e) => setDiastolic(e.detail.value)}
|
onInput={(e) => setDiastolic(e.detail.value)}
|
||||||
|
onConfirm={() => setFocusedField(null)}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user