171 lines
3.9 KiB
Plaintext
171 lines
3.9 KiB
Plaintext
<!-- 养老管理系统 - 我负责的老人列表 -->
|
|
<template>
|
|
<view class="my-elders-page">
|
|
<view class="header">
|
|
<text class="title">我负责的老人</text>
|
|
</view>
|
|
<view class="elders-list">
|
|
<view v-if="elders.length === 0" class="empty-text">暂无负责老人</view>
|
|
<view v-for="elder in elders" :key="elder.id" class="elder-item" @click="viewElderDetail(elder)">
|
|
<view class="elder-avatar">
|
|
<image class="avatar-image" :src="elder.profile_picture ?? ''" mode="aspectFill" v-if="elder.profile_picture !== null" />
|
|
<text class="avatar-fallback" v-else>{{ elder.name.charAt(0) }}</text>
|
|
</view>
|
|
<view class="elder-info">
|
|
<text class="elder-name">{{ elder.name }}</text>
|
|
<text class="elder-room">{{ elder.room_number }}{{ elder.bed_number }}</text>
|
|
<text class="elder-care-level">{{ getCareLevelText(elder.care_level) }}</text>
|
|
</view>
|
|
<view class="elder-status">
|
|
<view class="health-indicator" :class="getHealthStatusClass(elder.health_status)">
|
|
<text class="health-text">{{ getHealthStatusText(elder.health_status) }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="uts">
|
|
import { ref, onMounted } from 'vue'
|
|
import supa from '@/components/supadb/aksupainstance.uts'
|
|
import type { Elder } from '../types.uts'
|
|
import { getCareLevelText, getHealthStatusText, getHealthStatusClass } from '../types.uts'
|
|
import { state, getCurrentUserId } from '@/utils/store.uts'
|
|
|
|
const elders = ref<Array<Elder>>([])
|
|
const profile = ref(state.userProfile)
|
|
|
|
const loadMyElders = async (currentUserId) => {
|
|
try {
|
|
// 查找当前护理员负责的所有老人ID
|
|
const taskResult = await supa
|
|
.from('ec_care_tasks')
|
|
.select('*',{count:'exact'})
|
|
.eq('assigned_to', currentUserId)
|
|
.executeAs<Elder>()
|
|
if (taskResult.error === null && taskResult.data !== null) {
|
|
elders.value = taskResult.data
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('加载负责老人失败:', error)
|
|
}
|
|
}
|
|
|
|
const viewElderDetail = (elder: Elder) => {
|
|
uni.navigateTo({
|
|
url: `/pages/ec/elders/detail?id=${elder.id}`
|
|
})
|
|
}
|
|
|
|
onLoad((options: OnLoadOptions) => {
|
|
|
|
const currentUserId = options['id'] ?? getCurrentUserId()
|
|
|
|
loadMyElders(currentUserId)
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.my-elders-page {
|
|
min-height: 100vh;
|
|
background: #f5f5f5;
|
|
padding: 20px;
|
|
}
|
|
.header {
|
|
margin-bottom: 20px;
|
|
}
|
|
.title {
|
|
font-size: 22px;
|
|
font-weight: bold;
|
|
color: #333;
|
|
}
|
|
.elders-list {
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
padding: 15px;
|
|
}
|
|
.elder-item {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
padding: 12px 0;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
.elder-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
.elder-avatar {
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 20px;
|
|
margin-right: 12px;
|
|
overflow: hidden;
|
|
background-color: #f0f0f0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.avatar-image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
.avatar-fallback {
|
|
font-size: 16px;
|
|
color: #666;
|
|
}
|
|
.elder-info {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.elder-name {
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
color: #333;
|
|
margin-bottom: 3px;
|
|
}
|
|
.elder-room {
|
|
font-size: 12px;
|
|
color: #666;
|
|
margin-bottom: 2px;
|
|
}
|
|
.elder-care-level {
|
|
font-size: 12px;
|
|
color: #1890ff;
|
|
}
|
|
.elder-status {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-end;
|
|
}
|
|
.health-indicator {
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
font-size: 10px;
|
|
margin-bottom: 4px;
|
|
}
|
|
.health-excellent {
|
|
background-color: #f6ffed;
|
|
color: #52c41a;
|
|
}
|
|
.health-good {
|
|
background-color: #e6f7ff;
|
|
color: #1890ff;
|
|
}
|
|
.health-fair {
|
|
background-color: #fff7e6;
|
|
color: #d48806;
|
|
}
|
|
.health-poor {
|
|
background-color: #fff2f0;
|
|
color: #ff4d4f;
|
|
}
|
|
.empty-text {
|
|
text-align: center;
|
|
color: #999;
|
|
padding: 30px 0;
|
|
}
|
|
</style>
|