更新功能

This commit is contained in:
Your Name
2026-05-26 18:05:48 +08:00
parent 5b233fb0ab
commit 0dd9cdcba9
8 changed files with 4703 additions and 10 deletions
@@ -23,6 +23,10 @@
</div>
<div v-if="canEditDailyRecord" class="daily-matrix__toolbar-right">
<span v-if="hasPatientSelfRecord" class="daily-matrix__legend">
<span class="daily-matrix__cell-patient">自录</span>
<span class="daily-matrix__legend-text">= 患者在小程序自录</span>
</span>
<el-button type="primary" @click="openQuickAdd('blood')">+血糖</el-button>
<el-button @click="openQuickAdd('diet')">+饮食</el-button>
<el-button @click="openQuickAdd('exercise')">+运动</el-button>
@@ -30,6 +34,10 @@
<el-button @click="fetchTracking">刷新</el-button>
</div>
<div v-else class="daily-matrix__toolbar-right">
<span v-if="hasPatientSelfRecord" class="daily-matrix__legend">
<span class="daily-matrix__cell-patient">自录</span>
<span class="daily-matrix__legend-text">= 患者在小程序自录</span>
</span>
<el-button @click="fetchTracking">刷新</el-button>
</div>
</div>
@@ -57,7 +65,8 @@
:class="{
'is-clickable': isCellClickable(row.key, date),
'is-empty': !getCell(row.key, date).hasRecord,
'is-high': getCell(row.key, date).isHigh
'is-high': getCell(row.key, date).isHigh,
'is-patient-self': getCell(row.key, date).isPatientSelf && getCell(row.key, date).hasRecord
}"
@click="handleCellClick(row.key, date)"
>
@@ -82,6 +91,14 @@
<template v-else-if="getCell(row.key, date).value">
<span>{{ getCell(row.key, date).value }}</span>
<span v-if="getCell(row.key, date).isHigh" class="daily-matrix__cell-up"></span>
<el-tooltip
v-if="getCell(row.key, date).isPatientSelf"
content="患者在小程序自录的数据"
placement="top"
:show-after="120"
>
<span class="daily-matrix__cell-patient">自录</span>
</el-tooltip>
</template>
<template v-else></template>
</div>
@@ -345,6 +362,10 @@ interface BloodRecord {
western_medicine?: string
insulin?: string
remark?: string
/** 来源:0-医生录入 1-患者自录(小程序日常记录页) */
source?: number
/** 合并后该日是否含有「患者自录」记录 */
has_patient_self?: boolean
[key: string]: any
}
@@ -558,6 +579,10 @@ const visibleDates = computed(() => {
return dates
})
const hasPatientSelfRecord = computed(() => {
return bloodRecords.value.some((r) => Number((r as any).source) === 1)
})
const bloodByDate = computed(() => {
const map = new Map<string, BloodRecord>()
for (const record of bloodRecords.value) {
@@ -570,7 +595,8 @@ const bloodByDate = computed(() => {
patient_id: record.patient_id,
record_date: date,
record_time: record.record_time || '',
record_date_ts: record.record_date_ts
record_date_ts: record.record_date_ts,
has_patient_self: false
})
}
const merged = map.get(date)!
@@ -594,6 +620,10 @@ const bloodByDate = computed(() => {
;(merged as any)[field] = record[field]
}
}
// 当天有任意 source=1 的记录则标记为患者自录
if (Number(record.source) === 1) {
merged.has_patient_self = true
}
}
return map
})
@@ -723,35 +753,40 @@ function parseTrendNumber(value: unknown): number | null {
return parsed
}
function getCell(metric: string, date: string): { value: string; isHigh: boolean; hasRecord: boolean } {
function getCell(metric: string, date: string): { value: string; isHigh: boolean; hasRecord: boolean; isPatientSelf?: boolean } {
const blood = bloodByDate.value.get(date)
const diet = dietByDate.value.get(date)
const exercise = exerciseByDate.value.get(date)
const tracking = trackingByDate.value.get(date)
const isPatientSelf = !!blood?.has_patient_self
switch (metric) {
case 'fasting':
return {
value: blood?.fasting_blood_sugar != null && blood.fasting_blood_sugar !== '' ? String(blood.fasting_blood_sugar) : '',
isHigh: isHighFastingBloodSugar(blood?.fasting_blood_sugar, props.age),
hasRecord: !!blood && blood.fasting_blood_sugar != null && blood.fasting_blood_sugar !== ''
hasRecord: !!blood && blood.fasting_blood_sugar != null && blood.fasting_blood_sugar !== '',
isPatientSelf
}
case 'postprandial':
return {
value: blood?.postprandial_blood_sugar != null && blood.postprandial_blood_sugar !== '' ? String(blood.postprandial_blood_sugar) : '',
isHigh: isHighPostprandialBloodSugar(blood?.postprandial_blood_sugar, props.age),
hasRecord: !!blood && blood.postprandial_blood_sugar != null && blood.postprandial_blood_sugar !== ''
hasRecord: !!blood && blood.postprandial_blood_sugar != null && blood.postprandial_blood_sugar !== '',
isPatientSelf
}
case 'other':
return {
value: blood?.other_blood_sugar != null && blood.other_blood_sugar !== '' ? String(blood.other_blood_sugar) : '',
isHigh: isHighOtherBloodSugar(blood?.other_blood_sugar, props.age),
hasRecord: !!blood && blood.other_blood_sugar != null && blood.other_blood_sugar !== ''
hasRecord: !!blood && blood.other_blood_sugar != null && blood.other_blood_sugar !== '',
isPatientSelf
}
case 'bp':
return {
value: blood && (blood.systolic_pressure || blood.diastolic_pressure) ? formatBp(blood) : '',
isHigh: isHighBloodPressure(blood),
hasRecord: !!blood && !!(blood.systolic_pressure || blood.diastolic_pressure)
hasRecord: !!blood && !!(blood.systolic_pressure || blood.diastolic_pressure),
isPatientSelf
}
case 'western':
return {
@@ -1115,6 +1150,12 @@ defineExpose({ refresh: fetchTracking })
color: #dc2626;
font-weight: 700;
}
&.is-patient-self {
position: relative;
background: linear-gradient(180deg, rgba(139, 92, 246, 0.04) 0%, rgba(139, 92, 246, 0.10) 100%);
border-radius: 4px;
}
}
&__cell-up {
@@ -1122,6 +1163,38 @@ defineExpose({ refresh: fetchTracking })
font-size: 13px;
}
&__cell-patient {
display: inline-block;
margin-left: 4px;
padding: 1px 6px;
font-size: 11px;
font-weight: 600;
color: #6d28d9;
background: #ede9fe;
border: 1px solid #ddd6fe;
border-radius: 999px;
line-height: 1.2;
letter-spacing: 0.5px;
white-space: nowrap;
}
&__legend {
display: inline-flex;
align-items: center;
gap: 6px;
margin-right: 12px;
padding: 2px 10px 2px 6px;
background: #f8f6ff;
border: 1px dashed #ddd6fe;
border-radius: 999px;
}
&__legend-text {
font-size: 12px;
color: #6d28d9;
font-weight: 500;
}
&__todo {
margin-top: 16px;
}