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

139 lines
2.8 KiB
Plaintext

<!-- 养老管理系统 - 已完成护理任务列表 -->
<template>
<view class="completed-tasks-page">
<view class="header">
<text class="title">已完成护理任务</text>
</view>
<view class="tasks-list">
<view v-if="tasks.length === 0" class="empty-text">暂无已完成任务</view>
<view v-for="task in tasks" :key="task.id" class="task-item">
<view class="task-main">
<view class="task-info">
<text class="task-name">{{ task.task_name }}</text>
<text class="task-elder">{{ task.elder_name }}</text>
<text class="task-time">{{ formatTime(task.scheduled_time) }}</text>
</view>
</view>
<view class="task-status">
<text class="status-text">已完成</text>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, onMounted } from 'vue'
import supa from '@/components/supadb/aksupainstance.uts'
import type { CareTask } from '../types.uts'
import { formatTime } from '../types.uts'
import { state, getCurrentUserId } from '@/utils/store.uts'
const tasks = ref<Array<CareTask>>([])
const profile = ref(state.userProfile)
const loadCompletedTasks = async (currentUserId) => {
try {
const result = await supa
.from('ec_care_tasks')
.select(`
id,
task_name,
elder_name,
scheduled_time
`,{count:'exact'})
.eq('assigned_to', currentUserId)
.eq('status', 'completed')
.order('updated_at', { ascending: false })
.executeAs<CareTask>()
if (result.error === null && result.data !== null) {
tasks.value = result.data
}
} catch (error) {
console.error('加载已完成任务失败:', error)
}
}
onLoad((options : OnLoadOptions) => {
const currentUserId = options['id'] ?? getCurrentUserId()
loadCompletedTasks(currentUserId)
})
</script>
<style scoped>
.completed-tasks-page {
min-height: 100vh;
background: #f5f5f5;
padding: 20px;
}
.header {
margin-bottom: 20px;
}
.title {
font-size: 22px;
font-weight: bold;
color: #333;
}
.tasks-list {
background: #fff;
border-radius: 8px;
padding: 15px;
}
.task-item {
display: flex;
flex-direction: column;
padding: 12px;
border-radius: 6px;
margin-bottom: 8px;
border-left: 3px solid #52c41a;
background-color: #f6ffed;
}
.task-main {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 8px;
}
.task-info {
flex: 1;
display: flex;
flex-direction: column;
}
.task-name {
font-size: 14px;
font-weight: bold;
color: #333;
margin-bottom: 3px;
}
.task-elder {
font-size: 12px;
color: #666;
margin-bottom: 2px;
}
.task-time {
font-size: 12px;
color: #999;
}
.task-status .status-text {
font-size: 12px;
color: #52c41a;
}
.empty-text {
text-align: center;
color: #999;
padding: 30px 0;
}
</style>