656 lines
15 KiB
Plaintext
656 lines
15 KiB
Plaintext
<template>
|
|
<scroll-view direction="vertical" class="assignments-management" :enable-back-to-top="true">
|
|
<!-- Header -->
|
|
<view class="page-header">
|
|
<text class="page-title">作业管理</text>
|
|
<button class="create-btn" @click="createAssignment">
|
|
<text class="create-icon">+</text>
|
|
</button>
|
|
</view> <!-- Search and Filter -->
|
|
<view class="search-filter-bar">
|
|
<view class="search-input-wrapper">
|
|
<text class="search-icon"></text>
|
|
<input class="search-input" placeholder="搜索作业..." :value="searchQuery" @input="handleSearch" />
|
|
</view>
|
|
<view class="filter-selector" @click="showStatusPicker">
|
|
<text class="filter-label">{{ getCurrentFilterLabel() }}</text>
|
|
<text class="filter-arrow">▼</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- Quick Stats -->
|
|
<view class="quick-stats">
|
|
<view class="stat-item">
|
|
<text class="stat-number">{{ getActiveAssignments() }}</text>
|
|
<text class="stat-text">进行中</text>
|
|
</view>
|
|
<view class="stat-item">
|
|
<text class="stat-number">{{ getPendingReviews() }}</text>
|
|
<text class="stat-text">待批改</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- Assignments List -->
|
|
<view class="assignments-container">
|
|
<view class="assignments-list">
|
|
<view class="assignment-card" v-for="(assignment, index) in filteredAssignments" :key="index"
|
|
@click="viewAssignmentDetail(assignment)">
|
|
<view class="card-header">
|
|
<view class="assignment-info">
|
|
<text
|
|
class="assignment-title">{{ assignment.getString('title') ?? assignment.getString('name') ?? '未命名作业' }}</text>
|
|
<text class="project-name">{{ assignment.getString('project_name') ?? '' }}</text>
|
|
</view>
|
|
<view class="status-badge" :class="`status-${assignment.getString('status') ?? 'active'}`">
|
|
<text
|
|
class="status-text">{{ formatAssignmentStatusLocal(assignment.getString('status') ?? 'active') }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="card-content">
|
|
<view class="assignment-meta">
|
|
<view class="meta-item">
|
|
<text class="meta-text">{{ assignment.getNumber('participants') ?? 0 }}人参与</text>
|
|
</view>
|
|
<view class="meta-item">
|
|
<text
|
|
class="meta-text">{{ formatDateLocal(assignment.getString('deadline') ?? '') }}截止</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="progress-info">
|
|
<text class="progress-text">已提交
|
|
{{ assignment.getNumber('submitted') ?? 0 }}/{{ assignment.getNumber('participants') ?? 0 }}</text>
|
|
<view class="progress-bar">
|
|
<view class="progress-fill" :style="`width: ${getProgressPercentage(assignment)}%`">
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="card-actions">
|
|
<button class="action-btn secondary-btn" @click.stop="editAssignment(assignment)">
|
|
编辑
|
|
</button>
|
|
<button class="action-btn primary-btn" @click.stop="reviewSubmissions(assignment)">
|
|
批改
|
|
</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- Empty State -->
|
|
<view class="empty-state" v-if="filteredAssignments.length === 0">
|
|
<text class="empty-icon"></text>
|
|
<text class="empty-title">暂无作业</text>
|
|
<text class="empty-desc">{{ getEmptyStateMessage() }}</text>
|
|
<button class="empty-action-btn" @click="createAssignment">
|
|
创建作业
|
|
</button>
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
</template>
|
|
|
|
<script setup lang="uts">
|
|
import {
|
|
formatDate,
|
|
formatAssignmentStatus
|
|
} from '../types.uts'
|
|
// Local wrapper functions to avoid unref issues
|
|
const formatDateLocal = (dateStr : string) : string => {
|
|
return formatDate(dateStr)
|
|
}
|
|
|
|
const formatAssignmentStatusLocal = (status : string) : string => {
|
|
return formatAssignmentStatus(status)
|
|
}
|
|
|
|
// Reactive data
|
|
const assignments = ref<Array<UTSJSONObject>>([])
|
|
const filteredAssignments = ref<Array<UTSJSONObject>>([])
|
|
const searchQuery = ref('')
|
|
const currentStatusFilter = ref('all')
|
|
const currentFilterIndex = ref(0)
|
|
const loading = ref(true)
|
|
const statusFilters = [
|
|
{ label: '全部', value: 'all' },
|
|
{ label: '进行中', value: 'active' },
|
|
{ label: '已完成', value: 'completed' },
|
|
{ label: '已截止', value: 'expired' }
|
|
]
|
|
|
|
const statusFilterLabels = statusFilters.map(filter => filter.label as string)
|
|
|
|
// Methods
|
|
function filterAssignments() {
|
|
let filtered = assignments.value
|
|
|
|
// Status filter
|
|
if (currentStatusFilter.value !== 'all') {
|
|
filtered = filtered.filter(assignment =>
|
|
(assignment.getString('status') ?? 'active') === currentStatusFilter.value
|
|
)
|
|
}
|
|
|
|
// Search filter
|
|
if (searchQuery.value.trim() !== '') {
|
|
const query = searchQuery.value.toLowerCase()
|
|
filtered = filtered.filter(assignment => {
|
|
const title = (assignment.getString('title') ?? assignment.getString('name') ?? '').toLowerCase()
|
|
const project = (assignment.getString('project_name') ?? '').toLowerCase()
|
|
return title.includes(query) || project.includes(query)
|
|
})
|
|
}
|
|
|
|
filteredAssignments.value = filtered
|
|
}
|
|
|
|
function loadAssignments() {
|
|
loading.value = true
|
|
|
|
// Mock data - replace with actual API call
|
|
setTimeout(() => {
|
|
assignments.value = [
|
|
{
|
|
"id": "1",
|
|
"title": "跳远基础技术训练",
|
|
"project_name": "跳远训练",
|
|
"status": "active",
|
|
"deadline": "2024-01-25T23:59:59",
|
|
"participants": 28,
|
|
"submitted": 15,
|
|
"pending_review": 8,
|
|
"average_score": 82.5,
|
|
"created_at": "2024-01-15T10:00:00"
|
|
},
|
|
{
|
|
"id": "2",
|
|
"title": "短跑起跑技术",
|
|
"project_name": "短跑训练",
|
|
"status": "active",
|
|
"deadline": "2024-01-30T23:59:59",
|
|
"participants": 25,
|
|
"submitted": 20,
|
|
"pending_review": 5,
|
|
"average_score": 78.3,
|
|
"created_at": "2024-01-12T14:30:00"
|
|
},
|
|
{
|
|
"id": "3",
|
|
"title": "篮球运球基础",
|
|
"project_name": "篮球技能",
|
|
"status": "completed",
|
|
"deadline": "2024-01-20T23:59:59",
|
|
"participants": 30,
|
|
"submitted": 30,
|
|
"pending_review": 0,
|
|
"average_score": 85.7,
|
|
"created_at": "2024-01-08T09:15:00"
|
|
},
|
|
{
|
|
"id": "4",
|
|
"title": "足球传球练习",
|
|
"project_name": "足球基础",
|
|
"status": "expired",
|
|
"deadline": "2024-01-18T23:59:59",
|
|
"participants": 22,
|
|
"submitted": 18,
|
|
"pending_review": 2,
|
|
"average_score": 76.8,
|
|
"created_at": "2024-01-05T16:45:00"
|
|
}
|
|
]
|
|
filterAssignments()
|
|
loading.value = false
|
|
}, 1000)
|
|
}
|
|
|
|
function handleSearch() {
|
|
filterAssignments()
|
|
}
|
|
function setStatusFilter(status : string) {
|
|
currentStatusFilter.value = status
|
|
} function getCurrentFilterLabel() : string {
|
|
const filter = statusFilters.find(f => f.value === currentStatusFilter.value)
|
|
return filter != null ? (filter.label as string) : '全部'
|
|
} function showStatusPicker() {
|
|
const itemArray = statusFilters.map(filter => filter.label as string)
|
|
|
|
uni.showActionSheet({
|
|
itemList: itemArray,
|
|
success: (res) => {
|
|
const selectedFilter = statusFilters[res.tapIndex]
|
|
if (selectedFilter != null) {
|
|
currentFilterIndex.value = res.tapIndex
|
|
setStatusFilter(selectedFilter.value as string)
|
|
}
|
|
},
|
|
fail: (err) => {
|
|
console.log('用户取消选择', err)
|
|
}
|
|
})
|
|
}
|
|
|
|
function getTotalAssignments() : number {
|
|
return assignments.value.length
|
|
}
|
|
function getActiveAssignments() : number {
|
|
return assignments.value.filter(a => (a.getString('status') ?? 'active') === 'active').length
|
|
}
|
|
|
|
function getCompletedAssignments() : number {
|
|
return assignments.value.filter(a => (a.getString('status') ?? 'active') === 'completed').length
|
|
}
|
|
|
|
function getPendingReviews() : number {
|
|
return assignments.value.reduce((total, assignment) => {
|
|
return total + (assignment.getNumber('pending_review') ?? 0)
|
|
}, 0)
|
|
}
|
|
|
|
function getProgressPercentage(assignment : UTSJSONObject) : number {
|
|
const participants = assignment.getNumber('participants') ?? 0
|
|
const submitted = assignment.getNumber('submitted') ?? 0
|
|
if (participants <= 0) return 0
|
|
return Math.round((submitted / participants) * 100)
|
|
}
|
|
|
|
function getAssignmentAverageScore(assignment : UTSJSONObject) : string {
|
|
const score = assignment.getNumber('average_score') ?? 0
|
|
return score > 0 ? score.toFixed(1) : '--'
|
|
}
|
|
function getEmptyStateMessage() : string {
|
|
if (searchQuery.value.trim() !== '') {
|
|
return '没有找到匹配的作业'
|
|
}
|
|
if (currentStatusFilter.value !== 'all') {
|
|
return `没有${statusFilters.find(f => f.value === currentStatusFilter.value)?.label}的作业`
|
|
}
|
|
return '还没有创建任何作业,点击下方按钮创建第一个作业'
|
|
}
|
|
|
|
function createAssignment() {
|
|
uni.navigateTo({
|
|
url: '/pages/sport/teacher/create-assignment'
|
|
})
|
|
}
|
|
function viewAssignmentDetail(assignment : UTSJSONObject) {
|
|
const assignmentId = assignment.getString('id') ?? ''
|
|
uni.navigateTo({
|
|
url: `/pages/sport/teacher/assignment-detail?id=${assignmentId}`
|
|
})
|
|
}
|
|
|
|
function editAssignment(assignment : UTSJSONObject) {
|
|
const assignmentId = assignment.getString('id') ?? ''
|
|
uni.navigateTo({
|
|
url: `/pages/sport/teacher/edit-assignment?id=${assignmentId}`
|
|
})
|
|
}
|
|
function reviewSubmissions(assignment : UTSJSONObject) {
|
|
const assignmentId = assignment.getString('id') ?? ''
|
|
uni.navigateTo({
|
|
url: `/pages/sport/teacher/review-submissions?assignmentId=${assignmentId}`
|
|
})
|
|
}
|
|
// Lifecycle
|
|
onLoad(() => {
|
|
loadAssignments()
|
|
})
|
|
|
|
// Watch
|
|
watch([searchQuery, currentStatusFilter], () => {
|
|
filterAssignments()
|
|
})
|
|
</script>
|
|
|
|
<style>
|
|
.assignments-management {
|
|
flex:1;
|
|
background-color: #f8f9fa;
|
|
padding: 20rpx;
|
|
padding-bottom: 40rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
/* Header */
|
|
.page-header {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 25rpx;
|
|
}
|
|
|
|
.page-title {
|
|
font-size: 40rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
}
|
|
|
|
.create-btn {
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
border-radius: 30rpx;
|
|
background-image: linear-gradient(to bottom right, #667eea, #764ba2);
|
|
border: none;
|
|
color: white;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.create-icon {
|
|
font-size: 32rpx;
|
|
font-weight: bold;
|
|
}
|
|
|
|
/* Search and Filter Bar */
|
|
.search-filter-bar {
|
|
display: flex;
|
|
margin-bottom: 20rpx;
|
|
position: relative;
|
|
}
|
|
|
|
.search-filter-bar .search-input-wrapper {
|
|
margin-right: 15rpx;
|
|
}
|
|
|
|
.search-filter-bar .filter-selector {
|
|
margin-left: 0;
|
|
}
|
|
|
|
.search-input-wrapper {
|
|
flex: 1;
|
|
flex-direction: row;
|
|
display: flex;
|
|
align-items: center;
|
|
background-color: white;
|
|
border-radius: 25rpx;
|
|
padding: 15rpx 20rpx;
|
|
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.search-icon {
|
|
font-size: 28rpx;
|
|
margin-right: 15rpx;
|
|
opacity: 0.6;
|
|
}
|
|
|
|
.search-input {
|
|
flex: 1;
|
|
font-size: 28rpx;
|
|
border: none;
|
|
background: none;
|
|
}
|
|
|
|
.filter-selector {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
min-width: 140rpx;
|
|
padding: 15rpx 20rpx;
|
|
background-color: white;
|
|
border-radius: 25rpx;
|
|
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.filter-label {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
margin-right: 10rpx;
|
|
}
|
|
|
|
.filter-arrow {
|
|
font-size: 20rpx;
|
|
color: #999;
|
|
}
|
|
|
|
/* Quick Stats */
|
|
.quick-stats {
|
|
display: flex;
|
|
flex-direction: row;
|
|
margin-bottom: 25rpx;
|
|
}
|
|
|
|
.quick-stats .stat-item {
|
|
margin-right: 15rpx;
|
|
}
|
|
|
|
.quick-stats .stat-item:last-child {
|
|
margin-right: 0;
|
|
}
|
|
|
|
.stat-item {
|
|
flex: 1;
|
|
background-color: white;
|
|
border-radius: 16rpx;
|
|
padding: 20rpx;
|
|
text-align: center;
|
|
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.stat-number {
|
|
font-size: 32rpx;
|
|
font-weight: bold;
|
|
color: #667eea;
|
|
display: block;
|
|
margin-bottom: 5rpx;
|
|
}
|
|
|
|
.stat-text {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
}
|
|
/* Assignments List */
|
|
.assignments-container {
|
|
flex-direction: column;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
|
|
.assignments-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.assignments-list .assignment-card {
|
|
margin-bottom: 15rpx;
|
|
}
|
|
.assignments-list .assignment-card:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.assignment-card {
|
|
background-color: white;
|
|
border-radius: 16rpx;
|
|
padding: 20rpx;
|
|
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
|
margin-bottom: 15rpx;
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
align-items: flex-start;
|
|
margin-bottom: 15rpx;
|
|
}
|
|
|
|
.assignment-info {
|
|
flex: 1;
|
|
margin-right: 15rpx;
|
|
}
|
|
|
|
.assignment-title {
|
|
font-size: 30rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
margin-bottom: 5rpx;
|
|
display: block;
|
|
}
|
|
|
|
.project-name {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
}
|
|
|
|
.status-badge {
|
|
padding: 6rpx 12rpx;
|
|
border-radius: 12rpx;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.status-active {
|
|
background-color: rgba(0, 123, 255, 0.1);
|
|
border: 1rpx solid rgba(0, 123, 255, 0.3);
|
|
}
|
|
|
|
.status-completed {
|
|
background-color: rgba(40, 167, 69, 0.1);
|
|
border: 1rpx solid rgba(40, 167, 69, 0.3);
|
|
}
|
|
|
|
.status-expired {
|
|
background-color: rgba(220, 53, 69, 0.1);
|
|
border: 1rpx solid rgba(220, 53, 69, 0.3);
|
|
}
|
|
|
|
.status-text {
|
|
font-size: 22rpx;
|
|
font-weight: 400;
|
|
}
|
|
|
|
.status-active .status-text {
|
|
color: #007bff;
|
|
}
|
|
|
|
.status-completed .status-text {
|
|
color: #28a745;
|
|
}
|
|
|
|
.status-expired .status-text {
|
|
color: #dc3545;
|
|
}
|
|
|
|
.card-content {
|
|
margin-bottom: 15rpx;
|
|
}
|
|
|
|
.assignment-meta {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
margin-bottom: 15rpx;
|
|
}
|
|
|
|
.meta-item {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.meta-text {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
}
|
|
|
|
.progress-info {
|
|
margin-bottom: 10rpx;
|
|
}
|
|
|
|
.progress-text {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
margin-bottom: 8rpx;
|
|
display: block;
|
|
}
|
|
|
|
.progress-bar {
|
|
height: 6rpx;
|
|
background-color: #f0f0f0;
|
|
border-radius: 3rpx;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.progress-fill {
|
|
height: 100%;
|
|
background-image: linear-gradient(to bottom, #667eea, #764ba2);
|
|
border-radius: 3rpx;
|
|
transition: width 0.3s ease;
|
|
}
|
|
|
|
.card-actions {
|
|
display: flex;
|
|
padding-top: 15rpx;
|
|
border-top: 1rpx solid #f0f0f0;
|
|
}
|
|
|
|
.card-actions .action-btn {
|
|
margin-right: 12rpx;
|
|
}
|
|
|
|
.card-actions .action-btn:last-child {
|
|
margin-right: 0;
|
|
}
|
|
|
|
.action-btn {
|
|
flex: 1;
|
|
height: 60rpx;
|
|
border-radius: 30rpx;
|
|
font-size: 26rpx;
|
|
font-weight: 400;
|
|
border: none;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.primary-btn {
|
|
background-image: linear-gradient(to bottom right, #667eea, #764ba2);
|
|
color: white;
|
|
}
|
|
|
|
.secondary-btn {
|
|
background-color: #f8f9ff;
|
|
color: #667eea;
|
|
border: 2rpx solid #e0e6ff;
|
|
}
|
|
/* Empty State */
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 80rpx 40rpx;
|
|
margin-bottom: 40rpx;
|
|
}
|
|
|
|
.empty-icon {
|
|
font-size: 100rpx;
|
|
margin-bottom: 20rpx;
|
|
opacity: 0.5;
|
|
display: block;
|
|
}
|
|
|
|
.empty-title {
|
|
font-size: 28rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
margin-bottom: 10rpx;
|
|
display: block;
|
|
}
|
|
|
|
.empty-desc {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
line-height: 1.5;
|
|
margin-bottom: 30rpx;
|
|
}
|
|
|
|
.empty-action-btn {
|
|
padding: 15rpx 30rpx;
|
|
background-image: linear-gradient(to bottom right, #667eea, #764ba2);
|
|
border-radius: 25rpx;
|
|
color: white;
|
|
font-size: 26rpx;
|
|
font-weight: 400;
|
|
border: none;
|
|
}
|
|
</style> |