fix: P0 止血 — 消除崩溃风险 + 伪CAS修复 + 硬编码清除 + 晚间血压
- 新增 sea_orm_ext 模块: safe_version() / bump_version() 替代 14 处 unwrap() - 修复 points_service 伪 CAS 逻辑 bug: 在 Set() 前提取原始版本并重新验证 - AdminDashboard: API 失败时显示 unknown 状态而非虚假绿色 healthy - AdminDashboard: 今日操作改用真实数据,移除 "0 错误" 硬编码 - OperatorWorkbench: 移除硬编码 "美玲",改用真实用户名 - Home.tsx: operator "内容发布" 从硬编码 0 改为真实积分统计 - 小程序体征录入: 新增晚间血压 indicator_type,映射到 evening 字段
This commit is contained in:
@@ -11,7 +11,8 @@ import { trackEvent } from '@/services/analytics';
|
||||
import './index.scss';
|
||||
|
||||
const INDICATORS = [
|
||||
{ value: 'blood_pressure', label: '血压 (mmHg)' },
|
||||
{ value: 'blood_pressure', label: '晨间血压 (mmHg)' },
|
||||
{ value: 'blood_pressure_evening', label: '晚间血压 (mmHg)' },
|
||||
{ value: 'heart_rate', label: '心率 (bpm)' },
|
||||
{ value: 'blood_sugar_fasting', label: '空腹血糖 (mmol/L)' },
|
||||
{ value: 'blood_sugar_postprandial', label: '餐后血糖 (mmol/L)' },
|
||||
@@ -19,8 +20,10 @@ const INDICATORS = [
|
||||
{ value: 'temperature', label: '体温 (℃)' },
|
||||
];
|
||||
|
||||
const BP_INDICATORS = ['blood_pressure', 'blood_pressure_evening'];
|
||||
|
||||
const vitalSignSchema = z.object({
|
||||
indicator_type: z.enum(['blood_pressure', 'heart_rate', 'blood_sugar_fasting', 'blood_sugar_postprandial', 'weight', 'temperature']),
|
||||
indicator_type: z.enum(['blood_pressure', 'blood_pressure_evening', 'heart_rate', 'blood_sugar_fasting', 'blood_sugar_postprandial', 'weight', 'temperature']),
|
||||
value: z.number().positive({ message: '请输入有效数值' }),
|
||||
extra: z.object({
|
||||
systolic: z.number().min(60, '收缩压过低').max(250, '收缩压过高,请及时就医').optional(),
|
||||
@@ -34,11 +37,13 @@ function getWarnForIndicator(
|
||||
thresholds: HealthThreshold[],
|
||||
indicator: string,
|
||||
): { max?: number; min?: number; warning: string } | null {
|
||||
const high = findThreshold(thresholds, indicator === 'blood_pressure' ? 'systolic_bp' : indicator, 'high');
|
||||
const low = findThreshold(thresholds, indicator === 'blood_pressure' ? 'systolic_bp' : indicator, 'low');
|
||||
const isBp = BP_INDICATORS.includes(indicator);
|
||||
const high = findThreshold(thresholds, isBp ? 'systolic_bp' : indicator, 'high');
|
||||
const low = findThreshold(thresholds, isBp ? 'systolic_bp' : indicator, 'low');
|
||||
if (!high && !low) return null;
|
||||
const warningMap: Record<string, string> = {
|
||||
blood_pressure: '收缩压偏高,建议及时就医',
|
||||
blood_pressure_evening: '收缩压偏高,建议及时就医',
|
||||
heart_rate: '心率异常,请注意休息',
|
||||
blood_sugar_fasting: '血糖偏高,建议就医检查',
|
||||
blood_sugar_postprandial: '血糖偏高,建议就医检查',
|
||||
@@ -97,7 +102,7 @@ export default function HealthInput() {
|
||||
|
||||
const currentIndicator = INDICATORS[indicatorIdx].value;
|
||||
|
||||
if (currentIndicator === 'blood_pressure') {
|
||||
if (BP_INDICATORS.includes(currentIndicator)) {
|
||||
if (!systolic || !diastolic) {
|
||||
Taro.showToast({ title: '请填写收缩压和舒张压', icon: 'none' });
|
||||
return;
|
||||
@@ -109,8 +114,8 @@ export default function HealthInput() {
|
||||
}
|
||||
}
|
||||
|
||||
const input = currentIndicator === 'blood_pressure'
|
||||
? { indicator_type: 'blood_pressure' as const, value: parseFloat(systolic), extra: { systolic: parseFloat(systolic), diastolic: parseFloat(diastolic) } }
|
||||
const input = BP_INDICATORS.includes(currentIndicator)
|
||||
? { indicator_type: currentIndicator as 'blood_pressure' | 'blood_pressure_evening', value: parseFloat(systolic), extra: { systolic: parseFloat(systolic), diastolic: parseFloat(diastolic) } }
|
||||
: { indicator_type: currentIndicator as any, value: parseFloat(value) };
|
||||
|
||||
const result = vitalSignSchema.safeParse(input);
|
||||
@@ -188,7 +193,7 @@ export default function HealthInput() {
|
||||
</View>
|
||||
|
||||
{/* 数值输入 */}
|
||||
{INDICATORS[indicatorIdx].value === 'blood_pressure' ? (
|
||||
{BP_INDICATORS.includes(INDICATORS[indicatorIdx].value) ? (
|
||||
<View className='input-card'>
|
||||
<Text className='input-section-title'>血压数值</Text>
|
||||
<View className='input-bp-group'>
|
||||
|
||||
Reference in New Issue
Block a user