Files
akmon/pages/ec/doctor/medical-records.uvue
2026-01-20 08:04:15 +08:00

138 lines
3.2 KiB
Plaintext

<template>
<view class="medical-records">
<view class="header">
<text class="header-title">病历管理</text>
</view>
<scroll-view class="records-list" scroll-y="true" :style="{ height: '600px' }">
<view
v-for="record in records"
:key="record.id"
class="record-item"
@click="openRecord(record)"
>
<view class="record-header">
<text class="patient-name">{{ record.elder_name }}</text>
<text class="visit-date">{{ formatDateTime(record.visit_date) }}</text>
</view>
<view class="record-content">
<text class="visit-type">类型: {{ getVisitTypeText(record.visit_type) }}</text>
<text class="chief-complaint">主诉: {{ record.chief_complaint || '无' }}</text>
<text class="diagnosis">诊断: {{ record.diagnosis || '未填写' }}</text>
</view>
</view>
<view v-if="records.length === 0" class="empty-state">
<text class="empty-text">暂无病历记录</text>
</view>
</scroll-view>
</view>
</template>
<script setup lang="uts">
import { ref, onMounted } from 'vue'
import supa from '@/components/supadb/aksupainstance.uts'
import { formatDateTime } from '../types_new.uts'
type MedicalRecord = {
id: string
elder_id: string
elder_name: string
visit_type: string
visit_date: string
chief_complaint: string
diagnosis: string
}
const records = ref<Array<MedicalRecord>>([])
onMounted(() => {
loadRecords()
})
const loadRecords = async () => {
try {
const result = await supa
.from('ec_medical_records')
.select('id, elder_id, elder_name, visit_type, visit_date, chief_complaint, diagnosis')
.order('visit_date', { ascending: false })
.executeAs<MedicalRecord[]>()
if (result.error == null && result.data != null) {
records.value = result.data
}
} catch (error) {
console.error('加载病历失败:', error)
}
}
const getVisitTypeText = (type: string): string => {
const typeMap = new Map([
['routine', '常规'],
['emergency', '急诊'],
['consultation', '会诊'],
['follow_up', '复诊']
])
return typeMap.get(type) ?? type
}
const openRecord = (record: MedicalRecord) => {
uni.navigateTo({ url: `/pages/ec/doctor/medical-record-detail?id=${record.id}` })
}
</script>
<style scoped>
.medical-records {
padding: 20px;
background-color: #f5f5f5;
min-height: 100vh;
}
.header {
margin-bottom: 16px;
}
.header-title {
font-size: 20px;
font-weight: bold;
}
.records-list {
background-color: #fff;
border-radius: 10px;
}
.record-item {
padding: 14px 10px;
border-bottom: 1px solid #f0f0f0;
}
.record-item:last-child {
border-bottom: none;
}
.record-header {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.patient-name {
font-size: 15px;
font-weight: 600;
color: #333;
}
.visit-date {
font-size: 13px;
color: #666;
}
.record-content {
font-size: 13px;
color: #555;
}
.visit-type, .chief-complaint, .diagnosis {
display: block;
margin-bottom: 4px;
}
.empty-state {
padding: 30px 0;
text-align: center;
}
.empty-text {
font-size: 13px;
color: #999;
}
</style>