Переглянути джерело

feat(health): 添加血糖和血压记录的颜色标识及异常预警功能

- 为血糖记录项添加根据值和类型的颜色背景
- 为血压记录项添加基于收缩压和舒张压的颜色背景
- 实现 getItemColor 函数用于判断血糖和血压颜色
- 添加血糖异常弹窗提醒(空腹血糖>7.0)
- 添加血压异常弹窗提醒(血压>140/90)
- 使用 Bootstrap 风格颜色区分正常、警告和异常状态
mcbaiyun 1 місяць тому
батько
коміт
8b075df415

+ 33 - 1
src/pages/patient/health/details/blood-glucose.vue

@@ -30,7 +30,7 @@
 
       <view class="list">
         <view v-if="records.length === 0" class="empty">暂无记录,点击右下角 + 添加</view>
-        <view v-for="item in records" :key="item.id" class="list-item">
+        <view v-for="item in records" :key="item.id" class="list-item" :style="{ backgroundColor: getItemColor(item.value, item.type) }">
           <view class="date">{{ item.date }}</view>
           <view class="value">{{ item.value }} mmol/L · {{ item.type }}</view>
           <button class="btn-delete" @click="confirmDeleteRecord(item.id)">✕</button>
@@ -208,6 +208,28 @@ const averageGlucose = computed(() => {
   return (sum / records.value.length).toFixed(1)
 })
 
+// 根据血糖值获取颜色
+function getItemColor(value: number, type: string): string {
+  if (type === '空腹') {
+    if (value > 7.0) {
+      return '#f8d7da' // 红
+    } else if (value > 6.1) {
+      return '#fff3cd' // 黄
+    } else {
+      return '#e8f5e8' // 绿
+    }
+  } else {
+    // 随机血糖
+    if (value > 11.1) {
+      return '#f8d7da' // 红
+    } else if (value > 7.8) {
+      return '#fff3cd' // 黄
+    } else {
+      return '#e8f5e8' // 绿
+    }
+  }
+}
+
 // 使用 daysInMonth 从 src/utils/date.ts
 
 // Canvas / uCharts 绘图 - 使用 composable
@@ -340,6 +362,16 @@ async function confirmAdd() {
     uni.showToast && uni.showToast({ title: '请输入血糖值', icon: 'none' });
     return
   }
+  // 检查是否需要预警
+  // 设置弹窗预警:当输入血压>140/90或空腹血糖>7.0时,弹窗提示“建议尽快复诊” 
+  if (types[typeIndex.value] === '空腹' && addGlucose.value > 7.0) {
+    uni.showModal({
+      title: '血糖异常',
+      content: '建议尽快复诊',
+      showCancel: false,
+      confirmText: '知道了'
+    })
+  }
   const id = `user-${Date.now()}`
   const item: RecordItem = {
     id,

+ 22 - 1
src/pages/patient/health/details/blood-pressure.vue

@@ -34,7 +34,7 @@
 
       <view class="list">
         <view v-if="records.length === 0" class="empty">暂无记录,点击右下角 + 添加</view>
-        <view v-for="item in records" :key="item.id" class="list-item">
+        <view v-for="item in records" :key="item.id" class="list-item" :style="{ backgroundColor: getItemColor(item.s, item.d) }">
           <view class="date">{{ item.date }}</view>
           <view class="value">{{ item.s }}/{{ item.d }} mmHg</view>
           <button class="btn-delete" @click="confirmDeleteRecord(item.id)">✕</button>
@@ -205,6 +205,17 @@ const averageDiastolic = computed(() => {
   return Math.round(sum / records.value.length)
 })
 
+// 根据血压值获取颜色
+function getItemColor(s: number, d: number): string {
+  if (s < 120 && d < 80) {
+    return '#e8f5e8' // 绿
+  } else if (s < 140 && d < 90) {
+    return '#fff3cd' // 黄
+  } else {
+    return '#f8d7da' // 红
+  }
+}
+
 // 使用共享日期工具 (src/utils/date.ts)
 
 // 使用可复用的 chart composable,支持多序列
@@ -337,6 +348,16 @@ async function confirmAdd() {
     uni.showToast && uni.showToast({ title: '请输入血压值', icon: 'none' }); 
     return 
   }
+  // 检查是否需要预警
+  // 设置弹窗预警:当输入血压>140/90或空腹血糖>7.0时,弹窗提示“建议尽快复诊” 
+  if (addSystolic.value > 140 || addDiastolic.value > 90) {
+    uni.showModal({
+      title: '血压异常',
+      content: '建议尽快复诊',
+      showCancel: false,
+      confirmText: '知道了'
+    })
+  }
   const id = `user-${Date.now()}`
   const item: RecordItem = { 
     id,