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

137 lines
3.2 KiB
Plaintext

<template>
<view class="prescriptions">
<view class="header">
<text class="header-title">处方管理</text>
</view>
<scroll-view class="prescription-list" scroll-y="true" :style="{ height: '600px' }">
<view
v-for="item in prescriptions"
:key="item.id"
class="prescription-item"
@click="openPrescription(item)"
>
<view class="prescription-header">
<text class="patient-name">{{ item.elder_name }}</text>
<text class="medication-name">{{ item.medication_name }}</text>
</view>
<view class="prescription-content">
<text class="dosage">剂量: {{ item.dosage || '未填写' }}</text>
<text class="status">状态: {{ getStatusText(item.status) }}</text>
<text class="date-range">{{ item.start_date }} ~ {{ item.end_date || '...' }}</text>
</view>
</view>
<view v-if="prescriptions.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'
type Prescription = {
id: string
elder_id: string
elder_name: string
medication_name: string
dosage: string
status: string
start_date: string
end_date: string
}
const prescriptions = ref<Array<Prescription>>([])
onMounted(() => {
loadPrescriptions()
})
const loadPrescriptions = async () => {
try {
const result = await supa
.from('ec_medications')
.select('id, elder_id, elder_name, medication_name, dosage, status, start_date, end_date')
.order('created_at', { ascending: false })
.executeAs<Prescription[]>()
if (result.error == null && result.data != null) {
prescriptions.value = result.data
}
} catch (error) {
console.error('加载处方失败:', error)
}
}
const getStatusText = (status: string): string => {
const statusMap = new Map([
['active', '进行中'],
['completed', '已完成'],
['discontinued', '已停用']
])
return statusMap.get(status) ?? status
}
const openPrescription = (item: Prescription) => {
uni.navigateTo({ url: `/pages/ec/doctor/prescription-detail?id=${item.id}` })
}
</script>
<style scoped>
.prescriptions {
padding: 20px;
background-color: #f5f5f5;
min-height: 100vh;
}
.header {
margin-bottom: 16px;
}
.header-title {
font-size: 20px;
font-weight: bold;
}
.prescription-list {
background-color: #fff;
border-radius: 10px;
}
.prescription-item {
padding: 14px 10px;
border-bottom: 1px solid #f0f0f0;
}
.prescription-item:last-child {
border-bottom: none;
}
.prescription-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;
}
.medication-name {
font-size: 14px;
color: #666;
}
.prescription-content {
font-size: 13px;
color: #555;
}
.dosage, .status, .date-range {
display: block;
margin-bottom: 4px;
}
.empty-state {
padding: 30px 0;
text-align: center;
}
.empty-text {
font-size: 13px;
color: #999;
}
</style>