187 lines
3.7 KiB
Plaintext
187 lines
3.7 KiB
Plaintext
<!-- 养老管理系统 - 我的护理任务列表 -->
|
|
<template>
|
|
<view class="my-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" :class="getTaskPriorityClass(task.priority)"
|
|
@click="viewTaskDetail(task)">
|
|
<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 class="task-priority">
|
|
<view class="priority-badge" :class="task.priority">
|
|
<text class="priority-text">{{ getPriorityText(task.priority) }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="task-status">
|
|
<text class="status-text">{{ getStatusText(task.status) }}</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, getTaskPriorityClass, getPriorityText, getStatusText } from '../types.uts'
|
|
import { state, getCurrentUserId } from '@/utils/store.uts'
|
|
|
|
const tasks = ref<Array<CareTask>>([])
|
|
const profile = ref(state.userProfile)
|
|
|
|
const loadMyTasks = async (currentUserId) => {
|
|
try {
|
|
const result = await supa
|
|
.from('ec_care_tasks')
|
|
.select(`
|
|
id,
|
|
task_name,
|
|
elder_name,
|
|
scheduled_time,
|
|
status,
|
|
priority
|
|
`)
|
|
.eq('assigned_to', currentUserId)
|
|
.order('scheduled_time', { ascending: true })
|
|
.executeAs<CareTask>()
|
|
if (result.error === null && result.data !== null) {
|
|
tasks.value = result.data
|
|
}
|
|
} catch (error) {
|
|
console.error('加载任务失败:', error)
|
|
}
|
|
}
|
|
|
|
const viewTaskDetail = (task : CareTask) => {
|
|
uni.navigateTo({
|
|
url: `/pages/ec/tasks/detail?id=${task.id}`
|
|
})
|
|
}
|
|
|
|
onLoad((options : OnLoadOptions) => {
|
|
|
|
const currentUserId = options['id'] ?? getCurrentUserId()
|
|
|
|
loadMyTasks(currentUserId)
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.my-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 #d9d9d9;
|
|
}
|
|
|
|
.task-item.priority-urgent {
|
|
border-left-color: #ff4d4f;
|
|
background-color: #fff2f0;
|
|
}
|
|
|
|
.task-item.priority-high {
|
|
border-left-color: #fa8c16;
|
|
background-color: #fff7e6;
|
|
}
|
|
|
|
.task-item.priority-normal {
|
|
border-left-color: #1890ff;
|
|
background-color: #f0f9ff;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.priority-badge {
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
font-size: 10px;
|
|
}
|
|
|
|
.priority-badge.urgent {
|
|
background-color: #ff4d4f;
|
|
color: #fff;
|
|
}
|
|
|
|
.priority-badge.high {
|
|
background-color: #fa8c16;
|
|
color: #fff;
|
|
}
|
|
|
|
.priority-badge.normal {
|
|
background-color: #1890ff;
|
|
color: #fff;
|
|
}
|
|
|
|
.task-status .status-text {
|
|
font-size: 12px;
|
|
color: #1890ff;
|
|
}
|
|
|
|
.empty-text {
|
|
text-align: center;
|
|
color: #999;
|
|
padding: 30px 0;
|
|
}
|
|
</style> |